/* Vibe — «обсидиан и спектр»: матовая чёрная основа, металлические блики,
   золото как ведущий акцент (оно связано с монетой на входе) и три спутника —
   фиолетовый, индиго, бирюза плюс тёплый янтарь.

   Два правила, которые нельзя нарушать:
   1. Читаемость важнее красоты. Под длинным текстом и кодом — спокойный
      непрозрачный фон, градиенты живут в обводках, шапках и фоне экрана.
   2. Анимируем только transform и opacity (композитинг на GPU). Никаких
      бесконечных анимаций box-shadow / filter / background-position:
      телефон греется и садится батарея. */

:root {
  /* Основа: матовый чёрный с синевой, а не «серый». */
  --bg: #07080c;
  --bg-2: #0b0d14;
  --surface: #151827;
  --surface-2: #1d2133;
  --surface-3: #262b40;

  /* Под кодом и логами — почти чёрный, максимум контраста к моноширинному. */
  --ink: #06070c;

  --line: rgba(255, 255, 255, .10);
  --line-2: rgba(255, 255, 255, .17);
  --line-soft: rgba(255, 255, 255, .06);

  --text: #eef0f8;
  --muted: #98a0ba;

  /* Золото — ведущий акцент. */
  --gold-1: #fff7d6;
  --gold-2: #ffe49f;
  --gold-3: #f7c948;
  --gold-4: #e0a325;
  --gold-5: #b87616;
  --gold-6: #7a4a0d;

  /* Спутники: фиолетовый, индиго, бирюза, янтарь, роза. */
  --violet: #9d7bff;
  --violet-2: #6d3fe0;
  --violet-3: #3b1f8f;
  --indigo: #6d8bff;
  --indigo-2: #3a4fd8;
  --teal: #3ce6c8;
  --teal-2: #10a894;
  --amber: #ff9f45;
  --amber-2: #f2712a;
  --rose: #ff7183;
  --rose-2: #d63f57;

  --accent: var(--gold-3);
  --accent-soft: rgba(247, 201, 72, .13);
  --accent-line: rgba(247, 201, 72, .45);
  --on-accent: #21170a;

  --ok: var(--teal);
  --warn: var(--amber);
  --danger: var(--rose);

  /* Готовые градиенты — чтобы вся тема звучала одним аккордом. */
  --grad-gold: linear-gradient(145deg, var(--gold-1) 0%, var(--gold-3) 45%, var(--gold-5) 100%);
  --grad-amber: linear-gradient(145deg, var(--gold-2) 0%, var(--amber) 55%, var(--amber-2) 100%);
  --grad-violet: linear-gradient(145deg, var(--violet) 0%, var(--violet-2) 60%, var(--violet-3) 100%);
  --grad-teal: linear-gradient(145deg, var(--teal) 0%, var(--teal-2) 100%);
  --grad-rose: linear-gradient(145deg, var(--rose) 0%, var(--rose-2) 100%);
  /* Полный спектр — для тонких обводок и подчёркиваний. */
  --grad-spectrum: linear-gradient(115deg,
    var(--gold-2) 0%, var(--amber) 22%, var(--rose) 42%,
    var(--violet) 64%, var(--indigo) 82%, var(--teal) 100%);
  --grad-edge: linear-gradient(140deg,
    rgba(255, 228, 159, .75) 0%,
    rgba(157, 123, 255, .55) 45%,
    rgba(60, 230, 200, .45) 100%);
  /* Стекло: «поверхность + подсветка верхнего края». */
  --glass: linear-gradient(180deg, rgba(56, 58, 96, .60), rgba(16, 18, 30, .80));

  --radius: 15px;
  --ease: cubic-bezier(.2, .7, .3, 1);
  font-size: 16px;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  /* Прокручивается только лента сообщений. Без этого Safari на скролле
     сворачивает свои панели, видимая область меняется на лету, экран
     фиксированной высоты отстаёт — страница едет, а под композером
     остаётся пустая полоса. */
  overflow: hidden;
  background: var(--bg);
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  position: relative;
  /* Фон намеренно прозрачный: слои .bg-* лежат с отрицательным z-index, а
     собственный фон body закрасил бы их сверху. Цвет задан на html. */
  background: transparent;
}

/* ─── Живой фон ─────────────────────────────────────────────────────────────
   База — статичный многослойный градиент. Поверх — цветные пятна, которые
   медленно плывут. Двигаются transform'ом: перекраски нет, GPU только
   переставляет готовые слои. */

.bg-base {
  position: fixed;
  inset: 0;
  z-index: -4;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, #1b1a3a 0%, transparent 62%),
    linear-gradient(168deg, #0d0f1c 0%, #07080f 55%, #0b0a16 100%);
}

.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
  pointer-events: none;
  /* Слегка гасим общую яркость, чтобы текст сверху всегда выигрывал. */
  opacity: .9;
}
.bg-aurora span {
  position: absolute;
  display: block;
  border-radius: 50%;
  will-change: transform;
}
/* Золотое пятно — сверху слева, оно же «свет от монеты». */
.bg-aurora span:nth-child(1) {
  left: -28%; top: -22%;
  width: 112vw; height: 112vw;
  background: radial-gradient(circle, rgba(247, 201, 72, .42) 0%, rgba(224, 163, 37, .16) 44%, transparent 70%);
  animation: drift-a 34s ease-in-out infinite alternate;
}
/* Фиолетовое — справа сверху. */
.bg-aurora span:nth-child(2) {
  right: -32%; top: -4%;
  width: 106vw; height: 106vw;
  background: radial-gradient(circle, rgba(140, 96, 255, .46) 0%, rgba(77, 42, 178, .20) 46%, transparent 72%);
  animation: drift-b 41s ease-in-out infinite alternate;
}
/* Бирюзовое — снизу слева. */
.bg-aurora span:nth-child(3) {
  left: -34%; bottom: -6%;
  width: 104vw; height: 104vw;
  background: radial-gradient(circle, rgba(40, 210, 190, .34) 0%, rgba(16, 120, 110, .14) 46%, transparent 72%);
  animation: drift-c 47s ease-in-out infinite alternate;
}
/* Янтарное — снизу справа. Единственное неподвижное: три живых слоя дают
   достаточно движения, а четвёртый композитинг телефон бы просто грел. */
.bg-aurora span:nth-child(4) {
  right: -28%; bottom: -16%;
  width: 96vw; height: 96vw;
  background: radial-gradient(circle, rgba(255, 138, 56, .32) 0%, rgba(180, 70, 20, .12) 46%, transparent 72%);
  will-change: auto;
}
@keyframes drift-a {
  from { transform: translate3d(-4%, -3%, 0) scale(1); }
  to   { transform: translate3d(9%, 7%, 0) scale(1.16); }
}
@keyframes drift-b {
  from { transform: translate3d(5%, -4%, 0) scale(1.08); }
  to   { transform: translate3d(-8%, 9%, 0) scale(.94); }
}
@keyframes drift-c {
  from { transform: translate3d(-6%, 5%, 0) scale(.96); }
  to   { transform: translate3d(10%, -7%, 0) scale(1.14); }
}

/* Тонкая «плёнка» поверх пятен: возвращает фону матовость, чтобы цвет не бил
   в глаза под мелким текстом. */
.bg-veil {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(150% 95% at 50% 42%, rgba(5, 6, 11, .10) 0%, rgba(5, 6, 11, .48) 62%, rgba(4, 5, 9, .70) 100%);
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); }
[hidden] { display: none !important; }

