/* ============================================================
   Claude — стили Mini App (референс: мобильное приложение Anthropic)
   ============================================================ */

/* ---------- Токены ---------- */
:root {
  /* Светлая палитра Claude: тёплое кремовое полотно вместо стерильно-белого,
     фирменный терракотовый акцент. Снято со скриншотов приложения 07-26. */
  --bg: #faf9f5;
  --bg-elev: #ffffff;
  --bg-sheet: #ffffff;
  --bg-settings: #f0eee6;
  --text: #1f1e1d;
  --text-2: #83827d;
  --text-3: #b6b4ad;
  --line: rgba(0, 0, 0, 0.09);
  --bubble: #f0eee6;
  --chip: #f0eee6;
  --brand: #d97757; /* терракота Anthropic */
  --danger: #bf4d43;
  --code-bg: #f5f4ee;
  --code-head: #eceade;
  --send-bg: #1f1e1d;
  --send-fg: #ffffff;
  --scrim: rgba(0, 0, 0, 0.4);
  --attach-scrim: rgba(250, 249, 245, 0.5);
  /* многослойные мягкие тени + «стекло» (frosted glass, iOS) */
  --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.03), 0 2px 6px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 2px 10px rgba(0, 0, 0, 0.08), 0 24px 70px rgba(0, 0, 0, 0.22);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.55);
  /* пружины Apple: sheet-кривая + лёгкий overshoot для мелких элементов */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --spring-pop: cubic-bezier(0.34, 1.3, 0.5, 1);
  --sbw: min(84vw, 340px);
  /* fullscreen Telegram: --tg-sat/--tg-sab ставит JS из safeArea+contentSafeArea */
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-sat, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-sab, 0px));

  /* галочки и тумблеры в оригинале системно-синие, акцент бренда — терракота */
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  /* кольцо «пустых» кнопок и карточка-на-карточке (списки внутри шторок) */
  --ring: rgba(0, 0, 0, 0.14);
  --card-2: #f2f1ec;
  /* приветствие пустого экрана — приглушённо-кремовое, не чисто белое/чёрное */
  --hello-fg: #4a4944;
}

[data-accent="purple"]  { --accent: #af52de; --accent-soft: rgba(175, 82, 222, 0.13); }
[data-accent="green"]   { --accent: #34c759; --accent-soft: rgba(52, 199, 89, 0.14); }
[data-accent="orange"]  { --accent: #d97757; --accent-soft: rgba(217, 119, 87, 0.16); }
[data-accent="pink"]    { --accent: #ff2d55; --accent-soft: rgba(255, 45, 85, 0.12); }
[data-accent="graphite"]{ --accent: #6b6b70; --accent-soft: rgba(107, 107, 112, 0.14); }

[data-theme="dark"] {
  /* Тёмная Claude — не нейтрально-серая, а тёплая: почти чёрное полотно,
     чуть более светлые панели и шторки. */
  --bg: #1f1e1d;
  --bg-elev: #262624;
  --bg-sheet: #262624;
  --bg-settings: #141413;   /* сайдбар — самый тёмный слой, как в оригинале */
  --text: #f5f4ef;
  --text-2: #9a9791;
  --text-3: #625f5a;
  --line: rgba(255, 255, 255, 0.1);
  --bubble: #2f2e2b;
  --chip: #35342f;
  --code-bg: #141413;
  --code-head: #2a2926;
  --send-bg: #f5f4ef;
  --send-fg: #1f1e1d;
  --scrim: rgba(0, 0, 0, 0.58);
  --attach-scrim: rgba(20, 20, 19, 0.5);
  --ring: rgba(255, 255, 255, 0.14);
  --card-2: #30302d;
  --hello-fg: #c9c7bc;
  --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.28), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 2px 10px rgba(0, 0, 0, 0.4), 0 24px 70px rgba(0, 0, 0, 0.6);
  --glass: rgba(44, 44, 46, 0.68);
  --glass-brd: rgba(255, 255, 255, 0.09);
}

/* ---------- База ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit;
  transition: opacity 0.3s ease, transform 0.35s var(--spring-pop); }
button:active { opacity: 0.75; transition-duration: 0.05s, 0.05s; }
/* компактные кнопки пружинно «утапливаются» под пальцем */
.circle-btn:active, #btn-send:active, #scroll-down:active, .msg-actions button:active,
#btn-attach:active, #btn-mic:active, .codeblock-copy:active { transform: scale(0.88); opacity: 1; }
#model-pill:active, #limits-pill:active, .mode-pill:active, .chip.chip-mode:active,
#btn-new-chat:active, .shop-chip:active, .sheet-btn:active { transform: scale(0.96); opacity: 1; }
.shop-pack:active, .proj-row:active { transform: scale(0.98); opacity: 1; }
/* широкие строки-ячейки подсвечиваются как в iOS, без масштаба */
.as-row:active, .model-row:active, .suggestion:active, .sb-nav button:active, .chat-row:active, .row:active {
  background: var(--chip); opacity: 1;
}
textarea, input { font-family: inherit; }
.flex-1 { flex: 1; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- Круглые кнопки ----------
   В оригинале Claude кнопки шапки — «пустые»: прозрачный фон, тонкое кольцо,
   без теней и стекла. */
.circle-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: transparent; border: 1px solid var(--ring);
  display: grid; place-items: center; color: var(--text); flex-shrink: 0;
}
.topbar .circle-btn { background: color-mix(in srgb, var(--bg) 55%, transparent); }

/* ============================================================
   ОСНОВНОЙ ЭКРАН
   ============================================================ */
#screen-main {
  position: fixed; inset: 0;
  height: var(--tg-viewport-height, 100dvh);
  display: flex; flex-direction: column;
  background: var(--bg);
  z-index: 10;
  transition: transform 0.46s var(--spring), border-radius 0.46s var(--spring), background-color 0.35s ease;
  will-change: transform;
}
body.sb-open #screen-main {
  transform: translateX(var(--sbw));
  border-radius: 26px;
  overflow: hidden;
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.14);
}
#main-scrim { position: absolute; inset: 0; z-index: 60; background: transparent; }

/* ---------- Верхняя панель ----------
   плавает над лентой (как контролы Apple Maps): чат скроллится ПОД
   стеклянными пилюлями — блюр реально работает */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 10px) 12px 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
