/* ===== AI Zone — интерфейс чата ===== */
:root {
  color-scheme: dark; /* системные панели браузера (в т.ч. нижняя на Android) — тёмные, без бело-чёрных скачков */
  --bg: #07070c;
  --sidebar: #0b0c14;
  --panel: #11121d;   /* фон выпадающих меню/поповеров */
  --panel-2: #0e0f1a; /* фон модальных карточек */
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f5fb;
  --text-dim: #a6a8b8;
  --text-faint: #7d7f93; /* было #6b6d80 — давало ~4:1 на --bg, ниже WCAG AA (4.5:1) для мелкого текста */
  --violet: #7c5cff;
  --violet-2: #9d7bff;
  --cyan: #2bd6ff;
  --grad: linear-gradient(120deg, #7c5cff 0%, #5b8bff 45%, #2bd6ff 100%);
  --grad-soft: linear-gradient(120deg, rgba(124,92,255,.16), rgba(43,214,255,.16));
  --sidebar-w: 280px;
  --sidebar-rail: 74px;
}

/* ===== Светлая тема (переключатель в шапке, сохраняется в localStorage) ===== */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fc;
  --sidebar: #eceff7;
  --surface: rgba(0,0,0,.045);
  --surface-2: rgba(0,0,0,.08);
  --border: rgba(0,0,0,.1);
  --border-strong: rgba(0,0,0,.18);
  --text: #1a1c2b;
  --text-dim: #5b5e72;
  --text-faint: #6a6d82; /* было #8a8da1 — давало ~3:1 на светлом --bg, ниже WCAG AA */
  --panel: #ffffff;
  --panel-2: #ffffff;
}
/* инвертированная кнопка (фон = var(--text)): в светлой теме текст белый, иначе сольётся */
[data-theme="light"] .btn-upgrade { color: #fff; }
/* Точечные правки светлой темы (где был жёстко задан белый текст/тёмный фон) */
[data-theme="light"] .row--bot .bubble { background: #fff; }
[data-theme="light"] .bubble strong,
[data-theme="light"] .md-h { color: #0e1020; }
[data-theme="light"] h4.md-h { color: var(--text); }
[data-theme="light"] .md-table th { background: rgba(0,0,0,.05); }
[data-theme="light"] .md-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.02); }
[data-theme="light"] .typing span { background: #9a9db0; }
[data-theme="light"] .topbar { background: rgba(255,255,255,.72); }
[data-theme="light"] .chat-menu { background: #fff; }
[data-theme="light"] .share-url { background: #f0f2f8; }
/* Кнопка переключения темы в шапке */
/* Переключатель темы: база — свитч (ПК). На мобиле переопределяется в иконку (медиазапрос). */
.icon-btn.topbar__theme { width: auto; height: auto; padding: 0; background: none; }
.icon-btn.topbar__theme:hover { background: none; }
.theme-sw { position: relative; display: inline-flex; align-items: center; width: 52px; height: 28px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); transition: background .2s; }
.theme-sw__sun, .theme-sw__moon { position: absolute; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; }
.theme-sw__sun { left: 6px; color: #ffb45c; }
.theme-sw__moon { right: 6px; color: #9db8ff; }
.theme-sw__knob { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); transform: translateX(24px); transition: transform .22s ease; }
[data-theme="light"] .theme-sw__knob { transform: translateX(0); }
[data-theme="light"] .theme-sw { background: rgba(0,0,0,.08); }

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Единый видимый фокус для клавиатурной навигации (Tab) — кнопки на тёмном фоне без
   рамки (.icon-btn, .ctool, история чатов, аккаунт…) иначе не показывают, где фокус. */
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
/* Брендированный скроллбар и выделение текста — раньше был дефолтный системный
   (серый/синий), который выбивался из премиум-стиля везде, кроме 3 точечных мест. */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.24); background-clip: padding-box; }
::selection { background: var(--violet); color: #fff; }
[data-theme="light"] * { scrollbar-color: rgba(0,0,0,.18) transparent; }
[data-theme="light"] *::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); }
[data-theme="light"] *::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.28); }
html, body { height: 100%; width: 100%; overflow-x: hidden; background: var(--bg); }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-family: 'Sora', 'Manrope', system-ui, sans-serif; font-weight: 800; font-size: 19px; }
.logo__mark { display: grid; place-items: center; width: 40px; height: 40px; filter: drop-shadow(0 6px 14px rgba(124,92,255,.55)); }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: none; background: transparent; color: var(--text-dim);
  cursor: pointer; transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ===== Каркас ===== */
.app { display: flex; height: 100vh; height: 100dvh; }

/* ===== Сайдбар ===== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 14px;
  transition: transform .3s ease, width .25s ease, padding .25s ease;
}
.sidebar__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; padding: 0 4px; }

/* ===== Свёрнутый сайдбар — узкий иконочный рейл (только десктоп) ===== */
@media (min-width: 821px) {
  .app.sidebar-collapsed .sidebar { width: var(--sidebar-rail); padding: 16px 10px; }
  .app.sidebar-collapsed .logo,
  .app.sidebar-collapsed .new-chat .lbl,
  .app.sidebar-collapsed .gallery-btn .lbl,
  .app.sidebar-collapsed .img-toggle .lbl,
  .app.sidebar-collapsed .img-toggle__chev,
  .app.sidebar-collapsed .sidebar__section-label,
  .app.sidebar-collapsed .img-nav,
  .app.sidebar-collapsed .img-nav.is-open,
  .app.sidebar-collapsed .history-search,
  .app.sidebar-collapsed .history,
  .app.sidebar-collapsed .balance-card,
  .app.sidebar-collapsed .side-support span,
  .app.sidebar-collapsed .account__info { display: none; }
  .app.sidebar-collapsed .side-support { justify-content: center; padding: 9px 0; }
  .app.sidebar-collapsed .sidebar__top { justify-content: center; margin-bottom: 14px; }
  .app.sidebar-collapsed .sidebar__collapse svg { transform: rotate(180deg); } /* стрелка → «развернуть» */
  .app.sidebar-collapsed .new-chat,
  .app.sidebar-collapsed .gallery-btn,
  .app.sidebar-collapsed .img-toggle { padding: 12px 0; gap: 0; justify-content: center; }
  .app.sidebar-collapsed .account { justify-content: center; padding: 8px 0; }
  /* Аккаунт — в самый низ колонки (история скрыта и больше не распирает) */
  .app.sidebar-collapsed .sidebar__bottom { margin-top: auto; }
}

.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 13px; border-radius: 12px;
  background: var(--grad); color: #fff; border: none; cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif; font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 28px -10px rgba(124,92,255,.7);
  transition: transform .18s, box-shadow .25s;
}
.new-chat:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -10px rgba(124,92,255,.85); }

.gallery-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 11px; margin-top: 9px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif; font-weight: 700; font-size: 14px;
  transition: background .2s, color .2s, border-color .2s;
}
.gallery-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

/* Сворачиваемая кнопка «Создать изображение» + список моделей */
.img-toggle {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 11px 13px; margin-top: 9px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif; font-weight: 700; font-size: 14px;
  transition: background .2s, color .2s, border-color .2s;
}
.img-toggle:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.img-toggle .lbl { flex: 1; text-align: left; }
.img-toggle__ic { flex-shrink: 0; display: grid; place-items: center; }
.img-toggle__chev { flex-shrink: 0; color: var(--text-faint); transition: transform .25s; }
.img-toggle.is-open .img-toggle__chev { transform: rotate(180deg); } /* десктоп: › → ‹ (окно вбок) */
/* Телефон: меню открывается вниз — стрелка вниз (∨), открыто — вверх (∧) */
@media (max-width: 820px) {
  .img-toggle__chev { transform: rotate(90deg); }
  .img-toggle.is-open .img-toggle__chev { transform: rotate(270deg); }
}
.img-toggle.is-active { color: var(--text); border-color: rgba(124,92,255,.4); background: var(--grad-soft); }
.img-toggle.is-active .img-toggle__ic { color: var(--violet-2); }