/* ─── Полосы прокрутки ──────────────────────────────────────────────────────
   Системная светлая полоса на тёмном фоне читается как чужая деталь, да ещё
   и подсвечивает край экрана. Своя: тонкая, полупрозрачная, без дорожки.
   Правило общее, потому что прокручиваемых мест в приложении много — лента,
   шторки, журналы, длинные вывода команд. Где полосу надо спрятать совсем
   (полка вложений), это сказано отдельно ниже по файлу. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .16) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .26); }
*::-webkit-scrollbar-corner { background: transparent; }

/* Градиентный текст. Отдельным классом, чтобы не размазывать по файлу. */
.brand,
.sheet-body h2,
.card h2 {
  background: var(--grad-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ─── Мини-монета в шапке ───────────────────────────────────────────────────
   Статичная: она на рабочем экране, ей нельзя отвлекать. Большая монета на
   входе живёт в отдельном файле (coin.css) и рисуется в #coin-mount. */

.brand-coin {
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 27%, #fff8db 0%, #ffdd8b 26%, #e6ab2c 60%, #8f5610 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(122, 74, 13, .55),
    0 0 10px rgba(247, 201, 72, .45);
}

/* ─── Экран входа ───────────────────────────────────────────────────────────
   #coin-mount — площадка для монеты второго слоя. Задаём только место
   и размер, внутренности рисует coin.css. */

.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  height: 100%;
  overflow-y: auto;
  padding: max(env(safe-area-inset-top), 24px) 24px calc(24px + env(safe-area-inset-bottom));
}

#coin-mount {
  position: relative;
  flex: none;
  width: min(58vw, 220px);
  height: min(58vw, 220px);
  margin: 0 auto;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 26px 22px;
  display: grid;
  gap: 14px;
  position: relative;
  border-radius: 22px;
  /* Градиентная обводка: заливка по padding-box, спектр по border-box. */
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(34, 38, 58, .92), rgba(13, 15, 24, .95)) padding-box,
    var(--grad-edge) border-box;
  box-shadow:
    0 30px 70px rgba(0, 0, 0, .55),
    inset 0 1px 0 rgba(255, 255, 255, .07);
  animation: rise .5s var(--ease) both;
}
/* Яркая золотая нить по верхнему краю — «блик на матовом металле». */
.login-card::before {
  content: '';
  position: absolute;
  left: 16%;
  right: 16%;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-2), var(--gold-3) 50%, transparent);
  opacity: .9;
}
.login-card p { margin: 0; }

.brand {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: .08em;
}

/* ─── Приветствие ───────────────────────────────────────────────────────────
   Экран между запуском и списком проектов. Ничего, кроме монеты, имени и
   стрелки: он существует ради одной паузы на входе, а не ради содержимого. */

.hello {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  padding: max(env(safe-area-inset-top), 24px) 24px calc(24px + env(safe-area-inset-bottom));
}
/* Площадка для монеты: размеры задаёт экран, внутренности рисует coin.css. */
.hello-coin {
  position: relative;
  flex: none;
  width: min(64vw, 260px);
  height: min(64vw, 260px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.hello .brand {
  background: var(--grad-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hello .muted { margin: 0; }
/* Монета на приветствии крутится сама, а не перекидывается сторонами.
   Оборот настоящий: через гурт, обе стороны по очереди уходят ребром. Ради
   этого и перспектива здесь ближе — плоский поворот на большом расстоянии
   глаз читает как простую подмену картинки.
   Инлайновый transform, который ставит coin.js по тапу, анимация
   перебивает — это правило каскада, а не случайность. */
.hello-coin .coin__stage { perspective: 560px; }
.hello-coin .coin__flip {
  transition: none;
  animation: hello-spin 6.5s linear infinite;
}
@keyframes hello-spin {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(360deg); }
}
/* Монета ушла с экрана — вращение вместе с ней (класс ставит coin.js). */
.hello-coin .coin.is-paused .coin__flip { animation-play-state: paused; }

/* Стрелка дальше — единственная цель нажатия, поэтому крупная и заметная. */
.hello-go {
  margin-top: 10px;
  width: 66px;
  height: 66px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: #2a1d07;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--gold-2), var(--amber));
  box-shadow: 0 10px 26px rgba(247, 201, 72, .28);
  cursor: pointer;
  transition: transform .12s var(--ease);
}
.hello-go:active { transform: scale(.94); }

/* ─── Каркас приложения ─────────────────────────────────────────────────── */

/* Колонка, а не грид с фиксированным списком строк.
   Это принципиально: часть строк (полоса «нет входа», полоса «работает»)
   скрывается через [hidden] → display:none, и такой элемент перестаёт быть
   элементом грида. Строки сдвигаются, и 1fr достаётся не ленте, а полосе
   «работает» — она схлопывалась до 19 px, а её кнопка «Стоп» высотой 52 px
   вылезала на композер. У flex-колонки такой зависимости от числа детей нет. */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
/* Растягивается только лента. Всё остальное — по содержимому. */
.app > * { flex: 0 0 auto; }
.app > .stream-wrap { flex: 1 1 auto; }

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(env(safe-area-inset-top), 8px) 10px 9px;
  background: linear-gradient(180deg, rgba(26, 30, 48, .88), rgba(11, 13, 21, .80));
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  position: relative;
}
/* Спектральная нить под шапкой — самый заметный «многоцветный» штрих. */
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1.5px;
  background: var(--grad-spectrum);
  opacity: .75;
}
.title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: .01em;
}
/* Две строки в шапке: имя проекта и модель под ним. Колонка обязана иметь
   min-width:0, иначе длинное имя распирает шапку и выдавливает точку связи. */
.title-lines {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 1px;
  /* Обрезка живёт здесь, а не на самих строках. У строки со своим
     overflow:hidden текст в WebKit временами перестаёт рисоваться вовсе —
     ровно так пропадало имя проекта и в шапке, и в карточках списка. */
  overflow: hidden;
}
#project-title {
  min-width: 0;
  white-space: nowrap;
}
/* Модель — тихая подпись: важна, но не спорит с именем проекта. */
#model-chip {
  min-width: 0;
  white-space: nowrap;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold-2);
  opacity: .85;
}
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  transition: background-color .25s;
}
.dot.live { background: var(--teal); box-shadow: 0 0 10px rgba(60, 230, 200, .7); }
.dot.busy { background: var(--amber); box-shadow: 0 0 10px rgba(255, 159, 69, .7); }
.dot.down { background: var(--rose); box-shadow: 0 0 10px rgba(255, 113, 131, .7); }

/* Цель нажатия — не меньше 44×44: в шапке промахиваться нечем. */
.icon-btn {
  background: none;
  border: 0;
  color: var(--text);
  font-size: 1.45rem;
  line-height: 1;
  min-width: 46px;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 13px;
  cursor: pointer;
  flex: none;
  transition: transform .12s var(--ease), background-color .18s;
}
.icon-btn:active { background: rgba(157, 123, 255, .18); transform: scale(.9); }
/* Ставим на место отсутствующей кнопки, чтобы заголовок остался по центру. */
.topbar-pad { width: 46px; flex: none; }

/* Полосы вкладок с чужими проектами на экране проекта нет: внутри проекта она
   только отъедала высоту у ленты, а переключение идёт кнопкой «назад».
   Разметка и стили удалены целиком. */

/* ─── Лента сообщений ───────────────────────────────────────────────────── */