/* Пилюля модели у Claude переехала в композер (см. блок «Композер Claude»),
   в шапке остаётся только счётчик лимитов — стеклянный, как круглые кнопки. */
#limits-pill {
  height: 40px; border-radius: 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.7); backdrop-filter: blur(20px) saturate(1.7);
  box-shadow: var(--shadow-1), inset 0 0 0 0.5px var(--glass-brd);
  display: flex; align-items: center; flex-shrink: 0;
  gap: 6px; padding: 0 13px 0 11px;
  font-size: 15px; font-weight: 650; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
#limits-pill .lp-ic { display: grid; place-items: center; color: var(--brand); flex-shrink: 0; }
#limits-pill.low { color: var(--danger); }
#limits-pill.low .lp-ic { color: var(--danger); }

/* ---------- Лента чата ---------- */
#chat-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 62px) 16px 10px;
  scrollbar-width: none;
}
#chat-scroll::-webkit-scrollbar { display: none; }

#empty-state {
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding-bottom: 4px;
}
#empty-state.center { justify-content: center; }

/* Приветствие пустого чата: терракотовая звезда и засечный заголовок —
   визитная карточка оригинала. Текст приглушённо-кремовый, не чисто белый. */
#hello { margin: auto; text-align: center; padding-bottom: 10vh; }
#hello .hello-ic { width: 46px; height: 46px; margin: 0 auto 18px; color: var(--brand);
  display: grid; place-items: center; }
#hello .hello-ic svg { width: 44px; height: 44px; }
#hello h2 {
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  font-size: 33px; font-weight: 400; margin: 0; letter-spacing: -0.2px; color: var(--hello-fg);
}

#temp-banner { text-align: center; max-width: 360px; margin: auto; padding-bottom: 12vh; }
#temp-banner .ghost-big { color: var(--text); margin: 0 auto 18px; width: 44px; height: 44px; }
#temp-banner .ghost-big svg { width: 44px; height: 44px; }
#temp-banner p { font-size: 15.5px; line-height: 1.55; color: var(--text-2); margin: 0; }

/* заголовок «Чат инкогнито» в шапке */
#topbar-title { font-size: 16px; font-weight: 550; color: var(--text); white-space: nowrap; }

.suggestion {
  display: flex; align-items: center; gap: 16px;
  padding: 13px 8px; font-size: 16px; color: var(--text);
  text-align: left; width: 100%;
  border-radius: 16px;
  animation: rise-in 0.5s var(--spring) both;
}
/* каскадный вход подсказок пустого экрана */
#suggestions > *:nth-child(1) { animation-delay: 0.03s; }
#suggestions > *:nth-child(2) { animation-delay: 0.08s; }
#suggestions > *:nth-child(3) { animation-delay: 0.13s; }
#suggestions > *:nth-child(4) { animation-delay: 0.18s; }
#hello { animation: rise-in 0.55s var(--spring) both; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.suggestion .ic { width: 26px; height: 26px; color: var(--text); opacity: 0.9; flex-shrink: 0; }
/* «Искать в интернете» строкой-тумблером */
.suggestion.sg-toggle { gap: 16px; }
.sg-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sg-col small { font-size: 12.5px; color: var(--text-2); margin-top: 1px; line-height: 1.3; }
.suggestion.sg-toggle .switch { flex-shrink: 0; }

/* пилюля выбора режима-персоны (над подсказками пустого экрана) */
/* подложка заметно темнее фона — раньше сливалась (фидбек 07-18) */
.mode-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, 0.08); color: var(--text); border-radius: 20px;
  padding: 9px 14px; font-size: 15px; font-weight: 550; margin: 0 0 8px;
}
[data-theme="dark"] .mode-pill { background: rgba(255, 255, 255, 0.12); }
.mode-pill.on { background: var(--accent-soft); color: var(--accent); }
.mode-pill .ic { width: 20px; height: 20px; flex-shrink: 0; }
.mode-pill .mp-chev { display: grid; place-items: center; opacity: 0.6; }

