:root {
  --font: 'Onest', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --bg: #0a0a12;
  --bg-2: #0f0f1a;
  --surface: #15151f;
  --surface-2: #1d1c2a;
  --glass: rgb(20 19 32 / .62);
  --glass-strong: rgb(22 21 36 / .86);
  --line: rgb(255 255 255 / .07);
  --line-2: rgb(255 255 255 / .12);
  --text: #f1f0fa;
  --muted: #9a98b4;
  --faint: #66647e;
  --accent: #a48bff;
  --accent-2: #7c5cff;
  --accent-ink: #ffffff;
  --pink: #f472b6;
  --grad: linear-gradient(120deg, #8b5cf6 0%, #6366f1 45%, #ec4899 100%);
  --grad-soft: linear-gradient(120deg, rgb(139 92 246 / .16), rgb(99 102 241 / .12) 50%, rgb(236 72 153 / .14));
  --glow: 0 10px 34px -10px rgb(139 92 246 / .75), 0 4px 14px -6px rgb(236 72 153 / .5);
  --warn-bg: #2a2114;
  --warn-line: #4a3a1f;
  --warn: #f0b46a;
  --danger: #f87171;
  --ok: #4ade80;

  --radius: 16px;
  --radius-sm: 11px;
  --sidebar-w: 284px;
  --files-w: 340px;
  --shadow: 0 24px 60px -18px rgb(0 0 0 / .7);
}

/* По умолчанию — тёмная тема. Светлая — если выбрать её в настройках (или «как в системе»). */
:root { color-scheme: dark; }
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f3fb; --bg-2: #eceaf7; --surface: #ffffff; --surface-2: #f2f0fb;
  --glass: rgb(255 255 255 / .62); --glass-strong: rgb(255 255 255 / .88);
  --line: rgb(30 20 80 / .08); --line-2: rgb(30 20 80 / .14);
  --text: #16142a; --muted: #625f7d; --faint: #9a97b2;
  --accent: #6d4aff; --accent-2: #7c5cff; --accent-ink: #fff;
  --grad-soft: linear-gradient(120deg, rgb(139 92 246 / .12), rgb(99 102 241 / .08) 50%, rgb(236 72 153 / .1));
  --glow: 0 10px 30px -12px rgb(124 92 255 / .55), 0 4px 12px -6px rgb(236 72 153 / .35);
  --warn-bg: #fff6e8; --warn-line: #f2dcb4; --warn: #9a5b12;
  --shadow: 0 24px 60px -24px rgb(40 30 110 / .28);
}

/* «Меньше анимаций» в настройках */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }

/* Живой градиентный фон («аврора») — под всем интерфейсом */
body::before {
  content: ''; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 42% at 18% 12%, rgb(139 92 246 / .30), transparent 70%),
    radial-gradient(34% 40% at 86% 8%, rgb(236 72 153 / .20), transparent 70%),
    radial-gradient(40% 46% at 70% 88%, rgb(99 102 241 / .22), transparent 70%),
    radial-gradient(30% 34% at 8% 92%, rgb(56 189 248 / .10), transparent 70%);
  animation: aurora 26s ease-in-out infinite alternate;
  will-change: transform;
}
/* на телефонах — без движения фона: тяжёлый анимированный слой на весь экран
   iPhone иногда не вытягивает (белый экран) */
@media (hover: none), (max-width: 820px) {
  body::before { inset: 0; animation: none; will-change: auto; }
}
:root[data-theme="light"] body::before { opacity: .55; }
@keyframes aurora {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3%, -2%, 0) scale(1.06) rotate(2deg); }
  100% { transform: translate3d(-3%, 2%, 0) scale(1.02) rotate(-2deg); }
}
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.theme-btn .i-sun { display: none; }
:root[data-theme="light"] .theme-btn .i-sun { display: block; }
:root[data-theme="light"] .theme-btn .i-moon { display: none; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  position: relative;
  isolation: isolate;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
kbd { font: 500 11.5px var(--mono); padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 6px; color: var(--muted); }

/* ---------- бренд ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; position: relative;
  background: linear-gradient(135deg, #a9b4ff, var(--accent-2));
  box-shadow: 0 0 24px -4px var(--accent-2);
}
.brand-mark::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 3px #fff; }
.brand--lg { font-size: 24px; margin-bottom: 18px; }
.brand--lg .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.brand--lg .brand-mark::after { inset: 12px; }

/* ---------- кнопки ---------- */
.btn { border: 0; border-radius: var(--radius-sm); padding: 12px 18px; font-weight: 600; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn--accent { background: var(--accent); color: var(--accent-ink); }
.icon-btn--accent:hover { background: var(--accent); filter: brightness(1.08); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- вход ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%), var(--bg);
}
.login-card {
  width: min(400px, 100%); display: grid; gap: 12px; padding: 32px 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 6px; }
.login-card input {
  padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-2); font-family: var(--mono); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--danger); min-height: 1.2em; font-size: 13.5px; }