.stream {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
/* flex: none обязателен. Лента — колоночный flex, а у карточки инструмента
   стоит overflow:hidden, что отключает автоминимум высоты: без запрета сжатия
   такие карточки схлопываются в полоску, когда лента переполнена. */
/* Появление — только прозрачностью, без сдвига. Сдвиг меняет высоту прямо во
   время анимации, а лента в этот момент доезжает вниз: когда Claude печатает и
   тут же выполняет команды, вставки идут пачками и экран заметно дрожит. */
.stream > * {
  flex: none;
  animation: fade-in .18s linear both;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to   { opacity: 1; transform: none; }
}

.bubble {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: var(--radius);
  line-height: 1.58;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  position: relative;
}
/* Реплика владельца — тёплая, золото-янтарь. */
.bubble.user {
  align-self: flex-end;
  border: 1px solid transparent;
  background:
    linear-gradient(158deg, rgba(96, 74, 26, .55), rgba(58, 40, 18, .62)) padding-box,
    linear-gradient(158deg, rgba(255, 228, 159, .75), rgba(255, 159, 69, .35)) border-box;
  color: #fff3d8;
  border-bottom-right-radius: 5px;
}
/* Что было приложено к сообщению. Свою же картинку показываем целиком —
   по имени файла снимок экрана не узнать. После перезагрузки страницы превью
   взять неоткуда: остаётся строчка с именем. */
.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  white-space: normal;
}
/* Видео в пузыре: широкое, но не выше половины экрана — это чат, не кинозал. */
.msg-file-video {
  max-width: 100%;
  max-height: 46vh;
  border-radius: 10px;
  border: 1px solid rgba(255, 228, 159, .35);
  background: #000;
}
.msg-file-img {
  max-width: 160px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid rgba(255, 228, 159, .35);
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.msg-file {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .78rem;
  border: 1px solid rgba(255, 228, 159, .30);
  background: rgba(0, 0, 0, .22);
  color: inherit;
  text-decoration: none;
}

/* Картинка во весь экран: нажал на вложение — увидел, что именно отправил.
   Лежит выше всего остального, включая шторки. */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(4, 5, 9, .94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade .16s var(--ease) both;
}
.viewer img {
  max-width: 100%;
  /* Целиком в экран всегda: и высокие скрины, и широкие панорамы. */
  max-height: 88vh;
  min-height: 0;
  flex: 0 1 auto;
  object-fit: contain;
  border-radius: 12px;
  /* Возврат на место после недотянутого свайпа — плавный; само движение за
     пальцем идёт без перехода, его выключает код. */
  transition: transform .18s var(--ease), opacity .18s linear;
  /* Жест наш: браузер не должен тянуть страницу под просмотром. */
  touch-action: none;
}
.viewer-count {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(10, 12, 20, .75);
  color: var(--muted);
  font-size: .78rem;
}
.viewer-cap {
  flex: none;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
  overflow-wrap: anywhere;
}
/* Подвал сообщения: время и кнопка «копировать» одной строкой у правого края.
   Раньше обе детали висели абсолютом НИЖЕ пузыря и торчали за обводкой —
   выглядело так, будто они прилипли к сообщению снаружи. Внутри рамки они
   стоят на своём месте и ничего не перекрывают: строка своя, текст её не
   обтекает. */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  white-space: normal;
}
.copy-btn {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: .82rem;
  line-height: 1;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #1b2032;
  color: var(--muted);
  cursor: pointer;
  opacity: .75;
  transition: transform .12s var(--ease), opacity .12s linear;
}
.copy-btn:active { transform: scale(.9); }
.copy-btn.done {
  opacity: 1;
  color: #96f0e0;
  border-color: rgba(60, 230, 200, .5);
}
/* Время отправки — слева от кнопки копирования. Мелкое и приглушённое:
   справка, а не часть разговора. */
.msg-time {
  font-size: .64rem;
  line-height: 1;
  color: var(--muted);
  opacity: .8;
  white-space: nowrap;
  pointer-events: none;
}
/* Ссылка в сообщении: видно, что живая, и есть куда попасть пальцем. */
.msg-link {
  color: #9fd8ff;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.msg-link:active { opacity: .7; }
.bubble.user .msg-link { color: #ffe9b8; }

/* В своём пузыре фон тёплый: серая «справочная» краска на нём тонет. */
.bubble.user .msg-time { color: rgba(255, 243, 216, .6); }
.bubble.user .copy-btn {
  border-color: rgba(255, 228, 159, .3);
  background: rgba(24, 17, 6, .5);
  color: rgba(255, 243, 216, .75);
}

/* Ответ Claude — спокойный непрозрачный планшет: под ним читают длинный текст
   и код, поэтому здесь никакой цветной заливки. Цвет живёт в тонкой полосе
   слева, и только он. */
.bubble.assistant {
  align-self: flex-start;
  background: linear-gradient(180deg, #1c2032 0%, #171b2a 100%);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  padding-left: 17px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.bubble.assistant::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--teal), var(--indigo) 55%, var(--violet));
  opacity: .9;
}
.bubble.system {
  align-self: center;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
  padding: 2px;
}
/* «Остановлено» — не рядовая системная строка: это ответ на нажатие «Стоп»,
   и его надо увидеть сразу. Жёсткая остановка отмечена отдельно. */
.bubble.system.stopped {
  padding: 9px 14px;
  /* Текст сервера бывает в три строки — таблетка тут не годится. */
  border-radius: 13px;
  border: 1px solid rgba(255, 159, 69, .45);
  background: rgba(255, 159, 69, .10);
  color: #ffe0b8;
  max-width: 96%;
}
.bubble.system.stopped.hard {
  border-color: rgba(255, 113, 131, .6);
  background: rgba(255, 113, 131, .12);
  color: #ffd0d7;
}

.bubble.error {
  align-self: stretch;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(58, 22, 30, .96), rgba(36, 17, 23, .96)) padding-box,
    var(--grad-rose) border-box;
  color: #ffd9de;
  font-size: .9rem;
}

/* ─── Группа действий ───────────────────────────────────────────────────────
   Шесть подряд идущих вызовов инструментов раньше занимали весь экран, и текст
   ответа уходил за верхнюю кромку. Теперь подряд идущие вызовы сворачиваются
   в ОДНУ строку «6 действий · Bash, Read»; тап раскрывает список целиком.
   Главным на экране остаётся ответ Claude. */

.tool-group {
  align-self: stretch;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, #191d2c, #13161f) padding-box,
    linear-gradient(140deg, rgba(60, 230, 200, .45), rgba(109, 139, 255, .35) 55%, rgba(157, 123, 255, .30)) border-box;
  overflow: hidden;
}
/* Свёрнутая строка — кнопка во всю ширину и высотой в палец. */
.tg-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: .9rem;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  transition: background-color .18s;
}
.tg-head:active { background: rgba(109, 139, 255, .12); }
/* Счётчик: сразу видно, сколько шагов Claude сделал. */
.tg-count {
  flex: none;
  font-weight: 700;
  color: #7ff0dd;
  letter-spacing: .01em;
}
.tg-names {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
}
.tg-status {
  flex: none;
  font-size: .95rem;
  min-width: 22px;
  text-align: center;
  color: var(--muted);
}
.tg-status.ok { color: var(--teal); }
.tg-status.bad { color: var(--rose); }
.tg-chev {
  flex: none;
  width: 22px;
  text-align: center;
  color: var(--muted);
  transition: transform .18s var(--ease);
}
.tool-group.open .tg-chev { transform: rotate(180deg); }
/* Развёрнутый список: сами карточки, каждая со своими деталями. */
.tg-list {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: rgba(6, 7, 12, .45);
  /* Даже раскрытая группа не должна выталкивать ответ за экран. */
  max-height: calc(var(--app-h, 100dvh) * .52);
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Внутри группы у карточки своя рамка не нужна — она бы дублировала рамку
   группы и превращала список в «лесенку». */
.tg-list .tool { border-radius: 11px; }

/* ─── Карточка инструмента ──────────────────────────────────────────────── */

.tool {
  align-self: stretch;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, #191d2c, #13161f) padding-box,
    linear-gradient(140deg, rgba(60, 230, 200, .45), rgba(109, 139, 255, .35) 55%, rgba(157, 123, 255, .30)) border-box;
  overflow: hidden;
}
/* Заголовок карточки — кнопка во всю ширину и высотой в палец. */
.tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: .9rem;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  transition: background-color .18s;
}
.tool-head:active { background: rgba(109, 139, 255, .12); }
.tool-chev {
  flex: none;
  width: 26px;
  text-align: center;
  color: var(--muted);
  transition: transform .18s var(--ease);
}
.tool.open .tool-chev { transform: rotate(180deg); }
/* Имя инструмента — бирюза: техническое действие звучит иначе, чем ответ. */
.tool-name {
  font-weight: 700;
  color: #7ff0dd;
  letter-spacing: .01em;
}
.tool-summary {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
}
.tool-status {
  flex: none;
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  color: var(--muted);
}
.tool-status.ok { color: var(--teal); }
.tool-status.bad { color: var(--rose); }
.tool-body {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
  /* Код читают долго — фон почти чёрный, текст светлее «приглушённого». */
  color: #b9c2da;
  background: var(--ink);
  /* dvh, а не vh: с открытой клавиатурой лог не должен занимать весь экран. */
  max-height: calc(var(--app-h, 100dvh) * .42);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ─── Запрос разрешения ─────────────────────────────────────────────────── */

/* ─── Вопрос от Claude ──────────────────────────────────────────────────────
   Не разрешение, а выбор: варианты крупными целями, свой ответ строкой,
   шаги «назад/далее», если вопросов несколько. Ничего не уходит, пока не
   нажата «Ответить». */

.ask {
  align-self: stretch;
  border-radius: var(--radius);
  padding: 13px;
  display: grid;
  gap: 10px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, #171d2e, #12151f) padding-box,
    linear-gradient(150deg, rgba(109, 139, 255, .75), rgba(60, 230, 200, .35)) border-box;
  box-shadow: 0 8px 28px rgba(109, 139, 255, .16);
}
.ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #a9b6ff;
}
.ask-step { color: var(--muted); font-weight: 600; letter-spacing: 0; text-transform: none; }
.ask-q { font-size: 1.02rem; font-weight: 650; line-height: 1.4; }
.ask-opts { display: grid; gap: 7px; }
.ask-opt {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  cursor: pointer;
  transition: transform .1s var(--ease);
}
.ask-opt:active { transform: scale(.985); }
.ask-opt.on {
  border-color: rgba(109, 139, 255, .8);
  background: rgba(109, 139, 255, .16);
  box-shadow: inset 0 0 0 1px rgba(109, 139, 255, .35);
}
.ask-opt-label { font-weight: 700; }
.ask-opt-desc { font-size: .78rem; color: var(--muted); }
.ask-other {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font: inherit;
}
.ask-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ask-actions button { min-height: 40px; padding: 0 16px; border-radius: 12px; }
/* Ответ отдан — карточка превращается в спокойную запись о выборе. */
.ask-done { white-space: pre-line; color: var(--muted); font-size: .88rem; }

.perm {
  align-self: stretch;
  border-radius: var(--radius);
  padding: 13px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, #241f16, #191612) padding-box,
    var(--grad-amber) border-box;
  box-shadow: 0 8px 28px rgba(255, 159, 69, .16);
}
.perm-title {
  font-weight: 700;
  margin-bottom: 7px;
  color: #ffe3b4;
}
.perm-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  color: #b9c2da;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: calc(var(--app-h, 100dvh) * .26);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 13px;
}