/* запись голоса: waveform + таймер + кнопки поверх поля ввода */
.input-card.recording #btn-attach, .input-card.recording #input, .input-card.recording #model-pill,
.input-card.recording #btn-mic, .input-card.recording #btn-send { visibility: hidden; }
.rec-ov {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 12px;
  padding: 0 8px; border-radius: 30px; background: var(--bg-elev);
}
.rec-cancel, .rec-done { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.rec-cancel { color: var(--text-2); }
.rec-done { background: var(--accent); color: #fff; }
.rec-wave { flex: 1; display: flex; align-items: center; justify-content: center; gap: 2.5px; height: 34px; overflow: hidden; padding: 0 4px; }
.rec-wave i {
  width: 3px; height: 26px; border-radius: 3px; flex-shrink: 0;
  background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 70%, #fff));
  transform: scaleY(0.22); transform-origin: center;
  animation-name: recbar; animation-timing-function: cubic-bezier(.4,0,.2,1); animation-iteration-count: infinite;
}
@keyframes recbar { 0%, 100% { transform: scaleY(0.2); } 50% { transform: scaleY(var(--peak, 1)); } }
.rec-time { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 40px; text-align: center; flex-shrink: 0; }

/* ---------- Сообщения ---------- */
#messages { padding-top: 6px; }
.msg { margin: 5px 0; animation: msg-in 0.45s var(--spring) both; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg.user .bubble {
  background: var(--bubble); color: var(--text);
  border-radius: 22px; padding: 10px 16px;
  max-width: 85%; font-size: 16px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  user-select: text; -webkit-user-select: text;
}
.msg.user .u-imgs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg.user .u-imgs img { max-width: 170px; max-height: 170px; border-radius: 16px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--chip); border-radius: 14px; padding: 9px 13px;
  font-size: 14px; color: var(--text); max-width: 230px;
}
.file-chip .ic { width: 18px; color: var(--text-2); flex-shrink: 0; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg.assistant { padding: 6px 0 2px; }
.typing-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--text);
  margin: 8px 2px; animation: pulse 1s ease-in-out infinite; flex-shrink: 0;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.82); } }

/* индикаторы ожидания: «Думаю…» (текст) и скелетон с иконкой (картинка) */
.pending-ind[data-mode="txt"] { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.think-shimmer {
  font-size: 15px; font-weight: 500;
  background: linear-gradient(90deg, var(--text-2) 35%, var(--text) 50%, var(--text-2) 65%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: shimmer 1.5s linear infinite;
}
.img-skel {
  width: min(100%, 300px); aspect-ratio: 1 / 1; border-radius: 18px; margin: 8px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(110deg, var(--chip) 42%, var(--bg-elev) 50%, var(--chip) 58%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
  color: var(--text-2);
}
.img-skel span { font-size: 13.5px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.gen-img { border-radius: 18px; max-width: min(100%, 340px); display: block; margin: 8px 0; }

/* ---------- Markdown ---------- */
.md { font-size: 17px; line-height: 1.55; word-wrap: break-word; user-select: text; -webkit-user-select: text; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1 { font-size: 21px; margin: 18px 0 10px; }
.md h2 { font-size: 19px; margin: 16px 0 8px; }
.md h3, .md h4 { font-size: 17.5px; margin: 14px 0 6px; }
.md ul, .md ol { margin: 10px 0 12px; padding-left: 24px; }
.md li { margin: 5px 0; }
.md li::marker { color: var(--text-2); }
.md blockquote { border-left: 3px solid var(--text-3); margin: 12px 0; padding: 2px 0 2px 14px; color: var(--text-2); }
.md a { color: var(--accent); text-decoration: none; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.md img { max-width: 100%; border-radius: 14px; }
.md code { background: var(--chip); border-radius: 6px; padding: 2px 6px; font-size: 14.5px;
  font-family: "SF Mono", ui-monospace, Consolas, Menlo, monospace; }
.md pre code { background: none; padding: 0; font-size: 13.5px; }
.md table { border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; font-size: 15px; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.md th { background: var(--chip); font-weight: 600; }

.codeblock { margin: 12px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--code-bg); }
.codeblock-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 6px 5px 14px; background: var(--code-head);
  font-size: 12.5px; color: var(--text-2);
}
.codeblock-copy { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); padding: 5px 9px; border-radius: 8px; }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; line-height: 1.5; }

/* источники веб-поиска */
.sources-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px 0 2px; scrollbar-width: none; }
.sources-row::-webkit-scrollbar { display: none; }
.source-chip {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--chip); border-radius: 16px; padding: 7px 13px;
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.source-chip .ic { width: 14px; }

/* действия под ответом */
.msg-actions { display: flex; gap: 2px; margin-top: 6px; }
.msg-actions button { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); }
.msg-actions button.busy { opacity: 0.45; pointer-events: none; }
/* озвучка: пока синтезируем — кнопка пульсирует, во время проигрывания подсвечена */
.msg-actions button.loading { opacity: 0.5; pointer-events: none; animation: tts-pulse 1.1s ease-in-out infinite; }
.msg-actions button.speaking { color: var(--accent); background: var(--accent-soft, rgba(30, 155, 233, 0.12)); }
@keyframes tts-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.75; } }
/* кнопка правки под своим вопросом — прижата вправо, проявляется мягко */
.msg.user .u-actions { justify-content: flex-end; margin-top: 2px; opacity: 0.55; transition: opacity 0.2s var(--spring); }
.msg.user .u-actions button { width: 32px; height: 32px; }
.msg.user:hover .u-actions, .msg.user.editing .u-actions { opacity: 1; }

/* режим правки своего сообщения (как в ChatGPT) */
.edit-box {
  width: 100%; max-width: 85%; margin-left: auto;
  background: var(--bubble); border-radius: 22px; padding: 12px 14px 10px;
  animation: pop-in 0.22s var(--spring-pop);
}
.edit-box textarea {
  width: 100%; border: none; outline: none; resize: none; background: transparent;
  color: var(--text); font: inherit; font-size: 16px; line-height: 1.5;
  user-select: text; -webkit-user-select: text;
}
.edit-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.edit-row button { border-radius: 999px; padding: 8px 16px; font-size: 15px; font-weight: 500; }
.edit-cancel { background: transparent; color: var(--text-2); }
.edit-save { background: var(--send-bg); color: var(--send-fg); font-weight: 600; }
.edit-save:active { opacity: 0.85; }

