/* ============================================================================
 * Claude Manager — интерфейс. Переписан с нуля 2026-09-05.
 *
 * ПОЧЕМУ С НУЛЯ. Прежний файл рос полтора года и к концу содержал 212
 * селекторов, объявленных больше одного раза: #input-area стилизовался в
 * 25 местах, .bubble — в 14. Предсказать, что делает правило, стало нельзя,
 * и правки «поменяй цвет» не давали эффекта, потому что ниже по файлу их
 * перебивало другое объявление. Здесь каждый селектор встречается один раз,
 * а порядок разделов — от общего к частному.
 *
 * НА ЧЁМ ОСНОВАНО. Числа взяты из первоисточников, а не на глаз:
 *   • Apple HIG (developer.apple.com): кегль 17 pt по умолчанию и 11 pt
 *     минимум; цель нажатия 44x44 pt; свой трекинг на каждый кегль
 *     (на 17 pt это −0.43 pt); Liquid Glass — только слой управления,
 *     «не используйте в слое контента»; шторки с детентами и обязательной
 *     ручкой; вкладки — для мест, а не для режимов.
 *   • WCAG 2.2: 4.5:1 для текста, 3:1 для крупного И ДЛЯ ГРАНИЦ/ЗНАЧКОВ
 *     (1.4.11 — то, чего в HIG нет числом).
 *   • Material 3 (сгенерированные токены Google): шкала отступов «8 для
 *     раскладки, 4 внутри компонента» — у Apple такой шкалы нет вообще;
 *     длительности 200 мс на микро-отклик, 300–400 мс на смену экрана.
 *   • Разбор шести ИИ-чатов и исходников Telegram: ответу модели НИКТО не
 *     даёт пузырь — это документ во всю ширину; межстрочный 1.5–1.55 против
 *     системных 1.29, потому что ответ читают как статью; между ходами
 *     24–32 px, а не 2 px как в мессенджере.
 *
 * ЦВЕТ. Нейтрали холодные, акцент один и тёплый. Это осознанный разворот:
 * прошлая палитра была «тёплый крем + терракота» — самое заезженное
 * сочетание в нынешнем вебе. Терракота на холодном сером читается как
 * выбранный цвет, а не как настройка по умолчанию. Цветом обозначается
 * СМЫСЛ: акцент — там, где говорит Claude и куда жать; всё остальное серое.
 *
 * СТРУКТУРА ФАЙЛА
 *   01 токены · 02 сброс и основа · 03 примитивы
 *   04 каркас экрана · 05 сообщения · 06 живая работа
 *   07 композер · 08 оверлеи · 09 разделы приложения
 *   10 вход и загрузка · 11 движение и доступность
 * ========================================================================= */

/* ============================================================================
 * 01. ТОКЕНЫ
 *
 * Тема берётся из системы — HIG прямо просит «не предлагать настройку
 * внешнего вида внутри приложения». Поэтому в @media переопределяются
 * ТОЛЬКО токены, а компоненты всегда ходят через них: цвет, объявленный
 * внутри media-блока, у пользователя с «системной» темой не применится
 * вовсе и даст текст одной темы на фоне другой.
 * ========================================================================= */

:root {
  color-scheme: light dark;

  /* --- Нейтрали. Холодные, слегка синеватые: чистый серый читается как
     «цвет не выбирали», а тёплый спорил бы с тёплым акцентом. --- */
  --ground: #f1f1f4;          /* фон под всем */
  --surface: #ffffff;         /* карточка, поднятая над фоном */
  --surface-2: #f7f7f9;       /* вложенная секция */
  --surface-3: #e8e8ed;       /* вдавленное: поле ввода, трек шкалы */
  --surface-hi: #ffffff;      /* приподнятое над карточкой (в тёмной ярче) */
  /* Подложка листа/панели. В светлой — фон, карточки на нём белые; в тёмной
     лист сам поднимается над чёрным (--surface), а карточки внутри — ещё
     на ступень выше (--surface-hi). Иначе «всё на одном чёрном». */
  --sheet-bg: var(--ground);

  /* Метки — четыре уровня, как уровни vibrancy в HIG. На белой карточке
     дают 16.1:1, 5.3:1, 3.2:1 и 2.1:1 — третий и четвёртый годятся только
     для неактивного и декоративного, текстом их ставить нельзя. */
  --label: #111114;
  --label-2: #64646e;
  --label-3: #82828d;   /* 3.02:1 на подложке поля ввода */
  --label-4: #b4b4bd;
  --on-accent: #ffffff;

  /* Заливки мелких элементов управления (HIG: fill 1–4). */
  --fill-1: rgba(60, 60, 78, 0.20);
  --fill-2: rgba(60, 60, 78, 0.13);
  --fill-3: rgba(60, 60, 78, 0.08);
  --fill-4: rgba(60, 60, 78, 0.045);

  --separator: rgba(20, 20, 34, 0.10);
  --separator-opaque: #dcdce2;

  /* --- Акцент. Один на всё приложение, тёплый, применяется скупо:
     кнопка отправки, выбранное, ссылки, отметка речи Claude.
     #b8552f даёт 4.62:1 на белом (порог 4.5) и 4.80:1 белым по нему. --- */
  --accent: #b0512d;        /* 4.59:1 на фоне, 5.17:1 на белом */
  --accent-pressed: #93441f;
  --accent-fill: #b8552f;     /* подложка под белой подписью */
  --accent-tint: rgba(176, 81, 45, 0.11);
  --accent-tint-2: rgba(176, 81, 45, 0.05);

  /* --- Семантика. Значения из системной палитры Apple, притемнённые до
     порога контраста на светлой подложке. --- */
  --green: #1f7d35;
  --red: #d70015;
  --red-fill: #d70015;
  --orange: #c93400;
  --yellow: #8f6300;
  --blue: #0071e3;
  --purple: #8944ab;
  --teal: #0071a4;
  --graphite: #64646e;

  /* Поверхности кода тёмные в ОБЕИХ темах и темой не переопределяются:
     подсветка синтаксиса — шесть десятков оттенков, рассчитанных на тёмный
     фон. Раньше .hljs брал цвет ИНТЕРФЕЙСА и в светлой теме давал тёмный
     текст на тёмном блоке. */
  --code-bg: #16161a;
  --code-fg: #d8d8dd;
  --code-line: rgba(255, 255, 255, 0.07);

  /* --- Liquid Glass. Только слой управления: шапка, композер, шторки.
     Карточки, пузыри и строки списков стеклянными НЕ делаются. --- */
  --glass: rgba(241, 241, 244, 0.74);
  --glass-thick: rgba(241, 241, 244, 0.92);
  --glass-filter: saturate(180%) blur(24px);
  --glass-edge: inset 0 0.5px 0 rgba(255, 255, 255, 0.85);
  --glass-hairline: rgba(20, 20, 34, 0.11);

  --scrim: rgba(16, 16, 24, 0.30);

  /* Тени холодные и мягкие. Чистый чёрный под серым фоном даёт грязь. */
  --shadow-1: 0 1px 2px rgba(16, 16, 34, 0.055), 0 0 0 0.5px rgba(16, 16, 34, 0.045);
  --shadow-2: 0 4px 16px rgba(16, 16, 34, 0.09), 0 0 0 0.5px rgba(16, 16, 34, 0.045);
  --shadow-3: 0 18px 48px rgba(16, 16, 34, 0.19), 0 0 0 0.5px rgba(16, 16, 34, 0.055);

  /* --- Радиусы. Шкала Material (4/8/12/16/28) — у Apple чисел нет, только
     принцип «радиус вложенного согласован с контейнером». --- */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-sheet: 28px;
  --r-pill: 999px;

  /* --- Отступы. 8 — между блоками, 4 — внутри компонента. --- */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --gutter: 16px;             /* поле от края экрана */
  --tap: 44px;                /* цель нажатия: Apple 44 pt = WCAG AAA */

  /* --- Типографика. Лесенка Dynamic Type; трекинг — таблица Apple,
     переведённая из пунктов в em. Шрифт системный: на iPhone это SF Pro,
     ничего не качается, и текст выглядит ровно как в остальной системе. --- */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
          'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono',
               'Consolas', monospace;

  --t-large-title: 34px; --lh-large-title: 41px; --tr-large-title: 0.012em;
  --t-title-1: 28px;     --lh-title-1: 34px;     --tr-title-1: 0.013em;
  --t-title-2: 22px;     --lh-title-2: 28px;     --tr-title-2: -0.012em;
  --t-title-3: 20px;     --lh-title-3: 25px;     --tr-title-3: -0.023em;
  --t-headline: 17px;    --lh-headline: 22px;    --tr-headline: -0.025em;
  --t-body: 17px;        --lh-body: 22px;        --tr-body: -0.025em;
  --t-callout: 16px;     --lh-callout: 21px;     --tr-callout: -0.019em;
  --t-subhead: 15px;     --lh-subhead: 20px;     --tr-subhead: -0.015em;
  --t-footnote: 13px;    --lh-footnote: 18px;    --tr-footnote: -0.006em;
  --t-caption: 12px;     --lh-caption: 16px;     --tr-caption: 0em;
  --t-caption-2: 11px;   --lh-caption-2: 14px;   --tr-caption-2: 0.005em;

  /* Ответ модели читают как статью, а не как реплику: 1.55 против системных
     1.29. Это то, что физически отличает чат с ИИ от мессенджера. */
  --lh-prose: 1.55;

  /* --- Движение. 200 мс на отклик, 320 мс на смену экрана; кривая из
     токенов Material — у Apple опубликованных длительностей нет. --- */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0, 0, 0, 1);
  --d-fast: 200ms;
  --d-mid: 320ms;

  /* Безопасные поля. Задаются здесь, чтобы стенд мог их подменить: в
     headless-браузере env() всегда 0, и ошибки с вырезом иначе не видны. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --keyboard-h: 0px;

  --header-h: 48px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #000000;        /* чистый чёрный: на OLED-экране iPhone он
                                 гасит пиксели, а не подсвечивает их серым */
    --surface: #131316;
    --surface-2: #1b1b1f;
    --surface-3: #26262b;
    --surface-hi: #26262b;
    --sheet-bg: var(--surface);

    --label: #f5f5f7;
    --label-2: #a0a0aa;
    --label-3: #74747e;
    --label-4: #4c4c55;

    --fill-1: rgba(142, 142, 160, 0.32);
    --fill-2: rgba(142, 142, 160, 0.22);
    --fill-3: rgba(142, 142, 160, 0.15);
    --fill-4: rgba(142, 142, 160, 0.09);

    --separator: rgba(255, 255, 255, 0.13);
    --separator-opaque: #35353c;

    /* В тёмной теме акцент обязан быть СВЕТЛЫМ (он работает текстом), а
       подложка под белой подписью — тёмной. Один цвет обе роли не тянет. */
    --accent: #ff9a72;
    --accent-pressed: #ffb094;
    --accent-fill: #b8552f;
    --accent-tint: rgba(255, 154, 114, 0.15);
    --accent-tint-2: rgba(255, 154, 114, 0.07);

    --green: #3ad964;
    --red: #ff6961;
    --red-fill: #c9302c;
    --orange: #ff9f0a;
    --yellow: #ffd426;
    --blue: #64a8ff;
    --purple: #d09aeb;
    --teal: #5ac8e8;
    --graphite: #a0a0aa;

    --glass: rgba(22, 22, 26, 0.72);
    --glass-thick: rgba(22, 22, 26, 0.92);
    --glass-edge: inset 0 0.5px 0 rgba(255, 255, 255, 0.10);
    --glass-hairline: rgba(255, 255, 255, 0.12);

    --scrim: rgba(0, 0, 0, 0.55);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.55);
    --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.7);
  }
}

/* Тот же набор — принудительно. Нужен для стенда и для проверки контраста:
   headless-браузер темы не имеет, а атрибут понимает. Значения обязаны
   совпадать с блоком выше; за этим следит bin/test-design.js. */
:root[data-theme="dark"] {
  --ground: #000000;
  --surface: #131316;
  --surface-2: #1b1b1f;
  --surface-3: #26262b;
  --surface-hi: #26262b;
  --sheet-bg: var(--surface);
  --label: #f5f5f7;
  --label-2: #a0a0aa;
  --label-3: #74747e;
  --label-4: #4c4c55;
  --fill-1: rgba(142, 142, 160, 0.32);
  --fill-2: rgba(142, 142, 160, 0.22);
  --fill-3: rgba(142, 142, 160, 0.15);
  --fill-4: rgba(142, 142, 160, 0.09);
  --separator: rgba(255, 255, 255, 0.13);
  --separator-opaque: #35353c;
  --accent: #ff9a72;
  --accent-pressed: #ffb094;
  --accent-fill: #b8552f;
  --accent-tint: rgba(255, 154, 114, 0.15);
  --accent-tint-2: rgba(255, 154, 114, 0.07);
  --green: #3ad964;
  --red: #ff6961;
  --red-fill: #c9302c;
  --orange: #ff9f0a;
  --yellow: #ffd426;
  --blue: #64a8ff;
  --purple: #d09aeb;
  --teal: #5ac8e8;
  --graphite: #a0a0aa;
  --glass: rgba(22, 22, 26, 0.72);
  --glass-thick: rgba(22, 22, 26, 0.92);
  --glass-edge: inset 0 0.5px 0 rgba(255, 255, 255, 0.10);
  --glass-hairline: rgba(255, 255, 255, 0.12);
  --scrim: rgba(0, 0, 0, 0.55);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.7);
}

/* Псевдонимы старых имён. Шесть тысяч строк прежней вёрстки и генерируемая
   в app.js разметка обращаются к ним; держим их отдельным блоком, чтобы
   новые правила ниже пользовались только новыми именами.
   Роль сверяется по УПОТРЕБЛЕНИЮ, а не по названию: --text-muted звучит как
   «приглушённый», но им набраны подписи под заголовками — значит это
   --label-2 (4.5:1), а не цвет плейсхолдера (3.2:1). */
:root {
  --bg: var(--ground);
  --bg-panel: var(--surface);
  --bg-elevated: var(--surface-2);
  --bg-input: var(--surface-3);
  --bg-modal: var(--scrim);
  --bg-hover: var(--fill-4);
  --text: var(--label);
  --text-primary: var(--label);
  --text-secondary: var(--label-2);
  --text-muted: var(--label-2);
  --text-faint: var(--label-3);
  --text-dim: var(--label-3);
  --border: var(--separator);
  --border-strong: var(--separator-opaque);
  --accent-hover: var(--accent-pressed);
  --accent-dim: var(--accent-tint);
  --accent-glow: var(--accent-tint-2);
  --danger: var(--red);
  --success: var(--green);
  --warning: var(--orange);
  --radius: var(--r-md);
  --radius-sm: var(--r-sm);
  --radius-lg: var(--r-lg);
  --shadow: var(--shadow-1);
  --shadow-sm: var(--shadow-1);
  --shadow-lg: var(--shadow-3);
  --font-sans: var(--font);
  --panel-bg: var(--surface);
  --code-color: var(--code-fg);
  --tile-blue: var(--blue);
  --tile-purple: var(--purple);
  --tile-orange: var(--orange);
  --tile-green: var(--green);
  --tile-yellow: var(--yellow);
  --tile-teal: var(--teal);
  --tile-accent: var(--accent);
  --tile-graphite: var(--graphite);
}

/* ============================================================================
 * 02. СБРОС И ОСНОВА
 * ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--label);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Резинка на уровне страницы утаскивала бы весь интерфейс: прокрутка
     живёт внутри областей, а не у документа. */
  overscroll-behavior: none;
  overflow: hidden;
}

h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