/* Принять / Отклонить — самое частое и самое опасное действие.
   Две крупные кнопки в ряд, разного цвета, с разными значками и заметным
   зазором: промахнуться и «разрешить не то» так гораздо труднее. */
.perm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.perm-actions button {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  border: 1px solid;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s var(--ease);
}
.perm-actions button:active { transform: scale(.96); }
.perm-ico { font-size: 1.15rem; line-height: 1; }
.perm-allow {
  background: var(--grad-gold);
  border-color: var(--gold-4);
  color: var(--on-accent);
  box-shadow: 0 6px 20px rgba(224, 163, 37, .30);
}
.perm-deny {
  background: linear-gradient(180deg, rgba(72, 26, 36, .96), rgba(44, 18, 26, .96));
  border-color: var(--rose-2);
  color: #ffcbd3;
}
/* «Всегда» — отдельной строкой и тише остальных: случайно не нажать. */
.perm-always {
  margin-top: 10px;
  width: 100%;
  min-height: 44px;
  border-radius: 11px;
  border: 1px dashed rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: .88rem;
  cursor: pointer;
}
.perm-always:active { transform: scale(.98); }
.perm.resolved {
  background: linear-gradient(180deg, #1a1d29, #14161f) padding-box,
              linear-gradient(180deg, var(--line-2), var(--line)) border-box;
  box-shadow: none;
  opacity: .65;
}
.perm.resolved .perm-actions,
.perm.resolved .perm-always { display: none; }
.perm-verdict:not(:empty) { margin-top: 8px; font-size: .85rem; color: var(--muted); }

/* ─── Полоса «работает» и композер ──────────────────────────────────────── */

/* Полоса «работает» — отдельная строка НАД композером. Собственная
   min-height обязательна: внутри лежит кнопка «Стоп» высотой 52 px, и без
   неё полосу можно сжать так, что кнопка вылезет на поле ввода. */
/* Полоса «Claude работает» стоит над композером и ест высоту ленты, поэтому
   она нарочно низкая: строка текста и небольшая кнопка. */
.running-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 8px 5px 12px;
  background: linear-gradient(180deg, rgba(38, 30, 20, .95), rgba(14, 16, 25, .96));
  border-top: 1px solid rgba(255, 159, 69, .22);
  font-size: .8rem;
  color: #e6dcc6;
  position: relative;
  overflow: hidden;
  animation: rise .22s var(--ease) both;
}
/* Бегущая нить — признак того, что Claude сейчас работает. */
.running-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-2), var(--amber) 55%, transparent);
  animation: sweep 1.7s linear infinite;
  will-change: transform;
}
@keyframes sweep {
  from { transform: translate3d(-100%, 0, 0); }
  to   { transform: translate3d(100%, 0, 0); }
}
.running-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Это кнопка: снимаем всё «кнопочное», кроме поведения. */
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
}
.running-info.tappable { cursor: pointer; }
.running-more {
  flex: none;
  padding-left: 2px;
  color: #b9b0d8;
  font-size: 1.1rem;
  line-height: 1;
}

/* Работа субагентов: плотный список, читается как сводка, а не как лента. */
.agent-block { margin: 0 0 16px; }
.agent-head {
  margin: 0 0 6px;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #b9b0d8;
}
.agent-line {
  margin: 0 0 5px;
  padding-left: 10px;
  border-left: 2px solid rgba(157, 123, 255, .35);
  font-size: .9rem;
  line-height: 1.4;
  color: #ded8f2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.agent-line.tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
  color: #9f98bb;
  border-left-color: rgba(255, 255, 255, .16);
}
.agent-line.tool.bad {
  color: #ff9d9d;
  border-left-color: rgba(255, 120, 120, .5);
}
/* Обрезка на самой колонке, а не на строках: строка со своим overflow:hidden
   в WebKit иногда перестаёт рисовать текст (см. шапку и карточки списка). */
.running-lines { display: grid; min-width: 0; overflow: hidden; }
.running-lines > * { white-space: nowrap; }
#running-sub { color: var(--muted); font-size: .7rem; }

/* Кнопка остановки: маленькая. Нажимают её редко, а место над композером
   дорогое. Прерывание не мгновенное, поэтому у неё есть честное состояние
   ожидания — в нём она подрастает под длинную надпись. */
.stop-btn {
  flex: none;
  min-height: 32px;
  min-width: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(80, 28, 40, .96), rgba(48, 18, 28, .96)) padding-box,
    var(--grad-rose) border-box;
  color: #ffd3da;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(214, 63, 87, .20);
  transition: transform .12s var(--ease);
}
.stop-btn:active { transform: scale(.95); }
/* Во время остановки на кнопке написано, что сделает СЛЕДУЮЩЕЕ нажатие —
   «Остановить принудительно». Текст длинный, поэтому мельче и в две строки:
   иначе он выдавил бы с полосы сам счётчик «Останавливаю… 7 с». */
.stop-btn.waiting {
  min-width: 104px;
  max-width: 56%;
  padding: 0 10px;
}
.stop-btn.waiting #stop-label {
  font-size: .72rem;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
}
/* Принудительная остановка уже отправлена — кнопка больше ничего не ждёт. */
.stop-btn.hard {
  background:
    linear-gradient(180deg, rgba(120, 34, 52, .98), rgba(74, 22, 34, .98)) padding-box,
    var(--grad-rose) border-box;
  color: #ffe2e6;
}
.stop-glyph {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: currentColor;
  flex: none;
}
/* Пока идёт остановка — квадратик пульсирует (только transform). */
.stop-btn.waiting .stop-glyph {
  animation: stop-pulse 1s ease-in-out infinite;
  will-change: transform;
}
@keyframes stop-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(.72); }
}
.running-bar.stopping { color: #ffd7c9; }
/* Во время остановки объяснение важнее краткости: пусть переносится на вторую
   строку, а не обрывается многоточием. */
.running-bar.stopping #running-sub { white-space: normal; }
.running-bar.stopping .spinner { opacity: .5; }

/* Спиннер — маленькая крутящаяся монета вместо безликого кольца. */
.spinner {
  width: 15px; height: 15px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #7a4a0d, #ffe89b 25%, #b87616 50%, #fff3c4 75%, #7a4a0d);
  box-shadow: inset 0 0 0 2px rgba(20, 14, 4, .55);
  animation: spin 1.4s linear infinite;
  will-change: transform;
}
@keyframes spin { to { transform: rotate(360deg); } }

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Отступ под домашнюю черту нужен ровно в той части, что попала внутрь
     экрана. Если ниже уже есть пустота (панель браузера, клавиатура) — второй
     раз её закладывать нельзя: внизу вырастает мёртвая полоса. */
  padding: 9px 10px calc(9px + max(0px, env(safe-area-inset-bottom) - var(--app-bot, 0px)));
  background: linear-gradient(180deg, rgba(22, 26, 40, .92), rgba(8, 10, 16, .98));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
  position: relative;
}
/* Тонкий спектральный отблеск над композером — рифма к нити под шапкой. */
.composer::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: var(--grad-spectrum);
  opacity: .35;
}
.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
/* На узких экранах в ряду теперь три кнопки и поле. Ужимаем до нижней
   допустимой границы цели (44 px), чтобы полю ввода осталось место. */