/* карточка ошибки */
.error-card {
  background: rgba(255, 59, 48, 0.07); border: 1px solid rgba(255, 59, 48, 0.22);
  border-radius: 16px; padding: 13px 15px; margin: 8px 0; font-size: 15px;
}
.error-card .retry { margin-top: 8px; color: var(--accent); font-weight: 600; font-size: 15px; display: flex; gap: 6px; align-items: center; }

/* кнопка вниз — стеклянная, над контентом */
#scroll-down {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 108px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.7); backdrop-filter: blur(20px) saturate(1.7);
  box-shadow: var(--shadow-1), inset 0 0 0 0.5px var(--glass-brd);
  display: grid; place-items: center; color: var(--text); z-index: 20;
  /* backwards (не both): fill-режим не должен блокировать :active-transform после конца */
  animation: pop-in 0.4s var(--spring-pop) backwards;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.6); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
#scroll-down:active { transform: translateX(-50%) scale(0.88); }

/* ============================================================
   КОМПОЗЕР
   ============================================================ */
#composer {
  flex-shrink: 0; padding: 6px 12px calc(var(--safe-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 78%, transparent);
  position: relative; z-index: 45; /* выше блюра меню вложений — как в оригинале */
}
#chips-row { display: flex; gap: 8px; padding: 2px 6px 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--accent);
  padding: 8px 13px; border-radius: 18px; font-size: 14.5px; font-weight: 550;
}
.chip .ic { width: 17px; }
.chip .rm { display: grid; place-items: center; width: 18px; height: 18px; }
/* чип активного режима — тап открывает выбор (без крестика) */
.chip.chip-mode { cursor: pointer; }

#previews-row { display: flex; gap: 10px; padding: 2px 6px 10px; flex-wrap: wrap; }
.preview-thumb { position: relative; width: 64px; height: 64px; }
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.preview-rm {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(20, 20, 22, 0.85); color: #fff;
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.preview-file { position: relative; }
.preview-file .preview-rm { top: -9px; right: -9px; }

/* Композер Claude — карточка со скруглением 28px: поле ввода сверху, ряд
   управления снизу. Плюс — «пустой» с кольцом, пилюля модели темнее карточки,
   микрофон без фона, справа белый круг с волной. Всё как на скриншотах. */
.input-card {
  position: relative; background: var(--bg-elev); border-radius: 28px;
  border: 1px solid var(--ring); box-shadow: var(--shadow-1);
  padding: 8px 10px 10px; transition: box-shadow 0.35s ease, border-color 0.3s ease;
}
.input-card:focus-within { border-color: rgba(217, 119, 87, 0.45); }
.input-row { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
#btn-attach {
  width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 1px solid var(--ring);
  display: grid; place-items: center; color: var(--text); flex-shrink: 0;
}
#input {
  display: block; width: 100%; border: none; outline: none; background: transparent; resize: none;
  font-size: 17.5px; line-height: 23px; padding: 12px 10px 8px; margin: 0;
  color: var(--text); max-height: 134px;
  /* caret не наследовал color в Telegram WebView → курсор «|» был невидим */
  caret-color: var(--brand);
  -webkit-text-fill-color: var(--text);
}
#input::placeholder { color: var(--text-2); -webkit-text-fill-color: var(--text-2); }

/* пилюля модели: заметно темнее карточки композера (в оригинале она «утоплена») */
#model-pill {
  height: 40px; padding: 0 15px; border-radius: 20px; background: var(--bg);
  display: inline-flex; align-items: center; gap: 7px; max-width: 54vw;
  font-size: 15.5px; font-weight: 550; color: var(--text); flex-shrink: 0;
}
[data-theme="dark"] #model-pill { background: #1b1a19; }
#model-pill-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#model-pill-effort { color: var(--text-2); font-weight: 450; font-size: 14.5px; flex-shrink: 0; }

#btn-mic { width: 40px; height: 40px; display: grid; place-items: center;
  color: var(--text-2); flex-shrink: 0; }
#btn-send {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  transition: background 0.25s ease, color 0.25s ease, transform 0.35s var(--spring-pop), opacity 0.3s ease;
}
/* в покое — белый кружок с волной (голос), при наборе — терракотовая отправка */
#btn-send.mode-voice { background: var(--send-bg); color: var(--send-fg); }
#btn-send.mode-send, #btn-send.mode-stop { background: var(--brand); color: #fff; }
#btn-send.mode-disabled { background: var(--send-bg); color: var(--send-fg); opacity: 0.9; }

/* ============================================================
   ПОПАП ВЛОЖЕНИЙ
   ============================================================ */
