/* ================= ТОКЕНЫ ТЕМЫ ================= */
:root {
  --sidebar-w: 268px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  --bg: #000000;
  --bg-sidebar: #0d0d0d;
  --bg-elev: #161616;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.10);
  --bg-composer: #1c1c1c;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f2f2f2;
  --text-dim: #a8a8a8;
  --text-faint: #6e6e6e;
  --accent: #ffffff;
  --accent-ink: #0a0a0a;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-sidebar: #f7f7f8;
  --bg-elev: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-active: rgba(0, 0, 0, 0.08);
  --bg-composer: #f4f4f4;
  --border: rgba(0, 0, 0, 0.10);
  --text: #17171a;
  --text-dim: #5c5c66;
  --text-faint: #8e8e97;
  --accent: #17171a;
  --accent-ink: #ffffff;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.10);
}

/* ================= БАЗА ================= */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background .18s ease, color .18s ease;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

::selection { background: rgba(120, 160, 255, .35); }

/* Скроллбары */
* { scrollbar-width: thin; scrollbar-color: rgba(140, 140, 140, .35) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: rgba(140, 140, 140, .3);
  border: 2px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(140, 140, 140, .5); background-clip: content-box; }

/* ================= ИКОНКИ ================= */
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--text-dim);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn--ghost { opacity: 0; pointer-events: none; }
body.is-collapsed .icon-btn--ghost { opacity: 1; pointer-events: auto; }

/* ================= САЙДБАР ================= */
.sidebar {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  padding: 10px 8px 8px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  transition: margin-left .22s cubic-bezier(.4, 0, .2, 1);
}
body.is-collapsed .sidebar { margin-left: calc(var(--sidebar-w) * -1); }

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 10px 6px;
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.brand__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
}
.brand__name { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }

.sidebar__actions { display: flex; gap: 2px; }

/* Навигация */
.nav { display: flex; flex-direction: column; gap: 1px; }

.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14.5px;
  text-align: left;
  transition: background .15s ease;
}
.nav__item:hover { background: var(--bg-hover); }
.nav__item:active { background: var(--bg-active); }
.nav__item svg { width: 20px; height: 20px; flex: 0 0 20px; color: var(--text-dim); }

.nav__item--primary {
  background: var(--bg-hover);
  font-weight: 500;
  margin-bottom: 6px;
}
.nav__item--primary svg { color: var(--text); }

/* История чатов */
.sidebar__history {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar__history:empty { display: none; }

.history__label {
  padding: 8px 10px 4px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.history__row {
  display: flex;
  align-items: center;
  min-width: 0;
  border-radius: 10px;
  transition: background .15s ease;
}
.history__row:hover { background: var(--bg-hover); }
.history__row.is-active { background: var(--bg-active); }

.history__delete {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  opacity: 0;
  cursor: pointer;
  transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.history__row:hover .history__delete,
.history__row:focus-within .history__delete { opacity: 1; }
.history__delete:hover { color: #ff9aa4; }
.history__delete svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.history__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s ease, color .15s ease;
}
.history__item:hover { background: var(--bg-hover); color: var(--text); }
.history__item.is-active { background: var(--bg-active); color: var(--text); }

/* Профиль */
.sidebar__bottom { margin-top: auto; padding-top: 8px; }

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border-radius: 12px;
  text-align: left;
  transition: background .15s ease;
}
.user:hover { background: var(--bg-hover); }

.user__avatar {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, #7f7f7f, #cfcfcf);
  color: #111;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
}
.user__meta { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.user__name { font-size: 14.5px; font-weight: 600; }
.user__plan { color: var(--text-faint); font-size: 12.5px; }
.user__settings {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-dim);
}
.user__settings:hover { background: var(--bg-active); color: var(--text); }
.user__settings svg { width: 19px; height: 19px; }

/* ================= ОСНОВНАЯ ОБЛАСТЬ ================= */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 54px;
  padding: 0 14px 0 12px;
  flex: 0 0 auto;
}
.topbar__spacer { flex: 1 1 auto; }

/* --- Пустое состояние --- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  /* Центрируем по вертикали, но держим композер чуть выше геометрического центра,
     как на референсе; снизу оставляем место под нижнюю панель. */
  padding: 0 24px 14vh;
  overflow: hidden;
}
.hero.is-hidden { display: none; }