button, input, textarea, select {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg, video { display: block; max-width: 100%; }
svg { flex: none; }

::selection { background: var(--accent-tint); }

/* Фокус виден всегда, но только с клавиатуры: на телефоне кольцо вокруг
   каждой нажатой кнопки выглядит поломкой. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  /* Радиуса тут нет намеренно: общий border-radius ломал круглые кнопки,
     кольцо повторяет форму самого элемента. */
}
/* У полей своё кольцо — внутренняя рамка (см. input:focus ниже);
   наружное поверх неё — двойная рамка. */
input:focus-visible, textarea:focus-visible, select:focus-visible,
.form-input:focus-visible { outline: none; }

/* Полосы прокрутки. На iOS их нет вовсе, на компьютере делаем тонкими,
   чтобы они не спорили с содержимым. */
* { scrollbar-width: thin; scrollbar-color: var(--fill-1) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--fill-1);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

.muted { color: var(--label-2); }
.text-muted-inline { color: var(--label-2); }
.text-danger, .danger, .err { color: var(--red); }
.text-success, .ok { color: var(--green); }
.sm { font-size: var(--t-footnote); line-height: var(--lh-footnote); }

/* ============================================================================
 * 03. ПРИМИТИВЫ
 *
 * Всё приложение собрано из этих деталей. Динамические панели (git,
 * терминал, поиск) строятся кодом из тех же классов — поэтому правило,
 * написанное здесь один раз, красит и то, чего нет в разметке.
 * ========================================================================= */

/* --- Кнопки ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  background: var(--fill-3);
  color: var(--label);
  font-size: var(--t-callout);
  line-height: var(--lh-callout);
  letter-spacing: var(--tr-callout);
  font-weight: 590;
  white-space: nowrap;
  transition: background var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-pressed); }

.btn-secondary { background: var(--fill-3); color: var(--label); }

.btn-ghost {
  /* surface-hi, а не surface: в тёмной теме лист и есть surface, и кнопка
     на нём сливалась с фоном — оставалась одна тонкая обводка. */
  background: var(--surface-hi);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.btn-ghost:active { background: var(--fill-4); }

.btn-danger { background: var(--red-fill); color: #ffffff; }
.btn-ghost.btn-destructive { color: var(--red); }

.btn-sm {
  /* Не 36: «мелкая» кнопка — про плотность рисунка, а не про размер цели.
     Палец промахивается одинаково по любой. */
  min-height: var(--tap);
  padding: 0 var(--s3);
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  letter-spacing: var(--tr-subhead);
}
.btn-lg { min-height: 50px; font-size: var(--t-headline); }
.btn-full { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }

.btn-text { display: inline-flex; align-items: center; gap: var(--s2); }

/* Кружок-загрузка внутри кнопки. Размер привязан к кеглю, чтобы не
   разъезжаться при увеличенном системном шрифте. */
.btn-loader {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.7;
  animation: cm-spin 700ms linear infinite;
}

@keyframes cm-spin { to { transform: rotate(360deg); } }

/* Круглая кнопка со значком. 44x44 — минимум Apple и WCAG AAA;
   раньше такие кнопки были 38x38 и мимо них промахивались. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border-radius: var(--r-pill);
  color: var(--label);
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.icon-btn:active { background: var(--fill-3); }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }

/* --- Поля ввода --------------------------------------------------------- */

input[type="text"], input[type="password"], input[type="search"],
input[type="number"], input[type="datetime-local"], select, textarea,
.form-input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s3) var(--s4);
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--label);
  /* 17 px — не эстетика: Safari принудительно зумит страницу при фокусе
     на поле мельче 16 px, и после ввода экран остаётся увеличенным. */
  font-size: var(--t-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
  appearance: none;
  -webkit-appearance: none;
  transition: box-shadow var(--d-fast) var(--ease);
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--label-3); }
input:focus, textarea:focus, select:focus, .form-input:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

select {
  padding-right: var(--s8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-group { display: flex; flex-direction: column; gap: var(--s2); }
.input-group label {
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 590;
  color: var(--label-2);
}

/* Галочка. Родная слишком мелкая (18x18 при минимуме 44), поэтому рисуем
   свою и расширяем зону нажатия до всей строки. */
.remember-row, .pc-sessions-filter, .agents-check, .council-check,
.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--tap);
  cursor: pointer;
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  letter-spacing: var(--tr-subhead);
  color: var(--label);
}
.remember-row input[type="checkbox"],
.pc-sessions-filter input[type="checkbox"],
.agents-check input[type="checkbox"],
.council-check input[type="checkbox"],
.remember-check {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--separator);
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  transition: background var(--d-fast) var(--ease);
}
.remember-row input[type="checkbox"]:checked,
.pc-sessions-filter input[type="checkbox"]:checked,
.agents-check input[type="checkbox"]:checked,
.council-check input[type="checkbox"]:checked,
.remember-check:checked {
  background: var(--accent-fill);
  box-shadow: none;
}
.remember-row input[type="checkbox"]:checked::after,
.pc-sessions-filter input[type="checkbox"]:checked::after,
.agents-check input[type="checkbox"]:checked::after,
.council-check input[type="checkbox"]:checked::after,
.remember-check:checked::after {
  content: '';
  position: absolute;
  left: 7px; top: 3px;
  width: 6px; height: 11px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* --- Чипы и бейджи ------------------------------------------------------ */

.chip, .ws-chip, .caps-chip, .diff-chip, .pc-tag, .saved-mode-chip,
.upd-ver-tag, .agent-meta-pill, .diff-badge, .upd-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 3px var(--s2);
  border-radius: var(--r-sm);
  background: var(--fill-3);
  color: var(--label-2);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  font-weight: 590;
  white-space: nowrap;
}
/* Чип, который можно нажать, обязан быть целью нажатия. */
button.ws-chip, button.chip, button.caps-chip {
  min-height: 34px;
  padding: 0 var(--s3);
  color: var(--label);
}
button.ws-chip:active { background: var(--fill-2); }

/* --- Строка списка ------------------------------------------------------ */
/* Один рисунок строки на всё приложение: значок, текст с подписью, шеврон.
   Раньше каждая панель рисовала свою — оттого приложение и выглядело
   собранным из разных программ. */

.row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 52px;
  padding: var(--s2) var(--s4);
  background: var(--surface);
  color: var(--label);
  text-align: left;
  transition: background var(--d-fast) var(--ease);
}
.row:active { background: var(--fill-4); }
.row-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--label-2);
}
.row-ico svg { width: 21px; height: 21px; }
.row-text { flex: 1; min-width: 0; }
.row-title {
  display: block;
  font-size: var(--t-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  display: block;
  margin-top: 1px;
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  letter-spacing: var(--tr-footnote);
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-chev {
  flex: none;
  color: var(--label-3);
  font-size: 19px;
  line-height: 1;
}

/* Группа строк — карточка со скруглением по краям стопки. */
.group {
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.group > .row + .row { box-shadow: inset 0 0.5px 0 var(--separator); }

.group-label {
  padding: var(--s5) var(--s4) var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 590;
  color: var(--label-2);
}

/* --- Пустое состояние --------------------------------------------------- */

.empty-msg, .ws-empty, .caps-empty, .council-empty, .files-empty,
.rl-empty, .tool-panel-empty, .files-loading, .detected-loading {
  padding: var(--s8) var(--s5);
  text-align: center;
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  color: var(--label-2);
}

.empty-msg > svg {
  display: block;
  margin: 0 auto var(--s3);
  color: var(--label-3);
}

.settings-usage .empty-msg, .settings-account-summary .empty-msg { padding: var(--s4) 0; }
.empty-sub {
  display: block;
  margin-top: var(--s1);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-3);
}

.error-msg, .files-error {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red);
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
}

/* --- Полоса заполнения -------------------------------------------------- */

.bar-track, .usage-quota-bar, .rl-bar, .compact-progress-bar,
.boot-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--fill-2);
  overflow: hidden;
}
/* (.context-bar — в разделе «Этот диалог»: у неё сегменты, а не заливка.) */
.bar-fill, .usage-quota-bar-fill, .rl-bar-fill,
.compact-progress-bar-fill, .boot-bar-fill {
  width: 0;                 /* без данных полоса пуста, а не залита целиком */
  height: 100%;
  border-radius: inherit;
  background: var(--accent-fill);
  transition: width var(--d-mid) var(--ease);
}
/* ============================================================================
 * 04. КАРКАС ЭКРАНА
 * ========================================================================= */

/* Высоту НЕ задаём. `position: fixed; inset: 0` и так равен экрану, а любое
   `height` перебивает `bottom` и однажды уже схлопнуло приложение в ноль —
   человек три раза подряд видел пустоту и писал «опять не грузит». */
#app {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- Шапка --------------------------------------------------------------
 * Три элемента управления, каждый ведёт в СВОЁ место и больше никуда:
 * слева диалоги, по центру — состояние этого разговора, справа мастерская.
 * Прежняя шапка держала пять кнопок (176 pt из 390 — почти половина ширины
 * телефона), и три из них дублировались строками меню. */

#header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s1);
  flex: none;
  padding: var(--safe-top) var(--s2) 0;
  height: calc(var(--header-h) + var(--safe-top));
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-edge), 0 0.5px 0 var(--glass-hairline);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--s1);
  margin-left: auto;
}

/* Заголовок — кнопка. Показывает, С КЕМ и В КАКОМ состоянии разговор:
   название, кольцо занятости контекста и строка связи. Всё, что относится
   к этому диалогу, открывается отсюда — и больше ниоткуда. */
.header-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: 1;
  min-width: 0;
  height: var(--tap);
  padding: 0 var(--s2);
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--d-fast) var(--ease);
}
.header-title:active { background: var(--fill-4); }

.header-title-text { flex: 1; min-width: 0; }

#chat-title {
  display: block;
  font-size: var(--t-headline);
  line-height: 20px;
  letter-spacing: var(--tr-headline);
  font-weight: 640;
  color: var(--label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Подпись под названием: модель и связь. Раньше setConnectionUI() писала
   в элементы, которых в разметке не было, — состояние связи не показывалось
   вообще, и обрыв туннеля выглядел как «приложение задумалось». */
.header-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-caption-2);
  line-height: var(--lh-caption-2);
  letter-spacing: var(--tr-caption-2);
  color: var(--label-2);
  overflow: hidden;
  white-space: nowrap;
}
#connection-label { overflow: hidden; text-overflow: ellipsis; }
#connection-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--label-3);
}
/* setConnectionUI вешает dot-green/dot-yellow/dot-red; id-селектор перебивал
   .status-dot.dot-* и точка всегда оставалась серой (2026-09-06). */
#connection-dot.live, #connection-dot.ok, #connection-dot.dot-green { background: var(--green); }
#connection-dot.err, #connection-dot.off, #connection-dot.dot-red { background: var(--red); }
#connection-dot.warn, #connection-dot.dot-yellow { background: var(--orange); }

/* Кольцо контекста. Не отдельная кнопка, а показание внутри заголовка:
   раньше это был пятый элемент управления в шапке, который дублировался
   ещё и строкой меню. */
.context-indicator {
  width: 26px;
  height: 26px;
  flex: none;
  pointer-events: none;
}
.context-indicator svg { width: 26px; height: 26px; }
#context-indicator-text { font-size: 7.5px; }

.chatgpt-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  margin-left: var(--s1);
  border-radius: var(--r-xs);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.chatgpt-icon { width: 12px; height: 12px; }

/* --- Область переписки --------------------------------------------------
 * Прокрутка живёт ИМЕННО ЗДЕСЬ. Однажды я перенёс её на внутренний
 * контейнер, а обработчик остался на #chat-area — и разом отвалились
 * кнопка «вниз» и автоподгрузка старых сообщений. */

#chat-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

#messages-container {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: var(--s4) var(--gutter) var(--s6);
}

/* Кнопка «к последнему сообщению». Появляется, только когда переписка
   отмотана вверх, и висит над композером, а не над текстом. */
.scroll-to-bottom-btn {
  position: absolute;
  left: 50%;
  bottom: var(--s3);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  border-radius: 50%;
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  color: var(--label);
  box-shadow: var(--shadow-2);
  animation: cm-rise var(--d-fast) var(--ease);
}
.scroll-to-bottom-btn:active { transform: scale(0.94); }

@keyframes cm-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Приветствие на пустом экране. HIG про генеративные интерфейсы просит
   давать подсказки для начала, а не пустоту с курсором. */
.welcome-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--s3);
  padding: var(--s10) var(--s5);
  text-align: center;
}
.welcome-icon { margin-bottom: var(--s1); opacity: 0.95; }
.welcome-title {
  font-size: var(--t-title-2);
  line-height: var(--lh-title-2);
  letter-spacing: var(--tr-title-2);
  font-weight: 680;
  color: var(--label);
}
.welcome-subtitle {
  max-width: 30ch;
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  letter-spacing: var(--tr-subhead);
  color: var(--label-2);
}

/* ============================================================================
 * 05. СООБЩЕНИЯ
 *
 * Главное решение раздела: ОТВЕТУ МОДЕЛИ НЕ ДАЁТСЯ ПУЗЫРЬ. Из шести
 * разобранных ИИ-чатов (ChatGPT, Claude, Gemini, Perplexity, Grok, Copilot)
 * контейнер ассистенту рисует только один. Причина не эстетическая:
 * ответ содержит заголовки, списки, таблицы, код и вывод терминала — это
 * документ, а не реплика. Рамка вокруг документа делает его теснее и мешает
 * читать. Пузырь остаётся у пользователя: короткая фраза, справа, до 80%.
 * ========================================================================= */

.message {
  display: flex;
  flex-direction: column;
  /* 28 px между ходами. В мессенджере это 2–3 px, потому что там ценность
     в числе видимых реплик; здесь на экран помещается один-два хода, и
     воздух между ними — единственное, что их разделяет. */
  margin-bottom: var(--s8);
  animation: cm-msg-in var(--d-fast) var(--ease-out);
}
.message:last-child { margin-bottom: 0; }

@keyframes cm-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.message-user { align-items: flex-end; }
.message-claude, .message-system, .message-codex { align-items: stretch; }

/* Пузырь пользователя. Нейтральный, не акцентный: терракота в этом
   интерфейсе означает «говорит Claude» и «сюда жать» — если ею залить
   каждую свою реплику, значение цвета теряется, а лента начинает кричать. */
.message-user .bubble {
  max-width: 80%;
  padding: 10px var(--s4);
  border-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--label);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
  overflow-wrap: anywhere;
}

/* Ответ модели: во всю ширину, без подложки, с увеличенным межстрочным. */
.message-claude .bubble {
  max-width: 100%;
  font-size: var(--t-body);
  line-height: var(--lh-prose);
  letter-spacing: var(--tr-body);
  color: var(--label);
  overflow-wrap: anywhere;
}

/* Отметка речи Claude — единственное, что заменяет пузырь. Тонкая полоска
   акцентного цвета слева: даёт край, за который цепляется глаз, и не
   отнимает ширину у текста. */
.message-claude > .bubble::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.55;
}
.message-claude > .bubble {
  position: relative;
  padding-left: var(--s3);
}

.message-system {
  align-items: center;
  margin-bottom: var(--s5);
}
.message-system .bubble {
  max-width: 90%;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: var(--fill-4);
  color: var(--label-2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  text-align: center;
}

.bubble-error {
  padding: var(--s3) var(--s4) !important;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--red) 12%, transparent) !important;
  color: var(--red) !important;
}
.bubble-error::before { display: none !important; }
.error-actions { display: flex; gap: var(--s2); margin-top: var(--s3); }
.retry-btn {
  min-height: 36px;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  background: var(--fill-3);
  color: var(--label);
  font-size: var(--t-subhead);
  font-weight: 590;
}