#attach-scrim {
  position: absolute; inset: 0; z-index: 40;
  background: var(--attach-scrim);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  opacity: 0; transition: opacity 0.22s;
}
#attach-scrim.show { opacity: 1; }
#attach-pop {
  position: absolute; z-index: 50; left: 16px;
  bottom: calc(var(--safe-bottom) + 92px);
  width: 296px; background: var(--bg-elev); border-radius: 30px;
  padding: 14px 10px; box-shadow: var(--shadow-2);
  transform-origin: 15% 100%;
  transform: scale(0.5) translateY(12px); opacity: 0;
  transition: transform 0.4s var(--spring-pop), opacity 0.22s ease;
}
#attach-pop.show { transform: scale(1); opacity: 1; }
#attach-pop button {
  display: flex; align-items: center; gap: 18px; width: 100%;
  padding: 9px 12px; font-size: 19px; color: var(--text);
}
#attach-pop .ic {
  width: 46px; height: 46px; border-radius: 50%; background: var(--chip);
  display: grid; place-items: center; flex-shrink: 0;
}
#attach-pop .ap-lbl { flex: 1; text-align: left; } /* мини-тумблер прижат вправо */

/* ============================================================
   БОКОВОЕ МЕНЮ
   ============================================================ */
#sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sbw);
  height: var(--tg-viewport-height, 100dvh);
  display: flex; flex-direction: column;
  padding-top: calc(var(--safe-top) + 8px);
  z-index: 5; visibility: hidden;
}
body.sb-open #sidebar, body.sb-anim #sidebar { visibility: visible; }

.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 4px 20px; }
/* «Claude» — фирменным засечным начертанием, как вордмарк в оригинале */
.sb-head h1 {
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  font-size: 30px; font-weight: 500; letter-spacing: -0.2px; margin: 0;
}

.sb-scroll { flex: 1; overflow-y: auto; padding-bottom: 120px; scrollbar-width: none; }
.sb-scroll::-webkit-scrollbar { display: none; }

/* строки меню — «вставные» скругления как в списках iOS */
.sb-nav button {
  display: flex; align-items: center; gap: 18px; width: calc(100% - 20px);
  margin: 0 10px; border-radius: 14px;
  padding: 12px 10px; font-size: 19px; color: var(--text); text-align: left;
}
.sb-nav .ic { width: 26px; height: 26px; flex-shrink: 0; }

/* поиск по чатам — как строка поиска iOS */
.sb-search {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 16px 0; padding: 0 10px;
  height: 38px; border-radius: 12px; background: var(--chip);
}
.sb-search .ic { color: var(--text-2); flex-shrink: 0; display: grid; place-items: center; }
.sb-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 16px; color: var(--text); caret-color: var(--brand);
  -webkit-appearance: none; appearance: none;
}
.sb-search input::-webkit-search-cancel-button { display: none; }
.sb-search input::placeholder { color: var(--text-2); }
.sb-search-x { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }

.sb-recent-title { font-size: 20px; font-weight: 700; margin: 0; padding: 20px 20px 6px; }
.chat-row {
  display: flex; align-items: center; width: calc(100% - 20px);
  margin: 0 10px; border-radius: 14px;
  padding: 12.5px 10px; font-size: 17px; color: var(--text); text-align: left;
}
.chat-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.active { background: var(--chip); }
.sb-empty { padding: 14px 20px; color: var(--text-2); font-size: 15.5px; }

.sb-footer {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px calc(var(--safe-bottom) + 18px);
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.sb-footer > * { pointer-events: auto; }
/* «+ Новый чат» — белая пилюля, как в оригинале (в светлой теме — чёрная) */
#btn-new-chat {
  display: flex; align-items: center; gap: 9px;
  height: 52px; padding: 0 24px; border-radius: 26px;
  background: var(--send-bg); color: var(--send-fg); font-size: 17.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
#btn-new-chat .ic { width: 22px; height: 22px; }
#btn-settings { width: 48px; height: 48px; }

/* ============================================================
   ШТОРКИ / МОДАЛКИ / ТОСТЫ
   ============================================================ */
.layer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 70; opacity: 0; transition: opacity 0.38s ease; }
.layer-scrim.show { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
  background: var(--bg-sheet); border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 44px rgba(0, 0, 0, 0.14);
  transform: translateY(105%); transition: transform 0.5s var(--spring);
  max-height: 88dvh; display: flex; flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 10px);
}
.sheet.show { transform: none; }
.sheet-grab { width: 44px; height: 4px; border-radius: 2px; background: var(--text-3); margin: 10px auto 2px; flex-shrink: 0; }
/* шапка шторки: слева круглая X/назад, заголовок по центру — как в оригинале */
.sheet-head { position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 4px 60px 2px; flex-shrink: 0; }
.sheet-close { position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--ring);
  display: grid; place-items: center; color: var(--text); }
.sheet-close:active { transform: translateY(-50%) scale(0.9); }
.sheet-title { font-size: 20px; font-weight: 650; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 8px 16px 16px; }

/* строки экшен-меню */
.as-row {
  display: flex; align-items: center; gap: 15px; width: 100%;
  padding: 14px 8px; font-size: 17.5px; color: var(--text); text-align: left;
  border-radius: 12px;
}
.as-row .ic { width: 24px; height: 24px; flex-shrink: 0; }
.as-row.danger { color: var(--danger); }

/* Список моделей — карточка ЧУТЬ СВЕТЛЕЕ шторки (в оригинале списки «приподняты»),
   разделители не на всю ширину. */
.model-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 18px;
  text-align: left; background: var(--card-2); position: relative; }
.model-row:first-of-type { border-radius: 18px 18px 0 0; }
.model-row:last-of-type { border-radius: 0 0 18px 18px; }
.model-row + .model-row::before { content: ''; position: absolute; top: 0; left: 18px; right: 18px;
  height: 1px; background: var(--line); }