/* Модели генерации картинок — всплывающее окно с карточками (как у выбора текстовой модели) */
.img-section { position: relative; }
.img-nav { display: none; flex-direction: column; gap: 8px; }
.img-nav.is-open {
  display: flex; flex-direction: column; gap: 8px;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px;
  padding: 10px; max-height: 58vh; overflow-x: hidden; overflow-y: auto;
  box-shadow: 0 28px 64px -22px rgba(0, 0, 0, .75);
}
.img-nav.is-open::-webkit-scrollbar { width: 8px; }
.img-nav.is-open::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 8px; }
.img-nav__item {
  position: relative; flex-shrink: 0;
  display: flex; align-items: flex-start; gap: 11px; width: 100%; min-width: 0; text-align: left;
  padding: 13px 14px; border-radius: 15px; cursor: pointer;
  background: var(--surface); border: 1px solid transparent; color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif;
  transition: background .18s, border-color .18s, transform .15s;
}
.img-nav__item:hover { background: var(--surface-2); transform: translateY(-1px); }
.img-nav__item.is-active { background: var(--grad-soft); border-color: rgba(124, 92, 255, .5); }
.img-nav__ic { flex-shrink: 0; display: grid; place-items: center; margin-top: 1px; }
.img-nav__logo { width: 22px; height: 22px; background-color: #aeb0c0;
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.img-nav__kic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; }
.img-nav__kic--aud { color: #2bd6ff; background: rgba(43, 214, 255, .12); }
.img-nav__kic--mus { color: #a78bfa; background: rgba(167, 139, 250, .14); }
.img-nav__klogo { width: 19px; height: 19px; background-color: currentColor;
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.img-nav__meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.img-nav__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 7px; padding-right: 22px; }
.img-nav__name { font-weight: 700; font-size: 13.5px; line-height: 1.25; letter-spacing: -.01em; }
.img-nav__cost { flex-shrink: 0; font-size: 10.5px; font-weight: 700; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
/* Акцентный бейдж цены — только у аудио/музыки (бирюза / фиолет) */
#audNav .img-nav__cost { color: #2bd6ff; background: rgba(43, 214, 255, .1); border-color: rgba(43, 214, 255, .22); }
#musNav .img-nav__cost { color: #a78bfa; background: rgba(167, 139, 250, .12); border-color: rgba(167, 139, 250, .24); }
.img-nav__desc { display: block; font-size: 11.5px; color: var(--text-dim); line-height: 1.4; margin-top: 5px; }
/* Десктоп: окно открывается ВБОК (флайаут вправо, в область чата), 2 колонки — как меню текстовых моделей */
@media (min-width: 821px) {
  .img-nav.is-open {
    top: 0; left: calc(100% + 12px); right: auto; width: 384px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start;
    max-height: 74vh; z-index: 70;
  }
}

/* Модалка галереи */
.gal-overlay {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 4, 9, .74); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s;
}
.gal-overlay.is-open { opacity: 1; visibility: visible; }
.gal-card {
  position: relative; width: 100%; max-width: 760px; max-height: 86vh; overflow-y: auto;
  background: var(--panel-2); border: 1px solid rgba(255, 255, 255, .12); border-radius: 22px; padding: 28px 26px 24px;
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .85);
}
.gal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; border: none; background: var(--surface); color: var(--text-dim); font-size: 20px; cursor: pointer; display: grid; place-items: center; transition: .2s; }
.gal-close:hover { background: var(--surface-2); color: #fff; }
.gal-title { font-family: 'Sora', 'Manrope', sans-serif; font-size: 20px; font-weight: 800; margin-bottom: 18px; }
.gal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gal-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; cursor: zoom-in; transition: opacity .2s, transform .18s; }
.gal-thumb:hover { opacity: .9; transform: scale(1.02); }
.gal-empty { grid-column: 1 / -1; color: var(--text-faint); font-size: 14px; padding: 26px 0; text-align: center; }

/* Пустые состояния с иконкой (история/галерея/платежи) — раньше был только
   серый текст, премиум-приложения дают лёгкую иллюстрацию вместо пустоты. */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 34px 16px; text-align: center; }
.empty-state__ic { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: var(--grad-soft); color: var(--violet); flex-shrink: 0; }
.empty-state__ic svg { width: 24px; height: 24px; }
.empty-state__text { font-size: 13.5px; line-height: 1.55; color: var(--text-faint); max-width: 230px; }

/* Spotlight за курсором (как на лендинге у .card/.bento__tile) — позиция задаётся
   JS через --mx/--my на mousemove. Подключено к .model-card/.img-nav__item/.model-hero. */
.spot { overflow: hidden; }
.spot::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity .35s; border-radius: inherit;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(124, 92, 255, .22), transparent 55%);
}
.spot:hover::after { opacity: 1; }
/* Сайдбар уже у́же остальных мест — иконка/паддинги чуть компактнее */
.history__empty.empty-state { padding: 20px 8px; gap: 10px; }
.history__empty .empty-state__ic { width: 40px; height: 40px; border-radius: 12px; }
.history__empty .empty-state__ic svg { width: 19px; height: 19px; }
.history__empty .empty-state__text { font-size: 12.5px; max-width: 180px; }
@media (max-width: 560px) { .gal-grid { grid-template-columns: 1fr 1fr; } }

.sidebar__section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); margin: 22px 6px 8px; }
/* Поиск по истории чатов */
.history-search {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-faint); transition: border-color .2s;
}
.history-search:focus-within { border-color: rgba(124,92,255,.45); }
.history-search svg { flex-shrink: 0; }
.history-search input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text); font: inherit; font-size: 13.5px;
}
.history-search input::placeholder { color: var(--text-faint); }
.history-search input::-webkit-search-cancel-button { display: none; }
.history-search__clear {
  flex-shrink: 0; width: 20px; height: 20px; display: grid; place-items: center;
  border: none; background: var(--surface-2); color: var(--text-dim); border-radius: 50%;
  cursor: pointer; font-size: 15px; line-height: 1; transition: background .15s, color .15s;
}
.history-search__clear:hover { background: var(--border-strong); color: var(--text); }

.history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 0 -4px; padding: 0 4px 4px;
  /* Плавное затухание списка снизу вместо жёсткой обрезки/«тёмной полосы» */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent); }
.history__item {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 14px; border-radius: 11px; cursor: pointer;
  color: var(--text-dim); font-size: 15px; transition: background .2s, color .2s;
  white-space: nowrap; overflow: hidden;
}
.history__item:hover { background: var(--surface); color: var(--text); }
.history__item.is-active { background: var(--surface-2); color: var(--text); }
.history__item .history__ic { flex-shrink: 0; opacity: .6; display: inline-grid; place-items: center; }
.history__item .history__pinned { opacity: .9; color: var(--violet-2); }
.history__item > span:not(.history__ic) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.history__rename {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--violet);
  border-radius: 7px; padding: 5px 8px; color: var(--text); font: inherit; font-size: 14px; outline: none;
}
.history__more {
  flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-faint); border-radius: 7px;
  cursor: pointer; opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.history__item:hover .history__more, .history__item.is-active .history__more { opacity: 1; }
.history__more:hover { background: var(--surface-2); color: var(--text); }
@media (hover: none) { .history__more { opacity: .65; } }
.history__empty { color: var(--text-faint); font-size: 13px; padding: 10px 12px; }

/* Заголовок папки (сворачиваемая группа чатов) */
.folder-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; margin: 4px 0 2px; border: none; background: transparent; cursor: pointer;
  color: var(--text-faint); font: inherit; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; border-radius: 8px;
  transition: background .15s, color .15s;
}
.folder-head:hover { background: var(--surface); color: var(--text-dim); }
.folder-head__chev { flex-shrink: 0; transform: rotate(90deg); transition: transform .2s; }
.folder-head.is-collapsed .folder-head__chev { transform: rotate(0deg); }
.folder-head__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.folder-head__count { flex-shrink: 0; font-size: 11px; opacity: .7; }

/* Подменю выбора папки (наследует .chat-menu) */
.folder-menu { max-height: 260px; overflow-y: auto; }
.folder-menu .chat-menu__ic { font-size: 14px; }