/* Строка действий под сообщением. Все шесть разобранных приложений держат
   её именно здесь; и все шесть нарушают в ней минимум 44 px — у нас она
   44 px, потому что пальцем в 32 px не попадают. */
.copy-btn-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s2);
  min-height: var(--tap);
}
/* У своего пузыря строка действий прижата к правому нижнему углу: кнопки
   44 px с внутренним полем визуально «висели» на отступе пузыря. */
.message-user .copy-btn-row {
  justify-content: flex-end;
  margin: 0 calc(-1 * var(--s2)) calc(-1 * var(--s1)) 0;
}
.msg-time {
  font-size: var(--t-caption-2);
  line-height: var(--lh-caption-2);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.msg-ack { display: inline-flex; align-items: center; font-size: var(--t-caption-2); color: var(--label-2); }
.ack-pending { opacity: 0.7; }

.copy-prompt-btn, .copy-claude-btn, .rollback-msg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  color: var(--label-2);
  font-size: var(--t-caption);
  transition: color var(--d-fast) var(--ease), background var(--d-fast) var(--ease);
}
.copy-prompt-btn:active, .copy-claude-btn:active, .rollback-msg-btn:active {
  background: var(--fill-3);
  color: var(--label);
}
.copy-prompt-btn svg, .copy-claude-btn svg { width: 16px; height: 16px; }

/* Метки на сообщении. */
.btw-tag, .followup-tag {
  display: inline-flex;
  align-items: center;
  margin-right: var(--s2);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 590;
  vertical-align: middle;
}
.user-followup-text { opacity: 0.9; }

.message-attachments { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.attach-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  background: var(--fill-3);
  color: var(--label-2);
  font-size: var(--t-caption);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-tag.clickable { color: var(--accent); cursor: pointer; }

/* Разделитель дат — как в мессенджере: липкая капсула по центру. */
.date-divider {
  position: sticky;
  top: var(--s2);
  z-index: 2;
  align-self: center;
  margin: var(--s2) 0 var(--s5);
  padding: 4px var(--s3);
  border-radius: var(--r-pill);
  /* Непрозрачная: чип липкий и едет поверх текста — сквозь стекло
     просвечивали буквы. */
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--separator), 0 1px 3px rgba(0, 0, 0, 0.06);
  color: var(--label-2);
  font-size: var(--t-caption);
  font-weight: 590;
}

.interrupted-banner, .btw-banner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: var(--s2) 0 var(--s5);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: var(--fill-4);
  color: var(--label-2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
}

/* Подгрузка истории. Кнопок «показать ещё» здесь нет намеренно: листаешь
   вверх — старое подгружается само, как в любом мессенджере. Полоска
   только сообщает, сколько осталось. */
#history-more, .load-prev-segment-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s3) 0 var(--s5);
  color: var(--label-3);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
}
.history-more-loading { opacity: 0.6; }
.load-prev-segment-btn {
  min-height: 36px;
  padding: 0 var(--s4);
  border-radius: var(--r-pill);
  background: var(--fill-3);
  color: var(--label);
  font-size: var(--t-footnote);
  font-weight: 590;
}

/* ============================================================================
 * 05a. РАЗМЕТКА ВНУТРИ ОТВЕТА (markdown)
 *
 * Ответ — документ, поэтому у него настоящая типографическая иерархия:
 * заголовки, списки, таблицы, цитаты. Кегли согласованы с лесенкой iOS.
 * ========================================================================= */

.message-claude .bubble > *:first-child { margin-top: 0; }
.message-claude .bubble > *:last-child { margin-bottom: 0; }

.message-claude h1, .message-claude h2, .message-claude h3,
.message-claude h4, .message-claude h5 {
  margin: var(--s5) 0 var(--s2);
  font-weight: 680;
  letter-spacing: var(--tr-title-3);
  line-height: 1.3;
}
.message-claude h1 { font-size: var(--t-title-2); }
.message-claude h2 { font-size: var(--t-title-3); }
.message-claude h3 { font-size: var(--t-headline); }
.message-claude h4, .message-claude h5 {
  font-size: var(--t-callout);
  color: var(--label-2);
}

.message-claude p { margin: 0 0 var(--s3); }
.message-claude p:last-child { margin-bottom: 0; }

.md-ul, .md-ol, .message-claude ul, .message-claude ol {
  margin: 0 0 var(--s3);
  padding-left: var(--s5);
}
.md-ul, .message-claude ul { list-style: disc; }
.md-ol, .message-claude ol { list-style: decimal; }
.message-claude li { margin-bottom: var(--s1); }
.message-claude li::marker { color: var(--label-3); }

.message-claude blockquote {
  margin: 0 0 var(--s3);
  padding: var(--s1) 0 var(--s1) var(--s3);
  border-left: 2px solid var(--separator-opaque);
  color: var(--label-2);
}

.message-claude hr {
  height: 0;
  margin: var(--s5) 0;
  border: 0;
  border-top: 1px solid var(--separator);
}

.message-claude strong { font-weight: 640; }

/* Таблица. Шире экрана — прокручивается сама, а не растягивает страницу. */
.md-table-wrap {
  margin: 0 0 var(--s3);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  font-variant-numeric: tabular-nums;
}
.md-table th, .md-table td {
  padding: var(--s2) var(--s3);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--separator);
}
.md-table th {
  background: var(--fill-4);
  font-weight: 640;
  color: var(--label-2);
}
.md-table tr:last-child td { border-bottom: 0; }

/* --- Код --------------------------------------------------------------- */

.message-claude code, .command-display, code {
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.message-claude :not(pre) > code {
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--fill-3);
  color: var(--label);
  overflow-wrap: anywhere;
}

.message-claude pre, .codex-body pre {
  margin: 0 0 var(--s3);
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  line-height: 1.5;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  tab-size: 2;
}
.message-claude pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

/* Подсветка синтаксиса. Собственная палитра под тёмный блок — цвета
   интерфейса тут не годятся ни в одной теме. */
.hljs { color: var(--code-fg); background: transparent; }
.hljs-comment, .hljs-quote { color: #7b7f8b; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #ff9a72; }
.hljs-string, .hljs-attr, .hljs-addition { color: #9ad88f; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #e8c07d; }
.hljs-title, .hljs-name, .hljs-section, .hljs-function { color: #82b7ff; }
.hljs-variable, .hljs-template-variable, .hljs-attribute { color: #d9b3ff; }
.hljs-built_in, .hljs-class { color: #6ed0e0; }
.hljs-deletion { color: #ff8b83; }
.hljs-meta { color: #8e8e99; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* --- Диффы -------------------------------------------------------------- */

.diff-block, .diff-body {
  border-radius: var(--r-md);
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  line-height: 1.55;
  overflow: hidden;
}
.diff-file-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: rgba(255, 255, 255, 0.05);
  color: #c9c9d2;
  font-size: var(--t-caption);
}
.diff-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.diff-file-stat { color: #8e8e99; font-variant-numeric: tabular-nums; }
.diff-hunk-head {
  padding: 2px var(--s3);
  background: rgba(130, 183, 255, 0.10);
  color: #82b7ff;
}
.diff-row, .diff-line {
  display: flex;
  padding-right: var(--s2);
  white-space: pre;
}
.diff-ln {
  flex: none;
  width: 42px;
  padding: 0 var(--s2) 0 0;
  text-align: right;
  color: #6a6a76;
  user-select: none;
  font-variant-numeric: tabular-nums;
}
.diff-sign { flex: none; width: 12px; text-align: center; opacity: 0.75; }
.diff-code { flex: 1; min-width: 0; overflow-x: auto; }
.diff-add, .diff-line.diff-add { background: rgba(63, 185, 80, 0.16); }
.diff-rem, .diff-del, .diff-line.diff-rem { background: rgba(248, 81, 73, 0.16); }
.diff-ctx { color: #b0b0ba; }
.diff-gap {
  padding: 2px var(--s3);
  background: rgba(255, 255, 255, 0.03);
  color: #6a6a76;
  text-align: center;
}
.diff-binary { padding: var(--s3); color: #8e8e99; }
.diff-tray { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s2) var(--s3); }
.diff-stage { display: flex; gap: var(--s2); }
.dw .diff-code, .diff-body.wrap .diff-code { white-space: pre-wrap; overflow-wrap: anywhere; }
/* ============================================================================
 * 06. ЖИВАЯ РАБОТА
 *
 * Пока Claude работает, в ленте растёт блок: мысли, вызовы инструментов,
 * вывод терминала, план, счётчики. Это самое информативное место
 * приложения и самое легко превращаемое в кашу. Правило раздела: всё,
 * что не является результатом, набирается на тон тише основного текста и
 * прижимается к левому краю единой лесенкой, чтобы взгляд шёл по одной
 * вертикали, а не прыгал по карточкам.
 * ========================================================================= */

.live-terminal, .terminal-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s2);
  margin: var(--s2) 0 0;
  padding-left: var(--s3);
  border-left: 2px solid var(--separator);
  min-width: 0;
  /* Всё, что сюда попадает (команды, пути, рассуждения), обязано
     переноситься: горизонтальной прокрутки на телефоне быть не должно. */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-claude .live-terminal { margin-top: var(--s3); }
/* История: тот же вид, но с ограничением высоты и собственной прокруткой. */
.terminal-expandable .terminal-block, .agent-terminal {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Сохранённые рассуждения (сервер пишет их в вывод как есть) и текст
   Claude между вызовами инструментов. Это прозаические абзацы, поэтому
   шрифт — обычный, перенос — как в тексте с сохранением строк. */
.thinking-block, .claude-narration {
  font-family: var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.thinking-block {
  padding: var(--s1) var(--s3);
  border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--label-2);
  font-size: var(--t-footnote);
  font-style: italic;
}
.terminal-duration {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding-top: var(--s2);
  box-shadow: inset 0 0.5px 0 var(--separator);
  color: var(--green);
  font-size: var(--t-caption);
  font-variant-numeric: tabular-nums;
}
/* Галочка вместо глифа «⏱»: строку собирает и сервер, и клиент — иконка
   рисуется маской из CSS, чтобы разметку не трогать. */
.terminal-duration::before {
  content: '';
  flex: none;
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}
.interrupted-banner svg { flex: none; color: var(--orange); }

/* Строка состояния: чем занят и сколько потрачено. */
.cli-status-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
}
.status-activity { display: inline-flex; align-items: center; gap: 6px; }
.status-tokens, .tok-ctx, .tok-spend {
  font-variant-numeric: tabular-nums;
  color: var(--label-2);
}
.live-elapsed-badge {
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-3);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-variant-numeric: tabular-nums;
}
.status-dot-live {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: cm-pulse 1.6s var(--ease) infinite;
}
@keyframes cm-pulse { 50% { opacity: 0.35; } }

/* Пульсирующие точки «идёт работа». */
.working-indicator {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.working-indicator span,
.council-dots span, .codex-spinner span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: cm-bounce 1.2s var(--ease) infinite;
}
.working-indicator span:nth-child(2),
.council-dots span:nth-child(2), .codex-spinner span:nth-child(2) { animation-delay: 0.15s; }
.working-indicator span:nth-child(3),
.council-dots span:nth-child(3), .codex-spinner span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cm-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.council-dots, .codex-spinner { display: inline-flex; gap: 3px; align-items: center; }

.claude-narration {
  padding: var(--s1) var(--s3);
  border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--label);
  font-size: var(--t-subhead);
}

/* --- Размышления -------------------------------------------------------- */

.thinking-stream {
  border-radius: var(--r-md);
  background: var(--fill-4);
  overflow: hidden;
}
.thinking-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 38px;
  padding: 0 var(--s3);
  color: var(--label-2);
  font-size: var(--t-footnote);
  font-weight: 590;
}
.thinking-content {
  padding: 0 var(--s3) var(--s3);
  color: var(--label-2);
  font-size: var(--t-footnote);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Вызовы инструментов ------------------------------------------------ */

.tool-use-line {
  border-radius: var(--r-md);
  background: var(--fill-4);
  overflow: hidden;
}
.tool-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: 38px;
  padding: var(--s1) var(--s3);
  text-align: left;
  color: var(--label-2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
}
.tool-badge {
  flex: none;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tool-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--label-2);
}
.tool-expand-arrow {
  display: inline-flex;
  flex: none;
  color: var(--label-2);
  transition: transform var(--d-fast) var(--ease);
}
.tool-use-line.expanded .tool-expand-arrow { transform: rotate(90deg); }

.tool-expanded-panel {
  padding: 0 var(--s3) var(--s3);
  font-size: var(--t-caption);
  line-height: 1.5;
}
.tool-panel-empty { padding: var(--s3); }

/* Разбор параметров вызова: путь, команда, флаги. */
.tp-label, .tp-desc {
  color: var(--label-3);
  font-size: var(--t-caption-2);
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tp-path, .tp-cmd, .tp-out {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}
.tp-path { color: var(--label-2); }
.tp-cmd { color: var(--label); }
.tp-flag { color: var(--accent); }
.tp-meta { color: var(--label-3); font-size: var(--t-caption-2); }
.tp-pending { color: var(--label-3); font-style: italic; }
.command-display {
  display: block;
  padding: var(--s2);
  border-radius: var(--r-sm);
  background: var(--code-bg);
  color: var(--code-fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal-expandable { display: none; }
.terminal-expandable.expanded { display: block; margin-top: var(--s2); }
.toggle-output {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: var(--tap);
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  color: var(--label-2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 590;
}
.toggle-output:active { background: var(--fill-3); }

/* --- План работ --------------------------------------------------------- */

.todo-list-sticky {
  position: sticky;
  top: var(--s2);
  z-index: 3;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-1);
}
.todo-header {
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--s1);
}
.todo-list-sticky li, .todo-text {
  display: flex;
  gap: var(--s2);
  font-size: var(--t-footnote);
  line-height: 1.5;
  color: var(--label-2);
}
.todo-mark { flex: none; width: 14px; color: var(--label-3); }
.todo-list-sticky .live .todo-text, .todo-text.live { color: var(--label); font-weight: 590; }

/* --- Суб-агенты --------------------------------------------------------- */

.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 38px;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  background: var(--fill-3);
  color: var(--label);
  font-size: var(--t-footnote);
  font-weight: 590;
}
.agent-badge.running { box-shadow: inset 0 0 0 1px var(--accent); }
.agent-icon { display: inline-flex; color: var(--label-2); }
.agent-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-status { color: var(--label-3); font-size: var(--t-caption); }
.agent-panel { margin-top: var(--s2); }
.agent-terminal-content, .agent-transcript {
  max-height: 340px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Карточка вопроса от Claude ----------------------------------------- */

.askuser-card {
  margin-top: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--accent-tint);
}
.askuser-icon { color: var(--accent); margin-bottom: var(--s1); }
.askuser-title {
  font-size: var(--t-headline);
  line-height: var(--lh-headline);
  font-weight: 640;
  margin-bottom: var(--s2);
}
.askuser-q {
  margin-bottom: var(--s3);
  font-size: var(--t-callout);
  line-height: var(--lh-callout);
}
.askuser-options { display: flex; flex-direction: column; gap: var(--s2); }
.askuser-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: var(--fill-4);
  text-align: left;
  transition: background var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.askuser-option.selected {
  background: var(--accent-tint);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.askuser-option-label { font-size: var(--t-callout); font-weight: 590; }
.askuser-option-desc { font-size: var(--t-footnote); color: var(--label-2); }
.askuser-submit { margin-top: var(--s3); }
.askuser-foot-status, .askuser-status {
  margin-top: var(--s2);
  font-size: var(--t-footnote);
  color: var(--label-2);
}
.askuser-pending { opacity: 0.6; pointer-events: none; }

/* --- Пауза по лимиту ---------------------------------------------------- */

.rate-limit-pause-card {
  margin-top: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1), inset 0 0 0 1px color-mix(in srgb, var(--orange) 35%, transparent);
}
.rl-pause-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 640;
  color: var(--orange);
}
.rl-pause-body { margin-top: var(--s2); font-size: var(--t-subhead); color: var(--label-2); }
.rl-pause-countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 640;
  color: var(--label);
}
.rl-pause-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--tap);
  margin-top: var(--s2);
}
.rl-pause-label { flex: 1; font-size: var(--t-subhead); }
.rl-pause-done { color: var(--green); }

/* Тумблер в стиле iOS. */
.rl-pause-toggle, .codex-switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  transition: background var(--d-fast) var(--ease);
  cursor: pointer;
}
.rl-pause-toggle::after, .codex-switch::after, .settings-toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform var(--d-fast) var(--ease);
}
.rl-pause-toggle.on, .codex-switch.on, .codex-switch:has(input:checked),
.settings-toggle-row input[type="checkbox"]:checked {
  background: var(--green);
}
.rl-pause-toggle.on::after, .codex-switch.on::after,
.codex-switch:has(input:checked)::after,
.settings-toggle-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.codex-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
/* Тот же тумблер, но сам <input>: в настройках он и есть переключатель. */
.settings-toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  transition: background var(--d-fast) var(--ease);
  cursor: pointer;
}