.model-info { flex: 1; min-width: 0; }
.model-name { font-size: 17.5px; font-weight: 500; display: flex; align-items: center; gap: 9px; }
.model-tag { font-size: 13.5px; color: var(--text-2); margin-top: 3px; }
.model-check { width: 24px; color: var(--accent); visibility: hidden; }
.model-row.sel .model-check { visibility: visible; }
/* плашка «По умолчанию» рядом с названием уровня */
.model-badge {
  font-size: 12px; font-weight: 500; color: var(--text-2);
  background: var(--chip); padding: 3px 9px; border-radius: 10px;
}
/* строка-переход (Уровень размышлений / Ещё модели) — отдельная карточка */
.row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 16px 18px;
  border-radius: 18px; background: var(--card-2); text-align: left; }
.row-lbl { flex: 1; font-size: 17.5px; }
.row-val { color: var(--text-2); font-size: 16px; }
.row-chev { color: var(--text-3); display: grid; place-items: center; }
.sheet-note { text-align: center; font-size: 13px; color: var(--text-2); padding: 12px 16px 4px; line-height: 1.45; }

/* Шторка «Добавить в чат»: плитки + карточки-списки, как в оригинале */
.at-tiles { display: flex; gap: 10px; padding-bottom: 12px; }
.at-tile {
  width: 104px; height: 128px; border-radius: 20px; background: var(--card-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-size: 15.5px; font-weight: 550; color: var(--text);
}
.at-tile:active { transform: scale(0.96); }
.at-card { border-radius: 18px; overflow: hidden; margin-bottom: 12px; background: var(--card-2); }
.at-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 18px;
  text-align: left; position: relative; }
.at-row + .at-row::before { content: ''; position: absolute; top: 0; left: 54px; right: 0;
  height: 1px; background: var(--line); }
.at-row .ic { width: 24px; display: grid; place-items: center; color: var(--text); flex-shrink: 0; }
.at-lbl { flex: 1; font-size: 17px; }
.at-val { color: var(--text-2); font-size: 15.5px; }
.at-chev { color: var(--text-3); display: grid; place-items: center; }

/* кнопки в шторках */
.sheet-btn {
  display: block; width: 100%; padding: 15px; border-radius: 16px;
  background: var(--send-bg); color: var(--send-fg);
  font-size: 17px; font-weight: 600; text-align: center; margin-top: 10px;
}
.sheet-btn.danger { background: var(--danger); color: #fff; }
.sheet-btn.plain { background: var(--chip); color: var(--text); }

.sheet-input {
  width: 100%; border: none; outline: none; background: var(--chip);
  border-radius: 14px; padding: 14px 16px; font-size: 17px; color: var(--text);
}
textarea.sheet-input { min-height: 110px; resize: none; line-height: 1.45; }
.sheet-label { font-size: 13.5px; color: var(--text-2); margin: 14px 4px 7px; }

/* переключатель: пружинный knob + мягкое свечение при активации (фидбек 07-19) */
.switch {
  width: 51px; height: 31px; border-radius: 16px; background: var(--text-3);
  position: relative; flex-shrink: 0;
  transition: background 0.25s ease, box-shadow 0.35s ease;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 27px;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.44, 1), width 0.18s ease;
}
.switch:active .knob { width: 32px; } /* knob слегка растягивается под пальцем, как в iOS */
.switch.on { background: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 38%, transparent); }
.switch.on .knob { transform: translateX(20px); }
.switch.on:active .knob { transform: translateX(15px); }
/* компактный вариант (попап «+») */
.switch.sm { width: 40px; height: 25px; }
.switch.sm .knob { width: 21px; height: 21px; }
.switch.sm:active .knob { width: 21px; }
.switch.sm.on .knob { transform: translateX(15px); }

/* полноэкранные модалки */
.modal {
  position: fixed; inset: 0; z-index: 80; background: var(--bg-settings);
  transform: translateY(100%); transition: transform 0.48s var(--spring);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal.show { transform: none; }
.modal-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center;
  padding: calc(var(--safe-top) + 12px) 16px 10px;
  background: var(--bg-settings); /* непрозрачный — заголовок/крест не наезжают на текст при скролле */
}
.modal-title { font-size: 20px; font-weight: 700; margin: 0 auto 0 6px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 0 0 calc(var(--safe-bottom) + 30px); }