/* ---------- раскладка ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; overflow: hidden; }
.app.files-open { grid-template-columns: var(--sidebar-w) 1fr var(--files-w); }

/* ---------- сайдбар ---------- */
.sidebar {
  display: flex; flex-direction: column; gap: 10px; padding: 16px 12px 12px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg-2); border-right: 1px solid var(--line); min-height: 0;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; }
.new-chat {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600;
}
.new-chat:hover { border-color: var(--accent); }
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--faint);
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line);
}
.search input { flex: 1; border: 0; background: none; padding: 10px 0; outline: none; color: var(--text); min-width: 0; }
.chat-list { flex: 1; overflow-y: auto; margin: 4px -4px 0; padding: 0 4px; min-height: 0; }
.chat-group { margin: 12px 8px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.chat-item {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 6px 8px 10px;
  border: 0; border-radius: 9px; background: none; text-align: left; color: var(--muted);
}
.chat-item:hover, .chat-item.active { background: var(--surface); color: var(--text); }
.chat-item .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item .del { opacity: 0; width: 26px; height: 26px; }
.chat-item:hover .del, .chat-item.active .del { opacity: 1; }
.chat-empty { padding: 14px 10px; color: var(--faint); font-size: 13.5px; }
.ttl-note { margin: 0; padding: 0 8px; font-size: 12px; color: var(--faint); }
.sub-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 12px 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.sub-card > div { display: grid; }
.sub-card strong { font-size: 15.5px; letter-spacing: -.01em; }
.sub-card.expired { border-color: var(--warn-line); background: var(--warn-bg); }
.sub-card.expired strong { color: var(--warn); }
.sub-btn { padding: 7px 12px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13.5px; }
.sub-btn:hover { filter: brightness(1.08); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0 6px; font-weight: 600; }
.user-row span:nth-child(2) { flex: 1; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; }

/* ---------- основная зона ---------- */
.main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
  background: radial-gradient(70% 45% at 50% 0%, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 70%), var(--bg);
}
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.topbar-right { margin-left: auto; display: flex; gap: 4px; }

.model-picker { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: none; font-weight: 600; font-size: 16px;
}
.model-btn:hover { background: var(--surface); }
.model-btn .chev { width: 16px; height: 16px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px currentColor; flex: none; }
.model-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(340px, calc(100vw - 32px));
  list-style: none; margin: 0; padding: 6px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line-2); box-shadow: var(--shadow);
}
.model-menu li button {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; width: 100%;
  padding: 10px; border: 0; border-radius: 10px; background: none; text-align: left;
}
.model-menu li button:hover, .model-menu li button[aria-selected="true"] { background: var(--surface-2); }
.model-menu .name { font-weight: 600; }
.model-menu .tag { font-size: 12px; color: var(--muted); grid-column: 2; }
.model-menu .price { grid-row: 1 / span 2; grid-column: 3; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- лента ---------- */
.thread { flex: 1; overflow-y: auto; padding: 8px 16px 24px; min-height: 0; }
.empty { display: grid; justify-items: center; text-align: center; padding: clamp(24px, 12vh, 120px) 0 24px; }
.orb { width: 76px; height: 76px; border-radius: 50%; position: relative; margin-bottom: 26px; }
.orb::before {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 70%, var(--accent) 85%, transparent);
  animation: spin 6s linear infinite; opacity: .55;
  mask: radial-gradient(circle, transparent 60%, #000 62%);
}
.orb span {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d6dbff, var(--accent) 45%, var(--accent-2));
  box-shadow: 0 0 60px -6px var(--accent-2);
  animation: breathe 4s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.05); } }