/* --- Результат сжатия --------------------------------------------------- */

.compact-result-card {
  margin-top: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.compact-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 640;
  margin-bottom: var(--s2);
}
.compact-meta, .compact-ratio {
  font-size: var(--t-footnote);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.compact-summary {
  margin-top: var(--s3);
  font-size: var(--t-subhead);
  line-height: 1.5;
  color: var(--label-2);
}
.compact-details { margin-top: var(--s2); }

/* --- Пузырь ревьюера ---------------------------------------------------- */

.codex-bubble {
  margin-top: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.codex-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
  font-size: var(--t-footnote);
  font-weight: 640;
  color: var(--label-2);
}
.codex-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 700;
}
.codex-message { font-size: var(--t-subhead); line-height: 1.5; }
.codex-verdict-badge {
  padding: 2px var(--s2);
  border-radius: var(--r-xs);
  font-size: var(--t-caption-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.codex-reasons { margin-top: var(--s2); font-size: var(--t-footnote); color: var(--label-2); }
.codex-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-top: var(--s3);
  padding-top: var(--s2);
  border-top: 1px solid var(--separator);
  font-size: var(--t-caption-2);
  color: var(--label-3);
}
.codex-footer-cell { display: flex; gap: 4px; }
.codex-footer-key { color: var(--label-3); }
.codex-session-val, .codex-tokens-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.codex-pending, .codex-pending-text { opacity: 0.65; }

/* ============================================================================
 * 07. КОМПОЗЕР
 *
 * Переделан целиком. Было: одна строка, где текстовое поле зажато между
 * четырьмя круглыми кнопками — 194 px из 402, меньше половины ширины
 * телефона. Стало: текст занимает всю строку, а управление стоит РЯДОМ
 * СНИЗУ. Так устроены все современные чаты, и причина простая — длинный
 * промпт с телефона иначе не набрать.
 *
 * Порядок элементов внутри #input-area менять нельзя: код вставляет
 * плашку отложенных первым ребёнком (insertBefore(banner, firstChild)).
 * ========================================================================= */

#input-area {
  position: relative;
  z-index: 15;
  flex: none;
  padding: var(--s2) var(--gutter) calc(var(--s2) + var(--safe-bottom));
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-edge), 0 -0.5px 0 var(--glass-hairline);
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s2) var(--s2) var(--s2) var(--s3);
  border-radius: var(--r-sheet);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--d-fast) var(--ease);
}
.input-wrapper:focus-within { box-shadow: var(--shadow-2), inset 0 0 0 1.5px var(--accent-tint); }
.input-wrapper.drag-over { box-shadow: inset 0 0 0 2px var(--accent); }

#message-input {
  width: 100%;
  min-height: 40px;
  /* Шесть строк, дальше поле прокручивается само. Без потолка композер
     съедает переписку: в Telegram это ограничение зашито в код (12 строк),
     и по той же причине. */
  max-height: 156px;
  padding: 9px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: var(--t-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
  resize: none;
  overflow-y: auto;
}
#message-input:focus { box-shadow: none; }
#message-input:disabled { opacity: 0.5; }

/* Строка управления под текстом. */
.input-row {
  display: flex;
  align-items: center;
  gap: var(--s1);
}

.attach-button, .schedule-button, .voice-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border-radius: 50%;
  color: var(--label-2);
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.attach-button:active, .schedule-button:active, .voice-button:active {
  background: var(--fill-3);
  color: var(--label);
}
.voice-button.recording { background: var(--red); color: var(--on-accent); animation: cm-pulse 1.4s infinite; }

/* Чип модели. Живёт в строке управления, а не в отдельном ряду: узнать,
   кем сейчас отвечает Claude, и сменить — одно движение, не выходя из
   разговора. Раньше на это уходило четыре тапа через настройки. */
.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  max-width: 46%;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  background: var(--fill-3);
  color: var(--label-2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 590;
  white-space: nowrap;
  overflow: hidden;
}
.model-chip:active { background: var(--fill-2); }
.model-chip-own { color: var(--accent); background: var(--accent-tint); }
#model-chip-text { overflow: hidden; text-overflow: ellipsis; }

.input-row-spacer { flex: 1; }

/* Кнопка отправки. Всегда на месте — меняется только заливка, чтобы
   строка не дёргалась при первом введённом символе. */
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  margin-left: var(--s1);
  border-radius: 50%;
  background: var(--fill-2);
  color: var(--label-3);
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease),
              transform var(--d-fast) var(--ease);
}
.send-button:not(:disabled) { background: var(--accent-fill); color: var(--on-accent); }
.send-button:not(:disabled):active { transform: scale(0.92); background: var(--accent-pressed); }
.send-button.working { background: var(--red-fill); color: var(--on-accent); }
.send-button.followup { background: var(--orange); color: var(--on-accent); }

/* Иконки переключаются НЕ классом .hidden: у него display:none !important,
   и он оставлял пустой круг без значка. */
.send-button .icon-stop { display: none; }
.send-button.working .icon-send { display: none; }
.send-button.working .icon-stop { display: block; }

/* --- Вложения ----------------------------------------------------------- */

.attach-preview { display: flex; flex-wrap: wrap; gap: var(--s2); }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 var(--s1) 0 var(--s2);
  border-radius: var(--r-sm);
  background: var(--fill-3);
  font-size: var(--t-caption);
  max-width: 100%;
}
.attach-chip-icon { color: var(--label-2); }
.attach-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex: none;
  border-radius: 50%;
  color: var(--label-2);
}
.attach-chip-remove:active { background: var(--fill-2); }

/* --- Очередь неотправленного -------------------------------------------- */

.outbox-bar {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s2);
  border-radius: var(--r-md);
  background: var(--fill-4);
}
.outbox-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-caption-2);
  font-weight: 640;
  color: var(--label-2);
}
.outbox-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.outbox-title { flex: 1; }
.outbox-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 38px;
  font-size: var(--t-footnote);
}
.outbox-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outbox-flush, .outbox-del {
  min-width: var(--tap); height: var(--tap);
  border-radius: var(--r-sm);
  color: var(--label-2);
}
.outbox-flush:active, .outbox-del:active { background: var(--fill-3); }
.outbox-more { font-size: var(--t-caption); color: var(--label-3); }

/* --- Плашка отложенных -------------------------------------------------- */

#scheduled-banner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: var(--tap);
  margin-bottom: var(--s2);
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  background: var(--fill-4);
  color: var(--label-2);
  font-size: var(--t-footnote);
  text-align: left;
}
.scheduled-banner-ic { color: var(--label-2); }
.scheduled-banner-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scheduled-banner-arrow { color: var(--label-3); }

/* --- Подсказка slash-команд --------------------------------------------- */

.slash-popup {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(100% - var(--s2));
  z-index: 30;
  max-height: 46vh;
  overflow-y: auto;
  border-radius: var(--r-lg);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-3);
}
.slash-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s4);
  text-align: left;
}
.slash-item.active, .slash-item:active { background: var(--fill-3); }
.slash-item-name {
  font-family: var(--font-mono);
  font-size: var(--t-subhead);
  font-weight: 590;
  color: var(--label);
}
.slash-item-desc { font-size: var(--t-caption); color: var(--label-2); }

/* Кнопка «меню под палец» убрана: она открывала ровно то же, что кнопка в
   шапке. Из DOM не удаляем — на неё завязан код. */
.thumb-btn { display: none; }
/* ============================================================================
 * 08. ОВЕРЛЕИ: панели, шторки, диалоги
 *
 * Всё, что выезжает поверх переписки, собрано из трёх деталей —
 * .modal-overlay (затемнение и слой), .modal-panel (сама поверхность) и
 * .modal-header/.modal-body/.modal-footer. Динамические панели рабочего
 * пространства строятся кодом из тех же классов, поэтому правило,
 * написанное здесь, красит и то, чего нет в разметке.
 * ========================================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  background: var(--scrim);
  animation: cm-fade var(--d-fast) var(--ease);
  /* Размытия на затемнении НЕТ намеренно. Стекло внутри стекла гасит
     композитор iOS — экран становился чёрным, и это выглядело как «не
     грузится». Одно размытие на слой, как просит HIG. */
}
.modal-overlay.modal-top { z-index: 220; }

@keyframes cm-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  display: flex;
  /* Без этих двух строк панель — гибкий элемент с min-width:auto — растёт
     под самое широкое содержимое: замер показывал 504 px за краем экрана,
     то есть половину панели нельзя было увидеть. */
  flex: none;
  min-width: 0;
  flex-direction: column;
  min-height: 0;
  background: var(--sheet-bg);
  /* Отступ под вырез задаётся ЗДЕСЬ и только здесь. Когда его добавляла
     ещё и шапка панели, заголовок уезжал на 142 px вместо 83. */
  padding-top: var(--safe-top);
  /* Скругление у панели было всегда — но его никто не видел: шапка и подвал
     красят свой фон прямоугольником поверх углов. Без обрезки радиус —
     пустое слово (жалоба «очень много квадратных углов», 2026-09-06). */
  overflow: hidden;
}

/* Боковая панель. 92% ширины — как у всех: остаётся видимая полоска
   переписки, по которой понятно, что панель поверх, а не вместо. */
.modal-panel.slide-left, .modal-panel.slide-right {
  width: min(440px, 92%);
  height: 100%;
  box-shadow: var(--shadow-3);
}
.modal-panel.slide-left {
  margin-right: auto;
  border-radius: 0 var(--r-sheet) var(--r-sheet) 0;
  animation: cm-slide-left var(--d-mid) var(--ease-out);
}
.modal-panel.slide-right {
  margin-left: auto;
  border-radius: var(--r-sheet) 0 0 var(--r-sheet);
  animation: cm-slide-right var(--d-mid) var(--ease-out);
}
@keyframes cm-slide-left  { from { transform: translateX(-100%); } }
@keyframes cm-slide-right { from { transform: translateX(100%); } }

/* Панель во всю ширину — для проводника, просмотра файла, терминала.
   Раньше сюда же входило «без скруглений»; теперь это листы, и углы у
   них общие с остальными. */
.files-panel-wide { width: min(680px, 100%) !important; }

/* Лист снизу. Детент по содержимому, но не выше верхнего края «страницы»:
   вырез плюс полоска переписки, по которой видно, что лист поверх.
   Сбоку выезжают ТОЛЬКО две двери навигации — диалоги и мастерская; всё
   остальное (настройки, проводник, git, совет моделей, …) — задачи, а
   задача на iPhone — это лист снизу, который тянут вниз, чтобы закрыть
   (HIG: sheets для задач, drawers для навигации; жалоба «много окон,
   которые не обязаны быть выезжающими сбоку», 2026-09-06). */
.modal-panel.slide-up {
  width: 100%;
  max-width: 620px;
  max-height: calc(100% - var(--safe-top) - var(--s3));
  margin: auto auto 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  /* Лист не доходит до выреза — отступ под него ему не нужен. Отступ под
     нижнюю полосу НЕ здесь: подвал (.modal-footer) уже считает
     --safe-bottom сам, и лист с подвалом получал его дважды. Листу без
     подвала его добавляет последнее тело (правило ниже). */
  padding-top: 0;
  /* Волосяная кромка: в тёмной теме лист (--surface) на чёрном без неё
     сливается с затемнением, и границы у него нет. */
  box-shadow: 0 0 0 0.5px var(--separator), var(--shadow-3);
  animation: cm-slide-up var(--d-mid) var(--ease-out);
}
.modal-panel.slide-up > .modal-body:last-child,
.modal-panel.slide-up > .ws-git-body:last-child,
.modal-panel.slide-up > .ws-hub-body:last-child {
  padding-bottom: calc(var(--s8) + var(--safe-bottom));
}
/* Ручка листа: та же, что у .thumb-sheet — по ней видно, что лист тянется. */
.modal-panel.slide-up::before {
  content: '';
  flex: none;
  width: 36px;
  height: 5px;
  margin: var(--s2) auto 0;
  border-radius: var(--r-pill);
  background: var(--fill-1);
}
/* Лист-страница: настройки, проводник и прочие длинные экраны занимают
   всю доступную высоту, а не подстраиваются под содержимое — иначе
   высота прыгает при каждой перерисовке списка. */
.modal-panel.slide-up.sheet-page { height: calc(100% - var(--safe-top) - var(--s3)); }
@keyframes cm-slide-up { from { transform: translateY(100%); } }
/* Пока лист тянут пальцем вниз (wirePullDownDismiss), анимация въезда и
   переходы отключены — иначе transform дерётся с ними. */
.modal-panel.dragging { animation: none; transition: none; }

/* Короткий диалог по центру — подтверждения и запросы разрешения. */
.modal-dialog, .perm-dialog, .rollback-dialog {
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100% - var(--s8)));
  max-height: 86%;
  margin: auto;
  border-radius: var(--r-sheet);
  /* Без overflow:hidden стеклянная шапка и футер закрашивают скругления —
     диалог отката выглядел квадратным (2026-09-06). */
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: cm-pop var(--d-fast) var(--ease-out);
}
@keyframes cm-pop {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

/* Шапка панели. Заголовок слева — так iOS 26 расставляет заголовки; кнопка
   закрытия справа, размером с цель нажатия. */
.modal-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  min-height: 52px;
  padding: var(--s2) var(--s2) var(--s2) var(--s5);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: 0 0.5px 0 var(--glass-hairline);
}
.modal-header h2, .modal-header h3 {
  flex: 1;
  min-width: 0;
  font-size: var(--t-title-3);
  line-height: var(--lh-title-3);
  letter-spacing: var(--tr-title-3);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Кнопка закрытия — полноценная цель 44×44 сама по себе: в шаблонах
   мастерской (workspace.js) она без .icon-btn, и без этих строк была
   голым крестиком 22 px. */
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--r-pill);
  color: var(--label-2);
  font-size: 22px;
  line-height: 1;
}
.modal-close:active { background: var(--fill-3); }

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Вбок тело панели не ездит НИКОГДА. Длинный путь к папке в «сессиях с ПК»
     делал список шире экрана, и свайп «закрыть» превращался в прокрутку
     списка вбок на пару сантиметров — панель не закрывалась (2026-09-06). */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--s4) var(--gutter) var(--s8);
}
.modal-dialog .modal-body, .perm-dialog .perm-body { padding: var(--s4) var(--s5); }