/* ---------- Свечение вокруг поля ввода ----------
   Форма как у Gemini: тёмный ореол вокруг композера, от которого кругами
   расходятся цветные дуги. Размер считается от блока ввода в процентах,
   поэтому ореол повторяет его пропорции и держит одинаковые отступы по
   бокам на любой ширине экрана. */
.aurora {
  position: absolute;
  left: -16.031%;
  right: -16.031%;
  top: -35%;
  bottom: -35%;
  z-index: 0;
  pointer-events: none;
  opacity: .62;
  /* Растворяем ореол к краям, чтобы он не спорил с сайдбаром и заголовком */
  -webkit-mask-image: radial-gradient(closest-side, #000 34%, transparent 82%);
  mask-image: radial-gradient(closest-side, #000 34%, transparent 82%);
}

/* Ядро: тёмная масса, задающая объём ореола */
.aurora__core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, rgba(120, 145, 255, .14), transparent 62%),
    radial-gradient(closest-side, rgba(255, 255, 255, .045), transparent 40%);
  filter: blur(34px);
}

/* Цветные дуги по периметру — именно они дают разноцветный перелив */
.aurora__arc {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
  filter: blur(64px) saturate(135%);
  will-change: transform;
}

.aurora__arc--1 {
  inset: 27%;
  background: conic-gradient(from 0deg,
    transparent 0deg, rgba(80, 115, 255, .55) 60deg, transparent 140deg,
    transparent 205deg, rgba(60, 190, 255, .32) 255deg, transparent 325deg);
  animation: spin-a 30s linear infinite;
}

.aurora__arc--2 {
  inset: 33%;
  background: conic-gradient(from 120deg,
    transparent 0deg, rgba(165, 85, 255, .5) 62deg, transparent 145deg,
    transparent 215deg, rgba(255, 90, 155, .38) 268deg, transparent 332deg);
  animation: spin-b 38s linear infinite reverse;
}

.aurora__arc--3 {
  inset: 39%;
  background: conic-gradient(from 240deg,
    transparent 0deg, rgba(55, 205, 185, .38) 52deg, transparent 128deg,
    transparent 198deg, rgba(255, 175, 90, .3) 248deg, transparent 318deg);
  animation: spin-c 46s linear infinite;
}

/* Лёгкое зерно, чтобы градиенты не выглядели пластиковыми */
.aurora__grain {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(closest-side, #000 40%, transparent 78%);
  mask-image: radial-gradient(closest-side, #000 40%, transparent 78%);
}

@keyframes spin-a {
  from { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.06); }
  to   { transform: rotate(360deg) scale(1); }
}
@keyframes spin-b {
  from { transform: rotate(0deg) scale(1.05); }
  50%  { transform: rotate(180deg) scale(.97); }
  to   { transform: rotate(360deg) scale(1.05); }
}
@keyframes spin-c {
  from { transform: rotate(0deg) scale(.98); }
  50%  { transform: rotate(180deg) scale(1.07); }
  to   { transform: rotate(360deg) scale(.98); }
}

/* Контент поверх перелива */
.hero__title,
.hero .composer {
  position: relative;
  z-index: 1;
}

.hero__title {
  margin: 0 0 26px;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -.02em;
  color: var(--text);
  text-shadow: 0 2px 24px rgba(0, 0, 0, .55);
}

/* --- Композер --- */
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 780px);
  padding: 9px 10px 9px 8px;
  background: var(--bg-composer);
  border: 1px solid var(--border);
  border-radius: 28px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

/* Строка с полем ввода: кнопка, инпут, выбор модели, отправка */
.composer__row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Прикреплённые файлы над полем ввода */
.composer__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 2px 0;
}
.composer__attachments.is-hidden { display: none; }