.greeting { margin: 0; color: var(--accent); font-weight: 600; font-size: 17px; }
.empty h2 { margin: 2px 0 26px; font-size: clamp(30px, 5vw, 44px); line-height: 1.1; font-weight: 800; letter-spacing: -.03em; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 14.5px;
}
.chip:hover { border-color: var(--accent); }
.chip svg { width: 16px; height: 16px; color: var(--accent); }

.messages { max-width: 780px; margin: 0 auto; display: grid; gap: 22px; }
.msg-user {
  justify-self: end; max-width: 100%; padding: 11px 16px; border-radius: 18px 18px 6px 18px;
  background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-ai { display: grid; gap: 10px; min-width: 0; }
.msg-ai .meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.msg-ai .meta .dot { width: 7px; height: 7px; }
.msg-ai .cost { margin-left: auto; font-variant-numeric: tabular-nums; }
.tool {
  display: flex; align-items: center; gap: 8px; width: fit-content; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.tool .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tool.done .spin { animation: none; border-color: var(--ok); background: var(--ok); }
.tool .detail { color: var(--faint); }

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .8em; }
.md h3, .md h4 { margin: 1.2em 0 .5em; letter-spacing: -.01em; }
.md ul, .md ol { margin: 0 0 .8em; padding-left: 1.3em; }
.md code { font: 13.5px var(--mono); padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.md pre { margin: 0 0 .9em; padding: 14px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); overflow-x: auto; }
.md pre code { padding: 0; background: none; font-size: 13px; line-height: 1.6; }
.md a { color: var(--accent); }
.caret::after { content: ''; display: inline-block; width: 8px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-error { color: var(--danger); font-size: 14px; }

/* ---------- карточка «Запустить» ---------- */
.artifact {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; text-align: left;
  border-radius: 16px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.artifact:hover { border-color: var(--accent); }
.artifact .play {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; flex: none;
  background: var(--accent); color: var(--accent-ink);
}
.artifact .play svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.artifact .txt { display: grid; min-width: 0; flex: 1; }
.artifact .txt strong { font-size: 16px; }
.artifact .txt span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact .open-files {
  flex: none; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 13px; color: var(--muted);
}
.artifact .open-files:hover { color: var(--text); }

/* ---------- превью ---------- */
.preview {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line);
}
.preview-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.preview-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.preview-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { margin-left: auto; display: flex; gap: 2px; }
.preview iframe { flex: 1; width: 100%; border: 0; background: #fff; }

.scope { display: flex; gap: 2px; margin: 0 12px 10px; padding: 3px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.scope button { flex: 1; padding: 7px 10px; border: 0; border-radius: 8px; background: none; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.scope button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 var(--line-2); }
.files-empty { padding: 18px 20px; color: var(--faint); font-size: 13.5px; line-height: 1.5; }
.files-actions { display: flex; gap: 8px; margin: 0 12px 8px; }
.files-actions > button { flex: 1; justify-content: center; }
.dl-folder {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.dl-folder:hover { color: var(--text); }
.dl-folder svg { width: 15px; height: 15px; }
.file-view-head span { flex: 1; }
.card-actions { display: flex; gap: 6px; flex: none; }
.thinking { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
.thinking span { margin-left: 6px; }
@keyframes bounce { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.msg-note { color: var(--faint); font-size: 13.5px; font-style: italic; }
.run-folder {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  font-size: 13.5px; font-weight: 600;
}
.run-folder svg { width: 14px; height: 14px; fill: var(--accent); stroke: none; }
.file-list .new-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok);
}
.file-list li.changed button { background: color-mix(in srgb, var(--ok) 7%, transparent); }

/* ---------- композер ---------- */
.composer-wrap { padding: 0 16px max(12px, env(safe-area-inset-bottom)); max-width: 812px; width: 100%; margin: 0 auto; }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--warn-line); font-size: 14px;
}
.notice p { margin: 0; flex: 1 1 260px; }
.notice b { color: var(--warn); }
.notice .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 600; }
.notice button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line-2);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); }
.composer textarea {
  flex: 1; border: 0; background: none; resize: none; outline: none; padding: 9px 0; max-height: 220px; line-height: 1.5;
}
.send {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--accent-ink);
}
.send:disabled { background: var(--surface-2); color: var(--faint); cursor: default; }
.send .i-stop { display: none; }
.send.busy .i-send { display: none; }
.send.busy .i-stop { display: block; fill: currentColor; }
.send.busy { background: var(--text); color: var(--bg); }
.hint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; justify-content: space-between; margin: 8px 4px 0; font-size: 12.5px; color: var(--faint); }