@media (max-width: 360px) {
  .composer-row { gap: 6px; }
  .composer-row .attach,
  .composer-row .mic,
  .composer-row .send { width: 44px; height: 44px; }
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: calc(var(--app-h, 100dvh) * .40);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: rgba(6, 7, 12, .88);
  color: var(--text);
  /* 16px обязательны: при меньшем размере Safari зумит страницу на фокусе. */
  font-size: 16px;
  line-height: 1.4;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  /* Пока текст помещается, полосы прокрутки нет вовсе — её включает JS,
     когда поле упёрлось в потолок высоты (см. autogrow). */
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
/* Светлая системная полоса на тёмном поле бьёт по глазам — делаем свою. */
.composer textarea::-webkit-scrollbar { width: 7px; }
.composer textarea::-webkit-scrollbar-track { background: transparent; }
.composer textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .16);
  border-radius: 4px;
}
.composer textarea::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .26); }
.composer textarea:focus {
  outline: none;
  border-color: rgba(157, 123, 255, .7);
  box-shadow: 0 0 0 3px rgba(157, 123, 255, .16);
}
.send {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--grad-gold);
  color: var(--on-accent);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(224, 163, 37, .35);
  transition: transform .12s var(--ease);
}
.send:active { transform: scale(.9); }
.send:disabled { opacity: .4; }

/* ─── Голосовой ввод ────────────────────────────────────────────────────────
   Кнопка микрофона в композере и полоса состояния над ним. Полоса всегда
   говорит одно и то же тремя разными словами: идёт запись / идёт расшифровка /
   не вышло. Ожидание расшифровки длинное (примерно вдвое дольше записи),
   поэтому в ней всегда есть счётчик и оценка. */

.mic {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(46, 52, 76, .9), rgba(20, 23, 36, .9)) padding-box,
    linear-gradient(180deg, rgba(60, 230, 200, .55), rgba(109, 139, 255, .35)) border-box;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s var(--ease);
}
.mic:active { transform: scale(.9); }
/* Идёт запись — кнопка красная и «дышит». Анимируем только transform. */
.mic.recording {
  background:
    linear-gradient(180deg, rgba(120, 32, 48, .96), rgba(72, 20, 32, .96)) padding-box,
    var(--grad-rose) border-box;
  color: #ffd3da;
  animation: mic-pulse 1.4s ease-in-out infinite;
  will-change: transform;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(.9); }
}

.voice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(40, 24, 30, .95), rgba(18, 14, 20, .96)) padding-box,
    var(--grad-rose) border-box;
  color: #ffdde2;
  font-size: .86rem;
  animation: rise .2s var(--ease) both;
}
.voice-bar.v-send {
  background:
    linear-gradient(180deg, rgba(24, 34, 50, .95), rgba(14, 18, 28, .96)) padding-box,
    linear-gradient(140deg, rgba(60, 230, 200, .7), rgba(109, 139, 255, .5)) border-box;
  color: #d6f3ee;
}
/* Запись уже на сервере: зелёный уверенный тон вместо «ждущего» —
   человек должен с одного взгляда понять, что сторожить больше нечего. */
.voice-bar.v-send.v-safe {
  background:
    linear-gradient(180deg, rgba(14, 40, 34, .95), rgba(10, 22, 20, .96)) padding-box,
    linear-gradient(140deg, rgba(60, 230, 200, .9), rgba(60, 230, 200, .4)) border-box;
  color: #b6fff2;
}
.voice-bar.v-fail {
  background:
    linear-gradient(180deg, rgba(52, 34, 16, .95), rgba(24, 18, 12, .96)) padding-box,
    var(--grad-amber) border-box;
  color: #ffe3bd;
}
.voice-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.voice-lines { display: grid; gap: 2px; min-width: 0; }
.voice-lines > span { font-weight: 700; }
.voice-lines > small { font-size: .74rem; opacity: .85; }
/* Ожидание расшифровки длинное, поэтому оно ещё и нарисовано: полоска идёт к
   обещанному сроку. Двигаем scaleX — никакой перекраски и перевёрстки. */
.voice-progress {
  height: 3px;
  margin-top: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  overflow: hidden;
}
.voice-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--indigo));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .25s linear;
  will-change: transform;
}
.voice-actions { display: flex; gap: 8px; flex: none; }
.voice-actions button { padding: 10px 14px; font-size: .85rem; min-height: 44px; }

/* Метка слева: красная точка на записи, монета-спиннер на расшифровке. */
.voice-mark {
  flex: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 10px rgba(255, 113, 131, .6);
}
.voice-bar.v-rec .voice-mark {
  animation: mic-pulse 1.2s ease-in-out infinite;
  will-change: transform;
}
.voice-bar.v-send .voice-mark {
  background: conic-gradient(from 0deg, #10a894, #b6fff2 25%, #3ce6c8 50%, #ffffff 75%, #10a894);
  box-shadow: inset 0 0 0 2px rgba(6, 22, 20, .6);
  animation: spin 1.4s linear infinite;
  will-change: transform;
}
.voice-bar.v-fail .voice-mark {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 159, 69, .5);
}

/* ─── Вложения ──────────────────────────────────────────────────────────────
   Кнопка скрепки и полоса выбранных файлов над полем ввода. */

.attach {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(46, 52, 76, .9), rgba(20, 23, 36, .9)) padding-box,
    linear-gradient(180deg, rgba(157, 123, 255, .55), rgba(60, 230, 200, .35)) border-box;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s var(--ease);
}
/* Свои иконки композера: контур в цвет текста, одинаковый на всех системах. */
.ico {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.attach:active { transform: scale(.9); }
.attach:disabled { opacity: .45; }

.attach-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.attach-list::-webkit-scrollbar { display: none; }

.att {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 62vw;
  padding: 7px 34px 7px 8px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(6, 7, 12, .82);
  font-size: .78rem;
}
/* Превью картинки — сразу понятно, что именно прикрепил. */
.att-thumb {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, .06);
  display: block;
}
.att-mark {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(157, 123, 255, .16);
  color: #cbbcff;
  font-size: .66rem;
  font-weight: 800;
  text-transform: uppercase;
  overflow: hidden;
}
.att-text { display: grid; gap: 1px; min-width: 0; overflow: hidden; }
.att-name {
  white-space: nowrap;
  max-width: 40vw;
}
.att-size { color: var(--muted); font-size: .7rem; }
/* Крестик — отдельная цель нажатия 44×44, попасть можно не глядя. */
.att-drop {
  position: absolute;
  right: -5px; top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.att-drop:active { color: var(--rose); }
/* Полоска загрузки на нижней кромке плитки — только transform. */
/* Ход загрузки: полоска наполняется слева направо. На 50 МБ это единственный
   способ понять, идёт дело или встало. */
.att-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  overflow: hidden;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, .10);
}
.att-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grad-spectrum);
  transition: width .18s linear;
}
/* Первые байты ещё не ушли — показываем «дыхание», а не пустоту. */
.att-bar-fill.waiting {
  width: 100% !important;
  animation: sweep 1.1s linear infinite;
  will-change: transform;
}
.att.done .att-bar { display: none; }
.att.failed { border-color: rgba(255, 113, 131, .7); }
.att.failed .att-size { color: var(--rose); }

/* ─── Кнопки, поля, шторки ──────────────────────────────────────────────── */

button, select, input, textarea { font-family: inherit; }