.attach {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 230px;
  padding: 4px 6px 4px 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.attach__thumb {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-active);
  color: var(--text-faint);
}
.attach__thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach__thumb svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attach__meta { min-width: 0; }
.attach__name {
  display: block;
  max-width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attach__size { display: block; color: var(--text-faint); font-size: 11px; }
.attach__remove {
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .15s ease;
}
.attach__remove:hover { color: #ff9aa4; }
.attach__remove svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.attach.is-uploading { opacity: .6; }
.attach.is-error { border-color: rgba(255, 90, 105, .5); color: #ff9aa4; }

/* Подсветка композера при перетаскивании файлов */
.composer.is-dragover {
  border-color: rgba(140, 165, 255, .6);
  box-shadow: 0 0 0 3px rgba(120, 145, 255, .18);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Вложения в сообщении пользователя */
.msg__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.msg__file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, .07);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.msg__file svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Стеклянный вариант — только у центрального поля, чтобы перелив был виден сквозь него */
.composer--center {
  background: rgba(14, 14, 16, .62);
  -webkit-backdrop-filter: blur(30px) saturate(170%);
  backdrop-filter: blur(30px) saturate(170%);
  border-color: rgba(255, 255, 255, .20);
  box-shadow: 0 12px 44px rgba(0, 0, 0, .62), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.composer--center:focus-within {
  border-color: rgba(255, 255, 255, .34);
  box-shadow: 0 12px 50px rgba(0, 0, 0, .66), 0 0 0 3px rgba(255, 255, 255, .12);
}

html[data-theme="light"] .composer--center {
  background: rgba(255, 255, 255, .5);
  border-color: rgba(0, 0, 0, .12);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
}
html[data-theme="light"] .hero__title { text-shadow: none; }
html[data-theme="light"] .aurora { opacity: .5; filter: blur(72px) saturate(135%); }

/* Уважаем системную настройку «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  .aurora__blob { animation: none; }
}
.composer:focus-within { border-color: rgba(160, 160, 160, .45); box-shadow: 0 0 0 3px rgba(160, 160, 160, .10); }

.composer__add {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-dim);
  transition: background .15s ease, color .15s ease;
}
.composer__add:hover { background: var(--bg-hover); color: var(--text); }
.composer__add svg { width: 20px; height: 20px; }

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 4px;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
}
.composer__input::placeholder { color: var(--text-faint); }

.composer__send {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text-faint);
  transition: background .16s ease, color .16s ease, transform .12s ease;
}
.composer__send svg { width: 18px; height: 18px; }
.composer__send:not([disabled]) { background: var(--accent); color: var(--accent-ink); }
.composer__send:not([disabled]):hover { transform: scale(1.05); }

/* --- Диалог --- */
.chat { flex: 1 1 auto; min-height: 0; padding-top: 4px; }
.chat.is-hidden { display: none; }

/* ---------- Страницы «Библиотека» и «Память» ---------- */
.page {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 24px 40px;
}
.page.is-hidden { display: none; }

.page__head { margin: 8px 0 18px; }
.page__title { margin: 0 0 6px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.page__sub { margin: 0; color: var(--text-faint); font-size: 13.5px; }

.page__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.page__filters { display: flex; flex-wrap: wrap; gap: 6px; }
.page__search { flex: 1 1 200px; min-width: 160px; }
.page__search .field__input { width: 100%; box-sizing: border-box; }

.chip {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip.is-active { background: var(--bg-active); border-color: rgba(255, 255, 255, .22); color: var(--text); }

.page__body { min-height: 0; }

/* Пустое состояние внутри страницы */
.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-faint);
}
.empty__title { font-size: 15px; color: var(--text-dim); }
.empty__text { font-size: 13px; max-width: 360px; line-height: 1.55; }
.empty__icon { width: 40px; height: 40px; opacity: .35; }
.empty__icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty__action { margin-top: 6px; }

/* Сетка файлов */
.files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.file-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-composer);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.file-card:hover { border-color: rgba(255, 255, 255, .2); }
.file-card__preview {
  position: relative;
  display: grid;
  place-items: center;
  height: 104px;
  background: var(--bg-active);
  color: var(--text-faint);
  overflow: hidden;
}
.file-card__preview img { width: 100%; height: 100%; object-fit: cover; }
.file-card__preview svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.file-card__badge {
  position: absolute;
  top: 8px; left: 8px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  font-size: 10.5px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff;
}
.file-card__body { padding: 10px 11px 11px; }
.file-card__name {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-card__meta { margin: 0; color: var(--text-faint); font-size: 11.5px; }
.file-card__note { margin: 5px 0 0; font-size: 11.5px; color: #8ea2ff; }
.file-card__actions {
  display: flex;
  gap: 4px;
  margin-top: 9px;
}
.file-card__actions .msg__action { opacity: 1; }
.file-card__actions .msg__action svg { width: 14px; height: 14px; }

/* Предупреждение о переполнении памяти */
.mem-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 90, 105, .45);
  border-radius: 12px;
  background: rgba(255, 90, 105, .1);
  color: #ffb3ba;
  font-size: 13.5px;
  line-height: 1.5;
}
.mem-alert svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mem-alert strong { color: #ffd0d5; }

.mem-blocked {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 90, 105, .6);
  border-radius: 12px;
  background: rgba(255, 90, 105, .16);
  color: #ffd0d5;
  font-size: 13.5px;
}

/* Предупреждение в ленте чата: снять нельзя, только освободить место */
.quota-banner {
  width: min(100%, 780px);
  margin: 0 auto 14px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 90, 105, .55);
  border-radius: 14px;
  background: rgba(255, 90, 105, .13);
  color: #ffc4ca;
  font-size: 13.5px;
  line-height: 1.5;
}
.quota-banner strong { display: block; margin-bottom: 4px; color: #ffd7dc; font-size: 14.5px; }
.quota-banner a, .quota-banner button {
  color: #ffd7dc;
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

/* Мемори-запись: список чатов с выжимками */
.chat__scroll {
  height: 100%;
  overflow-y: auto;
  padding: 8px 24px 24px;
  scroll-behavior: smooth;
}

.thread {
  width: min(100%, 780px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg { display: flex; flex-direction: column; }

.msg--user { align-items: flex-end; }
.msg--user .msg__bubble {
  max-width: 78%;
  padding: 11px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px 18px 4px 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg--ai .msg__bubble {
  display: flex;
  gap: 12px;
  max-width: 100%;
}
.msg__avatar {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}
.msg__body { min-width: 0; white-space: pre-wrap; word-break: break-word; }

/* Кнопки действий под ответом ИИ — прячутся, пока курсор не на сообщении */
.msg__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity .15s ease;
}
.msg:hover .msg__actions,
.msg:focus-within .msg__actions { opacity: 1; }
.msg--error .msg__actions { opacity: 1; }

.msg__action {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.msg__action:hover { color: var(--text); background: var(--bg-hover); }
.msg__action:disabled { opacity: .45; cursor: default; }
.msg__action--danger:hover { color: #ff9aa4; background: transparent; }
.msg__action svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* Статус ожидания: приглушённая надпись с переливом слева направо */
.thinking { padding: 2px 0 4px; }
.thinking__toggle {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  cursor: pointer;
  color: var(--text-faint);
  background-image: linear-gradient(90deg, #63666e 0%, #63666e 32%, #d3d5da 50%, #63666e 68%, #63666e 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: thinking-flow 2.4s linear infinite;
}
.thinking__toggle:hover { color: var(--text-dim); }
@keyframes thinking-flow {
  from { background-position: 100% 0; }
  to   { background-position: -200% 0; }
}
.thinking__details {
  margin: 6px 0 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
}
@media (prefers-reduced-motion: reduce) {
  .thinking__toggle { animation: none; background-position: 0 0; }
}

/* Точки «печатает» */
.typing { display: inline-flex; gap: 4px; padding-top: 7px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
  animation: blink 1.3s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* --- Док композера снизу --- */
.composer-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 24px 14px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
.composer-dock.is-hidden { display: none; }
.disclaimer { margin: 0; color: var(--text-faint); font-size: 12px; }

/* ================= АДАПТИВ ================= */
@media (max-width: 820px) {
  :root { --sidebar-w: 262px; }
  .sidebar { position: fixed; z-index: 30; box-shadow: var(--shadow); }
  body:not(.is-collapsed)::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 20;
  }
  body.is-collapsed .sidebar { box-shadow: none; }
  .hero__title { font-size: 25px; }
  .msg--user .msg__bubble { max-width: 88%; }
}

/* ================= МОДАЛЬНОЕ ОКНО ВХОДА / РЕГИСТРАЦИИ ================= */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}
.auth-modal.is-hidden { display: none; }

/* Подложка: размывает интерфейс под модалкой */
.auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  animation: backdrop-in .28s ease both;
}
html[data-theme="light"] .auth-modal__backdrop { background: rgba(255, 255, 255, .45); }

@keyframes backdrop-in {
  from { opacity: 0; -webkit-backdrop-filter: blur(0px); backdrop-filter: blur(0px); }
  to   { opacity: 1; -webkit-backdrop-filter: blur(18px) saturate(120%); backdrop-filter: blur(18px) saturate(120%); }
}

@keyframes backdrop-out {
  from { opacity: 1; -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
  to   { opacity: 0; -webkit-backdrop-filter: blur(0px); backdrop-filter: blur(0px); }
}

/* Закрытие: подложка гаснет, карточка уезжает вниз */
.auth-modal.is-closing .auth-modal__backdrop { animation: backdrop-out .2s ease both; }
.auth-modal.is-closing .auth__card { animation: card-out .2s ease both; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes card-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(10px) scale(.97); }
}

.auth__card {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  padding: 28px 28px 22px;
  /* Подложка уже размывает фон, поэтому карточке достаточно плотного фона —
     второй backdrop-filter только замыливал бы её содержимое. */
  background: rgba(18, 18, 21, .92);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .09);
  animation: card-in .3s cubic-bezier(.2, .8, .3, 1) both;
}
html[data-theme="light"] .auth__card {
  background: rgba(255, 255, 255, .82);
  border-color: rgba(0, 0, 0, .10);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .16), inset 0 1px 0 rgba(255, 255, 255, .8);
}

.auth__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 22px;
}
.auth__brand .brand__name { font-size: 18px; }

.auth__tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--bg-hover);
  border-radius: 12px;
}
.auth__tab {
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.auth__tab:hover { color: var(--text); }
.auth__tab.is-active { background: var(--bg-active); color: var(--text); }

.auth__form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
/* Атрибут hidden перебивается нашим display: flex, поэтому скрываем классом */
.field.is-off { display: none; }
.field__label { color: var(--text-dim); font-size: 13px; font-weight: 500; }
.field__wrap { position: relative; display: block; }

.field__input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-composer);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field__input::placeholder { color: var(--text-faint); }
.field__input:focus {
  border-color: rgba(150, 170, 255, .55);
  box-shadow: 0 0 0 3px rgba(120, 145, 255, .14);
}
.field__wrap .field__input { padding-right: 42px; }

.field__peek {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-faint);
  transition: background .15s ease, color .15s ease;
}
.field__peek:hover { background: var(--bg-hover); color: var(--text); }
.field__peek svg { width: 18px; height: 18px; }
.field__peek.is-on { color: var(--text); }

.auth__error {
  margin: 0;
  padding: 9px 12px;
  background: rgba(255, 90, 105, .12);
  border: 1px solid rgba(255, 90, 105, .32);
  border-radius: 10px;
  color: #ff8b96;
  font-size: 13.5px;
}
.auth__error.is-hidden { display: none; }

.btn-primary {
  margin-top: 4px;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: transform .12s ease, opacity .15s ease;
}
.btn-primary:hover:not([disabled]) { transform: translateY(-1px); }
.btn-primary[disabled] { opacity: .55; cursor: default; }

.auth__hint {
  margin: 16px 0 0;
  color: var(--text-faint);
  font-size: 13.5px;
  text-align: center;
}
.auth__link {
  color: var(--text);
  font-size: 13.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth__link:hover { color: #9fb4ff; }

/* ================= МОДАЛКА АККАУНТА ================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal.is-hidden { display: none; }

/* Окна, которые открываются поверх настроек: без этого они оказываются
   за ними, потому что .settings-modal имеет собственный z-index. */
#exportModal,
#confirmModal { z-index: 120; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.modal__panel {
  position: relative;
  width: min(100%, 380px);
  padding: 24px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.modal__title { margin: 0 0 18px; font-size: 18px; font-weight: 600; }

.modal__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.modal__row:last-of-type { border-bottom: 0; }
.modal__label { color: var(--text-faint); font-size: 13.5px; }
.modal__value { color: var(--text); font-size: 14.5px; font-weight: 500; text-align: right; }

.modal__actions { margin-top: 18px; }
.modal__panel--confirm { width: min(100%, 340px); }
.modal__text { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.modal__panel--confirm .modal__actions {
  display: flex;
  gap: 8px;
}
.modal__panel--confirm .modal__actions > * { flex: 1 1 0; }

/* Окно экспорта контекста */
.modal__panel--export { width: min(100%, 420px); }
.modal__panel--export .modal__text { margin-bottom: 18px; }
.modal__panel--export .set-field { margin-bottom: 16px; }
.modal__panel--export .settings__actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.modal__panel--export .settings__actions > * { flex: 1 1 0; }

.export-choice { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.export-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.export-option:hover { background: var(--bg-hover); }
.export-option:has(input:checked) {
  border-color: rgba(255, 255, 255, .3);
  background: var(--bg-active);
}
.export-option:has(input:disabled) { opacity: .5; cursor: default; }
.export-option input { margin: 2px 0 0; accent-color: var(--accent); }
.export-option__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.export-option__label { font-size: 13.5px; }
.export-option__hint { color: var(--text-faint); font-size: 11.5px; line-height: 1.4; }

.btn-danger {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 90, 105, .14);
  border: 1px solid rgba(255, 90, 105, .35);
  border-radius: 12px;
  color: #ff9aa4;
  font-size: 14.5px;
  font-weight: 600;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-danger:hover { background: rgba(255, 90, 105, .22); border-color: rgba(255, 90, 105, .55); color: #ffb3ba; }

.btn-ghost {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-ghost:hover { background: rgba(255, 90, 105, .14); border-color: rgba(255, 90, 105, .4); color: #ff9aa4; }

/* Экран входа — оверлей поверх интерфейса, а не стена: гость может его закрыть
   и пользоваться сайтом. Поэтому is-locked ничего не скрывает. */

@media (max-width: 820px) {
  .auth__card { padding: 24px 20px 18px; }
}

/* Закрытие экрана входа и гостевой режим */
.auth__close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--text-faint);
  transition: background .15s ease, color .15s ease;
}
.auth__close:hover { background: var(--bg-hover); color: var(--text); }
.auth__close svg { width: 17px; height: 17px; }

.auth__guest {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 14px;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.auth__guest:hover { background: var(--bg-hover); color: var(--text); border-color: rgba(160, 160, 160, .3); }

.btn-primary.is-hidden,
.btn-ghost.is-hidden { display: none; }

/* Гость пользуется интерфейсом наравне со всеми — поэтому is-locked
   только подсказывает, что аккаунта нет, и ничего не скрывает. */

/* ================= МОДАЛЬНОЕ ОКНО НАСТРОЕК ================= */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}
.settings-modal.is-hidden { display: none; }

.settings-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  animation: backdrop-in .28s ease both;
}
html[data-theme="light"] .settings-modal__backdrop { background: rgba(255, 255, 255, .45); }
.settings-modal.is-closing .settings-modal__backdrop { animation: backdrop-out .2s ease both; }
.settings-modal.is-closing .settings { animation: card-out .2s ease both; }

.settings {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 680px);
  max-height: min(86vh, 620px);
  background: rgba(18, 18, 21, .94);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .09);
  animation: card-in .3s cubic-bezier(.2, .8, .3, 1) both;
  overflow: hidden;
}
html[data-theme="light"] .settings {
  background: rgba(255, 255, 255, .96);
  border-color: rgba(0, 0, 0, .10);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .18);
}

.settings__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px 24px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.settings__title { margin: 0; font-size: 18px; font-weight: 600; }

.settings__body {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
}

/* Вертикальный список вкладок слева */
.settings__tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 168px;
  padding: 12px;
  border-right: 1px solid var(--border);
}
.settings__tab {
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14.5px;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}
.settings__tab:hover { background: var(--bg-hover); color: var(--text); }
.settings__tab.is-active { background: var(--bg-active); color: var(--text); font-weight: 500; }

.settings__panes {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px 24px;
}
.settings__pane { display: none; flex-direction: column; gap: 14px; }
.settings__pane.is-active { display: flex; }

/* Строки «подпись — значение» */
.set-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.set-row__label { color: var(--text-faint); font-size: 13.5px; }
.set-row__value { color: var(--text); font-size: 14.5px; font-weight: 500; text-align: right; }

/* Поля ввода */
.set-field { display: flex; flex-direction: column; gap: 6px; }
.set-field__label { color: var(--text-dim); font-size: 13.5px; font-weight: 500; }
.set-field__hint { color: var(--text-faint); font-size: 12.5px; }

/* Переключатели */
.set-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.set-toggle:last-of-type { border-bottom: 0; }
.set-toggle__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-toggle__label { font-size: 14.5px; }
.set-toggle__hint { color: var(--text-faint); font-size: 12.5px; }

.switch {
  flex: 0 0 42px;
  appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin: 0;
  background: var(--bg-active);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .18s cubic-bezier(.3, .8, .3, 1), background .18s ease;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--accent-ink); }