/* ---------- вложения ---------- */
.attach {
  display: grid; place-items: center; width: 36px; height: 40px; border: 0; border-radius: 10px; flex: none;
  background: none; color: var(--muted); margin-left: -8px;
}
.attach:hover { color: var(--text); background: var(--surface-2); }
.att-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; }
.att {
  position: relative; display: flex; align-items: center; gap: 8px; flex: none; max-width: 220px; padding: 6px 30px 6px 6px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); font-size: 13px;
}
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; flex: none; }
.att .fi { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2); color: var(--accent); flex: none; font: 700 10px var(--mono); text-transform: uppercase; }
.att .nm { display: grid; min-width: 0; line-height: 1.3; }
.att .nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .nm span { color: var(--faint); font-size: 11.5px; }
.att .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.att .x svg { width: 12px; height: 12px; }
.drop-hint { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 80%, transparent); border: 2px dashed var(--accent); border-radius: 16px; margin: 8px; font-weight: 700; color: var(--accent); pointer-events: none; }

/* сообщение пользователя с вложениями и действиями */
.msg-user-wrap { justify-self: end; display: grid; justify-items: end; gap: 6px; max-width: 85%; }
.msg-user-wrap .msg-user { max-width: 100%; justify-self: end; }
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.msg-atts img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; background: var(--surface); }
.msg-atts .att { padding-right: 10px; cursor: pointer; }.msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg-user-wrap:hover .msg-actions, .msg-ai:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border: 0; border-radius: 8px;
  background: none; color: var(--faint); font-size: 12.5px; font-weight: 600;
}
.msg-actions button:hover { color: var(--text); background: var(--surface); }
.msg-actions svg { width: 14px; height: 14px; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.edit-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 8px 8px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); font-size: 13.5px;
}
.edit-bar svg { width: 15px; height: 15px; color: var(--accent); flex: none; }
.edit-bar span { flex: 1; min-width: 0; }
.edit-bar button { padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 600; }

/* сохранение файла на телефоне */
.save-file { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.save-file .fi { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); color: var(--accent); flex: none; }
.save-file .fi svg { width: 24px; height: 24px; }
.save-file .nm { display: grid; min-width: 0; }
.save-file .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* просмотр фото */
.lightbox {
  position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column;
  background: rgb(5 6 10 / .88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.lb-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top)); color: #e9eaf2;
}
.lb-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.lb-btn {
  display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; flex: none;
  background: rgb(255 255 255 / .12); color: #fff;
}
.lb-btn:hover { background: rgb(255 255 255 / .2); }
.lb-btn svg { width: 20px; height: 20px; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px max(24px, env(safe-area-inset-bottom)); }
.lb-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 16px;
  border: 1px solid rgb(255 255 255 / .14); box-shadow: 0 30px 80px -20px rgb(0 0 0 / .8);
  background: #111; transition: transform .2s ease, opacity .2s ease; touch-action: none;
}