.modal-footer, .modal-actions, .form-actions, .perm-actions, .session-btn-row {
  display: flex;
  gap: var(--s2);
  flex: none;
  padding: var(--s3) var(--gutter) calc(var(--s3) + var(--safe-bottom));
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: 0 -0.5px 0 var(--glass-hairline);
}
.modal-footer > .btn, .modal-actions > .btn, .perm-actions > .btn { flex: 1; }
.modal-dialog .modal-footer, .perm-dialog .perm-actions { padding-bottom: var(--s3); }
.form-actions, .session-btn-row {
  padding: 0;
  background: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* --- Нижний лист (мастерская и выбор модели) ----------------------------
 * Отдельный от .modal-panel механизм: лист тянут пальцем, поэтому у него
 * своя анимация и своё состояние .open. Содержимое обязано лежать прямыми
 * детьми .thumb-sheet-inner — по этому селектору код ищет, за что тянут. */

.thumb-sheet {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: flex-end;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-mid) var(--ease);
}
.thumb-sheet.open { opacity: 1; pointer-events: auto; }

.thumb-sheet-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  /* Детент: лист занимает столько, сколько нужно содержимому, но не выше
     82% экрана — под ним всегда видно переписку, и понятно, что это слой,
     а не другой экран. */
  max-height: 82dvh;
  padding-bottom: var(--safe-bottom);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.22);
  transform: translateY(100%);
  transition: transform var(--d-mid) var(--ease-out);
}
.thumb-sheet.open .thumb-sheet-inner { transform: none; }
.thumb-sheet-inner.dragging { transition: none; }

/* Прокручивается ВНУТРЕННЕЕ содержимое, а не лист. Без min-height:0
   гибкий ребёнок отказывается сжиматься, и список моделей однажды закрыл
   весь экран без единого способа выйти. */
.thumb-sheet-inner > *:not(.thumb-grab-hit) {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Ручка — не украшение: HIG требует её у изменяемой шторки и разрешает
   закрывать листом по тапу в неё. Зона нажатия во всю ширину и 28 px в
   высоту, иначе в полоску 36x5 попасть невозможно. */
.thumb-grab-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 100%;
  height: 36px;
  padding: 0;
}
.thumb-grab {
  width: 36px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--fill-1);
}

/* --- Боковая панель (drawer) --------------------------------------------
 * Тот же .thumb-sheet, но выезжает справа во всю высоту, а не снизу.
 * Мастерская стала такой по просьбе владельца: «пусть меню будет сбоку».
 * Правая дверь напротив левой (диалоги) — жест «влево» тянет её, «вправо»
 * задвигает; ширина как у списка диалогов, чтобы обе двери ощущались парой. */

.thumb-sheet.drawer {
  align-items: stretch;
  justify-content: flex-end;
}
.thumb-sheet.drawer .thumb-sheet-inner {
  width: min(440px, 92%);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding-top: var(--safe-top);
  padding-right: var(--safe-right);
  border-radius: var(--r-sheet) 0 0 var(--r-sheet);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.22);
  transform: translateX(100%);
}
.thumb-sheet.drawer.open .thumb-sheet-inner { transform: none; }

/* Шапка панели вместо горизонтальной ручки: у боковой панели тянуть
   «за полоску» нечего, зато нужен заголовок — иначе непонятно, куда
   попал. Стрелка вправо подсказывает, куда её задвигать. */
.drawer-head {
  justify-content: space-between;
  height: 52px;
  padding: 0 var(--gutter);
  color: var(--label);
}
.drawer-title {
  font-size: var(--t-title-3);
  line-height: var(--lh-title-3);
  letter-spacing: var(--tr-title-3);
  font-weight: 700;
}
.drawer-chev {
  display: inline-flex;
  color: var(--label-3);
}
.drawer-chev svg { width: 22px; height: 22px; }

/* --- Мастерская --------------------------------------------------------
 * Второй и последний уровень навигации. Здесь лежит всё, что НЕ относится
 * к текущему разговору: проект, платформа Claude, система. Каждая строка —
 * единственный вход в свою функцию: дублей с шапкой больше нет, потому что
 * из шапки эти кнопки убраны. */

.hub-scroll { padding: 0 var(--gutter) var(--s5); }

.hub-group-label {
  padding: var(--s5) var(--s4) var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 640;
  color: var(--label-2);
}
.hub-group {
  border-radius: var(--r-lg);
  background: var(--surface-hi);
  overflow: hidden;
}
.hub-group + .hub-group-label { padding-top: var(--s5); }

.hub-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 54px;
  padding: var(--s2) var(--s4);
  text-align: left;
  transition: background var(--d-fast) var(--ease);
}
.hub-row + .hub-row { box-shadow: inset 0 0.5px 0 var(--separator); }
.hub-row:active { background: var(--fill-4); }

/* Значки монохромные. Разноцветные плитки, которые тут стояли, делали
   список похожим на детский лаунчер и мешали читать: глаз цеплялся за
   цвет, а не за название. Цвет в этом интерфейсе означает смысл. */
.hub-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--label-2);
}
.hub-ico svg { width: 22px; height: 22px; }
.hub-text { flex: 1; min-width: 0; }
.hub-title {
  display: block;
  font-size: var(--t-body);
  line-height: 21px;
  letter-spacing: var(--tr-body);
  color: var(--label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-sub {
  display: block;
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  letter-spacing: var(--tr-footnote);
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-chev { display: inline-flex; flex: none; color: var(--label-3); }

/* --- Выбор модели ------------------------------------------------------- */

#model-sheet-body { padding: 0 var(--gutter) var(--s5); }
.model-sheet-label {
  padding: var(--s3) var(--s4) var(--s2);
  font-size: var(--t-footnote);
  font-weight: 640;
  color: var(--label-2);
}
.model-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 54px;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-md);
  text-align: left;
}
.model-row:active { background: var(--fill-4); }
.model-row-active { background: var(--accent-tint); }
.model-row-main { flex: 1; min-width: 0; }
.model-row-sub {
  display: block;
  font-size: var(--t-footnote);
  color: var(--label-2);
}

/* Шкала «модель / глубина». Ползунок с подписями — понятнее списка
   версий: HIG про генеративные интерфейсы просит называть РЕЗУЛЬТАТ, а не
   номер модели. */
.model-slider-wrap, .settings-options { display: flex; flex-direction: column; gap: var(--s2); }
.model-slider, .effort-slider {
  width: 100%;
  height: var(--tap);
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}
.model-slider::-webkit-slider-runnable-track,
.effort-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--fill-2);
}
.model-slider::-webkit-slider-thumb,
.effort-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 28px; height: 28px;
  margin-top: -12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.model-slider-labels, .model-slider-labels-multi {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  font-size: var(--t-caption);
  color: var(--label-2);
}
.model-slider-name { font-weight: 640; color: var(--label); }
.model-slider-desc, .model-slider-info {
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
}

/* --- Этот диалог (бывший поповер контекста) -----------------------------
 * Открывается тапом по заголовку. Собирает в одном месте всё, что
 * относится к текущему разговору: сколько занято памяти, чем сжать,
 * инструкции, стоимость, сохранение. Раньше это лежало в пяти разных
 * местах, включая седьмую секцию настроек. */

.context-popover {
  position: fixed;
  inset: 0;
  z-index: 230;
  display: flex;
  align-items: flex-end;
  background: var(--scrim);
  animation: cm-fade var(--d-fast) var(--ease);
}
.context-popover-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  min-height: 52px;
  padding: var(--s2) 0;
  font-size: var(--t-title-3);
  line-height: var(--lh-title-3);
  font-weight: 700;
}
.context-popover-header > span:first-child { flex: 1; }
.context-popover-body {
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--gutter) calc(var(--s5) + var(--safe-bottom));
}
.context-total {
  font-size: var(--t-title-2);
  line-height: var(--lh-title-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--s2);
}
.context-pct { color: var(--label-2); font-size: var(--t-subhead); }
.context-bar {
  height: 8px;
  margin-bottom: var(--s3);
  border-radius: var(--r-pill);
  background: var(--fill-2);
  overflow: hidden;
}
/* Сегменты лежат ВНУТРИ #context-bar-fill — он не заливка, а прозрачный
   контейнер во всю ширину. С width:0 (как у обычной .bar-fill) полоса была
   пуста при любых данных. */
.context-bar-fill { width: 100%; height: 100%; background: transparent; }
.context-bar-seg { height: 100%; float: left; }
.context-bar-loading { opacity: 0.4; }
.context-legend { display: flex; flex-direction: column; }
.context-legend-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 34px;
  font-size: var(--t-subhead);
}
.context-legend-dot { width: 9px; height: 9px; flex: none; border-radius: 3px; }
.context-legend-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-legend-val { color: var(--label-2); font-variant-numeric: tabular-nums; }
.context-hint {
  margin-top: var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
}
.context-error { color: var(--red); }
.context-actions { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }

/* ============================================================================
 * 08a. ЗАПРОС РАЗРЕШЕНИЯ
 * ========================================================================= */

.perm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px; height: 46px;
  margin: var(--s5) auto var(--s2);
  border-radius: 50%;
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  color: var(--orange);
}
.perm-title {
  padding: 0 var(--s5);
  font-size: var(--t-title-3);
  line-height: var(--lh-title-3);
  font-weight: 700;
  text-align: center;
}
.perm-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: var(--t-subhead);
  line-height: 1.5;
  color: var(--label-2);
}
.perm-desc { margin-bottom: var(--s2); }
.perm-meta {
  padding: var(--s2);
  border-radius: var(--r-sm);
  background: var(--fill-4);
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  overflow-wrap: anywhere;
}
.perm-badge, .perm-badge-bash {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-2);
  font-size: var(--t-caption-2);
  font-weight: 640;
}
.perm-queue {
  margin-top: var(--s2);
  font-size: var(--t-caption);
  color: var(--label-3);
  text-align: center;
}
/* ============================================================================
 * 09. РАЗДЕЛЫ ПРИЛОЖЕНИЯ
 *
 * Каждый раздел собран из примитивов раздела 03. Общий приём: содержимое
 * панели — это стопка групп (.group / .settings-section), внутри групп —
 * строки одинакового рисунка. Оттого разные подсистемы выглядят одной
 * программой, а не набором несвязанных экранов.
 * ========================================================================= */

/* --- Диалоги (боковая панель) -------------------------------------------
 * Настоящий список мессенджера: поиск сверху, группировка по дням,
 * название с папкой и временем, точка у работающего диалога. */

#sidebar .modal-body { padding: var(--s2) var(--gutter) var(--s8); }

/* Поиск по диалогам: поле липнет к верху списка, чтобы при длинной
   истории не пришлось мотать наверх ради него. */
.sidebar-search {
  position: sticky;
  top: 0;
  z-index: 2;
  /* Поле липнет к самому верху тела, а не к его внутреннему отступу:
     иначе в щели над полем просвечивали строки списка (снимок с
     телефона, 2026-09-06). Отступ переносим внутрь блока. */
  margin: calc(-1 * var(--s2)) 0 var(--s3);
  padding-top: var(--s2);
  padding-bottom: var(--s2);
  background: var(--sheet-bg);
}
.sidebar-search input { padding-left: 38px; }
.sidebar-search svg {
  position: absolute;
  left: var(--s3);
  top: 50%;
  margin-top: -9px;
  width: 18px; height: 18px;
  color: var(--label-3);
  pointer-events: none;
}

.convo-list { display: flex; flex-direction: column; margin-top: var(--s3); }

.convo-group-label {
  padding: var(--s4) var(--s1) var(--s1);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 640;
  color: var(--label-2);
}

.convo-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 58px;
  padding: var(--s2) var(--s2) var(--s2) var(--s3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease);
}
.convo-item:active { background: var(--fill-4); }
.convo-item.active { background: var(--accent-tint); }
.convo-item.renaming { background: var(--fill-3); }

.convo-info { flex: 1; min-width: 0; }
.convo-title {
  display: block;
  font-size: var(--t-callout);
  line-height: 20px;
  letter-spacing: var(--tr-callout);
  font-weight: 590;
  color: var(--label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo-meta, .convo-dir {
  display: block;
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo-dir { font-family: var(--font-mono); font-size: var(--t-caption); color: var(--label-3); }

.convo-working-dot {
  width: 8px; height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  animation: cm-pulse 1.6s var(--ease) infinite;
}
.convo-pin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: 50%;
  color: var(--label-2);
}
.convo-pin-btn.is-pinned, .files-act-star.is-pinned { color: var(--yellow); }
.files-row.is-pinned { background: var(--accent-tint); }
/* Булавка системного диалога стоит внутри заголовка — значок, не кнопка. */
.convo-pin {
  display: inline-flex;
  vertical-align: -1px;
  margin-right: var(--s1);
  color: var(--accent);
}
.convo-dir svg { vertical-align: -2px; margin-right: var(--s1); }

.convo-actions { display: flex; gap: 2px; flex: none; }
/* Переименовать/удалить — только у открытого диалога (и под мышью): три
   кнопки в каждой строке списка — это шум, а не действия. */
.convo-actions .convo-rename, .convo-actions .convo-delete { display: none; }
.convo-item.active .convo-actions .convo-rename,
.convo-item.active .convo-actions .convo-delete { display: inline-flex; }
.convo-rename, .convo-delete, .convo-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  color: var(--label-2);
}
.convo-rename:active, .convo-delete:active, .convo-pin-btn:active { background: var(--fill-3); }
.convo-delete:active { color: var(--red); }
.convo-rename-input {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--t-callout);
}
.convo-row { display: flex; align-items: center; gap: var(--s2); }
.convo-row-label { font-size: var(--t-footnote); color: var(--label-2); }

/* Нижние строки боковой панели: сессии с ПК, сохранённые, аккаунт. */
.sidebar-foot {
  flex: none;
  padding: var(--s2) var(--gutter) calc(var(--s3) + var(--safe-bottom));
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: 0 -0.5px 0 var(--glass-hairline);
}

/* --- Сессии с ПК -------------------------------------------------------- */