/* Контекстное меню чата */
.chat-menu {
  position: fixed; z-index: 1200; min-width: 190px; padding: 6px;
  background: #14151f; border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: 0 20px 50px -16px rgba(0, 0, 0, .8);
}
.chat-menu button {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 10px 11px; border: none; background: transparent; border-radius: 8px;
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer; transition: background .15s;
}
.chat-menu button:hover { background: var(--surface-2); }
.chat-menu .chat-menu__ic { display: grid; place-items: center; opacity: .8; }
.chat-menu button.is-danger { color: #ff6b8a; }
.chat-menu button.is-danger:hover { background: rgba(255, 90, 120, .12); }

.sidebar__bottom { margin-top: 6px; display: flex; flex-direction: column; gap: 12px; }
.balance-card { background: var(--grad-soft); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.balance-card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.balance-card__label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.balance-card__val { display: inline-flex; align-items: center; gap: 4px; }
.balance-card__val::before { content: '⚡'; font-size: 15px; }
.balance-card__val b { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 19px; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.btn-topup { width: 100%; padding: 10px; border-radius: 10px; border: none; background: var(--grad); color: #fff; font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 14px; cursor: pointer; transition: transform 0.18s, box-shadow 0.25s; box-shadow: 0 8px 22px -10px rgba(124, 92, 255, 0.7); }
.btn-topup:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -10px rgba(124, 92, 255, 0.85); }
.upsell { background: var(--grad-soft); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.upsell__title { font-weight: 700; font-size: 15px; margin-bottom: 5px; }
.upsell p { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.btn-upgrade { width: 100%; padding: 9px; border-radius: 10px; background: var(--text); color: #0b0b12; border: none; font-weight: 700; font-size: 14px; cursor: pointer; transition: opacity .2s; }
.btn-upgrade:hover { opacity: .9; }

.side-support { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: none; background: transparent; color: var(--text-dim); font-family: inherit; font-weight: 600; font-size: 13.5px; border-radius: 10px; cursor: pointer; transition: background .2s, color .2s; }
.side-support:hover { background: var(--surface); color: var(--text); }
.side-support svg { width: 16px; height: 16px; flex-shrink: 0; }
.account { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 12px; transition: background .2s; cursor: pointer; }
.account:hover { background: var(--surface); }
.account__avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(120deg,#ff5ca8,#ff9f5c); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.account__info { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.account__name { font-weight: 700; font-size: 14px; }
.account__plan { font-size: 12px; color: var(--text-faint); }

/* ===== Основная область ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  background: rgba(7,7,12,.7); backdrop-filter: blur(12px);
  /* Иконка приветствия (.welcome__logo) из-за filter:drop-shadow создаёт свой
     слой и шла в разметке после шапки — её искра вылезала поверх меню моделей.
     Поднимаем шапку (вместе с меню) над контентом чата. */
  position: relative; z-index: 50;
}
/* Гамбургер ☰ — только на мобиле (см. медиазапрос). На десктопе в свёрнутом рейле
   уже есть стрелка разворота, так что в шапке он не нужен. */
.topbar__menu { display: none; }
.topbar__theme { margin-left: auto; }
.btn-back { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--text-dim); transition: background .2s, color .2s; }
.btn-back:hover { background: var(--surface-2); color: var(--text); }

/* Селектор модели */
.model-select { position: relative; }
.model-select__btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; font-family: 'Manrope', system-ui, sans-serif; font-weight: 700; font-size: 15px;
  transition: background .2s, border-color .2s;
}
.model-select__btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.model-select__btn svg { color: var(--text-dim); }
.model-select__menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  width: 384px; max-width: 92vw; max-height: 70vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px;
  padding: 4px 10px 12px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.7);
}
.model-select__menu::-webkit-scrollbar { width: 8px; }
.model-select__menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 8px; }

/* Заголовки групп тарифов */
.model-group {
  display: flex; align-items: center; gap: 7px;
  padding: 13px 4px 8px; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .07em;
}
.model-group__icon { font-size: 13px; }
.tg-free { color: #43e08e; }
.tg-base { color: #a6a8b8; }
.tg-pro { color: #5b8bff; }
.tg-ultra { color: #ffb45c; }

/* Сетка карточек 2 колонки */
.model-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.model-card {
  border-radius: 14px; padding: 12px 13px; cursor: pointer;
  background: var(--surface); border: 1px solid transparent;
  transition: background .18s, border-color .18s, transform .15s;
}
.model-card:hover { background: var(--surface-2); transform: translateY(-1px); }
.model-card.is-selected { background: var(--grad-soft); border-color: rgba(124, 92, 255, .5); }
/* Карточка с фирменным значком провайдера */
.model-card.has-chip { display: flex; gap: 10px; align-items: flex-start; }
.model-card__chip { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; background-color: #aeb0c0;
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.model-card.is-selected .model-card__chip { background-color: var(--text); }
.model-card__body { flex: 1; min-width: 0; }
.model-card__name { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; font-weight: 700; font-size: 14px; line-height: 1.3; }
.model-card__check { opacity: 0; flex-shrink: 0; margin-top: 1px; transition: opacity .15s; }
.model-card.is-selected .model-card__check { opacity: 1; }
.model-card__desc { font-size: 12px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }

/* ----- Кнопка ⓘ «о модели» на карточках ----- */
.model-card { position: relative; }
.model-card__name { padding-right: 20px; } /* место под кнопку info, чтобы не наезжала на галочку */
.model-card__info {
  position: absolute; top: 7px; right: 7px; width: 22px; height: 22px; z-index: 2;
  display: grid; place-items: center; border: none; border-radius: 7px;
  background: transparent; color: var(--text-faint); cursor: pointer; opacity: .55; transition: .18s;
}
.model-card__info:hover { background: var(--surface-2); color: var(--text); opacity: 1; }
.img-nav__info {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  flex-shrink: 0; width: 24px; height: 24px;
  display: grid; place-items: center; border-radius: 8px;
  color: var(--text-faint); cursor: pointer; opacity: .55; transition: .18s;
}
.img-nav__info:hover { background: var(--surface); color: var(--text); opacity: 1; }

/* ----- Модалка «О модели» (инструкция + характеристики) ----- */
.minfo-overlay {
  position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 4, 9, .74); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; transition: .2s;
}
.minfo-overlay.is-open { opacity: 1; visibility: visible; }
.minfo-card {
  position: relative; width: min(880px, 100%); max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px; padding: 22px 24px;
  font-family: 'Manrope', sans-serif; color: var(--text); transform: translateY(10px); transition: transform .22s;
}
.minfo-overlay.is-open .minfo-card { transform: none; }
.minfo-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; border: none; background: var(--surface); color: var(--text-dim); font-size: 20px; cursor: pointer; display: grid; place-items: center; transition: .2s; }
.minfo-close:hover { background: var(--surface-2); color: #fff; }
.minfo-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-right: 40px; }
.minfo-ic { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--text); }
.minfo-ic .model-card__chip, .minfo-ic .img-nav__logo { width: 22px; height: 22px; background-color: #cdd0e0; }
.minfo-name { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 19px; line-height: 1.2; }
.minfo-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.minfo-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.minfo-col { min-width: 0; }
.minfo-h { font-weight: 800; font-size: 13.5px; margin: 16px 0 10px; }
.minfo-col > .minfo-h:first-child { margin-top: 0; }
.minfo-step { display: flex; gap: 10px; margin-bottom: 11px; }
.minfo-step__n { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; }
.minfo-step b { font-size: 13.5px; }
.minfo-step p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.minfo-about { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.minfo-caps { list-style: none; margin: 0; padding: 0; }
.minfo-caps li { font-size: 13px; line-height: 1.5; padding: 6px 0; border-bottom: 1px solid var(--border); }
.minfo-caps li:last-child { border-bottom: none; }
.minfo-include { list-style: none; margin: 0; padding: 0; }
.minfo-include li { position: relative; padding: 5px 0 5px 22px; font-size: 12.5px; line-height: 1.45; color: var(--text-dim); }
.minfo-include li::before { content: '✓'; position: absolute; left: 2px; top: 5px; color: var(--cyan); font-weight: 800; font-size: 12px; }
.minfo-when { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.minfo-ex { font-size: 12.5px; color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; margin-bottom: 7px; line-height: 1.4; }
.minfo-tip { margin-top: 12px; font-size: 12.5px; color: var(--text-dim); background: var(--grad-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; line-height: 1.5; }
.minfo-tip b { color: var(--text); }
@media (max-width: 640px) { .minfo-cols { grid-template-columns: 1fr; gap: 4px; } .minfo-card { padding: 18px 16px; } }

/* ===== Модалка «Аккаунт» ===== */
.acc-overlay {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 4, 9, .74); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s;
}
.acc-overlay.is-open { opacity: 1; visibility: visible; }
.acc-card {
  position: relative; width: 100%; max-width: 470px; max-height: 88vh; overflow-y: auto;
  border: 1px solid transparent; border-radius: 24px; padding: 28px 26px 22px;
  background:
    linear-gradient(#0e0f1a, #0e0f1a) padding-box,
    linear-gradient(150deg, rgba(124, 92, 255, .5), rgba(255, 255, 255, .07) 40%, rgba(43, 214, 255, .4)) border-box;
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .85);
}
.acc-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; border: none; background: var(--surface); color: var(--text-dim); font-size: 20px; cursor: pointer; display: grid; place-items: center; transition: .2s; }
.acc-close:hover { background: var(--surface-2); color: #fff; }
.acc-title { display: flex; align-items: center; gap: 10px; font-family: 'Sora', 'Manrope', sans-serif; font-size: 20px; font-weight: 800; margin-bottom: 18px; }

.acc-profile { display: flex; align-items: center; gap: 13px; margin-bottom: 16px; }
.acc-ava { width: 46px; height: 46px; border-radius: 13px; background: var(--grad); display: grid; place-items: center; font-weight: 800; font-size: 19px; color: #fff; flex-shrink: 0; }
.acc-name { font-weight: 800; font-size: 16px; }
.acc-mail { color: var(--text-dim); font-size: 13.5px; }

.acc-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.acc-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px; }
.acc-stat label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 6px; }
.acc-stat b { font-family: 'Sora', 'Manrope', sans-serif; font-size: 21px; font-weight: 800; }
.acc-stat b small { font-size: 12px; color: var(--text-dim); font-family: 'Manrope', sans-serif; font-weight: 600; }
.acc-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .08); margin-top: 9px; overflow: hidden; }
.acc-bar i { display: block; height: 100%; background: var(--grad); border-radius: 6px; }
.acc-link { display: block; margin-top: 7px; background: none; border: none; padding: 0; color: #5b8bff; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.acc-link:hover { text-decoration: underline; }

/* Плашка «почта не подтверждена» */
.acc-verify {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid rgba(255, 180, 92, .45); border-radius: 14px; padding: 12px 15px; margin-bottom: 16px;
  background: rgba(255, 180, 92, .07); font-size: 13.5px; color: var(--text-dim);
}
.acc-verify .acc-link { margin-top: 0; flex-shrink: 0; color: #ffb45c; }
.acc-verify .acc-link:disabled { opacity: .7; cursor: default; text-decoration: none; }

.acc-subrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid rgba(124, 92, 255, .4); border-radius: 14px; padding: 12px 15px; margin-bottom: 16px;
  background: var(--grad-soft); font-size: 13.5px;
}
.acc-subrow.is-active { border-color: rgba(67, 224, 142, .4); background: rgba(67, 224, 142, .06); }
.acc-subrow .acc-link { margin-top: 0; flex-shrink: 0; }

/* Промокод и рефералка */
.acc-promo, .acc-ref { margin-bottom: 16px; }
.acc-promo > label, .acc-ref > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 8px; }
.acc-ref__hint { font-size: 12.5px; color: var(--text-dim); margin: 0 0 9px; line-height: 1.5; }
.acc-promo__row { display: flex; gap: 8px; }
.acc-promo__row input {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 14px; color: var(--text); font: inherit; font-size: 14px;
}
.acc-promo__row input:focus { outline: none; border-color: var(--border-strong); }
.acc-promo__row input[readonly] { color: var(--text-dim); cursor: default; }
.acc-promo__btn {
  flex-shrink: 0; border: 1px solid transparent; border-radius: 12px; padding: 0 16px;
  background: var(--grad); color: #fff; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: filter .15s;
}
.acc-promo__btn:hover { filter: brightness(1.08); }
.acc-promo__btn:disabled { opacity: .6; cursor: default; }
.acc-promo__msg { font-size: 13px; margin-top: 7px; min-height: 16px; }
.acc-promo__msg.is-ok { color: #43e08e; }
/* Персонализация — текстовые поля «О себе»/«Как отвечать» */
.acc-pers__ta {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; resize: vertical;
  color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; min-height: 64px;
}
.acc-pers__ta:focus { outline: none; border-color: var(--border-strong); }
.acc-pers__ta::placeholder { color: var(--text-faint); }
/* Премиум-статус в кабинете */
.acc-premium-badge { display: inline-block; vertical-align: middle; margin-left: 8px; font-size: 11px; font-weight: 800;
  padding: 2px 9px; border-radius: 100px; color: #fff; background: linear-gradient(120deg, #7c5cff, #2bd6ff); letter-spacing: .02em; }
.acc-premium-bar { margin-bottom: 16px; padding: 11px 14px; border-radius: 12px; font-size: 13.5px; color: var(--text);
  background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(43,214,255,.08)); border: 1px solid rgba(124,92,255,.4); }
.acc-premium-bar b { color: #fff; }
.acc-promo__msg.is-err { color: #ff6b8a; }
.acc-ref__stat { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; }

.acc-payments label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 8px; }
.acc-pay { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; font-size: 13.5px; padding: 8px 2px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.acc-pay span:first-child { color: var(--text); }
.acc-ok { color: #43e08e; }
.acc-pend { color: #ffb45c; }
.acc-empty { color: var(--text-faint); font-size: 13.5px; padding: 8px 0; }

.acc-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.acc-btn { padding: 10px 18px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: inherit; font-weight: 700; font-size: 13.5px; cursor: pointer; transition: .2s; }
.acc-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.acc-danger { background: none; border: none; color: #ff8a8a; font-family: inherit; font-size: 12.5px; cursor: pointer; opacity: .8; }
.acc-danger:hover { opacity: 1; text-decoration: underline; }

/* ===== Лента чата ===== */
.chat { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat__inner { max-width: 980px; margin: 0 auto; padding: 32px 24px 24px; display: flex; flex-direction: column; gap: 26px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row--user { flex-direction: row-reverse; }
.row--bot { flex-wrap: wrap; }

/* Действия под ответом ИИ */
.msg-actions { width: 100%; margin-left: 48px; display: flex; gap: 3px; margin-top: 2px; }
.msg-act {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  border: none; background: none; color: var(--text-faint); cursor: pointer;
  transition: background .18s, color .18s;
}
.msg-act svg { width: 16px; height: 16px; }
.msg-act--flip svg { transform: rotate(180deg); }
.msg-act:hover { background: var(--surface-2); color: var(--text); }
.msg-act.is-on { color: var(--violet-2); }
.msg-act.is-done { color: #43e08e; }
/* Действия под сообщением пользователя (кнопка «Редактировать») — справа */
/* Кнопка правки — инлайн слева от пузыря, по центру по вертикали (привязана к сообщению) */
.msg-actions--user { width: auto; margin: 0; align-self: center; opacity: .55; transition: opacity .15s; }
.row--user:hover .msg-actions--user { opacity: 1; }
/* Инлайн-редактор своего сообщения */
.msg-edit { display: flex; flex-direction: column; gap: 8px; min-width: min(420px, 60vw); }
.msg-edit__ta { width: 100%; box-sizing: border-box; background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.35); border-radius: 10px; color: #fff; font: inherit; font-size: 15px; line-height: 1.5; padding: 9px 11px; resize: none; outline: none; }
.msg-edit__btns { display: flex; gap: 8px; justify-content: flex-end; }
.msg-edit__cancel, .msg-edit__save { border: none; border-radius: 9px; padding: 7px 15px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: opacity .2s; }
.msg-edit__cancel { background: rgba(255,255,255,.2); color: #fff; }
.msg-edit__save { background: #fff; color: #5b2bd6; }
.msg-edit__cancel:hover, .msg-edit__save:hover { opacity: .85; }
/* Модалка «Поделиться ссылкой» */
.share-ov { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(4,4,9,.74); backdrop-filter: blur(8px); }
.share-card { width: min(440px, 100%); background: var(--panel-2); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 24px; }
.share-h { font-size: 18px; font-weight: 800; color: #fff; }
.share-d { font-size: 13.5px; line-height: 1.55; color: var(--text-dim); margin: 8px 0 16px; }
.share-row { display: flex; gap: 8px; }
.share-url { flex: 1; min-width: 0; background: #15161f; border: 1px solid var(--border-strong); border-radius: 11px; color: var(--text); font: inherit; font-size: 13px; padding: 10px 12px; outline: none; }
.share-copy { flex-shrink: 0; border: none; border-radius: 11px; padding: 0 16px; font: inherit; font-weight: 700; font-size: 13px; color: #fff; background: var(--grad); cursor: pointer; }
.share-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.share-btns button, .share-open { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 11px; padding: 9px 16px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none; }
.share-native { background: var(--grad) !important; border: none !important; color: #fff !important; }
.share-close { background: var(--surface-2) !important; }
.share-btns button:hover, .share-open:hover { opacity: .9; }
.row__avatar { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.row--bot .row__avatar { color: #fff; }
.row--user .row__avatar { background: linear-gradient(120deg,#ff5ca8,#ff9f5c); }
.bubble { max-width: 84%; min-width: 0; padding: 14px 18px; border-radius: 16px; font-size: 15.5px; line-height: 1.7; }
.row--user .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.row--bot .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; color: var(--text); }
.bubble p { margin: 0 0 10px; } .bubble p:last-child { margin-bottom: 0; }
/* Плашка-уведомление внутри ответа (напр. фолбэк при исчерпании бесплатного лимита) */
.chat-notice { display: flex; gap: 7px; align-items: flex-start; margin: 0 0 12px;
  padding: 9px 12px; border-radius: 11px; font-size: 13px; line-height: 1.45;
  color: #ffd9a8; background: rgba(255,170,80,.10); border: 1px solid rgba(255,170,80,.28); }
/* Плашка запрета (модерация: запрещённый контент) */
.chat-blocked { display: flex; gap: 8px; align-items: flex-start;
  padding: 11px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.5;
  color: #ffb3b3; background: rgba(255,80,80,.10); border: 1px solid rgba(255,80,80,.30); }
/* Карточка «бесплатные на сегодня кончились» — дружелюбная, с кнопкой действия */
.chat-limit { text-align: center; padding: 22px 22px 20px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(43,214,255,.08));
  border: 1px solid rgba(124,92,255,.35); }
.chat-limit__ic { font-size: 26px; line-height: 1; }
.chat-limit__title { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 16px; color: var(--text); margin: 10px 0 6px; }
.chat-limit__text { color: var(--text-dim); font-size: 13.5px; line-height: 1.55; margin: 0 auto 16px; max-width: 420px; }
.chat-limit__btn { padding: 11px 24px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-family: inherit; font-weight: 700; font-size: 14.5px;
  box-shadow: 0 10px 26px -8px rgba(124,92,255,.6); transition: transform .18s, box-shadow .2s; }
.chat-limit__btn:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -8px rgba(124,92,255,.78); }
.bubble pre { background: #0a0b12; border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow-x: auto; margin: 10px 0; font-size: 13.5px; }
.bubble code { font-family: 'SF Mono', Consolas, monospace; font-size: .9em; background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 5px; }
.bubble pre code { background: none; padding: 0; }
/* Блоки кода всегда на тёмном фоне → текст светлый в обеих темах */
.bubble pre, .bubble pre code, .code-block pre, .code-block pre code { color: #e6e8f0; }
[data-theme="light"] .bubble code { background: rgba(0,0,0,.07); } /* инлайн-код: чип виден на светлом */
[data-theme="light"] .code-copy { color: #c2c4d2; } /* кнопка копирования читаема на тёмной шапке кода */
/* В светлой теме блок кода — мягкий серый, а не почти-чёрный */
[data-theme="light"] .bubble pre, [data-theme="light"] .code-block { background: #2a2c38; }

/* Блок кода с шапкой и кнопкой «Копировать» */
.code-block { margin: 10px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #0a0b12; }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px 7px 14px; background: rgba(255,255,255,.04); border-bottom: 1px solid var(--border); }
.code-lang { font-size: 12px; color: var(--text-faint); text-transform: lowercase; font-family: 'SF Mono', Consolas, monospace; }
.code-copy { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: none; border-radius: 8px; background: transparent; color: var(--text-dim); font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.code-copy svg { width: 14px; height: 14px; }
.code-copy:hover { background: var(--surface-2); color: var(--text); }
.code-copy.is-done { color: #43e08e; }
.code-block pre { margin: 0; border: none; border-radius: 0; background: none; }
.bubble ul, .bubble ol { margin: 8px 0 8px 20px; } .bubble li { margin: 4px 0; }
.bubble strong { color: #fff; font-weight: 700; }
.bubble em { font-style: italic; }
.bubble del { opacity: .6; }
/* Заголовки в ответе */
.md-h { color: #fff; font-weight: 700; line-height: 1.3; margin: 14px 0 6px; }
.md-h:first-child { margin-top: 0; }
h2.md-h { font-size: 1.22em; }
h3.md-h { font-size: 1.1em; }
h4.md-h { font-size: 1em; color: var(--text); }
/* Цитаты */
.md-quote { margin: 10px 0; padding: 6px 14px; border-left: 3px solid var(--violet); background: rgba(124,92,255,.08); border-radius: 0 8px 8px 0; color: var(--text-dim); }
/* Разделитель */
.md-hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
/* Таблицы (с горизонтальной прокруткой на узких экранах) */
.md-table { margin: 10px 0; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md-table th, .md-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.md-table th:last-child, .md-table td:last-child { border-right: none; }
.md-table tbody tr:last-child td { border-bottom: none; }
.md-table th { background: rgba(255,255,255,.05); color: #fff; font-weight: 700; }
.md-table tbody tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.bubble a { color: var(--cyan); text-decoration: underline; }

/* Индикатор печати */
.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--violet-2); animation: blink 1.2s infinite both; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,60%,100%{ opacity: .25; transform: translateY(0);} 30%{ opacity: 1; transform: translateY(-3px);} }
.cursor { display: inline-block; width: 8px; height: 16px; background: var(--violet-2); margin-left: 2px; border-radius: 2px; animation: caret 1s steps(1) infinite; vertical-align: text-bottom; }
@keyframes caret { 50% { opacity: 0; } }

/* ===== Голосовой режим (разговор) ===== */
.voice-ov {
  position: fixed; inset: 0; z-index: 1400; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 28px;
  background: radial-gradient(circle at 50% 38%, rgba(124,92,255,.16), rgba(6,6,12,.96) 60%);
  backdrop-filter: blur(14px);
}
.voice-ov.is-open { display: flex; }
.voice-close {
  position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 12px;
  border: none; background: var(--surface); color: var(--text-dim); font-size: 20px; cursor: pointer;
  display: grid; place-items: center; transition: background .2s, color .2s;
}
.voice-close:hover { background: var(--surface-2); color: var(--text); }
.voice-orb {
  position: relative; width: 168px; height: 168px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #7c5cff, #5b8bff 55%, #2bd6ff);
  box-shadow: 0 0 80px -10px rgba(124,92,255,.8); transition: transform .25s;
}
.voice-orb:hover { transform: scale(1.03); }
.voice-orb span {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(124,92,255,.5);
  opacity: 0;
}
/* Слушаю — пульсация колец */
.voice-orb[data-phase="listening"] span { animation: voiceRing 1.8s ease-out infinite; }
.voice-orb[data-phase="listening"] span:nth-child(2) { animation-delay: .6s; }
.voice-orb[data-phase="listening"] span:nth-child(3) { animation-delay: 1.2s; }
@keyframes voiceRing { 0% { opacity: .55; transform: scale(1); } 100% { opacity: 0; transform: scale(1.7); } }
/* Думаю — вращение/дыхание */
.voice-orb[data-phase="thinking"] { animation: voiceBreathe 1.2s ease-in-out infinite; }
@keyframes voiceBreathe { 50% { transform: scale(.92); box-shadow: 0 0 50px -10px rgba(124,92,255,.6); } }
/* Отвечаю — лёгкое подрагивание */
.voice-orb[data-phase="speaking"] { animation: voiceTalk .55s ease-in-out infinite; }
@keyframes voiceTalk { 50% { transform: scale(1.06); } }
.voice-status { font-family: 'Sora','Manrope',system-ui,sans-serif; font-size: 21px; font-weight: 700; color: var(--text); text-align: center; }
.voice-trans { max-width: 560px; min-height: 24px; color: var(--text-dim); font-size: 16px; line-height: 1.5; text-align: center; }
.voice-hint { position: absolute; bottom: 26px; left: 0; right: 0; text-align: center; color: var(--text-faint); font-size: 12.5px; padding: 0 20px; }

/* ===== Приветствие ===== */
.welcome { max-width: 720px; margin: 0 auto; padding: 8vh 24px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.welcome__logo { width: 64px; height: 64px; display: grid; place-items: center; margin-bottom: 24px; filter: drop-shadow(0 20px 40px rgba(124,92,255,.6)); }
.welcome h1 { font-family: 'Sora', 'Manrope', system-ui, sans-serif; font-size: clamp(28px, 4vw, 40px); font-weight: 800; margin-bottom: 10px; letter-spacing: -.02em; }
.welcome p { color: var(--text-dim); font-size: 17px; margin-bottom: 34px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 560px; }
.suggestion {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 16px; border-radius: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif; font-size: 14px; font-weight: 600;
  transition: transform .18s, border-color .2s, background .2s;
}
.suggestion:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-2); }
.suggestion__icon { font-size: 22px; }
.suggestion small { color: var(--text-faint); font-weight: 500; }

/* ===== Composer ===== */
.composer { padding: 12px 18px 18px; }
.composer__inner { max-width: 980px; margin: 0 auto; position: relative; }
.composer__form {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 8px 8px 8px 12px; transition: border-color .2s, box-shadow .2s;
}
.composer__form:focus-within { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 4px rgba(124,92,255,.12); }
.composer__tool { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: none; background: transparent; color: var(--text-faint); cursor: pointer; flex-shrink: 0; transition: color .2s, background .2s; }
.composer__tool:hover { color: var(--text-dim); background: var(--surface-2); }
.composer__mic.is-recording { color: #ff5c6c; background: rgba(255, 92, 108, .12); animation: micPulse 1.3s ease-in-out infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 108, .45); } 50% { box-shadow: 0 0 0 6px rgba(255, 92, 108, 0); } }
.composer__input {
  flex: 1; resize: none; border: none; background: none; outline: none;
  color: var(--text); font-family: 'Manrope', system-ui, sans-serif; font-size: 16px; line-height: 1.5;
  max-height: 200px; padding: 9px 4px;
}
.composer__input::placeholder { color: var(--text-faint); }
.composer__send {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: none; background: var(--grad); color: #fff; cursor: pointer; flex-shrink: 0;
  transition: transform .18s, opacity .2s;
}
.composer__send:hover:not(:disabled) { transform: translateY(-1px); }
.composer__send:disabled { opacity: .35; cursor: default; }
.composer__send.is-stop { background: var(--surface-2); color: var(--text); }
.composer__hint { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-faint); margin-top: 10px; }
.composer__hint > span:first-child { flex: 1; text-align: center; }
.cost-hint { flex-shrink: 0; padding: 3px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); font-weight: 600; }

/* Карточка модели на стартовом экране */
.model-hero {
  position: relative;
  width: 100%; max-width: 520px; margin: 6px auto 22px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px;
}
.model-hero__top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.model-hero__name { font-weight: 700; font-size: 17px; }
.model-hero__tier { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.mh-free { background: rgba(94, 230, 168, .14); color: #5ee6a8; }
.mh-base { background: rgba(91, 139, 255, .14); color: #8fb0ff; }
.mh-pro { background: rgba(124, 92, 255, .16); color: #b49bff; }
.mh-ultra { background: rgba(255, 196, 84, .14); color: #ffce6b; }
.model-hero__desc { font-size: 13.5px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.5; }
.model-hero__badges { display: flex; flex-wrap: wrap; gap: 7px; }
.mh-badge { font-size: 12px; color: var(--text-dim); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; }
.mh-badge--cost { color: var(--text); border-color: var(--border-strong); }
.model-hero__hint { margin-top: 11px; font-size: 12px; color: var(--text-faint); }

/* Развёрнутая объясняющая карточка для режима «Совет ИИ» на стартовом экране —
   переиспользует .model-hero как базу, расширяет под иллюстрацию/шаги/состав. */
.model-hero.council-hero { max-width: 600px; padding: 22px 26px 24px; }
.council-hero__illustration { display: flex; justify-content: center; margin: -4px 0 6px; }
.council-hero__illustration svg { width: 100%; max-width: 280px; height: auto; }
@media (prefers-reduced-motion: no-preference) {
  .council-hero__illustration .council-pulse { animation: councilHeroPulse 2.6s ease-in-out infinite; transform-origin: center; }
}
@keyframes councilHeroPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.council-hero__title { font-weight: 800; font-size: 19px; margin-bottom: 8px; text-align: center; }
.council-hero__lead { font-size: 13.5px; color: var(--text-dim); line-height: 1.6; text-align: center; margin-bottom: 18px; }
.council-hero__steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.council-hero__step { display: flex; align-items: flex-start; gap: 11px; text-align: left; }
.council-hero__num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--grad);
  color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.council-hero__step div { font-size: 13px; color: var(--text-dim); line-height: 1.45; }
.council-hero__step b { color: var(--text); font-size: 13.5px; }
.council-hero__chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 14px; }
.council-hero__chip {
  font-size: 11.5px; font-weight: 600; color: var(--text-dim); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px;
}
.council-hero__chip.is-chairman { color: var(--text); border-color: rgba(124,92,255,.45); background: var(--grad-soft); }
.council-hero__footer { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
@media (max-width: 820px) {
  .model-hero.council-hero { padding: 18px 16px 20px; }
  .council-hero__illustration svg { max-width: 220px; }
}

/* ===== Прикреплённые файлы (полоска над полем ввода) ===== */
.composer__attach { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.attach-chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px 7px 11px;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface);
  font-size: 13px; color: var(--text-dim); max-width: 220px;
}
.attach-chip--img { padding: 0; overflow: hidden; position: relative; }
.attach-chip--img img { width: 54px; height: 54px; object-fit: cover; display: block; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-doc { flex-shrink: 0; }
.attach-sub { color: var(--text-faint); font-size: 12px; flex-shrink: 0; }
.attach-spin {
  width: 15px; height: 15px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid rgba(124,92,255,.25); border-top-color: #9d7bff;
  animation: attach-spin .7s linear infinite;
}
@keyframes attach-spin { to { transform: rotate(360deg); } }
.attach-x {
  display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0;
  border: none; border-radius: 6px; background: rgba(0,0,0,.25); color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer; transition: background .2s;
}
.attach-chip--img .attach-x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; font-size: 13px; }
.attach-x:hover { background: rgba(0,0,0,.5); }

/* Превью вложений внутри сообщения пользователя */
.msg-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-img { max-width: 240px; max-height: 240px; border-radius: 12px; display: block; cursor: zoom-in; }
.msg-docs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.msg-doc { font-size: 12.5px; padding: 5px 10px; border-radius: 10px; background: rgba(255,255,255,.06); color: var(--text-dim); }

/* ===== Оверлей для мобилки ===== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.sidebar-overlay.is-visible { display: block; }

/* Скроллбар */
.chat::-webkit-scrollbar, .history::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb, .history::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 8px; }
.chat::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); }

/* ===== Панель инструментов (Нарисуй / Веб-поиск / Агенты) ===== */
.composer__tools { display: flex; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }

/* Белая подсказка над инструментами */
.composer-hint {
  position: absolute; bottom: calc(100% + 10px); left: 10px; z-index: 20; max-width: 420px;
  background: #fff; color: #16171f; font-size: 13.5px; font-weight: 600; line-height: 1.45;
  padding: 11px 15px; border-radius: 13px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6);
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity .2s, transform .2s, visibility .2s;
  pointer-events: none;
}
.composer-hint::after {
  content: ""; position: absolute; top: 100%; left: 26px;
  border: 7px solid transparent; border-top-color: #fff;
}
.composer-hint.is-show { opacity: 1; visibility: visible; transform: none; }
.ctool {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 100px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  font-family: 'Manrope', sans-serif; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: 0.18s;
}
.ctool[hidden] { display: none !important; } /* в режимах картинок/видео прячем веб-поиск */
.ctool svg { width: 16px; height: 16px; }
.ctool:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.ctool.is-active { color: #fff; background: var(--grad); border-color: transparent; box-shadow: 0 8px 22px -10px rgba(124, 92, 255, 0.7); }
.ctool__hint { font-size: 11px; font-weight: 700; color: var(--text-faint); margin-left: 2px; }
.ctool:hover .ctool__hint { color: var(--text-dim); }
.ctool.is-active .ctool__hint { color: rgba(255, 255, 255, 0.75); }

/* Фирменные тултипы кнопок-инструментов (вместо системных title) */
.ctool[data-tip] { position: relative; }
.ctool[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 11px); left: 0; z-index: 40;
  width: max-content; max-width: 300px; text-align: left;
  background: #fff; color: #16171f; font-size: 12.5px; font-weight: 600; line-height: 1.45;
  padding: 9px 13px; border-radius: 11px; box-shadow: 0 14px 36px -10px rgba(0, 0, 0, .65);
  opacity: 0; visibility: hidden; transform: translateY(5px);
  transition: opacity .18s, transform .18s, visibility .18s; transition-delay: 0s;
  pointer-events: none;
}
.ctool[data-tip]::before {
  content: ""; position: absolute; bottom: calc(100% + 4px); left: 22px; z-index: 41;
  border: 7px solid transparent; border-top-color: #fff;
  opacity: 0; visibility: hidden; transform: translateY(5px);
  transition: opacity .18s, transform .18s, visibility .18s; transition-delay: 0s;
  pointer-events: none;
}
.ctool[data-tip]:hover::after, .ctool[data-tip]:hover::before {
  opacity: 1; visibility: visible; transform: none; transition-delay: .35s;
}
.ctool-wrap { position: relative; }

.agents-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 30; width: 280px;
  max-height: min(62vh, 480px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 14px; padding: 6px;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.7);
}
.agent-item { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 10px; cursor: pointer; transition: background 0.18s; }
.agent-item:hover { background: var(--surface); }
.agent-item.is-active { background: var(--grad-soft); }
.agent-item__ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; flex-shrink: 0; }
.agent-item__txt { min-width: 0; flex: 1; }
.agent-item__t { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-item__d { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-del { flex-shrink: 0; width: 24px; height: 24px; border: none; border-radius: 7px; background: transparent; color: var(--text-faint); cursor: pointer; opacity: 0; font-size: 13px; transition: .15s; }
.agent-item:hover .agent-del { opacity: 1; }
.agent-del:hover { background: rgba(255,90,120,.18); color: #ff8a8a; }
.agent-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 8px 6px 4px; }
.agent-empty { font-size: 12.5px; color: var(--text-faint); padding: 6px 11px; }
.agent-create { width: 100%; margin-top: 4px; border: 1px dashed var(--border-strong); background: transparent; color: var(--violet-2); font: inherit; font-weight: 700; font-size: 13.5px; padding: 9px; border-radius: 10px; cursor: pointer; transition: background .18s; }
.agent-create:hover { background: var(--surface); }
/* Модалка создания ассистента */
.as-ov { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(4,4,9,.74); backdrop-filter: blur(8px); }
.as-card { width: min(460px, 100%); background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 20px; padding: 22px; }
.as-h { display: flex; align-items: center; font-size: 18px; font-weight: 800; color: var(--text); }
.as-x { margin-left: auto; width: 32px; height: 32px; border: none; border-radius: 9px; background: var(--surface); color: var(--text-dim); font-size: 19px; cursor: pointer; }
.as-x:hover { background: var(--surface-2); color: var(--text); }
.as-sub { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin: 8px 0 14px; }
.as-field { width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 11px; color: var(--text); font: inherit; font-size: 14px; padding: 11px 12px; margin-bottom: 10px; outline: none; transition: border-color .2s; }
.as-field:focus { border-color: var(--violet); }
.as-ta { resize: vertical; min-height: 120px; max-height: 320px; line-height: 1.5; }
.as-save { width: 100%; border: none; border-radius: 11px; padding: 12px; font: inherit; font-weight: 800; font-size: 14px; color: #fff; background: var(--grad); cursor: pointer; transition: opacity .2s; }
.as-save:hover { opacity: .92; } .as-save:disabled { opacity: .55; cursor: default; }
.as-msg { font-size: 12.5px; margin: 9px 0 0; min-height: 14px; } .as-msg.err { color: #ff8a8a; }

/* Меню выбора формата картинки (в стиле ChatGPT) */
#aspectMenu { width: 240px; }
.aspect-head { font-size: 12px; color: var(--text-faint); padding: 6px 11px 8px; }
.aspect-item { display: flex; align-items: center; gap: 12px; padding: 9px 11px; border-radius: 10px; cursor: pointer; transition: background 0.18s; }
.aspect-item:hover { background: var(--surface); }
.aspect-item.is-active { background: var(--surface-2); }
.aspect-icwrap { width: 22px; display: grid; place-items: center; flex-shrink: 0; }
.aspect-ic { border: 1.8px solid var(--text-dim); border-radius: 3px; display: block; }
.aspect-item.is-active .aspect-ic { border-color: #7c5cff; }
.aspect-name { flex: 1; font-weight: 600; font-size: 14px; }
.aspect-meta { color: var(--text-faint); font-size: 13px; display: grid; place-items: center; min-width: 20px; }
.aspect-item.is-active .aspect-meta { color: #9d7bff; }

/* Сгенерированное изображение в чате */
.bubble img.gen-img { display: block; max-width: 100%; border-radius: 12px; margin-top: 6px; cursor: zoom-in; transition: opacity .2s; }
.bubble img.gen-img:hover { opacity: .92; }
.gen-grid { display: grid; gap: 8px; margin-top: 6px; }
.gen-grid--multi { grid-template-columns: 1fr 1fr; max-width: 460px; }
.gen-grid--multi img.gen-img { width: 100%; margin-top: 0; aspect-ratio: 1; object-fit: cover; }

/* Шиммер-скелетон во время генерации картинки/видео — раньше во время ожидания
   показывался только текст с морганием курсора, без визуального превью результата. */
.gen-skeleton {
  width: 100%; max-width: 320px; border-radius: 14px; margin: 10px 0 4px;
  border: 1px solid var(--border);
  /* surface/surface-2 (4%/7% белого) почти неразличимы на тёмном фоне — пик яркости
     поднят до 14%, чтобы бегущая полоса была реально видна, а не просто плоский серый. */
  background: linear-gradient(110deg, var(--surface-2) 8%, rgba(255,255,255,.14) 22%, var(--surface-2) 36%);
  background-size: 200% 100%;
  animation: genShimmer 1.8s ease-in-out infinite;
}
[data-theme="light"] .gen-skeleton { background: linear-gradient(110deg, var(--surface-2) 8%, rgba(0,0,0,.1) 22%, var(--surface-2) 36%); }
.gen-skel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 320px; margin: 10px 0 4px; }
.gen-skel-grid .gen-skeleton { max-width: none; margin: 0; aspect-ratio: 1; }
@keyframes genShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .gen-skeleton { animation: none; } }

/* ----- Совет ИИ: трекер стадий + вкладки участников + финальная карточка ----- */
.council { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }

.council-stages { display: flex; align-items: center; padding: 2px 0 4px; }
.council-stage { display: flex; align-items: center; gap: 8px; }
.council-stage__dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong);
  transition: background .3s, box-shadow .3s, transform .3s;
}
.council-stage.is-active .council-stage__dot {
  background: var(--violet); box-shadow: 0 0 0 4px rgba(124,92,255,.25); transform: scale(1.25);
  animation: councilPulse 1.1s ease-in-out infinite;
}
.council-stage.is-done .council-stage__dot { background: var(--cyan); box-shadow: none; transform: scale(1); }
@keyframes councilPulse { 0%, 100% { transform: scale(1.1); } 50% { transform: scale(1.35); } }
.council-stage__label { font-size: 12.5px; color: var(--text-faint); transition: color .3s; }
.council-stage.is-active .council-stage__label,
.council-stage.is-done .council-stage__label { color: var(--text-dim); }
.council-stage__line { width: 30px; height: 1px; background: var(--border); margin: 0 8px; }

.council-tabs {
  position: relative; display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.council-tab {
  position: relative; z-index: 1; padding: 8px 14px; background: transparent; border: none;
  color: var(--text-faint); cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: 'Manrope', system-ui, sans-serif; transition: color .2s;
}
.council-tab:hover { color: var(--text-dim); }
.council-tab.is-active { color: var(--text); }
.council-tabs__indicator {
  position: absolute; left: 0; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--grad); box-shadow: 0 0 8px 1px rgba(124,92,255,.5);
  transition: transform .28s var(--ease, ease), width .28s var(--ease, ease);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { .council-tabs__indicator { transition: none; } }

.council-tab-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
}
.council-tab-panel .gen-skeleton { max-width: none; width: 100%; margin: 0; }
.council-tab-panel .markdown-content { padding: 0; font-size: 14px; color: var(--text-dim); line-height: 1.6; }

.council-final {
  border: 1px solid rgba(124,92,255,.35); border-radius: 16px; padding: 16px 18px;
  background: var(--grad-soft); box-shadow: 0 0 24px -6px rgba(124,92,255,.4);
}
.council-final.is-error { border-color: var(--border); background: var(--surface); box-shadow: none; }
.council-final__label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--cyan); margin-bottom: 8px;
}
.council-final .markdown-content { padding: 0; font-size: 15px; color: var(--text); line-height: 1.7; }

/* Видео-результат */
.gen-video { display: flex; flex-direction: column; gap: 8px; max-width: 460px; margin-top: 6px; }
.gen-video video { width: 100%; border-radius: 12px; display: block; background: #000; }
.vid-dl { align-self: flex-start; padding: 9px 16px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-family: inherit; font-weight: 700; font-size: 13px; transition: filter .2s; }
.vid-dl:hover { filter: brightness(1.07); }

/* Плеер озвучки / музыки */
.gen-audio { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 460px; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.gen-audio__ic { font-size: 20px; flex-shrink: 0; }
.gen-audio audio { flex: 1; min-width: 200px; height: 38px; }
.aud-dl { padding: 8px 14px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-family: inherit; font-weight: 700; font-size: 12.5px; transition: filter .2s; }
.aud-dl:hover { filter: brightness(1.07); }

/* Лайтбокс: картинка во весь экран + скачивание */
.lightbox {
  position: fixed; inset: 0; z-index: 1200; padding: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(4, 4, 9, .9); backdrop-filter: blur(10px);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox__stage { display: flex; align-items: center; gap: 14px; max-width: 96vw; }
.lightbox__img { max-width: 100%; min-width: 0; max-height: 78vh; border-radius: 16px; box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .9); }
.lightbox__close {
  position: absolute; top: 18px; right: 18px; width: 42px; height: 42px; border-radius: 12px;
  border: none; background: rgba(255, 255, 255, .08); color: #fff; font-size: 24px;
  cursor: pointer; display: grid; place-items: center; transition: background .2s;
}
.lightbox__close:hover { background: rgba(255, 255, 255, .16); }
.lightbox__dl {
  padding: 13px 28px; border-radius: 12px; background: var(--grad); color: #fff;
  border: none; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 14.5px; box-shadow: 0 10px 30px -8px rgba(124, 92, 255, .6);
  transition: transform .18s;
}
.lightbox__dl:hover { transform: translateY(-2px); }
.lightbox__bar { display: flex; gap: 10px; align-items: center; }
.lightbox__retention {
  margin-right: 4px; padding: 7px 13px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  font-family: inherit; cursor: pointer; transition: background .2s, color .2s, border-color .2s;
}
.lightbox__retention::after { content: ' ⓘ'; opacity: .55; font-weight: 700; }
.lightbox__retention:hover { background: rgba(255, 255, 255, .12); color: var(--text); border-color: var(--border-strong); }
.lightbox__del {
  padding: 13px 22px; border-radius: 12px; background: rgba(255, 90, 120, .14);
  border: 1px solid rgba(255, 90, 120, .4); color: #ff8a9a; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 14.5px; transition: background .2s;
}
.lightbox__del:hover { background: rgba(255, 90, 120, .24); }
.lightbox__nav {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .1); color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; transition: background .2s;
}
.lightbox__nav:hover { background: rgba(255, 255, 255, .22); }
.gen-loading { display: inline-flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; }

/* ===== Адаптив ===== */
@media (max-width: 820px) {
  /* Жёсткая страховка от горизонтального переполнения на мобильных браузерах.
     Симптом был: чат рендерился в ~65% ширины, справа чёрная полоса — браузер
     «зумил» страницу, чтобы вместить случайно вылезший за край элемент. Клампим
     корневые контейнеры по ширине экрана, чтобы такого не могло произойти. */
  html, body { max-width: 100vw; overflow-x: hidden; }
  .app, .main, .topbar, .composer, .chat__inner { max-width: 100vw; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 45;
    width: min(300px, 85vw);
    transform: translateX(-100%);
    box-shadow: 6px 0 24px -12px rgba(0, 0, 0, .4);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-collapsed .sidebar { margin-left: 0; }
  .sidebar__collapse { display: none; }
  .topbar__menu { display: grid; }
  .suggestions { grid-template-columns: 1fr; }

  /* Компактнее выезжающее меню на мобиле — кнопки и отступы меньше, чтобы всё влезало */
  .sidebar { padding: 10px 12px; }
  .sidebar__top { margin-bottom: 9px; }
  .new-chat { padding: 9px; font-size: 14px; }
  .gallery-btn { padding: 7px; margin-top: 5px; font-size: 13.5px; }
  .img-toggle { padding: 7px 12px; margin-top: 5px; font-size: 13.5px; }
  .sidebar__section-label { margin: 9px 6px 5px; font-size: 11px; }
  .history__item { padding: 8px 12px; font-size: 14px; }
  .history-search { padding: 7px 10px; margin-bottom: 6px; }
  .sidebar__bottom { margin-top: 8px; gap: 7px; }
  .balance-card { padding: 10px 14px; }
  .balance-card__top { margin-bottom: 6px; }
  .btn-topup { padding: 8px; }
  .side-support { padding: 6px 10px; }
  .account { padding: 5px 8px; }

  /* Тема: на мобиле — снова иконка, а не свитч */
  .icon-btn.topbar__theme { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
  .icon-btn.topbar__theme:hover { background: var(--surface-2); }
  .theme-sw { position: static; width: auto; height: auto; background: none; border: none; display: grid; place-items: center; }
  .theme-sw__knob { display: none; }
  .theme-sw__sun, .theme-sw__moon { position: static; transform: none; width: 20px; height: 20px; color: var(--text-dim); }
  .theme-sw__moon { display: none; }
  [data-theme="light"] .theme-sw__sun { display: none; }
  [data-theme="light"] .theme-sw__moon { display: block; }

  /* Выпадашки композера (соотношение/количество/формат/агенты) — во всю ширину
     над полем ввода, чтобы не вылезали за край экрана на узких устройствах. */
  .composer__tools .ctool-wrap { position: static; }
  .composer__tools .agents-menu,
  #aspectMenu, #countMenu, #formatMenu {
    left: 10px; right: 10px; width: auto;
    bottom: calc(100% + 10px); max-height: 56vh; overflow-y: auto;
  }
}

/* Телефоны */
@media (max-width: 520px) {
  .topbar { padding: 7px 12px; gap: 8px; }
  .topbar .icon-btn, .topbar .btn-back, .icon-btn.topbar__theme { width: 35px; height: 35px; }
  .topbar .icon-btn svg, .btn-back svg { width: 21px; height: 21px; }
  .model-select__btn { padding: 7px 11px; font-size: 14px; }
  /* Кнопка модели сдвинута вправо (перед ней «гамбургер»), поэтому меню с left:0
     вылезало за правый край и распирало вёрстку. Привязываем к краям экрана. */
  .model-select { position: static; }
  .model-select__menu {
    position: fixed; top: 60px; left: 12px; right: 12px;
    width: auto; max-width: none;
  }
  /* min-width:0 — чтобы карточки сжимались и не обрезались даже в 2 колонки */
  .model-card { padding: 10px 11px; min-width: 0; }
  .model-card__name { font-size: 13.5px; }

  .chat__inner { padding: 20px 12px 16px; gap: 20px; }
  .bubble { max-width: 92%; padding: 12px 14px; font-size: 15px; }
  .msg-actions { margin-left: 44px; }

  .composer { padding: 10px 10px 14px; }
  .composer-hint { left: 4px; right: 4px; max-width: none; }
  .ctool { padding: 9px 12px; font-size: 12.5px; gap: 5px; }
  .ctool__hint { display: none; }
  .ctool[data-tip]::after { max-width: calc(100vw - 44px); white-space: normal; }
  /* Подсказка под полем переносится, чтобы оценка стоимости не сжимала текст */
  .composer__hint { flex-wrap: wrap; justify-content: center; row-gap: 6px; }
  .composer__hint > span:first-child { flex: 1 1 100%; }

  /* Карточка модели на старте — компактнее */
  .model-hero { padding: 14px 15px; margin-bottom: 16px; max-width: none; }
  .model-hero__name { font-size: 16px; }
  .model-hero__desc { font-size: 13px; }

  /* Кнопка действий с чатом всегда видна (нет наведения на тач) */
  .history__more { opacity: .7; }

  .welcome { padding: 0 16px; }
  .welcome h1 { font-size: 26px; }
  .welcome > p { font-size: 14px; }

  .acc-card, .gal-card { padding: 22px 16px 18px; }
  .acc-row2 { grid-template-columns: 1fr; }
  .acc-pay { gap: 8px; font-size: 12.5px; }
  .acc-actions { flex-direction: column-reverse; gap: 12px; }
  .acc-actions .acc-btn { width: 100%; }

  .lightbox { padding: 14px; gap: 14px; }
  .lightbox__img { max-height: 72vh; }
}

/* Совсем узкие экраны — меню моделей в одну колонку */
@media (max-width: 340px) {
  .model-grid { grid-template-columns: 1fr; }
}