/* деплой */
.deploys-item .cnt { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 600; }
.deploy-folder { color: var(--accent) !important; border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)) !important; }
.deploy-sheet { max-height: 88dvh; overflow-y: auto; }
.fld { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.fld input, .vars input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); font: 14px var(--mono); min-width: 0;
}
.fld input:focus, .vars input:focus { outline: none; border-color: var(--accent); }
.vars-head { display: grid; gap: 2px; margin-bottom: 8px; font-size: 14px; }
.vars { display: grid; gap: 8px; }
.vars .row { display: grid; grid-template-columns: 1fr 1.4fr 32px; gap: 6px; align-items: center; }
.vars .row .icon-btn { width: 32px; height: 32px; }
.add-var { margin: 8px 0 12px; padding: 6px 0; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.steps { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.steps li .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.steps li.done { color: var(--text); }
.steps li.done .spin { animation: none; border-color: var(--ok); background: var(--ok); }
.steps li.fail .spin { animation: none; border-color: var(--danger); background: var(--danger); }
.deploy-log { max-height: 180px; overflow: auto; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font: 11.5px/1.5 var(--mono); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.deploy-log:empty { display: none; }
.deploy-result { margin-bottom: 12px; padding: 12px; border-radius: 12px; font-size: 14px; overflow-wrap: anywhere; }
.deploy-result.ok { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line)); }
.deploy-result.bad { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); }
.deploy-result a { color: var(--accent); font-weight: 700; }
.deploy-progress .btn, #deploysClose { width: 100%; }
.deploys { display: grid; gap: 8px; margin-bottom: 12px; }
.dep { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.dep .top { display: flex; align-items: center; gap: 8px; }
.dep .top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep .badge { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.dep .badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.dep .badge.building { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.dep .badge.failed { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.dep a { color: var(--accent); font-size: 13.5px; overflow-wrap: anywhere; }
.dep .meta2 { font-size: 12px; color: var(--faint); }
.dep .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.dep .acts button { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dep .acts button:hover { color: var(--text); }
.dep .acts button.danger:hover { color: var(--danger); border-color: var(--danger); }

/* окно удаления чата */
.del-title { margin: 0 0 6px; font-size: 18px; }
.del-name { margin: 0 0 14px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.del-files { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin-bottom: 10px; border-radius: 12px; background: var(--bg-2); cursor: pointer; font-size: 14px; }
.del-files input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--danger); flex: none; }
.del-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.del-actions .btn { width: 100%; border: 1px solid var(--line-2); background: var(--surface-2); }
.del-actions .btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.del-actions .btn:disabled { opacity: .5; cursor: default; }
.btn--danger { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff; }

/* ---------- голос ---------- */
.mic {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; flex: none;
  background: var(--surface-2); color: var(--muted);
}
.mic:hover { color: var(--text); }
.mic[data-mode="rec"] { background: var(--ok); color: #fff; }
.mic[data-mode="busy"] { cursor: default; }
.mic .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.rec { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; min-width: 0; }
.rec .icon-btn { width: 32px; height: 32px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; flex: none; }
.rec-time { font: 600 14px var(--mono); font-variant-numeric: tabular-nums; }
.rec-hint { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.8); } }
.composer.recording { border-color: color-mix(in srgb, var(--danger) 55%, var(--line-2)); }
.voice-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: none; color: var(--faint); font-size: 12.5px; font-weight: 600;
}
.voice-toggle svg { width: 14px; height: 14px; }
.voice-toggle[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2)); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.listen {
  display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); background: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.listen:hover { color: var(--text); border-color: var(--accent); }
.listen svg { width: 13px; height: 13px; }
.listen .i-pause, .listen .spin { display: none; }
.listen[data-state="playing"] { color: var(--accent); border-color: var(--accent); }
.listen[data-state="playing"] .i-play { display: none; }
.listen[data-state="playing"] .i-pause { display: block; }
.listen[data-state="loading"] .i-play { display: none; }
.listen[data-state="loading"] .spin { display: block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.msg-user .voice-ic { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; color: var(--accent); }

/* ---------- файлы ---------- */
.files { display: none; flex-direction: column; min-height: 0; background: var(--bg-2); border-left: 1px solid var(--line); }
.files-open .files { display: flex; }
.files-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 18px; padding-top: max(14px, env(safe-area-inset-top)); }
.preview-head { padding-top: max(10px, env(safe-area-inset-top)); }

/* ---------- установка как приложение ---------- */
.install-bar {
  display: flex; align-items: center; gap: 12px; margin: 0 12px 4px; padding: 10px 10px 10px 12px;
  border-radius: 14px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
}
.install-bar img { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.install-bar .t { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.install-bar .t strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-bar .t span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-bar .go { padding: 8px 12px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13.5px; flex: none; }
.install-bar .icon-btn { width: 30px; height: 30px; flex: none; }
.install-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--line-2)); background: none; color: var(--text); font-weight: 600; font-size: 14px;
}
.install-item svg { color: var(--accent); }
.sheet-wrap { position: fixed; inset: 0; z-index: 90; display: grid; align-items: end; background: rgb(0 0 0 / .55); }
.sheet {
  width: min(480px, 100%); margin: 0 auto; padding: 22px 20px max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface); border: 1px solid var(--line-2); border-bottom: 0;
  box-shadow: var(--shadow); animation: up .25s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-head img { width: 48px; height: 48px; border-radius: 12px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.sheet-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.sheet ol { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: s; }
.sheet ol li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--bg-2); font-size: 14.5px; counter-increment: s; }
.sheet ol li::before { content: counter(s); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; flex: none; }
.sheet ol li .ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); color: #4c8dff; vertical-align: middle; margin: 0 2px; }
.sheet ol li .ic svg { width: 17px; height: 17px; }
.sheet .note { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.sheet .btn { width: 100%; }
.crumbs { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 12px 8px; font-size: 13px; }
.crumbs button { border: 0; background: none; padding: 3px 6px; border-radius: 6px; color: var(--muted); }
.crumbs button:hover { background: var(--surface); color: var(--text); }
.crumbs span { color: var(--faint); padding: 3px 0; }
.file-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; min-height: 0; }
.file-list button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; text-align: left; font-size: 14px;
}
.file-list button:hover { background: var(--surface); }
.file-list .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .s { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.file-list svg { color: var(--muted); }
.file-list .is-dir svg { color: var(--accent); }
.file-view { display: flex; flex-direction: column; flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.file-view-head { display: flex; align-items: center; gap: 6px; padding: 8px; font: 500 13px var(--mono); }
.file-view-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-view pre { flex: 1; margin: 0; padding: 12px 16px; overflow: auto; font: 12.5px/1.6 var(--mono); white-space: pre; }
.files-note { margin: 0; padding: 10px 18px 14px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--line); }

/* ---------- прочее ---------- */
.scrim { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  transition: .25s; max-width: calc(100vw - 32px); z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.only-mobile { display: none; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .app.files-open { grid-template-columns: var(--sidebar-w) 1fr; }
  .files { position: fixed; inset: 0 0 0 auto; width: min(var(--files-w), 92vw); z-index: 40; box-shadow: var(--shadow); }
  .files-open .scrim { display: block; }
}
@media (max-width: 820px) {
  .app, .app.files-open { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 86vw); z-index: 40;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow);
  }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .scrim { display: block; }
  .topbar { padding: 10px 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  /* в режиме приложения на iPhone — отступы от чёлки и полоски «домой» */
  .sidebar { padding-top: max(16px, env(safe-area-inset-top)); }
  .composer-wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .model-btn { font-size: 15px; }
  .hint .keys { display: none; }
  .rec-hint { display: none; }
  .preview { position: fixed; z-index: 45; border-left: 0; }
  .artifact .open-files[data-files] { display: none; }
  .chat-item .del { opacity: 1; }
}
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 35; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* =====================================================================
   ДИЗАЙН-СЛОЙ: стекло, градиенты, свечение (поверх базовых стилей)
   ===================================================================== */
.login { background: transparent; }
.login-card { background: var(--glass-strong); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3); border-color: var(--line-2); }
.main { background: transparent; }
.sidebar {
  background: var(--glass); border-right: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
}
.files { background: var(--glass); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4); border-left-color: var(--line); }