.primary, .ghost, .danger {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: .95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .12s var(--ease), box-shadow .2s, color .2s;
}
.primary:active, .ghost:active, .danger:active { transform: scale(.97); }
/* Кнопка занята делом — видно, что нажимать её второй раз бесполезно. */
.primary:disabled, .ghost:disabled, .danger:disabled { opacity: .55; cursor: default; }
.primary:disabled:active, .ghost:disabled:active, .danger:disabled:active { transform: none; }
.primary {
  background: var(--grad-gold);
  color: var(--on-accent);
  border-color: var(--gold-4);
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(224, 163, 37, .28);
}
/* «Тихая» кнопка — стеклянная плитка с подсвеченным верхним краем. */
.ghost {
  background:
    var(--glass) padding-box,
    linear-gradient(180deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, .05)) border-box;
  color: var(--text);
}
.ghost:active { box-shadow: 0 0 0 3px rgba(157, 123, 255, .14); }
.danger {
  background:
    linear-gradient(180deg, rgba(62, 24, 34, .92), rgba(38, 17, 24, .92)) padding-box,
    linear-gradient(180deg, rgba(255, 113, 131, .8), rgba(214, 63, 87, .5)) border-box;
  color: #ffb9c2;
}
.wide { width: 100%; }

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(157, 123, 255, .18);
  border: 1px solid rgba(157, 123, 255, .5);
  color: #d5c8ff;
  font-size: .75rem;
  line-height: 1.5;
}

.zone-label {
  margin: 0;
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--rose);
  opacity: .85;
  font-weight: 700;
}

input[type="text"], input[type="password"], select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(6, 7, 12, .85);
  color: var(--text);
  /* 16px: иначе Safari зумит страницу при фокусе. */
  font-size: 16px;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"]:focus, input[type="password"]:focus, select:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(247, 201, 72, .14);
}
input::placeholder, textarea::placeholder { color: #6c7490; }

.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row input { flex: 1; min-width: 0; }
.inline-row button { flex: none; }

/* Шторка живёт в той же системе координат, что и экраны: иначе с открытой
   клавиатурой её низ (а там поле «Название») уезжает под клавиатуру. */
.sheet {
  position: fixed;
  left: 0; right: 0;
  top: var(--app-top, 0px);
  height: var(--app-h, 100dvh);
  z-index: 50;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 8, .68);
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(32, 36, 56, .98), rgba(11, 13, 21, .99));
  border-top: 1px solid var(--line-2);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .6);
  animation: sheet-up .26s var(--ease) both;
  will-change: transform;
}
@keyframes sheet-up {
  from { transform: translate3d(0, 100%, 0); }
  to   { transform: none; }
}
/* Спектральная нить по верхней кромке шторки. */
.sheet-body::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: var(--grad-spectrum);
  opacity: .7;
  border-radius: 22px 22px 0 0;
}
/* Хват сверху — намёк, что это шторка. */
.sheet-body::before {
  content: '';
  width: 40px; height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  justify-self: center;
  margin-bottom: 2px;
}
.sheet-body h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.sheet-body hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 4px 0; }
.row { display: grid; gap: 6px; }
.row label { font-size: .85rem; color: var(--muted); }

.adopt-list { display: grid; gap: 8px; }
.adopt-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(40, 45, 68, .8), rgba(20, 23, 36, .8)) padding-box,
    linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .04)) border-box;
  font-size: .9rem;
  overflow: hidden;
}
.adopt-item > span { min-width: 0; white-space: nowrap; }
.adopt-item button { padding: 8px 12px; font-size: .85rem; }
.adopt-actions { display: flex; gap: 6px; flex: none; }

/* ─── Три экрана: вход → список проектов → проект ────────────────────────
   Экраны лежат стопкой и переезжают горизонтально. Двигаем только transform
   и opacity; неактивные выключены из отрисовки через visibility. */

.view {
  position: fixed;
  left: 0;
  right: 0;
  /* --app-h и --app-top ставит JS по visualViewport.
     Высота: 100dvh на айфоне не ужимается, когда вылезает клавиатура.
     Смещение: position:fixed на iOS отсчитывается от ВЁРСТОЧНОГО вьюпорта, а
     клавиатура сдвигает вниз ВИДИМЫЙ. Без поправки на visualViewport.offsetTop
     экран рисуется выше видимой области — поле ввода уезжает вверх, а под ним
     остаётся пустая полоса. */
  top: var(--app-top, 0px);
  height: var(--app-h, 100dvh);
  overflow: hidden;
  z-index: 1;
  transform: translate3d(100%, 0, 0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: transform;
  transition:
    transform .3s var(--ease),
    opacity .22s linear,
    visibility 0s linear .3s;
}
.view.active {
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
  transition:
    transform .3s var(--ease),
    opacity .22s linear,
    visibility 0s;
}
/* Экран, оставшийся позади, слегка уезжает влево — видно, куда возвращаться. */
.view.behind {
  transform: translate3d(-22%, 0, 0);
  opacity: 0;
}
/* Карточка входа на низком экране должна прокручиваться. */
.view.login { overflow-y: auto; }

/* ─── Домашний экран: список проектов ───────────────────────────────────── */

.home {
  display: grid;
  grid-template-rows: auto 1fr;
}
/* На домашнем экране заголовок один — ставим его по центру шапки. */
.home .title { justify-content: center; }
.brand-word {
  letter-spacing: .06em;
  font-weight: 800;
  background: var(--grad-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px calc(20px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  align-content: start;
}
.home-head {
  margin: 8px 2px 0;
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #b9b0d8;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Заголовок раздела с уходящей вправо цветной чертой. */
.home-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(157, 123, 255, .55), transparent);
}
/* Подпись списка: чьи это чаты. Маленькая строка вместо пары вкладок —
   переключение уехало под список, ближе к большому пальцу. */
.home-title {
  margin: 16px 2px 2px;
  color: #b9b0d8;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Переход к соседнему движку: крупная строка под списком чатов. Стрелка
   показывает направление — вправо к Кодексу, влево обратно к Клоду. */
.engine-switch {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px dashed rgba(157, 123, 255, .38);
  border-radius: 14px;
  background: rgba(157, 123, 255, .07);
  color: #d8d0f0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.engine-switch:active {
  background: rgba(157, 123, 255, .16);
  border-color: rgba(157, 123, 255, .6);
}
/* Вперёд, к Кодексу: «Кодекс →», стрелка справа от надписи. Обратно к Клоду
   кнопка читается зеркально — «← Клод», и стрелка оказывается слева. */
.engine-switch.is-forward { flex-direction: row-reverse; }
.es-arrow {
  font-size: 1.15rem;
  line-height: 1;
  color: #b79bff;
}
.tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  font-size: .74rem;
  font-weight: 700;
}

.home-list { display: grid; gap: 10px; }

/* Строка проекта: крупная цель, всё нужное видно сразу.
   Цвет обводки и торцевой полосы меняется по кругу — список перестаёт быть
   монотонной стопкой одинаковых прямоугольников. */
.project-card {
  --edge: linear-gradient(180deg, var(--gold-2), var(--gold-5));
  --halo: rgba(247, 201, 72, .16);
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 76px;
  padding: 12px 14px 12px 18px;
  text-align: left;
  position: relative;
  overflow: hidden;
  border-radius: 17px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(34, 39, 60, .90), rgba(17, 20, 32, .92)) padding-box,
    linear-gradient(140deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .05) 55%) border-box;
  color: var(--text);
  cursor: pointer;
  animation: rise .26s var(--ease) both;
  transition: transform .12s var(--ease);
}
/* Цветной торец слева. */
.project-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--edge);
}
/* Мягкое цветное свечение из-под левого края. */
.project-card::after {
  content: '';
  position: absolute;
  left: -30%; top: -60%;
  width: 70%; height: 220%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--halo) 0%, transparent 70%);
  pointer-events: none;
}
.project-card:nth-child(4n+2) {
  --edge: linear-gradient(180deg, var(--violet), var(--violet-3));
  --halo: rgba(157, 123, 255, .20);
}
.project-card:nth-child(4n+3) {
  --edge: linear-gradient(180deg, var(--teal), var(--teal-2));
  --halo: rgba(60, 230, 200, .16);
}
.project-card:nth-child(4n+4) {
  --edge: linear-gradient(180deg, var(--indigo), var(--indigo-2));
  --halo: rgba(109, 139, 255, .18);
}
.project-card:active { transform: scale(.985); }
.pc-main { flex: 1; min-width: 0; display: grid; gap: 5px; position: relative; }
/* Строка «имя + метка» — грид с явной колонкой minmax(0, 1fr) под имя.
   Раньше здесь был flex, и имя (единственный сжимаемый элемент, к тому же с
   overflow:hidden → автоминимум 0) в WebKit схлопывалось в нулевую ширину:
   на экране оставались карточка и метка, а названия не было, пока что-нибудь
   не вызывало пересчёт раскладки. У грида ширина колонки задана явно и от
   порядка разрешения минимумов не зависит. */