/* ---------- Настройки ---------- */
.set-avatar { width: 96px; height: 96px; margin: 4px auto 12px; position: relative; }
.set-avatar img, .set-avatar .initials { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.set-avatar .initials { background: #7d8b8f; color: #fff; font-size: 36px; font-weight: 600; display: grid; place-items: center; }
.set-avatar .pencil {
  position: absolute; right: -4px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-elev); box-shadow: var(--shadow-1); display: grid; place-items: center; color: var(--text);
}
.set-name { text-align: center; font-size: 22px; font-weight: 700; margin: 0 0 6px; }
/* заголовки секций настроек — мелкие серые, как в оригинале («Account», «App») */
.set-label { font-size: 15px; font-weight: 500; color: var(--text-2); margin: 24px 22px 8px; }
.card { background: var(--card-2); border-radius: 18px; margin: 0 16px; overflow: hidden; }

/* Внешний вид: три плитки-превью, выбранная обведена синим — экран Appearance */
.appear-card { background: transparent; }
.appear-tiles { display: flex; gap: 12px; padding: 4px 2px; }
.appear-tile { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; }
.ap-prev {
  position: relative; width: 100%; aspect-ratio: 1.45; border-radius: 14px;
  border: 2px solid transparent; overflow: hidden; display: block;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.appear-tile.sel .ap-prev { border-color: var(--accent); }
.ap-prev i { position: absolute; left: 12%; height: 6%; border-radius: 3px; }
.ap-prev i:first-child { top: 16%; width: 46%; }
.ap-prev i + i { top: 30%; width: 30%; }
.ap-prev b { position: absolute; right: 12%; bottom: 14%; width: 14%; aspect-ratio: 1;
  border-radius: 50%; background: #d97757; }
.ap-light { background: #ffffff; }
.ap-light i { background: #d5d3cc; }
.ap-dark { background: #262624; }
.ap-dark i { background: #4a4945; }
/* системная — диагональ светлое/тёмное, как в оригинале */
.ap-system { background: linear-gradient(to bottom right, #ffffff 49.7%, #262624 50.3%); }
.ap-system i { background: #b8b6af; }
.ap-name { font-size: 14.5px; color: var(--text-2); }
.appear-tile.sel .ap-name { color: var(--accent); }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 58px; padding: 8px 16px; font-size: 17px; color: var(--text);
  text-align: left; position: relative;
}
.row:not(:last-child)::after {
  content: ""; position: absolute; left: 54px; right: 0; bottom: 0; height: 1px; background: var(--line);
}
.row > .ic { width: 26px; height: 26px; color: var(--text); flex-shrink: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .val { margin-left: auto; color: var(--text-2); font-size: 16.5px; display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.row .chev { color: var(--text-3); flex-shrink: 0; }
.row .sub { font-size: 15px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.brand { color: var(--brand); font-weight: 600; }
.row.brand > .ic { color: var(--brand); }
.accent-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }

/* сетка цветов */
.accent-grid { display: flex; gap: 16px; justify-content: center; padding: 18px 0 10px; flex-wrap: wrap; }
.accent-cell { width: 46px; height: 46px; border-radius: 50%; position: relative; display: grid; place-items: center; }
.accent-cell.sel::after { content: ""; position: absolute; inset: -6px; border: 2.5px solid var(--text); border-radius: 50%; }
.accent-cell svg { color: #fff; }

/* шторка «Лимиты»: прогресс-бары по моделям */
.limit-sub { font-size: 13.5px; color: var(--text-2); text-align: center; padding: 2px 8px 12px; }
.lim2 { padding: 10px 4px; }
.lim2-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 16px; }
.lim2-top b { font-variant-numeric: tabular-nums; font-weight: 650; }
.lim2-top small { color: var(--text-2); font-weight: 400; font-size: 13px; }
.lim2-bar { height: 7px; border-radius: 4px; background: var(--chip); margin: 7px 0 4px; overflow: hidden; }
.lim2-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s; }
.lim2-bar i.full { background: var(--danger); }
.lim2-sub { font-size: 13px; color: var(--text-2); }

/* касса: баланс + пополнение + пакеты */
.modal.shop .modal-body { padding: 0 16px calc(var(--safe-bottom) + 30px); }
.shop-load { text-align: center; color: var(--text-2); padding: 40px; }
.shop-bal { background: var(--bg-elev); border-radius: 18px; padding: 18px; text-align: center; box-shadow: var(--shadow-1); }
.shop-bal-cap { font-size: 13.5px; color: var(--text-2); }
.shop-bal-sum { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.shop-bal-note { font-size: 13px; color: var(--text-2); }
.shop-lbl { font-size: 15px; font-weight: 700; margin: 22px 4px 10px; }
.shop-topup { }
.shop-chips { display: flex; gap: 8px; margin-bottom: 10px; }
.shop-chip { flex: 1; background: var(--chip); border-radius: 14px; padding: 12px 4px; font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.shop-chip.sel { background: var(--accent); color: #fff; }
.shop-field { display: flex; gap: 8px; }
/* белое поле с бордером — не сливается с фоном настроек */
.shop-field input { flex: 1; min-width: 0; background: var(--bg-elev); border: 1px solid var(--line); outline: none; border-radius: 14px; padding: 13px 16px; font-size: 16px; color: var(--text); caret-color: var(--brand); }
.shop-field input:focus { border-color: var(--accent); }
.shop-pay { background: var(--send-bg); color: var(--send-fg); border-radius: 14px; padding: 0 22px; font-size: 16px; font-weight: 600; flex-shrink: 0; }
.shop-pay:disabled { opacity: 0.6; }
.shop-hint { font-size: 12.5px; color: var(--text-2); text-align: center; margin-top: 8px; }
.shop-pack {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--bg-elev); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow-1); text-align: left;
}
.shop-pack.busy { opacity: 0.5; pointer-events: none; }
.shop-pack-info { flex: 1; min-width: 0; }
.shop-pack-title { font-size: 16px; font-weight: 600; }
.shop-pack-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.shop-pack-price { font-size: 17px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* память */
.mem-row { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 16px; }
.mem-row span { flex: 1; user-select: text; -webkit-user-select: text; }
.mem-row button { color: var(--text-2); width: 32px; height: 32px; display: grid; place-items: center; }
.mem-add { display: flex; gap: 10px; margin-top: 12px; }
.mem-add input { flex: 1; }
.mem-add button {
  width: 50px; height: 50px; border-radius: 14px; background: var(--send-bg);
  color: var(--send-fg); display: grid; place-items: center; flex-shrink: 0;
}

/* ---------- Библиотека ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px 16px; }
.lib-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.empty-note { text-align: center; color: var(--text-2); font-size: 15.5px; padding: 60px 30px; line-height: 1.5; }
.empty-note .ic { width: 44px; height: 44px; margin: 0 auto 14px; opacity: 0.5; }

/* ---------- Проекты ---------- */
.proj-list { padding: 6px 16px; }
.proj-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--bg-elev); border-radius: 16px; padding: 15px 16px;
  margin-bottom: 10px; font-size: 17px; color: var(--text); text-align: left;
}
.proj-row .ic { width: 24px; color: var(--text); }
.proj-row .cnt { margin-left: auto; color: var(--text-2); font-size: 15px; }
.proj-new {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  width: 100%; padding: 15px; border-radius: 16px; border: 1.5px dashed var(--text-3);
  color: var(--text-2); font-size: 16.5px; margin-top: 4px;
}

/* ---------- Просмотр изображения (pinch-зум + сохранение) ---------- */
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, 0.93);
  animation: fade-in 0.28s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.viewer-canvas {
  position: absolute; inset: 0; display: grid; place-items: center;
  touch-action: none; overflow: hidden;
  animation: viewer-zoom 0.42s var(--spring) both;
}
@keyframes viewer-zoom { from { transform: scale(0.9); } to { transform: none; } }
.viewer-canvas img {
  max-width: 94vw; max-height: 82vh; border-radius: 8px;
  will-change: transform; user-select: none; -webkit-user-drag: none; -webkit-user-select: none;
}
.viewer .modal-close { position: absolute; top: calc(var(--safe-top) + 12px); right: 16px; }
.viewer .viewer-save { position: absolute; top: calc(var(--safe-top) + 12px); left: 16px; }
.viewer .viewer-save.busy { opacity: 0.45; pointer-events: none; }

/* ---------- Пейволл (VPN + ChatGPT) ---------- */
.pw-list { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 14px; }
.pw-item { display: flex; align-items: center; gap: 14px; padding: 10px 4px; }
.pw-ic {
  width: 44px; height: 44px; border-radius: 14px; background: var(--chip);
  display: grid; place-items: center; flex-shrink: 0; color: var(--text);
}
.pw-item b { display: block; font-size: 15.5px; }
.pw-item small { color: var(--text-2); font-size: 13px; line-height: 1.35; display: block; margin-top: 1px; }

/* ---------- Админка ---------- */
.adm-wrap { padding: 4px 16px 30px; }
.adm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.adm-card {
  background: var(--bg-elev); border-radius: 16px; padding: 14px 15px;
  display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow-1);
}
.adm-card b { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.adm-card span { font-size: 12.5px; color: var(--text-2); line-height: 1.3; }
.adm-line { font-size: 14px; color: var(--text-2); margin: 2px 2px 6px; line-height: 1.5; }
.adm-lbl { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 18px 2px 8px; text-transform: uppercase; letter-spacing: 0.4px; }
.adm-bars { display: flex; align-items: flex-end; gap: 4px; height: 50px; margin: 4px 2px 10px; }
.adm-bars i { flex: 1; background: var(--accent); opacity: 0.75; border-radius: 3px 3px 0 0; min-width: 6px; }
.adm-row {
  display: flex; gap: 10px; align-items: baseline; padding: 7px 2px;
  font-size: 14px; border-bottom: 0.5px solid var(--line);
}
.adm-row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-row .dim { color: var(--text-3); font-size: 12px; }

/* ---------- Тост (стекло + пружинный вход) ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 100px); z-index: 120;
  transform: translate(-50%, 18px) scale(0.94); opacity: 0;
  background: rgba(28, 28, 30, 0.78); color: #fff;
  -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
  padding: 11px 19px; border-radius: 22px; font-size: 15px;
  max-width: 86vw; text-align: center;
  box-shadow: var(--shadow-1), inset 0 0 0 0.5px rgba(255, 255, 255, 0.12);
  transition: transform 0.45s var(--spring-pop), opacity 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0) scale(1); opacity: 1; }
[data-theme="dark"] .toast { background: rgba(242, 242, 242, 0.82); color: #111;
  box-shadow: var(--shadow-1), inset 0 0 0 0.5px rgba(0, 0, 0, 0.06); }

/* планшет/десктоп: ограничение ширины контента чата */
@media (min-width: 700px) {
  #chat-scroll { padding-left: max(16px, calc((100vw - 720px) / 2)); padding-right: max(16px, calc((100vw - 720px) / 2)); }
  #composer { padding-left: max(16px, calc((100vw - 720px) / 2)); padding-right: max(16px, calc((100vw - 720px) / 2)); }
}

/* ---------- Плавная смена темы ---------- */
body, .sheet, .modal, .card, .row, .shop-bal, .shop-pack, .adm-card, #sidebar,
.msg.user .bubble, .chip, .codeblock, .toast, #attach-pop {
  transition-property: background-color, color, border-color, box-shadow;
  transition-duration: 0.35s; transition-timing-function: ease;
}
/* у слоёв с transform-переходами свойства темы дописаны в их собственные transition */
.sheet { transition: transform 0.5s var(--spring), background-color 0.35s ease; }
.modal { transition: transform 0.48s var(--spring), background-color 0.35s ease; }
#attach-pop { transition: transform 0.4s var(--spring-pop), opacity 0.22s ease, background-color 0.35s ease; }
.toast { transition: transform 0.45s var(--spring-pop), opacity 0.3s ease, background-color 0.35s ease; }

/* ---------- Уважение reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