/* бренд */
.brand-mark { background: conic-gradient(from 210deg, #ec4899, #8b5cf6, #6366f1, #22d3ee, #ec4899); box-shadow: 0 0 26px -2px rgb(139 92 246 / .8); }
.brand-name { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* кнопки с градиентом */
.btn--primary, .btn--grad, .send, .sub-btn, .icon-btn--accent, .install-bar .go, .artifact .play {
  background: var(--grad) !important; color: #fff !important; border: 0 !important; box-shadow: var(--glow);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.btn--primary:hover, .btn--grad:hover, .send:hover:not(:disabled), .sub-btn:hover, .install-bar .go:hover { transform: translateY(-1px); filter: brightness(1.08) saturate(1.1); }
.send:disabled { background: var(--surface-2) !important; box-shadow: none; color: var(--faint) !important; }
.send.busy { background: var(--text) !important; color: var(--bg) !important; box-shadow: none; }

/* «Новый чат» — градиентная рамка */
.new-chat {
  border: 1px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box;
}
.new-chat:hover { box-shadow: var(--glow); }
.new-chat svg { color: var(--accent); }
.search, .sub-card, .balance-card { background: var(--grad-soft), var(--surface); border-color: var(--line-2); }

.chat-item.active { background: var(--grad-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }

/* пустой экран */
.empty h2 { background: linear-gradient(120deg, var(--text) 10%, #c4b5fd 50%, #f9a8d4 90%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.greeting { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.orb span { background: radial-gradient(circle at 32% 28%, #fdf4ff, #c4b5fd 30%, #8b5cf6 58%, #6366f1 78%, #ec4899); box-shadow: 0 0 80px -6px rgb(139 92 246 / .9), 0 0 40px -10px rgb(236 72 153 / .8); }
.orb::before { background: conic-gradient(from 0deg, transparent 0 60%, #ec4899 75%, #8b5cf6 88%, transparent); opacity: .8; }
.chip { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-color: var(--line-2); transition: transform .15s, border-color .2s, box-shadow .2s; }
.chip:hover { border-color: transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box; border: 1px solid transparent; box-shadow: var(--glow); transform: translateY(-1px); }

/* сообщения */
.msg-user { background: var(--grad-soft), var(--surface-2); border-color: rgb(164 139 255 / .22); }
.artifact { border: 1px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box; }
.artifact:hover { box-shadow: var(--glow); }
.tool { background: var(--glass); }

/* поле ввода */
.composer { background: var(--glass-strong); backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3); border-color: var(--line-2); box-shadow: 0 12px 40px -20px rgb(0 0 0 / .6); }
.composer:focus-within { border-color: transparent; background: linear-gradient(var(--glass-strong), var(--glass-strong)) padding-box, var(--grad) border-box; border: 1px solid transparent; box-shadow: var(--glow); }

/* меню и окна */
.model-menu, .sheet { background: var(--glass-strong); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3); border-color: var(--line-2); }
.toast { background: var(--grad); color: #fff; box-shadow: var(--glow); }

/* ---------- настройки ---------- */
.user-open {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px 8px 6px 2px;
  border: 0; border-radius: 12px; background: none; font-weight: 600; text-align: left;
}
.user-open:hover { background: var(--surface); }
.user-open #userLabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-open .gear { width: 16px; height: 16px; color: var(--faint); }
.user-open:hover .gear { color: var(--accent); transform: rotate(30deg); transition: transform .3s; }
.avatar { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.user-row span:nth-child(2) { flex: initial; }

.settings {
  position: absolute; inset: 0; z-index: 21; overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 40px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.settings > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.set-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.set-head h1 { margin: 0; font-size: clamp(28px, 5vw, 40px); font-weight: 800; letter-spacing: -.03em; background: linear-gradient(120deg, var(--text) 20%, #c4b5fd 60%, #f9a8d4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.set-tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 18px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.set-tabs::-webkit-scrollbar { display: none; }
.set-tabs button { position: relative; flex: none; padding: 12px 14px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.set-tabs button:hover { color: var(--text); }
.set-tabs button[aria-selected="true"] { color: var(--text); }
.set-tabs button[aria-selected="true"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad); box-shadow: 0 0 12px rgb(139 92 246 / .8); }
.set-panel { display: grid; gap: 14px; animation: up .25s ease; }
.set-card {
  display: grid; gap: 0; padding: 6px 20px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line-2);
  backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.set-card > b { display: block; padding-top: 16px; font-size: 15.5px; }
.set-card > p { margin: 4px 0 12px; color: var(--muted); font-size: 13.5px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.set-row b { font-size: 15px; }
.set-row p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.pill { padding: 5px 12px; border-radius: 999px; font: 700 14px var(--mono); background: var(--grad-soft); border: 1px solid var(--line-2); }
.inline-form { display: flex; gap: 10px; }
.inline-form input, .set-card textarea {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font: inherit; outline: none;
}
.inline-form input:focus, .set-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(139 92 246 / .2); }
.set-card textarea { width: 100%; resize: vertical; min-height: 150px; line-height: 1.5; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.presets button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font-size: 13px; }
.presets button::before { content: '+ '; color: var(--accent); }
.presets button:hover { color: var(--text); border-color: var(--accent); }
.set-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 16px; }
.set-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--grad-soft); border: 1px solid rgb(164 139 255 / .25); font-size: 13.5px; line-height: 1.5; }
.set-note svg { color: var(--accent); margin-top: 2px; }
.sessions { display: grid; padding-bottom: 8px; }
.sess { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.sess p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.tag-now { margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: rgb(74 222 128 / .15); color: var(--ok); }
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-2); flex: none; }
.seg button { padding: 7px 12px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.switch { position: relative; flex: none; width: 48px; height: 28px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .35); transition: transform .2s; }
.switch input:checked + span { background: var(--grad); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .45; }
.btn.sm { padding: 8px 14px; font-size: 13.5px; border-radius: 11px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none; }
.btn.ghost { background: var(--surface); border: 1px solid var(--line-2); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger-ghost { background: none; border: 1px solid rgb(248 113 113 / .35); color: var(--danger); }
.btn.danger-ghost:hover { background: rgb(248 113 113 / .1); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .set-row { flex-wrap: wrap; }
  .set-row:has(.switch) { flex-wrap: nowrap; }
  .set-row .seg { width: 100%; }
  .set-row .seg button { flex: 1; padding: 8px 4px; }
  .inline-form { flex-direction: column; }
  .set-card { padding: 4px 16px; }
}

/* ---------- звонок ---------- */
.call-btn-top { color: var(--accent); }
.call-btn-top:hover { background: var(--grad-soft); }
.call {
  position: fixed; inset: 0; z-index: 96; display: flex; flex-direction: column; align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(60% 45% at 50% 38%, rgb(139 92 246 / .35), transparent 70%),
    radial-gradient(50% 40% at 80% 90%, rgb(236 72 153 / .22), transparent 70%),
    #07060d;
  color: #f1f0fa; animation: fade .25s ease;
}
.call-top { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 520px; font-weight: 600; font-size: 15px; }
.call-dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 12px #4ade80; animation: pulse 1.6s ease-in-out infinite; }
.call-timer { margin-left: auto; font: 600 14px var(--mono); opacity: .75; font-variant-numeric: tabular-nums; }
.call-stage { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
.call-stage canvas { width: min(86vw, 50vh, 460px); aspect-ratio: 1; }
.call-caption { width: 100%; max-width: 560px; min-height: 96px; display: grid; gap: 8px; text-align: center; margin-bottom: 18px; }
.call-caption p { margin: 0; line-height: 1.45; }
.cap-user { font-size: 14px; color: rgb(241 240 250 / .55); }
.cap-ai { font-size: 17px; font-weight: 500; }
.call-ctrls { display: flex; gap: 22px; }
.call-ctl {
  display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%; border: 0;
  background: rgb(255 255 255 / .12); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .15s, background .2s;
}
.call-ctl:hover { transform: scale(1.05); }
.call-ctl svg { width: 26px; height: 26px; }
.call-ctl .i-off { display: none; }
.call-ctl[aria-pressed="true"] { background: #fff; color: #111; }
.call-ctl[aria-pressed="true"] .i-on { display: none; }
.call-ctl[aria-pressed="true"] .i-off { display: block; }
.call-ctl.end { background: #ef4444; box-shadow: 0 10px 30px -8px rgb(239 68 68 / .8); }
.call-ctl.end svg { transform: rotate(0deg); }
.msg-callnote { justify-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); background: var(--grad-soft); border: 1px solid var(--line-2); }

/* Телефоны: без размытия «стекла» (тяжело для видеочипа) — плотные полупрозрачные фоны */
@media (hover: none), (max-width: 820px) {
  .chip, .tool, .composer, .sidebar, .files, .set-card, .login-card, .settings, .call-ctl {
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  }
  .sidebar, .files { background: var(--glass-strong); }
  .composer, .composer:focus-within { background-color: var(--surface); }
  .chip, .tool, .set-card { background: var(--surface); }
  .settings { background: var(--bg); }
}

/* картинки, нарисованные ассистентом */
.msg-atts.ai-imgs { justify-content: flex-start; }
.msg-atts.ai-imgs img { width: min(320px, 100%); height: auto; max-height: 380px; object-fit: cover; border-radius: 16px; box-shadow: 0 16px 40px -18px rgb(139 92 246 / .6); }

/* лимиты в настройках */
.use-row { display: grid; gap: 6px; }
.use-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.use-num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.use-bar { height: 6px; border-radius: 99px; background: rgb(127 127 160 / .18); overflow: hidden; }
.use-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8b5cf6, #ec4899); }
.use-bar.hot i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