.pc-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
/* Ни имя, ни путь больше НЕ обрезают себя сами. Своя область обрезки
   (overflow:hidden) у строки внутри анимированной карточки в WebKit иногда
   остаётся нулевой: коробка нормальной ширины, а текст в неё не попадает —
   на экране пустая карточка с меткой и моделью. Лишнее теперь срезает сама
   карточка (у неё overflow:hidden и заведомо ненулевой размер), а текст
   виден всегда: в худшем случае он просто уедет под метку. */
.pc-name {
  min-width: 0;
  font-size: 1.06rem;
  font-weight: 700;
  white-space: nowrap;
}
/* Каталог тянется, модель — нет: она короткая и важная. */
.pc-sub {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.pc-dir {
  font-size: .74rem;
  color: var(--muted);
  white-space: nowrap;
}
.pc-model {
  flex: none;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--gold-2);
  opacity: .8;
  white-space: nowrap;
}
/* Метки состояний — три разных цвета, различимых боковым зрением. */
.pc-chip {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  border: 1px solid rgba(109, 139, 255, .45);
  color: #c3cdff;
  background: rgba(109, 139, 255, .14);
}
.pc-chip.new {
  border-color: rgba(60, 230, 200, .40);
  color: #96f0e0;
  background: rgba(60, 230, 200, .10);
}
/* Незаконченное сообщение: тихая метка, спорить со статусом она не должна. */
.pc-chip.draft {
  border-color: rgba(157, 123, 255, .45);
  color: #d3c6ff;
  background: rgba(157, 123, 255, .12);
  font-weight: 500;
}
.pc-chip.waiting {
  border-color: rgba(255, 159, 69, .6);
  color: #ffe0b8;
  background: rgba(255, 159, 69, .16);
}
.pc-chip.working {
  border-color: rgba(247, 201, 72, .6);
  color: #2a1d07;
  background: linear-gradient(120deg, var(--gold-2), var(--amber));
  animation: chip-pulse 1.6s ease-in-out infinite;
  will-change: opacity;
}
@keyframes chip-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
.pc-go { flex: none; font-size: 1.5rem; color: var(--muted); position: relative; }

/* «Продолжить» — быстрый возврат в последний проект. Самый яркий элемент
   списка: золото по фиолетовому. */
.resume {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  padding: 10px 16px;
  border-radius: 17px;
  border: 1px solid transparent;
  background:
    linear-gradient(120deg, #3a1f74 0%, #4a2a5e 38%, #4a3617 78%, #1a1524 100%) padding-box,
    linear-gradient(120deg, var(--gold-2), var(--violet) 75%) border-box;
  color: #ffeec2;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 30px rgba(109, 63, 224, .18);
  transition: transform .12s var(--ease);
}
.resume:active { transform: scale(.985); }
.resume-label { font-size: .74rem; color: var(--gold-2); opacity: .9; flex: none; text-transform: uppercase; letter-spacing: .08em; }
.resume-name {
  flex: 1;
  min-width: 0;
  font-size: 1.06rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
.resume-go { font-size: 1.4rem; flex: none; }

.home-links { display: grid; gap: 10px; margin-top: 10px; }

/* ─── Баннер «нет входа» ────────────────────────────────────────────────── */

.auth-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  text-align: left;
  border-radius: 17px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(66, 25, 38, .95), rgba(38, 16, 24, .95)) padding-box,
    var(--grad-rose) border-box;
  color: #ffdbe0;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(214, 63, 87, .18);
  transition: transform .12s var(--ease);
}
.auth-banner:active { transform: scale(.985); }
.auth-banner-mark {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #2a0d13;
  background: var(--grad-rose);
}
.auth-banner-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.auth-banner-text small { color: #f3bcc4; font-size: .78rem; }
.auth-banner-go {
  flex: none;
  font-size: .82rem;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255, 113, 131, .6);
  background: rgba(0, 0, 0, .28);
}

/* Тонкая полоска на экране проекта — то же предупреждение, но не в ущерб ленте. */
.auth-strip {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid rgba(255, 113, 131, .5);
  background: linear-gradient(180deg, rgba(70, 26, 38, .95), rgba(44, 18, 26, .9));
  color: #ffdbe0;
  font-size: .84rem;
  text-align: left;
  cursor: pointer;
}
.auth-strip:active { background: rgba(92, 32, 46, .95); }

/* ─── Лента: обёртка, плавающие кнопки ──────────────────────────────────── */

.stream-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.stream { height: 100%; }

.jump {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(42, 47, 72, .97), rgba(19, 22, 35, .97)) padding-box,
    linear-gradient(180deg, rgba(157, 123, 255, .7), rgba(60, 230, 200, .4)) border-box;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .5);
  animation: rise .2s var(--ease) both;
}
.jump:active { transform: scale(.92); }
.jump-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--grad-amber);
  color: var(--on-accent);
  font-size: .7rem;
  font-weight: 800;
}

/* Ставим над кнопкой «вниз», чтобы две плавающие цели не наезжали друг
   на друга: промах здесь стоит дорого. */
.perm-pill {
  position: absolute;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(62, 45, 20, .97), rgba(34, 27, 16, .97)) padding-box,
    var(--grad-amber) border-box;
  color: #ffe9b8;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 159, 69, .25);
  animation: rise .2s var(--ease) both;
}
.perm-pill-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--grad-amber);
  color: #2a1e05;
  font-size: .78rem;
  font-weight: 800;
}

/* Переключатель в меню: крупная цель на всю строку — попадать в маленький
   квадратик на телефоне неудобно. */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-box {
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, .35);
  position: relative;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.switch-box::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8b93ad;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.switch input:checked + .switch-box {
  background: linear-gradient(120deg, var(--gold-2), var(--amber));
  border-color: transparent;
}
.switch input:checked + .switch-box::after {
  transform: translateX(18px);
  background: #2a1d07;
}
.switch input:disabled + .switch-box { opacity: .45; }
.switch-text { display: grid; gap: 2px; min-width: 0; }
.switch-text small { font-size: .74rem; }

/* ─── Сервисная панель ──────────────────────────────────────────────────── */

.service {
  display: grid;
  grid-template-rows: auto 1fr;
}
.screen-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  align-content: start;
}
/* Карточки панели: стекло с цветной нитью по верхнему краю. Нить у каждой
   карточки своя — разделы различаются, не читая заголовков. */
/* overflow:hidden здесь ставить нельзя: карточка — элемент грида .screen-body,
   и обнулённый автоминимум заставляет строки схлопываться под высоту экрана.
   Поэтому нить по верхнему краю просто утоплена от углов. */