.pc-sessions-controls {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-bottom: var(--s2);
}
.pc-sessions-filter { flex: 1; min-width: 180px; }
.pc-sessions-status {
  padding: var(--s1) 0 var(--s2);
  font-size: var(--t-footnote);
  color: var(--label-2);
}
.pc-sessions-folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin-bottom: var(--s2);
  padding: 0 var(--s1) 0 var(--s2);
  border-radius: var(--r-sm);
  background: var(--fill-3);
  font-size: var(--t-caption);
  max-width: 100%;
}
.pc-folder-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-folder-chip-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex: none;
  border-radius: 50%;
  color: var(--label-2);
}
.pc-sessions-list, .saved-sessions-list, .files-list, .recyclebin-list,
.agents-list, .council-history, .accounts-list {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}
.pc-session-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--surface-hi);
  text-align: left;
}
.pc-session-item:active { background: var(--fill-4); }
.pc-session-head { display: flex; align-items: center; gap: var(--s2); }
.pc-session-title {
  flex: 1;
  min-width: 0;
  font-size: var(--t-callout);
  font-weight: 590;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-session-title.untitled { color: var(--label-3); font-style: italic; }
/* Путь режется с НАЧАЛА (важен хвост), поэтому блок rtl; но сам текст —
   изолированный ltr-абзац, иначе rtl переворачивает знаки «C:/…/». */
.pc-session-cwd {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--label-2);
  direction: rtl;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-session-cwd > bdi { direction: ltr; unicode-bidi: plaintext; }
.pc-session-meta { font-size: var(--t-footnote); color: var(--label-2); }
.pc-tag-live { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.pc-tag-new { background: var(--accent-tint); color: var(--accent); }
.pc-tag-renamed { background: var(--fill-2); color: var(--label-2); }

.pc-preview-messages, .saved-preview-messages { display: flex; flex-direction: column; gap: var(--s3); }
.pc-prev-role {
  font-size: var(--t-caption-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--label-3);
}
.pc-prev-text {
  font-size: var(--t-subhead);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.pc-preview-meta, .saved-preview-meta {
  padding-bottom: var(--s3);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
  overflow-wrap: anywhere;
}
.pc-preview-meta:empty, .saved-preview-meta:empty { display: none; }
/* Пока сессия не прочитана — лист не пустой, а «Загрузка…». */
.pc-preview-messages:empty::before, .saved-preview-messages:empty::before {
  content: 'Загрузка…';
  display: block;
  padding: var(--s6);
  text-align: center;
  font-size: var(--t-subhead);
  color: var(--label-3);
}
/* Две кнопки под превью — столбиком: в строку их подписи не помещались. */
.pc-preview-panel .modal-footer { flex-direction: column; }
.pc-prev-fork { color: var(--accent); }

.saved-mode-chip-full { background: var(--accent-tint); color: var(--accent); }
.saved-mode-chip-auto { background: var(--fill-2); color: var(--label-2); }

/* --- Настройки ----------------------------------------------------------
 * Плоский список из четырнадцати секций был неработоспособен: «Совет
 * моделей» находился только пролистыванием до седьмой. Всё, что является
 * входом в другую подсистему, переехало в мастерскую; здесь остались
 * настоящие настройки. */

.settings-body { padding-top: var(--s2); }

.settings-section { margin-bottom: var(--s5); }
.settings-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 28px;
  padding: 0 var(--s2) var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  font-weight: 590;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--label-2);
}
/* Кнопка в заголовке — текстовая, без заливки: огромные «пилюли» рядом с
   подписью секции выглядели главнее самой секции. */
.settings-section-label > .settings-inline-btn {
  /* Визуально — мелкая текстовая кнопка в строке подписи, но зона нажатия
     остаётся 44px: высота --tap, лишнее уходит в отрицательные поля. */
  min-height: var(--tap);
  margin: calc((28px - var(--tap)) / 2) 0;
  padding: 0 var(--s1);
  border-radius: var(--r-sm);
  background: none;
  color: var(--accent);
  font-weight: 590;
  letter-spacing: 0;
  text-transform: none;
}
.settings-section-label > .settings-inline-btn:active { background: var(--accent-tint); }
.settings-section > .settings-options,
.settings-section > .settings-usage,
.settings-section-hero > .settings-usage {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.settings-section > .settings-options:empty { display: none; }
.settings-options .settings-hint, .settings-usage .settings-hint { padding-left: 0; padding-right: 0; }
.settings-options > .session-btn-row { padding: 0; }
.settings-section-moved { display: none; }

.settings-hint {
  padding: var(--s2) var(--s2) 0;
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
}
.settings-toggle-row { justify-content: space-between; padding: var(--s2) 0; }
/* Тумблер справа, как в iOS Settings (в разметке input идёт первым). */
.settings-toggle-row > input[type="checkbox"] { order: 2; margin-left: auto; }
.settings-toggle-row + .settings-toggle-row { box-shadow: inset 0 0.5px 0 var(--separator); }
.settings-toggle-row > span:first-of-type { flex: 1; min-width: 0; }
.settings-toggle-sub {
  display: block;
  margin-top: 2px;
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
}
/* Описание лежит ПОД подписью, а не третьей колонкой справа: колонкой оно
   налезало на подпись, как только та переносилась на вторую строку. */
.settings-option {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s2) 0;
  cursor: pointer;
}
.settings-option + .settings-option { box-shadow: inset 0 0.5px 0 var(--separator); }
.settings-option-main { flex: 1; min-width: 0; }
.settings-option-label, .settings-option-desc { display: block; }
.settings-option-label { font-size: var(--t-callout); line-height: var(--lh-callout); }
.settings-option-desc { margin-top: 2px; font-size: var(--t-footnote); line-height: var(--lh-footnote); color: var(--label-2); }
.settings-option.active .settings-option-label { font-weight: 600; }
.settings-option-check { display: inline-flex; flex: none; width: 22px; height: 22px; align-items: center; justify-content: center; color: var(--accent); }
.settings-option-check svg { width: 18px; height: 18px; }
.settings-option:not(.active) .settings-option-check { visibility: hidden; }

.settings-inline-btn {
  min-height: var(--tap);
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  background: var(--fill-3);
  color: var(--label);
  font-size: var(--t-footnote);
  font-weight: 590;
}
.settings-inline-btn:active { background: var(--fill-2); }
.settings-inline-btn.active { background: var(--accent-fill); color: var(--on-accent); }

/* Строка-вход в подсистему. */
.settings-feature-btn {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 56px;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
}
.settings-feature-btn + .settings-feature-btn { margin-top: var(--s1); }
.settings-feature-btn:active { background: var(--fill-4); }
.settings-feature-ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex: none;
  color: var(--label-2);
}
.settings-feature-text { flex: 1; min-width: 0; }
.settings-feature-title { display: block; font-size: var(--t-body); }
.settings-feature-sub {
  display: block;
  font-size: var(--t-footnote);
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-feature-arrow { display: inline-flex; flex: none; color: var(--label-3); }
.settings-feature-ic svg { width: 22px; height: 22px; }

.settings-account-summary, .acc-summary-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--t-subhead);
}
.acc-summary-name { font-weight: 590; }
.acc-summary-status { color: var(--label-2); font-size: var(--t-footnote); }

/* --- Лимиты подписки ---------------------------------------------------- */

.usage-quota-block + .usage-quota-block { margin-top: var(--s4); }
.usage-quota-acc-head, .usage-quota-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s1);
}
.usage-quota-acc-name { font-weight: 640; font-size: var(--t-callout); }
.usage-quota-row { margin-bottom: var(--s3); }
.usage-quota-label { font-size: var(--t-footnote); color: var(--label-2); }
.usage-quota-val {
  font-size: var(--t-footnote);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.usage-quota-bar { height: 8px; margin-top: 6px; }
.usage-quota-bar-skel, .usage-quota-val-skel {
  background: var(--fill-3);
  border-radius: var(--r-pill);
  color: transparent;
  animation: cm-pulse 1.4s var(--ease) infinite;
}
.usage-quota-row-empty { font-size: var(--t-footnote); color: var(--label-3); }
.usage-quota-raw-btn {
  min-height: 34px;
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  color: var(--label-2);
  font-size: var(--t-caption);
}
.usage-session-footer {
  margin-top: var(--s2);
  font-size: var(--t-caption);
  color: var(--label-3);
}
.rl-head, .rl-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
}
.rl-label { font-size: var(--t-footnote); color: var(--label-2); }
.rl-pct, .rl-row { font-size: var(--t-footnote); font-variant-numeric: tabular-nums; }
.rl-bar { height: 8px; margin: 6px 0; }

/* --- Обновления --------------------------------------------------------- */

.upd-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s3);
  padding: var(--s3) 0;
}
.upd-row + .upd-row { box-shadow: inset 0 0.5px 0 var(--separator); }
.upd-main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); flex: 1 1 60%; min-width: 0; }
.upd-title { font-size: var(--t-callout); font-weight: 590; }
.upd-ver, .upd-note {
  font-size: var(--t-footnote);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.upd-note { flex: 1 1 100%; line-height: var(--lh-footnote); }
.upd-side { flex: none; margin-left: auto; }
.upd-side:empty { display: none; }
.upd-side .settings-inline-btn { min-height: 32px; }
.upd-badge.upd-ok { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.upd-badge.upd-behind { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--orange); }
.upd-channel {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: var(--s2) 0;
  font-size: var(--t-footnote);
  color: var(--label-2);
}
.upd-channel > span { margin-right: auto; }
.upd-channel .settings-inline-btn { min-height: 32px; font-size: var(--t-footnote); }
.upd-changelog {
  margin-top: var(--s2);
  font-size: var(--t-footnote);
  line-height: 1.5;
  color: var(--label-2);
}
.upd-changelog-head { font-weight: 640; color: var(--label); }

/* --- GPT-ревьюер -------------------------------------------------------- */

.codex-hero {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  margin-bottom: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.codex-hero-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--fill-3);
  color: var(--label-2);
}
.codex-hero-text { font-size: var(--t-subhead); line-height: 1.45; color: var(--label-2); }
.codex-card, .codex-toggle-card, .codex-status-card {
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.codex-toggle-card { display: flex; align-items: center; gap: var(--s3); min-height: 60px; }
.codex-card-main { flex: 1; min-width: 0; }
.codex-card > h3, .codex-card > .codex-card-title { margin: 0 0 var(--s2); }
.codex-card-title { font-size: var(--t-body); }
.codex-card-sub { font-size: var(--t-footnote); color: var(--label-2); }
.codex-field-label, .codex-label-head {
  display: block;
  margin-bottom: var(--s1);
  font-size: var(--t-footnote);
  font-weight: 590;
  color: var(--label-2);
}
.codex-input { margin-bottom: var(--s2); }
.codex-hint { font-size: var(--t-footnote); color: var(--label-2); }
.codex-status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 34px;
}
.codex-status-row + .codex-status-row { box-shadow: inset 0 0.5px 0 var(--separator); }
.codex-status-key { font-size: var(--t-footnote); color: var(--label-2); }
.codex-status-val, .codex-status-mono {
  font-size: var(--t-footnote);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.codex-status-mono { font-family: var(--font-mono); }

/* --- Возможности Claude ------------------------------------------------- */

.caps-tabs {
  display: flex;
  gap: 2px;
  /* 2 px обёртки плюс 40 px вкладки дают 44 — цель нажатия целиком. */
  padding: var(--s1);
  /* Вкладки и поиск стоят вне .modal-body — боковой отступ им нужен свой. */
  margin: 0 var(--gutter) var(--s3);
  border-radius: var(--r-sm);
  background: var(--fill-3);
}
.caps-tab {
  flex: 1;
  /* Сегментный переключатель iOS ниже, но там своя система попаданий —
     в вебе цель обязана быть 44 px сама по себе. */
  min-height: var(--tap);
  border-radius: 6px;
  color: var(--label-2);
  font-size: var(--t-footnote);
  font-weight: 590;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.caps-tab.active {
  background: var(--surface);
  color: var(--label);
  box-shadow: var(--shadow-1);
}
.caps-searchbar { margin: 0 var(--gutter) var(--s3); }
.caps-group-label {
  padding: var(--s4) var(--s2) var(--s1);
}
.caps-body > .caps-group-label:first-child {
  padding-top: 0;
  font-size: var(--t-footnote);
  font-weight: 640;
  color: var(--label-2);
}
.caps-row, .mcp-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  /* --surface-hi, не --surface: в тёмной теме лист сам --surface, и карточки
     на нём сливались с фоном (2026-09-06). */
  background: var(--surface-hi);
}
.caps-row + .caps-row, .mcp-row + .mcp-row { margin-top: var(--s1); }
.caps-row-head { display: flex; align-items: center; gap: var(--s2); }
.caps-row-name { flex: 1; min-width: 0; font-size: var(--t-callout); font-weight: 590; }
.caps-row-desc { font-size: var(--t-footnote); line-height: 1.45; color: var(--label-2); overflow-wrap: anywhere; }
.caps-footer {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--gutter) calc(var(--s3) + var(--safe-bottom));
}
.caps-meta { flex: 1; font-size: var(--t-footnote); color: var(--label-2); }
.mcp-actions { display: flex; gap: var(--s2); margin-top: var(--s2); }

/* --- Доска агентов ------------------------------------------------------ */

.agents-body { display: flex; flex-direction: column; gap: var(--s2); }
.agents-form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
  margin-bottom: var(--s3);
  border-radius: var(--r-lg);
  background: var(--surface-hi);
}
.agents-form-row { display: flex; gap: var(--s2); }
.agents-form-row > * { flex: 1; min-width: 0; }
.agent-form-hint, .agent-desc { font-size: var(--t-footnote); color: var(--label-2); }

.agent-head { display: flex; align-items: flex-start; gap: var(--s2); }
.agent-title {
  flex: 1;
  min-width: 0;
  font-size: var(--t-callout);
  line-height: var(--lh-callout);
  font-weight: 590;
  /* Длинное имя задачи — не больше двух строк, дальше многоточие. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.agent-head .agent-kind, .agent-head .agent-busy, .agent-head .caps-chip { margin-top: 2px; }
.agent-kind, .agent-meta {
  font-size: var(--t-footnote);
  color: var(--label-2);
}
.agent-busy { color: var(--accent); font-size: var(--t-footnote); font-weight: 590; white-space: nowrap; }
.agent-card .agent-prompt { margin-top: var(--s1); font-size: var(--t-subhead); line-height: 1.45; color: var(--label); }
.agent-card .agent-transcript { margin-top: var(--s2); padding-top: var(--s2); box-shadow: inset 0 0.5px 0 var(--separator); }
.agent-msg + .agent-msg { margin-top: var(--s2); }
.agent-msg.agent-user { color: var(--label-2); }
.agent-msg.agent-user::before { content: 'Вы: '; font-weight: 700; }
.agent-msg.agent-assistant::before { content: 'Агент: '; font-weight: 700; color: var(--accent); }
.agent-actions { display: flex; gap: var(--s2); margin-top: var(--s2); }
.agent-summary-label, .agent-task-label, .agent-modal-body .agent-prompt {
  font-size: var(--t-caption-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--label-3);
}
.agent-summary-body, .agent-task-body, .agent-task {
  font-size: var(--t-subhead);
  line-height: 1.5;
  color: var(--label-2);
}
.agent-modal-body { display: flex; flex-direction: column; gap: var(--s3); }

/* --- Совет моделей ------------------------------------------------------ */

.council-body { display: flex; flex-direction: column; gap: var(--s3); }
.council-group-label, .council-member-label, .council-vsec-label {
  font-size: var(--t-footnote);
  font-weight: 640;
  color: var(--label-2);
}
.council-members, .council-list { display: flex; flex-direction: column; gap: var(--s1); }
.council-member {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: var(--surface-hi);
}
.council-member input[type="checkbox"] { accent-color: var(--accent); }
.council-provider-name { flex: 1; min-width: 0; font-size: var(--t-callout); }
.council-provider-off { color: var(--label-3); }
.council-off-reason { font-size: var(--t-caption); color: var(--label-3); }
.council-hint { font-size: var(--t-footnote); color: var(--label-2); }
.council-result { display: flex; flex-direction: column; gap: var(--s3); }
.council-card-head { display: flex; align-items: center; gap: var(--s2); }
.council-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--fill-2);
  font-size: var(--t-caption);
  font-weight: 700;
}
.council-card-name { flex: 1; min-width: 0; font-weight: 590; }
.council-card-state, .council-card-meta {
  font-size: var(--t-caption);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.council-card-text {
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--surface-hi);
  font-size: var(--t-subhead);
  line-height: 1.5;
}
.council-card-wait, .council-arbiter-wait { color: var(--label-2); font-style: italic; }
.council-card-error, .council-arbiter-fail { color: var(--red); }
.council-verdict {
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface-hi);
  box-shadow: inset 0 0 0 1px var(--accent-tint);
}
.council-verdict-title { font-size: var(--t-headline); font-weight: 700; margin-bottom: var(--s2); }
.council-reco, .council-resolution { font-size: var(--t-subhead); line-height: 1.5; }
.council-disagree { margin-top: var(--s3); }
.council-disagree-topic { font-size: var(--t-subhead); font-weight: 640; margin-bottom: var(--s1); }
.council-list li { font-size: var(--t-subhead); line-height: 1.5; }
.council-pos { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s1); }
.council-letter.sm { width: 20px; height: 20px; font-size: var(--t-caption-2); }
.council-vsec-label { margin-top: var(--s3); }
.council-card { display: flex; flex-direction: column; gap: var(--s2); }
.council-card.council-failed .council-card-state { color: var(--red); }
.council-card.council-done .council-card-state { color: var(--green); }
.council-card.council-running .council-card-state { color: var(--accent); }
.council-result .council-question { font-size: var(--t-headline); line-height: var(--lh-headline); font-weight: 590; }
.council-nodisagree { color: var(--green); }
.council-conf, .council-pos, .council-total {
  font-size: var(--t-footnote);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.council-hist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: var(--surface-hi);
  text-align: left;
}
.council-hist + .council-hist { margin-top: var(--s1); }
.council-hist-q { font-size: var(--t-subhead); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.council-hist-meta { font-size: var(--t-caption); color: var(--label-2); }

/* --- Проводник ---------------------------------------------------------- */

.files-pathbar, .folder-picker-pathbar {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: var(--s2) var(--gutter);
  background: var(--surface-2);
  box-shadow: 0 0.5px 0 var(--separator);
}
#folder-picker-path {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--label-2);
  direction: rtl;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Путь в проводнике: папка и имя — два куска. Сжимается папка, имя
   остаётся целым; RTL-трюк с обрезкой начала переворачивал русские
   папки и знаки, поэтому его здесь нет. */
.files-path {
  display: flex;
  align-items: baseline;
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label);
  white-space: nowrap;
  overflow: hidden;
}
.path-dir, .path-base {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: plaintext;
}
.path-dir { flex: 0 1000 auto; color: var(--label-2); }
.path-base { flex: 0 0 auto; max-width: 100%; }
.files-navbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: var(--r-pill);
  color: var(--label-2);
}
.files-navbtn:active { background: var(--fill-3); }
/* Тулбар едет вбок; края затухают, чтобы было видно, что за краем есть ещё. */
.files-toolbar {
  display: flex;
  gap: var(--s2);
  padding: var(--s2) var(--gutter);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--s4), #000 calc(100% - var(--s5)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--s4), #000 calc(100% - var(--s5)), transparent);
}
.files-toolbar::-webkit-scrollbar { display: none; }
.files-toolbar .btn { flex: none; }
.files-toolbar .btn svg { flex: none; }
/* «Очистить корзину» — опасное действие красным текстом, без красной заливки. */
.files-toolbar .btn.text-danger { color: var(--red); background: transparent; }
.files-note {
  padding: var(--s3) var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
  text-align: center;
}