.settings__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
.settings__actions .btn-primary,
.settings__actions .btn-ghost { width: auto; margin-top: 0; flex: 1 1 auto; }

.btn-ghost--danger:hover {
  background: rgba(255, 90, 105, .14);
  border-color: rgba(255, 90, 105, .4);
  color: #ff9aa4;
}

/* Функции, отключаемые в настройках */
body.no-aurora .aurora { display: none; }
body.no-hints .chips { display: none; }

@media (max-width: 700px) {
  .settings { max-height: 90vh; }
  .settings__body { flex-direction: column; }
  .settings__tabs {
    flex: 0 0 auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .settings__tab { white-space: nowrap; }
  .settings__panes { padding: 16px 18px 20px; }
}

/* ================= ВЫБОР МОДЕЛИ В ШАПКЕ ================= */
.model-picker { position: relative; }

/* Внутри поля ввода: компактно, без рамок, меню раскрывается вверх */
.model-picker--in-composer { flex: 0 0 auto; }

.model-picker__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: color .15s ease;
  white-space: nowrap;
}
.model-picker__btn:hover { color: var(--text); }
.model-picker__btn[aria-expanded="true"] { color: var(--text); }

/* Значок модели: картинка, если задана, иначе цветная точка.
   Один и тот же класс используется в кнопке и в списке. */