.card {
  position: relative;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(30, 34, 52, .92), rgba(15, 17, 27, .94)) padding-box,
    linear-gradient(160deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, .05)) border-box;
  border-radius: 18px;
  padding: 15px 14px;
  display: grid;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
}
.card::before {
  content: '';
  position: absolute;
  left: 16px; right: 16px; top: 0;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--grad-gold);
}
.card:nth-of-type(2)::before { background: var(--grad-teal); }
.card:nth-of-type(3)::before { background: var(--grad-amber); }
.card:nth-of-type(4)::before { background: linear-gradient(90deg, var(--indigo), var(--violet)); }
.card:nth-of-type(5)::before { background: var(--grad-spectrum); }
.card:nth-of-type(6)::before { background: var(--grad-rose); }
.card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.card:nth-of-type(2) h2 { background: var(--grad-teal); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card:nth-of-type(3) h2 { background: var(--grad-amber); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card:nth-of-type(4) h2 { background: linear-gradient(100deg, #9fb4ff, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Расход по проектам: строка = проект, деньги выровнены вправо. */
.usage-list { display: grid; gap: 6px; }
.usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(6, 7, 12, .55);
  font-size: .86rem;
  overflow: hidden;
}
.usage-name { min-width: 0; white-space: nowrap; }
.usage-sub { grid-column: 1; font-size: .72rem; color: var(--muted); }
.usage-cost { font-weight: 800; color: var(--gold-2); white-space: nowrap; }
.usage-head {
  margin: 6px 2px 0;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.usage-row.failed { border-color: rgba(255, 113, 131, .45); }
.usage-row.failed .usage-cost { color: #ffc2ca; }
/* ─── Обновление сессий ─────────────────────────────────────────────────────
   Операция долгая: агент пишет память проекта. Пока она идёт, видно и что
   именно происходит, и сколько уже прошло — молчаливое ожидание здесь
   неотличимо от зависшей кнопки. */

.refresh-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1px solid rgba(109, 139, 255, .45);
  background: rgba(109, 139, 255, .10);
  font-size: .86rem;
  color: #d7dcff;
}
.refresh-lines { display: grid; gap: 2px; min-width: 0; }
.refresh-lines > span { font-weight: 700; }
.refresh-lines > small { font-size: .74rem; color: var(--muted); }

.refresh-results { display: grid; gap: 6px; }
.refresh-results:empty { display: none; }
.refresh-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(6, 7, 12, .55);
  font-size: .86rem;
  overflow: hidden;
}
.refresh-name { min-width: 0; white-space: nowrap; }
.refresh-action { font-weight: 800; white-space: nowrap; color: var(--muted); }
.refresh-reason { grid-column: 1 / -1; font-size: .74rem; color: var(--muted); }
.refresh-row.ok { border-color: rgba(60, 230, 200, .45); }
.refresh-row.ok .refresh-action { color: var(--teal); }
.refresh-row.bad { border-color: rgba(255, 113, 131, .5); }
.refresh-row.bad .refresh-action { color: #ffc2ca; }
.refresh-row.skip .refresh-action { color: #ffd9ad; }

.card hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 2px 0; }
.card > div[hidden] { display: none !important; }
#auth-browser, #auth-flow, #auth-token-box, .confirm-row { display: grid; gap: 10px; }

.auth-state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-chip {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.auth-chip.ok { color: #0b2b26; border-color: transparent; background: var(--grad-teal); }
.auth-chip.bad { color: #ffcbd3; border-color: var(--rose); background: rgba(255, 113, 131, .16); }
.auth-chip.unknown { color: #ffe0ab; border-color: var(--amber); background: rgba(255, 159, 69, .14); }

/* Крупная кнопка — для решений, которые делаешь одной рукой. */
.big { min-height: 54px; font-size: 1rem; }
.linkbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .86rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  overflow-wrap: anywhere;
}
.notice.ok { border-color: rgba(60, 230, 200, .55); color: #b6f2e6; background: rgba(60, 230, 200, .10); }
.notice.bad { border-color: rgba(255, 113, 131, .6); color: #ffd0d7; background: rgba(255, 113, 131, .10); }
.notice.warn { border-color: rgba(255, 159, 69, .6); color: #ffe0b8; background: rgba(255, 159, 69, .10); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
/* Строка «за всё время» — на всю ширину сетки, тихая справка под плитками. */
.usage-alltime {
  grid-column: 1 / -1;
  margin: 2px 2px 0;
}
/* Плитки состояния: тёмная основа + свой цвет подписи по кругу. */
.stat {
  --tile: var(--gold-3);
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(6, 7, 12, .62);
  min-width: 0;
  position: relative;
}
.stat::before {
  content: '';
  position: absolute;
  left: 0; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tile);
  opacity: .9;
}
.stat:nth-child(2) { --tile: var(--violet); }
.stat:nth-child(3) { --tile: var(--indigo); }
.stat:nth-child(4) { --tile: var(--teal); }
.stat:nth-child(5) { --tile: var(--amber); }
.stat:nth-child(6) { --tile: var(--rose); }
.stat-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.stat-value { font-size: .95rem; font-weight: 700; overflow-wrap: anywhere; }
.bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .09);
  overflow: hidden;
  margin-top: 5px;
}
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--indigo)); }
.bar-fill.hot { background: linear-gradient(90deg, var(--amber), var(--rose)); }

.logs {
  margin: 0;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: #b3bcd4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: calc(var(--app-h, 100dvh) * .40);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.danger-badge {
  background: rgba(255, 113, 131, .16);
  border-color: rgba(255, 113, 131, .6);
  color: #ffcbd3;
}

/* ─── Всплывающее уведомление ───────────────────────────────────────────── */

/* Плашка отложенных над композером: тихая строка, не спорит со статусом. */
.sched-bar {
  padding: 7px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  background: rgba(20, 23, 36, .85);
  color: var(--muted);
  font-size: .78rem;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.sched-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

/* Лимиты подписки: полоса-прогресс на каждое окно. */
.limit-row { margin: 10px 0; }
.limit-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.limit-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}
.limit-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--indigo));
}
.limit-bar span.hot { background: linear-gradient(90deg, var(--amber), var(--rose)); }

/* Медиа проекта: сетка фото и строки файлов/ссылок. */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 6px 0 10px;
}
.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  background: #10131f;
}
.media-row {
  display: block;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.media-row:last-of-type { border-bottom: 0; }

/* Гостевой режим: владельческие элементы скрыты. Это удобство интерфейса —
   настоящая проверка прав на сервере, у каждого маршрута. */
body.guest .owner-only,
body.guest #home-add,
body.guest #home-archive,
body.guest #home-service,
body.guest #home-devices,
body.guest #resume-btn,
body.guest #auth-banner,
body.guest #auth-strip,
body.guest #mode,
body.guest #model-row,
body.guest #rename-input,
body.guest #rename-btn,
body.guest #reset-btn,
body.guest #project-refresh,
body.guest #archive-btn,
body.guest #service-open,
body.guest #remove-btn,
body.guest .zone-label { display: none !important; }

/* Список устройств, которым выдан вход. */
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}
.device {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(20, 23, 36, .7);
}
/* Своё устройство подсвечено: выкидывать его случайно не хочется. */
.device.current { border-color: rgba(60, 230, 200, .45); }
.device-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
  /* Обрезаем контейнером строки, а не самим текстом: самообрезка текстовых
     элементов в WebKit приводит к тому, что текст просто не рисуется. */
  overflow: hidden;
}
.device-info b, .device-info small { white-space: nowrap; }
.device-tag {
  font-size: .68rem;
  font-weight: 400;
  color: #96f0e0;
}
.device-kick { flex: none; }

/* Плёнка «отпустите файл». pointer-events: none обязателен: перехватив
   указатель, она сама же и съела бы событие drop. */
.drop-veil {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 7, 12, .72);
  backdrop-filter: blur(2px);
  pointer-events: none;
  animation: fade-in .12s linear both;
}
.drop-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 420px;
  padding: 28px 34px;
  border-radius: 20px;
  border: 2px dashed rgba(157, 123, 255, .6);
  background: rgba(20, 23, 36, .92);
  text-align: center;
}
.drop-mark {
  font-size: 1.6rem;
  line-height: 1;
  color: var(--violet);
}
.drop-frame small { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  /* Выше композера: подсказка не должна закрывать поле ввода и «Стоп».
     --app-bot — расстояние от низа вёрсточного вьюпорта до низа видимого:
     с открытой клавиатурой без него подсказка ушла бы ей под низ. */
  bottom: calc(var(--app-bot, 0px) + 92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: 88vw;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(30, 34, 52, .98), rgba(14, 16, 26, .98)) padding-box,
    var(--grad-edge) border-box;
  color: var(--text);
  font-size: .88rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
  animation: toast-in .2s var(--ease) both;
}
.toast.bad {
  background:
    linear-gradient(180deg, rgba(52, 20, 28, .98), rgba(30, 13, 18, .98)) padding-box,
    var(--grad-rose) border-box;
  color: #ffd0d7;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Шторки лежат выше экранов. */
.sheet { z-index: 80; }

/* ─── Уважение к настройкам доступности ─────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    /* Задержку тоже снимаем: у переключения экранов на visibility стоит
       отложенный переход, иначе экран появлялся бы с паузой. */
    transition-delay: 0s !important;
    animation-delay: 0s !important;
  }
}

/* Экран «не запустилось». Появляется поверх всего, когда самолечение уже
   пробовали и оно не помогло: белый экран не говорит человеку ничего. */
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #07080c;
  color: #e9e4ff;
  overflow: auto;
}
.boot-error h1 { margin: 0; font-size: 1.3rem; }