.files-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 50px;
  padding: var(--s1) var(--s2);
  border-radius: var(--r-md);
}
.files-row:active { background: var(--fill-4); }
.files-row-main { display: flex; align-items: center; gap: var(--s3); flex: 1; min-width: 0; }
.files-icon { flex: none; color: var(--label-2); }
/* Колонка — блочный flex-столбец: в JS имя и мета — <span>, а инлайн не
   умеет text-overflow: ellipsis. */
.files-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.files-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-callout); }
.files-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-caption);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.files-acts { display: flex; gap: 2px; flex: none; }
.files-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  color: var(--label-2);
}
.files-act:active { background: var(--fill-3); }
.files-act-star.is-pinned { color: var(--yellow); }
.files-meta .saved-mode-chip { vertical-align: middle; }
/* Лист действий над строкой (сохранённые сессии). */
/* Лист действий над строкой списка (создаётся из app.js, showActionSheet). */
.action-sheet { max-height: 70vh; }
.action-sheet-body { padding-bottom: calc(var(--s5) + var(--safe-bottom)); }
.hub-row-destructive .hub-title { color: var(--red); }
.folder-picker-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 50px;
  padding: 0 var(--s2);
  border-radius: var(--r-md);
  text-align: left;
}
.folder-picker-row:active { background: var(--fill-4); }

/* Заголовок просмотрщика — имя файла обычным шрифтом шапки, без RTL:
   имя короткое, а RTL переворачивал знаки в русских именах. */
.modal-header .file-viewer-title {
  font-family: var(--font);
  font-size: var(--t-headline);
  line-height: var(--lh-headline);
  direction: ltr;
  unicode-bidi: plaintext;
  text-align: left;
}
/* Тело просмотрщика занимает всю высоту листа; редактор и PDF растянуты на неё. */
.file-viewer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 0;
}
.file-edit {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: var(--s3) var(--s4);
  /* 16 px, не 13: Safari зумит страницу при фокусе на поле мельче 16 px. */
  font: var(--t-callout) / 1.5 var(--font-mono);
  letter-spacing: 0;
  background: transparent;
  color: var(--label);
  white-space: pre;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.file-edit:focus { outline: none; box-shadow: none; }
.file-frame { flex: 1; width: 100%; min-height: 0; border: 0; }
.file-binary {
  padding: var(--s8) var(--s4);
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  text-align: center;
  color: var(--label-2);
}
.file-binary-icon { display: flex; justify-content: center; margin-bottom: var(--s3); color: var(--label-3); }
.file-img-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--s4); }
.file-img { max-width: 100%; max-height: 100%; height: auto; border-radius: var(--r-md); }
.file-note {
  flex: none;
  margin-top: auto;
  text-align: center;
  padding: var(--s2) var(--s4);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
  background: var(--surface-2);
  box-shadow: 0 0.5px 0 var(--separator);
}

/* --- Аккаунты ----------------------------------------------------------- */

.account-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.account-item + .account-item { margin-top: var(--s2); }
.account-item.active { box-shadow: inset 0 0 0 1.5px var(--accent); }
.account-info { flex: 1; min-width: 0; }
.account-name { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-callout); font-weight: 590; }
.account-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name .sub-badge { flex: none; }
.account-meta { font-size: var(--t-footnote); color: var(--label-2); }
.account-warn { color: var(--red); font-weight: 590; }
.account-actions { display: flex; align-items: center; gap: var(--s1); flex: none; }
.account-check { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); color: var(--accent); }
.account-remove { color: var(--red); }
.account-remove:active { background: color-mix(in srgb, var(--red) 12%, transparent); }
/* Главная кнопка сверху, «Отмена» под ней (в разметке — наоборот). */
.add-account-form .form-actions { flex-direction: column-reverse; }
.add-account-form .form-actions > .btn { width: 100%; min-height: var(--tap); }
.detected-accounts:empty { display: none; }
.status-dot.dot-green { background: var(--green); }
.status-dot.dot-yellow { background: var(--yellow); }
.status-dot.dot-orange { background: var(--orange); }
.status-dot.dot-red { background: var(--red); }
.add-account-form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.detected-label { font-size: var(--t-footnote); font-weight: 590; color: var(--label-2); }
.detected-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  background: var(--fill-4);
  text-align: left;
}
.detected-item + .detected-item { margin-top: var(--s1); }
.detected-name { flex: 1; min-width: 0; font-size: var(--t-subhead); overflow: hidden; text-overflow: ellipsis; }
.detected-tag { font-size: var(--t-caption); color: var(--label-2); }

/* --- Отложенные, сжатие, откат, CLAUDE.md ------------------------------- */

.schedule-modal-label, .compact-modal-label, .claudemd-hint,
.rollback-preview-label {
  display: block;
  margin-bottom: var(--s2);
  font-size: var(--t-footnote);
  font-weight: 590;
  color: var(--label-2);
}
.compact-modal-label .muted, .schedule-modal-label .muted { color: var(--label-3); font-weight: 400; }
.schedule-modal-hint + .schedule-modal-label { margin-top: var(--s4); }
.schedule-modal-hint { margin-top: 0; }
/* Выноска-предупреждение внутри листа. */
.modal-callout {
  padding: var(--s3) var(--s4);
  margin: 0 0 var(--s4);
  border-radius: var(--r-md);
  background: var(--accent-tint);
  color: var(--label);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
}
.modal-callout-warn { background: color-mix(in srgb, var(--yellow) 16%, transparent); }
/* CLAUDE.md — код, моноширинный. Отложка и инструкция сжатия — обычный
   текст, как в композере. */
.claudemd-textarea {
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  line-height: 1.5;
}
.schedule-modal-textarea, .compact-modal-textarea {
  font-size: var(--t-body);
  line-height: var(--lh-body);
}
.schedule-modal-hint, .compact-modal-hint, .claudemd-status,
.rollback-note, .save-mode-sub, .scheduled-status {
  margin-top: var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
}
.schedule-quick-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.schedule-modal-when { margin-top: var(--s3); }
.schedule-modal-list { display: flex; flex-direction: column; gap: var(--s1); margin-top: var(--s4); }
.scheduled-row-head { display: flex; align-items: center; gap: var(--s2); }
.scheduled-row-when {
  font-size: var(--t-caption);
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.scheduled-row-text { font-size: var(--t-subhead); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scheduled-row-error { color: var(--red); font-size: var(--t-caption); }
.scheduled-cancel {
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: 50%;
  color: var(--label-3);
}

.rollback-warn { color: var(--red); font-size: var(--t-subhead); line-height: 1.45; }
.rollback-preview-wrap { margin: var(--s3) 0; }
.rollback-preview {
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--fill-4);
  font-size: var(--t-subhead);
  line-height: 1.45;
  max-height: 180px;
  overflow-y: auto;
}
.claudemd-modal-panel .modal-body, .compact-modal-panel .modal-body,
.schedule-modal-panel .modal-body { padding-bottom: var(--s5); }
#claudemd-path {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--label-2);
  overflow-wrap: anywhere;
}

.save-mode-opt {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 56px;
  margin: 0 calc(-1 * var(--s2));
  padding: var(--s3) var(--s2);
  border-radius: var(--r-md);
  cursor: pointer;
}
.save-mode-opt + .save-mode-opt { margin-top: var(--s1); }
.save-mode-opt:has(input:checked) { background: var(--accent-tint); }
.save-mode-opt input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--label-3);
  background: none;
  transition: box-shadow var(--d-fast) var(--ease);
}
.save-mode-opt input[type="radio"]:checked { box-shadow: inset 0 0 0 7px var(--accent); }
.save-mode-text { flex: 1; min-width: 0; }
.save-mode-title { display: block; font-size: var(--t-callout); line-height: var(--lh-callout); font-weight: 600; color: var(--label); }
.save-mode-sub { display: block; margin-top: 2px; }
/* Кнопки центрального диалога — без стеклянной подложки: она тянется
   через всю ширину и рисует «полосу» под текстом. */
.modal-dialog .perm-actions {
  padding: var(--s3) var(--s5) var(--s5);
  background: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.attach-viewer-panel .modal-body { padding: 0; }
/* Заголовок превью — имя файла, не заголовок раздела: кегль headline. */
.attach-viewer-panel .modal-header h2, .attach-viewer-panel .modal-header h3 {
  font-size: var(--t-headline);
  line-height: var(--lh-headline);
}
.attach-img-preview, .attach-pdf-preview { width: 100%; }
.attach-text-preview {
  padding: var(--s4);
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.restart-spinner {
  width: 34px; height: 34px;
  margin: var(--s5) auto var(--s3);
  border: 3px solid var(--fill-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cm-spin 800ms linear infinite;
}

/* ============================================================================
 * 09a. РАБОЧЕЕ ПРОСТРАНСТВО (git, терминал, поиск, проекты)
 *
 * Панели строятся кодом; классы совпадают с примитивами выше, поэтому
 * здесь только то, что специфично.
 * ========================================================================= */

.ws-modal { max-width: 620px; }
.ws-sheet { max-height: 88% !important; }

.ws-hub-body, .ws-git-body { display: flex; flex-direction: column; gap: var(--s3); }

/* Карточка проекта: имя строкой, под ним путь и ветка — каждая своей
   строкой. В одну строку они не влезали и рубились с обоих концов. */
.ws-project-card, .ws-project-row-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: 62px;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
}
.ws-project-name, .ws-project-row-name {
  display: block;
  max-width: 100%;
  font-size: var(--t-callout);
  font-weight: 590;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-project-meta, .ws-project-row-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 100%;
  min-width: 0;
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  color: var(--label-3);
}
.ws-project-meta > span, .ws-project-row-meta > span {
  display: block;
  max-width: 100%;
  direction: ltr;
  unicode-bidi: plaintext;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-project-meta > span:empty, .ws-project-row-meta > span:empty { display: none; }
.ws-project-meta-path { font-family: var(--font-mono); }
.ws-project-meta-git { color: var(--label-3); }
.ws-project-row-pin { width: var(--tap); height: var(--tap); flex: none; border-radius: 50%; color: var(--label-3); }

/* Плитки подсистем проекта. Четыре штуки — сетка читается быстрее списка. */
.ws-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s2);
}
.ws-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s2);
  min-height: 84px;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
  transition: background var(--d-fast) var(--ease);
}
.ws-tile:active { background: var(--fill-4); }
.ws-tile.active { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ws-tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  color: var(--accent);
}
.ws-tile-icon svg { width: 22px; height: 22px; }
.ws-tile-label { font-size: var(--t-subhead); font-weight: 590; }
.ws-tile-badge {
  position: absolute;
  top: var(--s2); right: var(--s2);
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: var(--t-caption-2);
  font-weight: 700;
  text-align: center;
}
/* Пустой бейдж — не «чёрточка», а ничего. */
.ws-tile-badge:empty { display: none; }