.model-picker__mark,
.model-item__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
}

.model-picker__mark img,
.model-item__mark img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
  /* Логотипы моделей светлые на тёмном фоне — добавляем лёгкий ореол */
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, .18));
}

.model-picker__mark--dot,
.model-item__mark--dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mc, #888);
  align-self: center;
}

.model-picker__label { font-weight: 500; white-space: nowrap; }
.model-picker__caret { width: 14px; height: 14px; color: var(--text-faint); transition: transform .18s ease; }
.model-picker__btn:hover .model-picker__caret { color: var(--text-dim); }
.model-picker__btn[aria-expanded="true"] .model-picker__caret { transform: rotate(180deg); }

/* Выпадающий список */
.model-menu {
  position: absolute;
  /* Раскрываем вверх: поле стоит у нижнего края области */
  bottom: calc(100% + 12px);
  right: 0;
  z-index: 40;
  width: 352px;
  max-width: min(88vw, 352px);
  /* Высоту списка под доступное место задаёт JS при открытии (openModelMenu) */
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  transform-origin: bottom right;
  animation: menu-in .16s cubic-bezier(.2, .8, .3, 1) both;
}
.model-menu.is-hidden { display: none; }
.model-menu.is-closing { animation: menu-out .13s ease both; }

/* В нижнем композере меню тоже уходит вверх — места снизу нет */
#composerBottom .model-menu { bottom: calc(100% + 12px); top: auto; }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes menu-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(4px) scale(.98); }
}