/* Заголовок секции — как в списках iOS: капитель, второй цвет. */
.ws-section-title {
  padding: var(--s3) var(--s2) var(--s1);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  font-weight: 590;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
}
/* Секция git несёт справа кнопку «Добавить всё» — заголовок и кнопка в одну линию. */
.ws-git-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding-top: var(--s2);
  padding-bottom: 0;
}
.ws-git-section > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-list-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 50px;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  text-align: left;
}
.ws-list-row:active { background: var(--fill-4); }
.ws-list-main { flex: 1; min-width: 0; }
.ws-list-name { font-size: var(--t-callout); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-list-meta { font-size: var(--t-caption); color: var(--label-2); }

.ws-git-bar {
  display: flex;
  gap: var(--s2);
  padding: var(--s2) var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.ws-git-bar::-webkit-scrollbar { display: none; }
/* Чипы git-панели — подзаголовки-кнопки: ветка, история, stash. Высота
   цели 44 px, форма — пилюля, как у всех кнопок. */
.ws-git-bar .ws-chip {
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r-pill);
  font-size: var(--t-subhead);
  flex: none;
}
.ws-git-status { font-size: var(--t-subhead); line-height: var(--lh-subhead); color: var(--label); }
.ws-git-status:empty { display: none; }
.ws-git-files { display: flex; flex-direction: column; gap: 2px; }
.ws-git-file {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 46px;
  padding: 0 var(--s2);
  border-radius: var(--r-md);
}
.ws-git-file:active { background: var(--fill-4); }
.ws-git-file-main { display: flex; align-items: center; gap: var(--s2); flex: 1; min-width: 0; }
/* Путь — папка + имя файла двумя кусками (.path-dir / .path-base, как в
   проводнике): сжимается папка, имя остаётся целым. RTL-обрезка «с начала»
   переворачивала русские папки и знаки препинания. */
.ws-git-file-name {
  display: flex;
  align-items: baseline;
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  white-space: nowrap;
  overflow: hidden;
}
.ws-git-file-actions { display: flex; gap: 2px; flex: none; }
/* Поле коммита — стеклянный футер листа, как .modal-footer. */
.ws-git-commit {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  flex: none;
  padding: var(--s3) var(--gutter) calc(var(--s3) + var(--safe-bottom));
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: 0 -0.5px 0 var(--glass-hairline);
}
#ws-git-msg { min-height: 64px; resize: none; }
.ws-new-branch { display: flex; gap: var(--s2); }
.ws-mini-btn {
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: var(--r-pill);
  color: var(--label-2);
}
.ws-mini-btn:active { background: var(--fill-3); }
/* Текстовая мини-кнопка («Добавить всё», «Вернуть») — пилюля по ширине текста. */
.ws-mini-btn.text {
  width: auto;
  padding: 0 var(--s3);
  font-size: var(--t-subhead);
  font-weight: 590;
  letter-spacing: normal;
  text-transform: none;
  color: var(--accent);
  white-space: nowrap;
}

.ws-search-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--s2) var(--gutter);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}
.ws-search-box { display: flex; flex-wrap: wrap; gap: var(--s2); }
.ws-search-box > input[type="search"] { flex: 1 1 100%; min-width: 0; }
#ws-hub-search, #ws-search-input { border-radius: var(--r-lg); }
.ws-search-mode { display: flex; gap: var(--s2); margin-top: var(--s2); padding: 0 var(--s2); font-size: var(--t-footnote); color: var(--label-2); }
/* Статистика индекса живёт внутри липкой шапки поиска, под полем. */
.ws-search-hint {
  flex: 1 1 100%;
  padding: 0 var(--s2);
  font-size: var(--t-footnote);
  line-height: var(--lh-footnote);
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-search-hint:empty { display: none; }
.ws-search-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: var(--s3);
  border-radius: var(--r-md);
  text-align: left;
}
.ws-search-hit:active { background: var(--fill-4); }
.ws-search-hit-head { display: flex; align-items: center; gap: var(--s2); }
.ws-search-hit-conv { flex: 1; min-width: 0; font-size: var(--t-subhead); font-weight: 590; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-search-hit-meta { font-size: var(--t-caption); color: var(--label-3); }
.ws-search-hit-text {
  font-size: var(--t-footnote);
  line-height: 1.45;
  color: var(--label-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ws-search-hit-pc .ws-search-hit-conv::after {
  content: ' · с ПК';
  color: var(--label-3);
  font-weight: 400;
}
.ws-flash { animation: cm-flash 2s var(--ease); }
@keyframes cm-flash {
  0%, 70% { background: var(--accent-tint); }
  100% { background: transparent; }
}

/* Терминал. Клавиши-модификаторы крупные: попасть в Ctrl на телефоне
   иначе нельзя, а промах в терминале дорого стоит. */
.ws-term-modal { max-width: 720px; }
.ws-term-host {
  flex: 1;
  min-height: 0;
  padding: var(--s2);
  background: var(--code-bg);
}
.ws-term-keys {
  display: flex;
  gap: var(--s1);
  flex: none;
  padding: var(--s2) var(--gutter) calc(var(--s2) + var(--safe-bottom));
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.ws-term-keys::-webkit-scrollbar { display: none; }
.ws-key {
  min-width: var(--tap);
  height: var(--tap);
  flex: none;
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--label);
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  box-shadow: var(--shadow-1);
}
.ws-key:active { background: var(--fill-2); }
.ws-key.armed { background: var(--accent-fill); color: var(--on-accent); }
/* ============================================================================
 * 10. ВХОД, ЗАГРУЗКА, СЛУЖЕБНОЕ
 * ========================================================================= */

#login-screen {
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  background: var(--ground);
}
.login-container {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  width: 100%;
  max-width: 380px;
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.logo-icon { margin-bottom: var(--s1); }
.login-title {
  font-size: var(--t-title-1);
  line-height: var(--lh-title-1);
  letter-spacing: var(--tr-title-1);
  font-weight: 700;
}
.login-subtitle {
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  color: var(--label-2);
  text-align: center;
}
.login-form { display: flex; flex-direction: column; gap: var(--s4); }
.login-form .btn { width: 100%; }

/* Пара «код + вставить». Раньше набиралась инлайновыми стилями прямо в
   разметке, и кнопка выходила 38 px высотой при минимуме 44. */
.totp-row { display: flex; align-items: center; gap: var(--s2); }
.totp-row input { flex: 1; }
#totp-input {
  font-family: var(--font-mono);
  font-size: var(--t-title-3);
  letter-spacing: 0.28em;
  text-align: center;
}
#totp-paste-btn { flex: none; white-space: nowrap; }

/* --- Загрузочный экран --------------------------------------------------- */

.boot-overlay, .reload-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  background: var(--ground);
}
.reload-overlay { background: var(--scrim); z-index: 380; }
.boot-overlay.fading, .reload-overlay.fading {
  opacity: 0;
  transition: opacity var(--d-mid) var(--ease);
  pointer-events: none;
}
.boot-card, .reload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  max-width: 280px;
  text-align: center;
}
.reload-card {
  padding: var(--s6) var(--s5);
  border-radius: var(--r-sheet);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-3);
}
.boot-logo { margin-bottom: var(--s1); }
.boot-title {
  font-size: var(--t-title-3);
  line-height: var(--lh-title-3);
  font-weight: 700;
}
.boot-label, .reload-label {
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  color: var(--label-2);
}
.boot-bar { width: 100%; height: 4px; }
.boot-hint { font-size: var(--t-footnote); color: var(--label-3); }
.reload-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--fill-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cm-spin 800ms linear infinite;
}
.reload-force-reload { margin-top: var(--s2); }
/* Запасной вход — появляется только после нескольких неудачных попыток. */
.reload-alt-host { margin-top: var(--s1); }

/* --- Всплывающие сообщения ---------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s10) + var(--safe-bottom));
  z-index: 500;
  max-width: min(420px, calc(100vw - var(--s8)));
  padding: var(--s3) var(--s5);
  border-radius: var(--r-pill);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  color: var(--label);
  font-size: var(--t-subhead);
  line-height: var(--lh-subhead);
  text-align: center;
  box-shadow: var(--shadow-3);
  transform: translateX(-50%);
  animation: cm-toast var(--d-mid) var(--ease-out);
}
.toast.err { color: var(--red); }
.toast.ok { color: var(--green); }
@keyframes cm-toast {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Исчерпан лимит ------------------------------------------------------ */

#limit-modal-content { display: flex; flex-direction: column; }
#limit-modal-content .perm-body p { margin: 0; }
#limit-modal-content .perm-body p + p { margin-top: var(--s2); }
.limit-reset { color: var(--label-3); font-variant-numeric: tabular-nums; }
.sub-badge, .chip-name {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 640;
}

/* Стекло как отдельный класс — на случай, когда его вешают из кода. */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}

/* ============================================================================
 * 11. ШИРОКИЙ ЭКРАН
 *
 * Приложение сделано под телефон, но открывается и с компьютера. Задача
 * здесь одна и она из HIG: «ограничить ширину текста ради читаемости».
 * Растянутая на 27 дюймов строка не читается — поэтому колонка переписки
 * держит потолок ширины, а не разъезжается.
 * ========================================================================= */

@media (min-width: 900px) {
  #messages-container, #input-area > .input-wrapper {
    max-width: 780px;
    margin-left: auto;
    margin-right: auto;
  }
  #input-area { padding-left: var(--s5); padding-right: var(--s5); }
  .slash-popup { left: 50%; right: auto; width: min(780px, calc(100% - 40px)); transform: translateX(-50%); }
  #header { padding-left: var(--s4); padding-right: var(--s4); }
  /* На мыши уместна подсветка при наведении — на телефоне её не бывает. */
  .row:hover, .hub-row:hover, .convo-item:hover, .files-row:hover,
  .ws-list-row:hover, .model-row:hover { background: var(--fill-4); }
  .convo-item:hover .convo-actions .convo-rename,
  .convo-item:hover .convo-actions .convo-delete { display: inline-flex; }
  .icon-btn:hover, .attach-button:hover, .schedule-button:hover,
  .voice-button:hover { background: var(--fill-3); }
}

/* ============================================================================
 * 12. ДВИЖЕНИЕ И ДОСТУПНОСТЬ
 * ========================================================================= */

/* HIG: при включённом «уменьшении движения» заменять сдвиги на растворение,
   гасить пружины и не анимировать размытие. Полностью отключать анимацию
   нельзя — исчезнет обратная связь. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .modal-panel.slide-left, .modal-panel.slide-right,
  .modal-panel.slide-up, .modal-dialog {
    animation: cm-fade 0.15s ease !important;
  }
  .thumb-sheet-inner { transition: none; }
}

/* Повышенный контраст: убираем полупрозрачные подложки, которые в этом
   режиме перестают читаться. */
@media (prefers-contrast: more) {
  :root {
    --separator: rgba(20, 20, 34, 0.35);
    --label-2: #4a4a54;
    --label-3: #64646e;
    --glass: var(--ground);
    --glass-thick: var(--ground);
  }
  :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --separator: rgba(255, 255, 255, 0.4);
  }
  .btn-ghost { box-shadow: inset 0 0 0 1.5px currentColor; }
}

/* Экранный диктор: скрыто визуально, читается вслух. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
 * 13. ХВОСТ: контейнеры и мелочи, которые код создаёт на лету
 *
 * Собраны в конце намеренно — это не отдельные компоненты, а обёртки и
 * уточнения к тому, что уже описано выше. Держать их здесь дешевле, чем
 * размазывать по разделам: сразу видно, что осталось без собственного вида.
 * ========================================================================= */

.caps-body { display: flex; flex-direction: column; }
.detected-accounts { display: flex; flex-direction: column; gap: var(--s1); margin-top: var(--s2); }
.ws-projects { display: flex; flex-direction: column; gap: var(--s1); }
.ws-hub-body > * + * { margin-top: 0; }

.council-ask { display: flex; flex-direction: column; gap: var(--s3); }
/* Только textarea: div.council-question в результате получал те же 96 px пустоты. */
textarea.council-question, #council-question { min-height: 96px; }
.council-select { min-height: var(--tap); }

.codex-verdict-cell { display: flex; align-items: center; gap: var(--s1); }

.compact-confirm { background: var(--orange); color: #ffffff; }

.diff-file { border-radius: var(--r-md); overflow: hidden; }
.diff-file + .diff-file { margin-top: var(--s2); }

.file-viewer-footer {
  display: flex;
  gap: var(--s2);
  flex: none;
  padding: var(--s3) var(--gutter) calc(var(--s3) + var(--safe-bottom));
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: 0 -0.5px 0 var(--glass-hairline);
}
.file-viewer-footer > .btn { flex: 1; }

/* Выбор папки и просмотр сессии — высокие шторки: в них листают длинные
   списки, и половина экрана делает их бесполезными. */
.folder-picker-panel, .pc-preview-panel { max-height: calc(100% - var(--safe-top) - var(--s3)) !important; }

.pc-folder-chip-ic { flex: none; color: var(--label-2); }

.thumb-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex: none;
  color: var(--label-2);
}

.ws-sheet-tools { display: flex; gap: var(--s2); flex: none; }

/* Строка кнопок под панелью сессий — раньше её кнопки были 34 px в высоту. */
.session-btn-row { flex-wrap: wrap; }
.session-btn-row > .btn { flex: 1 1 46%; }

/* ============================================================================
 * 14. УТОЧНЕНИЯ К НОВОЙ СТРУКТУРЕ
 * ========================================================================= */

/* Эти кнопки остаются в DOM как цели: строки мастерской жмут их через
   .click(), и вся логика открытия панелей не тронута. В шапке они не
   показываются — видимый вход в каждую функцию ровно один.
   #workspace-btn вставляет сюда workspace.js; ему место в строке
   «Проекты», а не четвёртой кнопкой в шапке. */
#header .header-right > #files-toggle,
#header .header-right > #settings-btn,
#header .header-right > #workspace-btn { display: none; }

/* Лист «этот диалог» — не .thumb-sheet, но выезжает так же. Без этого
   правила его внутренняя часть осталась бы сдвинутой на 100% вниз,
   то есть за экраном. */
.context-popover .thumb-sheet-inner {
  transform: none;
  animation: cm-slide-up var(--d-mid) var(--ease-out);
}
.context-popover .thumb-sheet-inner.dragging { animation: none; }
.context-block { padding-bottom: var(--s4); }
/* (.sidebar-search и #sidebar .modal-body — в разделе «Диалоги».) */

/* Мелкие вертикальные отступы, которые раньше были разбросаны
   инлайновыми стилями по разметке. */
.stack-4 { margin-top: var(--s1); }
.stack-8 { margin-top: var(--s2); }
.align-start { text-align: left; }
.align-center { text-align: center; }

/* ============================================================================
 * 15. НАЙДЕННОЕ ПРОВЕРКОЙ ПОКРЫТИЯ
 *
 * Эти классы код рисует внутри шаблонных строк, и в разметке их нет —
 * поэтому глазами они не находятся. Их нашла проверка «все классы, которыми
 * пользуется код, описаны в стилях»: без неё эти куски интерфейса остались
 * бы неоформленными до первой жалобы.
 * ========================================================================= */

/* Строка аккаунта в сводке настроек. */
.acc-summary-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 38px;
}
.acc-summary-row + .acc-summary-row { box-shadow: inset 0 0.5px 0 var(--separator); }
.acc-summary-row.last { box-shadow: none; }

/* Карточка агента на доске. */
.agent-card {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface-hi);
}
.agent-card + .agent-card { margin-top: var(--s2); }
.agent-card.agent-open { box-shadow: inset 0 0 0 1.5px var(--accent-tint); }
.agent-card.agent-bg .agent-title::after {
  content: ' · в фоне';
  color: var(--label-2);
  font-weight: 400;
}

/* Состояние агента в шапке его окна. */
.agent-meta-status {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 640;
}
.agent-meta-running { background: var(--accent-tint); color: var(--accent); }
.agent-meta-done { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.agent-meta-error { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

/* Состояние MCP-сервера. */
.mcp-status {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--t-caption-2);
  font-weight: 640;
}
.mcp-connected { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.mcp-failed { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.mcp-needs-auth { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.mcp-pending { color: var(--label-2); }
.mcp-disabled { color: var(--label-3); }

/* Заголовки внутри ответа модели, которые ставит собственный разбор
   markdown (класс проставляется кодом, тег выбирается по числу решёток). */
.md-h { font-weight: 680; letter-spacing: var(--tr-title-3); }

/* Реплика в читалке сессии с ПК. */
.pc-prev-msg {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s2) 0;
}
.pc-prev-msg + .pc-prev-msg { box-shadow: inset 0 0.5px 0 var(--separator); }

/* Строка отложенного сообщения. */
.scheduled-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 50px;
  padding: var(--s1) var(--s2);
  border-radius: var(--r-md);
  background: var(--surface);
}

/* Точка состояния в списках (аккаунты, сессии). */
.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--label-3);
}

/* Строка листа выбора модели. */
.thumb-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 54px;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-md);
  text-align: left;
}
.thumb-row:active { background: var(--fill-4); }

/* Пункт плана: в липкой шапке и внутри развёрнутого инструмента. */
.todo-item, .tp-todo {
  display: flex;
  gap: var(--s2);
  font-size: var(--t-footnote);
  line-height: 1.5;
  color: var(--label-2);
}
.tp-todo-in_progress, .todo-item.live { color: var(--label); font-weight: 590; }
.tp-todo-completed { color: var(--label-3); }

/* Состояние файла в git — чип со словом («изменён», «новый», «удалён»). */
.ws-git-file-status {
  flex: none;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--fill-3);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  font-weight: 590;
  color: var(--label-2);
  white-space: nowrap;
}
.ws-git-file-status.st-new { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.ws-git-file-status.st-del, .ws-git-file-status.st-conflict { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.ws-git-file-status.st-ren { background: var(--accent-tint); color: var(--accent); }

/* Строка проекта в списке. */
.ws-project-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.ws-project-row + .ws-project-row { margin-top: var(--s1); }