.model-menu__head {
  padding: 8px 10px 6px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.model-menu__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
  /* Высоту под доступное место задаёт JS при открытии */
  overflow-y: auto;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
  transition: background .13s ease;
}
.model-item:hover { background: var(--bg-hover); }
.model-item.is-active { background: var(--bg-active); }

/* Только значок и название — в одну строку, без пояснений */
.model-item__name {
  flex: 1 1 auto;
  color: var(--text);
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item__check { flex: 0 0 16px; width: 16px; height: 16px; color: var(--accent); opacity: 0; }
.model-item.is-active .model-item__check { opacity: 1; }

.model-menu__foot {
  padding: 8px 10px 4px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.model-menu__hint { color: var(--text-faint); font-size: 12px; }

/* На узких экранах прячем название модели, оставляя точку и стрелку */
@media (max-width: 640px) {
  .model-picker__label { display: none; }
  .model-menu { width: min(88vw, 320px); }
}

/* ================= КВОТЫ В ЛИМИТАХ ================= */
.set-note {
  margin: 0 0 4px;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.45;
}

.quota-list { display: flex; flex-direction: column; gap: 14px; }

.quota {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.quota__top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.quota__dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--qc, #888);
}

.quota__name { flex: 1 1 auto; font-size: 14px; color: var(--text); }

.quota__pct {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.quota__bar {
  position: relative;
  height: 6px;
  background: var(--bg-active);
  border-radius: 99px;
  overflow: hidden;
}

.quota__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 99px;
  background: var(--qc, #7aa2ff);
  transition: width .45s cubic-bezier(.3, .8, .3, 1);
}

/* Предупреждение и исчерпание */
.quota.is-warn .quota__pct { color: #ffb84d; }
.quota.is-warn .quota__fill { background: #ffb84d; }
.quota.is-full .quota__pct { color: #ff7b86; }
.quota.is-full .quota__fill { background: #ff7b86; }

.quota__hint { color: var(--text-faint); font-size: 12px; }

/* Общий месячный лимит */
.quota-total {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.quota-total__bar {
  position: relative;
  flex: 1 1 auto;
  height: 8px;
  background: var(--bg-active);
  border-radius: 99px;
  overflow: hidden;
}
.quota-total__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #5a7dff, #b45cff);
  transition: width .45s cubic-bezier(.3, .8, .3, 1);
}
.quota-total__pct {
  flex: 0 0 auto;
  min-width: 42px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Строка-переключатель (переиспользуется в настройках) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.toggle-row:last-of-type { border-bottom: 0; }
.toggle-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle-row__label { font-size: 14.5px; }
.toggle-row__hint { color: var(--text-faint); font-size: 12.5px; }

/* ================= ФИКСИРОВАННЫЙ РАЗМЕР МОДАЛКИ НАСТРОЕК =================
   Окно всегда одной высоты, вкладки не «прыгают». Если содержимое не влезает —
   прокручивается только область контента. */
.settings {
  height: min(86vh, 560px);
  max-height: min(86vh, 560px);
}

/* Список вкладок тоже прокручивается, если их станет много */
.settings__tabs { overflow-y: auto; }

.settings__panes { overscroll-behavior: contain; }

@media (max-height: 620px) {
  .settings { height: 92vh; max-height: 92vh; }
}

/* Ошибка получения ответа */
.msg--error .msg__body { color: #ff9aa4; }
.msg--error .msg__avatar { background: rgba(255, 90, 105, .2); color: #ff9aa4; }
