/* ==========================================================================
   AFINA "paper" skin — warm paper palette, serif answers, rounded surfaces.
   Loaded AFTER styles.css: it only overrides tokens and component looks.
   ========================================================================== */

:root {
  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.45, .64, 1);
  --brand: #e06a3a;
  --bg: #ebe8df;
  --bg-side: #e3dfd5;
  --bg-elev: #f5f3ec;
  --comp: #f5f3ec;
  --menu: #f5f3ec;
  --bg-hover: rgba(28, 27, 25, .06);
  --sel: rgba(28, 27, 25, .09);
  --bg-code: #f1efe8;
  --code-head: #e6e2d8;
  --bubble: #dfdbd0;
  --border: rgba(28, 27, 25, .12);
  --border-strong: rgba(28, 27, 25, .22);
  --ring: rgba(28, 27, 25, .3);
  --text: #1c1b19;
  --text-soft: #3a3833;
  --text-faint: #77736a;
  --accent: #b5532e;
  --accent-hover: #a04624;
  --accent-fg: #a04624;
  --accent-soft: rgba(181, 83, 46, .11);
  --danger: #c4372c;
  --ok: #4f8a4a;
  --shadow: 0 2px 16px rgba(28, 27, 25, .08);
  --sh: 0 2px 16px rgba(28, 27, 25, .06);
  --sh-f: 0 3px 22px rgba(28, 27, 25, .1);
  --radius: 14px;
  --radius-sm: 10px;
  --measure: 760px;
  --sidebar-w: 272px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
          "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --t-c: #8a857a; --t-s: #59753f; --t-k: #a04624; --t-n: #8a6a2f;
  --logo-eye: var(--bg-side);
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    --brand: #e8774a;
    --bg: #1b1a19;
    --bg-side: #141312;
    --bg-elev: #252422;
    --comp: #252422;
    --menu: #2a2927;
    --bg-hover: rgba(236, 233, 225, .06);
    --sel: rgba(236, 233, 225, .09);
    --bg-code: #121110;
    --code-head: #1b1a19;
    --bubble: #262523;
    --border: rgba(236, 233, 225, .09);
    --border-strong: rgba(236, 233, 225, .18);
    --ring: rgba(236, 233, 225, .28);
    --text: #ece9e1;
    --text-soft: #c5c1b6;
    --text-faint: #8d897e;
    --accent: #c9633a;
    --accent-hover: #d8704a;
    --accent-fg: #e49a76;
    --accent-soft: rgba(201, 99, 58, .17);
    --danger: #e5484d;
    --ok: #7fb069;
    --shadow: 0 2px 20px rgba(0, 0, 0, .35);
    --sh: 0 2px 20px rgba(0, 0, 0, .28);
    --sh-f: 0 3px 26px rgba(0, 0, 0, .4);
    --t-c: #6f6b62; --t-s: #a3bd8f; --t-k: #e49a76; --t-n: #d3b27a;
  }
}
:root.theme-dark {
  --brand: #e8774a;
  --bg: #1b1a19;
  --bg-side: #141312;
  --bg-elev: #252422;
  --comp: #252422;
  --menu: #2a2927;
  --bg-hover: rgba(236, 233, 225, .06);
  --sel: rgba(236, 233, 225, .09);
  --bg-code: #121110;
  --code-head: #1b1a19;
  --bubble: #262523;
  --border: rgba(236, 233, 225, .09);
  --border-strong: rgba(236, 233, 225, .18);
  --ring: rgba(236, 233, 225, .28);
  --text: #ece9e1;
  --text-soft: #c5c1b6;
  --text-faint: #8d897e;
  --accent: #c9633a;
  --accent-hover: #d8704a;
  --accent-fg: #e49a76;
  --accent-soft: rgba(201, 99, 58, .17);
  --danger: #e5484d;
  --ok: #7fb069;
  --shadow: 0 2px 20px rgba(0, 0, 0, .35);
  --sh: 0 2px 20px rgba(0, 0, 0, .28);
  --sh-f: 0 3px 26px rgba(0, 0, 0, .4);
  --t-c: #6f6b62; --t-s: #a3bd8f; --t-k: #e49a76; --t-n: #d3b27a;
}
:root.theme-light {
  --brand: #e06a3a;
  --bg: #ebe8df; --bg-side: #e3dfd5; --bg-elev: #f5f3ec; --comp: #f5f3ec; --menu: #f5f3ec;
  --bg-hover: rgba(28, 27, 25, .06); --sel: rgba(28, 27, 25, .09);
  --bg-code: #f1efe8; --code-head: #e6e2d8; --bubble: #dfdbd0;
  --border: rgba(28, 27, 25, .12); --border-strong: rgba(28, 27, 25, .22);
  --ring: rgba(28, 27, 25, .3);
  --text: #1c1b19; --text-soft: #3a3833; --text-faint: #77736a;
  --accent: #b5532e; --accent-hover: #a04624; --accent-fg: #a04624;
  --accent-soft: rgba(181, 83, 46, .11);
  --danger: #c4372c; --ok: #4f8a4a;
  --shadow: 0 2px 16px rgba(28, 27, 25, .08);
  --sh: 0 2px 16px rgba(28, 27, 25, .06); --sh-f: 0 3px 22px rgba(28, 27, 25, .1);
  --t-c: #8a857a; --t-s: #59753f; --t-k: #a04624; --t-n: #8a6a2f;
}

body { letter-spacing: -.006em; text-rendering: optimizeLegibility; }
::selection { background: var(--ring); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
textarea:focus-visible, input:focus-visible { outline: none; }
a { color: var(--accent-fg); }

/* ---------------------------------------------------------------- sidebar */
.sidebar { background: var(--bg-side); --logo-eye: var(--bg-side); }
.brand { height: 56px; padding: 0 10px 0 14px; gap: 10px; }
/* AFINA pixel logo: wide lockup in the open sidebar, the cat alone in the rail.
   The lockup comes in a dark-background and a light-background version. */
.brand-logo { display: flex; align-items: center; height: 30px; flex: none; }
.brand-logo img, .bl-lock { width: auto; image-rendering: pixelated; }
.bl-mark { display: none; height: 30px; }
.bl-lock { display: block; height: 26px; }
.bl-light { display: none; }
:root.theme-light .bl-dark { display: none; }
:root.theme-light .bl-light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not(.theme-dark):not(.theme-light) .bl-dark { display: none; }
  :root:not(.theme-dark):not(.theme-light) .bl-light { display: block; }
}
.app.side-collapsed .bl-mark { display: block; }
.app.side-collapsed .bl-lock { display: none !important; }
.brand-logo { margin-right: auto; }
.app.side-collapsed .brand-logo { margin: 0 auto; }
.login-title { margin: 14px 0 6px; line-height: 0; }
.login-title .bl-lock { height: 30px; margin: 0 auto; }
.login-mark { display: block; width: auto; height: 64px; margin: 0 auto; image-rendering: pixelated; }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: .02em; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; color: var(--text-faint); }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.new-btn {
  width: calc(100% - 12px); margin: 4px 6px 6px; height: 38px; padding: 0 13px; gap: 12px;
  background: none; color: var(--accent-fg); font-weight: 600; font-size: 14px;
  border-radius: 11px; transition: background .15s, transform .25s var(--ease);
}
.new-btn:hover { background: var(--bg-hover); }
.new-btn:active { transform: scale(.985); }
.new-btn .ic {
  display: grid; place-items: center; width: 24px; height: 24px; margin-left: -3px;
  border-radius: 50%; background: var(--accent); color: #fff; flex: none;
  transition: transform .5s var(--spring);
}
.new-btn:hover .ic { transform: rotate(90deg) scale(1.06); }
.new-btn .ic .ico { width: 15px; height: 15px; stroke-width: 2.2; }

.side-nav { padding: 0 6px; gap: 1px; }
.side-link { height: 38px; padding: 0 13px; gap: 12px; border-radius: 11px; font-size: 14px; color: var(--text-soft); }
.side-link .ico { width: 18px; height: 18px; stroke-width: 1.7; color: var(--text-faint); }
.side-link:hover { background: var(--bg-hover); color: var(--text); }
.side-link:hover .ico { color: var(--text-soft); }
.side-link.active { background: var(--sel); font-weight: 400; }

.hist-section { padding: 0 6px; }
.proj-header {
  padding: 18px 13px 6px; font-size: 12px; font-weight: 550; letter-spacing: .01em;
  text-transform: none; color: var(--text-faint);
}
.chat-group { padding: 14px 13px 4px; font-size: 12px; font-weight: 550; letter-spacing: .01em; color: var(--text-faint); }
.history .chat-group:first-child { padding-top: 4px; }
.history { display: flex; flex-direction: column; gap: 1px; }
.chat-item {
  height: 36px; padding: 0 6px 0 13px; border-radius: 11px; font-size: 14px; flex: none;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--sel); font-weight: 400; color: var(--text); }
.chat-item .row-act { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; }
.chat-item .row-act:hover { background: var(--bg-hover); }

.sidebar-bottom { padding: 8px 6px 10px; border-top: 1px solid var(--border); gap: 2px; }
.admin-bottom { height: 38px; padding: 0 13px; gap: 12px; border-radius: 11px; }
.account { height: 46px; padding: 0 13px; gap: 12px; border-radius: 11px; }
.acc-avatar { width: 28px; height: 28px; margin-left: -5px; background: var(--text-soft); color: var(--bg); font-size: 12px; font-weight: 700; }
.acc-text { line-height: 1.2; font-size: 14px; }
.acc-text small { display: block; font-size: 11.5px; color: var(--text-faint); }

/* ------------------------------------------------------------------ header */
.main { background: var(--bg); }
.topbar { height: 56px; flex-basis: 56px; padding: 0 14px; border-bottom: 0; gap: 6px; }
/* the panel is folded with the arrow in the sidebar and unfolded with its logo,
   so the extra "three lines" button next to the chat title is not needed */
.desktop-menu-btn { display: none !important; }
.session-title { font-size: 14.5px; max-width: min(52vw, 520px); flex: 0 1 auto; border-radius: 10px; }
.topbar-right { margin-left: auto; gap: 6px; }
#themeBtn .sun { display: none; }
#themeBtn .ico { width: 18px; height: 18px; stroke-width: 1.7; }
:root.theme-dark #themeBtn .sun { display: block; }
:root.theme-dark #themeBtn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) #themeBtn .sun { display: block; }
  :root:not(.theme-light) #themeBtn .moon { display: none; }
}

/* --------------------------------------------------------------- messages */
.thread { max-width: var(--measure); padding: 16px 24px 34px; }
.msg { margin-bottom: 28px; animation: mrise .55s var(--ease) both; }
@keyframes mrise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.msg.user .body {
  max-width: 82%; padding: 10px 16px; background: var(--bubble); border: 0;
  border-radius: 19px 19px 6px 19px; font-size: 15.5px; line-height: 1.55;
}
.msg.user .content { line-height: 1.55; font-size: 15.5px; }
.msg.assistant .content { font-family: var(--serif); font-size: 16.5px; line-height: 1.7; }
.msg.assistant .content :is(table, th, td, pre, code, .code-head, button) { font-family: var(--font); }
.msg.assistant .content :is(pre, pre code, code) { font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace; }
.content p { margin: 0 0 12px; }
.content h1, .content h2, .content h3, .content h4 { font-family: var(--font); letter-spacing: -.02em; margin: 20px 0 10px; }
.content h1 { font-size: 22px; } .content h2 { font-size: 19px; } .content h3 { font-size: 18px; }
.content li::marker { color: var(--text-faint); }
.content strong { font-weight: 600; }
.content code { font-size: .88em; padding: 2px 6px; border-radius: 6px; background: var(--bg-hover); border: 1px solid var(--border); }
.content blockquote { border-left-color: var(--border-strong); }
.content table { font-size: 14.5px; }
.content th, .content td { border-color: var(--border); }
.content th { background: var(--bg-hover); }

/* code blocks */
/* overflow: clip (not hidden) keeps the rounded corners but does not turn the
   block into its own scroll container, so the header below can stay stuck */
.content pre { border-radius: 14px; background: var(--bg-code); border: 1px solid var(--border); margin: 0 0 12px; overflow: clip; }
/* long code: the header with the copy button follows you while you scroll the block */
.content pre .code-head { position: sticky; top: 0; z-index: 3; height: 36px; padding: 0 8px 0 14px; background: var(--code-head); border-bottom: 0; font-size: 12.5px; color: var(--text-faint); }
.content pre .code-lang { text-transform: none; }
.content pre .code-btn { border-radius: 7px; }
.content pre code { padding: 14px 16px; font-size: 13.5px; line-height: 1.65; background: none; border: 0; }
.content pre .code-gutter { background: var(--bg-code); font-size: 13.5px; line-height: 1.65; border-right-color: var(--border); padding: 14px 8px 14px 14px; }
html:root .content .hljs-comment, html:root .content .hljs-quote { color: var(--t-c); font-style: italic; }
html:root .content .hljs-keyword, html:root .content .hljs-selector-tag, html:root .content .hljs-built_in,
html:root .content .hljs-literal, html:root .content .hljs-type { color: var(--t-k); }
html:root .content .hljs-string, html:root .content .hljs-attr, html:root .content .hljs-template-tag,
html:root .content .hljs-addition, html:root .content .hljs-regexp { color: var(--t-s); }
html:root .content .hljs-number, html:root .content .hljs-symbol, html:root .content .hljs-bullet,
html:root .content .hljs-meta { color: var(--t-n); }
html:root .content .hljs-title, html:root .content .hljs-section, html:root .content .hljs-name,
html:root .content .hljs-variable, html:root .content .hljs-params, html:root .content .hljs-attribute,
html:root .content .hljs-tag, html:root .content .hljs-link, html:root .content .hljs-deletion { color: var(--text); }

/* thinking block: a small pill, body with a left rule */
.reasoning { border: 0; background: none; border-radius: 0; margin-bottom: 12px; overflow: visible; }
.reasoning summary {
  display: inline-flex; height: 30px; padding: 0 11px; gap: 7px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 13px; color: var(--text-soft); font-family: var(--font);
  transition: background .15s;
}
.reasoning summary:hover { background: var(--bg-hover); }
.reasoning summary .rb-icon { color: var(--accent-fg); }
.reasoning .rlabel { font-weight: 400; }
.reasoning .rlabel.thinking {
  background: linear-gradient(90deg, var(--text-faint) 30%, var(--text) 50%, var(--text-faint) 70%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: shimmer 1.6s linear infinite;
}
.reasoning .rlabel.thinking::after { display: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.reasoning .rmeta { margin-left: 2px; }
.reasoning .rbody {
  margin: 10px 0 0; padding: 0 0 0 14px; border-top: 0; border-left: 2px solid var(--border-strong);
  font-family: var(--font); font-size: 14px; line-height: 1.7; color: var(--text-faint);
}

.ma-btn { width: 30px; height: 30px; border-radius: 8px; }
.msg-actions { margin-top: 10px; }
.found-chip { border-radius: 10px; background: var(--bg-hover); }
.caret-blink { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; animation: caretpulse 1s ease-in-out infinite; }
@keyframes caretpulse { 50% { transform: scale(.55); opacity: .5; } }

/* ----------------------------------------------------------------- hero */
.empty-state { max-width: var(--measure); padding: 0 24px 26px; gap: 0; }
.greet { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; animation: hin .9s var(--ease) both; }
@keyframes hin { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.hero-logo { display: block; height: 54px; }
.hero-logo img { display: block; height: 100%; width: auto; image-rendering: pixelated; }
.greeting { font-family: var(--serif); font-size: clamp(30px, 3.8vw, 42px); font-weight: 400; letter-spacing: -.02em; line-height: 1.15; color: var(--text-soft); }
.greeting .nm { color: var(--text); }

/* empty chat: hero + composer + chips are centred as one group */
.main:has(#emptyState) { justify-content: center; }
.main:has(#emptyState) .topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 4; }
.main:has(#emptyState) .chat { flex: 0 0 auto; overflow: visible; }
.main:has(#emptyState) .composer-wrap { padding-bottom: 0; }
.main:has(#emptyState) .composer .input { min-height: 52px; }
.main:has(#emptyState) .below { display: block; }
.main:has(#emptyState) .note { display: none; }
.main:has(#emptyState) { padding-bottom: 6vh; }

/* -------------------------------------------------------------- composer */
.composer-wrap { padding: 0 24px 6px; }
.attachments { max-width: var(--measure); }
.att-chip { background: var(--bg-hover); border-color: var(--border); }
.composer {
  display: block; max-width: var(--measure); margin: 0 auto; padding: 14px 12px 10px 18px;
  border-radius: 20px; background: var(--comp); border: 1px solid var(--border);
  box-shadow: var(--sh); cursor: text;
  transition: border-color .25s, box-shadow .4s var(--ease), background-color .3s;
}
.composer:focus-within { border-color: var(--ring); box-shadow: var(--sh-f); }
.composer .input {
  display: block; width: 100%; min-height: 30px; max-height: 240px; padding: 0;
  font-size: 16px; line-height: 24px; letter-spacing: inherit; background: none;
}
.composer .input::placeholder { color: var(--text-faint); }
.tools { display: flex; align-items: center; gap: 4px; margin: 8px 0 0 -6px; }
.tools .sp { flex: 1; }
.plus-btn { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 10px; color: var(--text-faint); }
.plus-btn:hover { background: var(--bg-hover); color: var(--text); }
.plus-btn .ico { width: 18px; height: 18px; stroke-width: 1.8; }
.web-btn {
  width: auto; height: 32px; flex: none; padding: 0 10px; gap: 6px; border-radius: 10px;
  font-size: 13.5px; color: var(--text-soft); transition: background .15s, color .15s, transform .3s var(--spring);
}
.web-btn .ico { width: 17px; height: 17px; stroke-width: 1.7; }
.web-btn:hover { background: var(--bg-hover); color: var(--text); }
.web-btn:active { transform: scale(.95); }
.web-btn.active { background: var(--accent-soft); color: var(--accent-fg); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px 0 10px;
  border-radius: 10px; font-size: 13.5px; color: var(--text-soft); border: 0; background: none;
}
.chip:hover { background: var(--bg-hover); }
.chip .caret { width: 14px; height: 14px; color: var(--text-faint); }
/* model button sits under the composer, right-aligned: "Core 2.1  Низкий ⌄" */
.composer-meta { display: flex; align-items: center; max-width: var(--measure); margin: 6px auto 0; padding: 0 4px; }
.composer-meta .sp { flex: 1; }
.composer-meta .model-chip { height: 34px; padding: 0 10px 0 12px; gap: 8px; font-size: 14px; color: var(--text); }
.composer-meta .model-chip[aria-expanded=true], .composer-meta .model-chip:hover { background: var(--bg-hover); }
.reason-chip { color: var(--text-faint); font-size: 14px; }
.main:has(#emptyState) .composer-meta + .below .chips { padding-top: 22px; }
.send-btn {
  width: 34px; height: 34px; flex: 0 0 34px; margin-left: 4px; border-radius: 50%;
  background: var(--accent); color: #fff;
  transition: background .25s, color .25s, transform .4s var(--spring);
}
.send-btn .ico { width: 18px; height: 18px; }
.send-btn:hover { background: var(--accent-hover); transform: scale(1.07); }
.send-btn:active { transform: scale(.9); }
.send-btn.idle { background: var(--bg-hover); color: var(--text-faint); cursor: default; transform: none; }
.send-btn.stop { background: var(--accent); color: #fff; }
.send-btn.stop:hover { background: var(--accent-hover); }

.below { display: none; position: relative; max-width: var(--measure); margin: 0 auto; min-height: 54px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding-top: 16px; }
.cat-chip {
  display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 14px; color: var(--text-soft);
  transition: background .15s, color .15s, transform .3s var(--spring);
}
.cat-chip:hover { background: var(--bg-hover); color: var(--text); }
.cat-chip:active { transform: scale(.97); }
.cat-chip.on { background: var(--accent-soft); color: var(--accent-fg); border-color: transparent; }
.cat-chip .ico { width: 16px; height: 16px; stroke-width: 1.7; color: var(--text-faint); }
#sugg {
  position: absolute; left: 0; right: 0; top: 62px; z-index: 8; opacity: 0; visibility: hidden;
  transform: translateY(-6px) scale(.985); transform-origin: top center;
  transition: opacity .2s, transform .4s var(--spring), visibility 0s .4s;
}
#sugg.open { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .4s var(--spring), visibility 0s; }
#sugg .box { padding: 6px; border-radius: 16px; background: var(--menu); border: 1px solid var(--border); box-shadow: 0 20px 50px -16px rgba(0, 0, 0, .3); }
#sugg .box button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 11px 12px; border-radius: 10px; font-size: 14.5px; color: var(--text-soft); text-align: left;
  transition: background .15s, color .15s;
}
#sugg .box button .ico { width: 15px; height: 15px; color: var(--text-faint); opacity: 0; transform: translate(-4px, 4px); transition: all .3s var(--ease); }
#sugg .box button:hover { background: var(--bg-hover); color: var(--text); }
#sugg .box button:hover .ico { opacity: 1; transform: none; }
.note { max-width: var(--measure); margin: 0 auto; padding: 10px 0 8px; text-align: center; font-size: 12px; color: var(--text-faint); }

/* -------------------------------------------------- model / depth popover */
.popover {
  width: 330px; min-width: 0; max-width: calc(100vw - 20px); padding: 6px; border-radius: 16px;
  background: var(--menu); border: 1px solid var(--border); box-shadow: 0 24px 60px -14px rgba(0, 0, 0, .35);
}
.pop-title { padding: 7px 11px 5px; font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text-faint); }
.pop-item { flex-direction: row; align-items: center; padding: 9px 11px; border-radius: 10px; font-size: 14px; }
.pop-item .pi-left { gap: 1px; }
.pop-item .pi-title { font-weight: 550; font-size: 14px; }
.pop-item { padding: 7px 12px; }
.popover { padding: 4px; }
.popover .pop-title { padding: 6px 12px 3px; }
.popover .pop-sep { margin: 4px 4px; }
.reason-slider { padding: 2px 6px 4px; }
.reason-slider:not(.open) { display: none; }
.pop-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; text-align: left; color: var(--text); transition: background .15s;
}
.pop-row:hover { background: var(--bg-hover); }
.pop-row .pr-name { flex: 1; }
.pop-row .pr-val { color: var(--text-faint); }
.pop-row .pr-chev { color: var(--text-faint); transition: transform .25s var(--ease); }
.pop-row.open .pr-chev { transform: rotate(90deg); }
.pop-row[hidden] { display: none !important; }
.pop-row .pr-name small { margin-left: 6px; font-size: 12px; color: var(--text-faint); }
.pop-row.on .pr-val { color: var(--accent-fg); font-weight: 600; }
#ensembleRow { margin-top: 2px; }
.pop-item .pi-desc { font-size: 12.5px; color: var(--text-faint); }
.pop-item.active { background: none; }
.pop-item .pi-check { margin-left: auto; color: var(--accent-fg); }
.pop-sep { margin: 6px 4px; }
.reason-slider { padding: 2px 6px 6px; }
.reason-slider input[type=range] { display: none; }
.reason-slider .rs-labels { display: flex; margin: 0; padding: 3px; border-radius: 11px; background: var(--bg-hover); }
.reason-slider .rs-tick {
  flex: 1; text-align: center; padding: 6px 0; border-radius: 8px; font-size: 12.5px; color: var(--text-faint);
  transition: color .25s, background .25s, box-shadow .25s;
}
.reason-slider .rs-tick:hover { color: var(--text-soft); }
.reason-slider .rs-tick.active { background: var(--comp); color: var(--text); font-weight: 550; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.pop-note { padding: 4px 11px 8px; }

/* --------------------------------------------------- panels, forms, misc */
.sources-panel { background: var(--bg-side); }
.modal { backdrop-filter: blur(4px); background: rgba(20, 18, 15, .4); }
.modal-card { border-radius: 18px; background: var(--menu); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55); }
.field input, .field select, .field textarea, .login-field input,
.set-row select, .set-row input[type=text], .set-row input[type=password] { background: var(--bg); border-radius: 10px; }
.btn-primary, .login-submit { border-radius: 10px; }
.btn-ghost, .btn-danger { border-radius: 10px; }
.toast { background: var(--text); color: var(--bg); border: 0; border-radius: 999px; padding: 10px 18px; }
.toast.err { background: var(--danger); color: #fff; }
.tool-card { border-radius: 12px; }
.login-body, body.landing { background: var(--bg); }
.login-card { background: var(--menu); border-radius: 20px; }
.login-logo { color: var(--brand); }
.stat-card, .list-item { border-radius: 14px; background: var(--comp); }
.scroll-down { background: var(--comp); border: 1px solid var(--border); box-shadow: var(--sh); }

/* ------------------------------------- icons: crisp, one size in the chat */
.ico { shape-rendering: geometricPrecision; stroke-width: 1.7; }
.msg .ico, .found-chip .ico, .sources-panel .ico { stroke-width: 1.65; }
.msg .ma-btn .ico { width: 20px; height: 20px; display: block; }   /* 20px viewBox -> 1:1, no resampling */
.content pre .code-btn .ico { width: 20px; height: 20px; }

/* --------------------------- actions under an answer: one even row */
.msg-actions { margin: 8px 0 0 -8px; gap: 10px; min-height: 32px; align-items: center; flex-wrap: nowrap; }
.ma-bar { display: flex; align-items: center; gap: 2px; }
.ma-btn { width: 32px; height: 32px; flex: 0 0 32px; padding: 0; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-faint); }
.ma-btn:hover { background: var(--bg-hover); color: var(--text); }
.ma-btn.on { color: var(--accent-fg); }
/* speed / time / tokens: always small and grey, on the same line as the icons */
.ma-meta {
  margin-left: 8px; font-size: 12.5px; line-height: 1; color: var(--text-faint);
  white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 400; letter-spacing: 0;
}
.ma-meta:empty { display: none; }
/* one timer only: while thinking it is in the "Думает… 11 с" row, afterwards
   the speed/time/tokens line in .ma-meta; the second clock under the dot is gone */
.msg-stats { display: none !important; }

/* ------------------------------ thinking: a plain row, click to fold */
.reasoning summary {
  display: inline-flex; align-items: center; height: auto; padding: 4px 0; gap: 8px; border: 0;
  background: none; font-size: 14px; color: var(--text-soft); font-family: var(--font); border-radius: 8px;
}
.reasoning summary:hover { background: none; color: var(--text); }
.reasoning summary .rb-icon { width: 18px; height: 18px; color: var(--accent-fg); }
.reasoning .rchev { width: 16px; height: 16px; margin-left: 0; color: var(--text-faint); }
.reasoning .rlabel { font-weight: 400; }
.reasoning .rbody { margin-top: 8px; }

/* ------------------------------------- web search: chip + side panel */
.found-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; margin: 0 0 14px; padding: 0 12px 0 11px;
  border-radius: 999px; background: var(--bg-hover); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-soft); font-family: var(--font); cursor: pointer;
}
.found-chip:hover { background: var(--sel); color: var(--text); }
.found-chip .ico { width: 18px; height: 18px; color: var(--text-soft); }
.found-chip .fc-favs { display: inline-flex; margin-left: 2px; }
.found-chip .fc-fav { width: 18px; height: 18px; margin-left: -6px; border-radius: 50%; background: var(--bg); border: 2px solid var(--bg-hover); object-fit: cover; box-sizing: content-box; }
.found-chip .fc-fav:first-child { margin-left: 0; }
.sources-panel { width: 400px; flex: 0 0 400px; border-left: 1px solid var(--border); background: var(--bg-side); }
.sp-head { height: 56px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--border); }
.sp-title { font-size: 14.5px; font-weight: 600; }
.sp-body { padding: 8px 10px 20px; gap: 2px; }
.sp-item { padding: 12px 12px 12px; border-radius: 12px; }
.sp-item:hover { background: var(--bg-hover); }
.sp-src-head { gap: 8px; margin-bottom: 6px; }
.sp-fav { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.sp-src-name { font-size: 12.5px; }
.sp-idx { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bg-hover); font-size: 11px; color: var(--text-faint); }
.sp-item .sp-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.sp-snippet { font-size: 13px; line-height: 1.5; -webkit-line-clamp: 3; }
@media (max-width: 860px) {
  .sources-panel { position: fixed; inset: 0 0 0 auto; z-index: 55; width: min(400px, 100vw); box-shadow: -20px 0 60px rgba(0, 0, 0, .35); }
}

/* ---------------- messages typed while an answer is being written */
.queue-box { max-width: var(--measure); margin: 0 auto 8px; display: flex; flex-direction: column; gap: 6px; }
.queue-box[hidden] { display: none !important; }
.q-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 5px 6px 5px 12px;
  border-radius: 14px; background: var(--bg-hover); border: 1px solid var(--border); font-size: 14px;
  animation: hin .35s var(--ease) both;
}
.q-tag { flex: none; font-size: 11.5px; font-weight: 600; color: var(--accent-fg); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }
.q-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-soft); }
.q-now { flex: none; height: 30px; padding: 0 11px; border-radius: 9px; font-size: 13px; color: var(--accent-fg); transition: background .15s; }
.q-now:hover { background: var(--accent-soft); }
.q-x { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--text-faint); }
.q-x:hover { background: var(--sel); color: var(--text); }
.send-now-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; margin-left: 4px;
  border-radius: 10px; font-size: 13.5px; color: var(--accent-fg); background: var(--accent-soft);
  transition: background .15s, transform .3s var(--spring);
}
.send-now-btn .ico { width: 16px; height: 16px; }
.send-now-btn:hover { background: var(--sel); }
.send-now-btn:active { transform: scale(.95); }
.send-now-btn[hidden] { display: none !important; }
@media (max-width: 560px) { .send-now-btn span { display: none; } .send-now-btn { padding: 0 9px; } }

/* --------------------------- "Аудио": chat mode + voice picker card */
body.audio-mode .web-btn, body.audio-mode .composer-meta, body.audio-mode .below { display: none !important; }
.audio-sub { max-width: 520px; margin: 10px auto 0; text-align: center; font-size: 14.5px; line-height: 1.55; color: var(--text-faint); }
.vp-pending .msg-actions { display: none; }
.vp-card {
  width: 100%; max-width: 560px; padding: 14px 14px 12px; border-radius: 18px;
  background: var(--comp); border: 1px solid var(--border); box-shadow: var(--sh);
  font-family: var(--font); animation: hin .45s var(--ease) both;
}
.vp-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 2px 10px; }
.vp-title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.vp-sub { min-width: 0; font-size: 12.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg-hover); margin-bottom: 10px; }
.vp-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border-radius: 9px;
  font-size: 13px; color: var(--text-faint); transition: background .2s, color .2s, box-shadow .2s;
}
.vp-tab:hover { color: var(--text-soft); }
.vp-tab.on { background: var(--comp); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .22); }
.vp-cnt { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--bg-hover); color: var(--text-faint); }
.vp-tab.on .vp-cnt { background: var(--accent-soft); color: var(--accent-fg); }
.vp-body { min-height: 0; }
.vp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vp-voice {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 6px 6px 6px; border-radius: 12px; text-align: left;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  transition: border-color .15s, background .15s, transform .25s var(--spring), box-shadow .2s;
}
.vp-voice:hover { background: var(--bg-hover); }
.vp-voice:active { transform: scale(.97); }
.vp-voice.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.vp-av {
  position: relative; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  overflow: hidden; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 78% 56%), hsl(calc(var(--h) + 24) 70% 42%));
}
.vp-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; opacity: 0; transition: opacity .25s; }
.vp-av.has-img { background: #1b1a19; color: transparent; }
.vp-av.has-img img { opacity: 1; }
.vp-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp-play {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  color: var(--text-soft); background: var(--bg-hover); transition: background .15s, color .15s, transform .25s var(--spring);
}
.vp-play .ico { width: 12px; height: 12px; }
.vp-play:hover { background: var(--accent); color: #fff; transform: scale(1.12); }
.vp-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.vp-speed { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-soft); }
.vp-speed input { flex: 1; min-width: 60px; accent-color: var(--accent); }
.vp-speed-val { width: 36px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.vp-foot .btn-ghost { padding: 7px 12px; font-size: 13px; }
.vp-go { padding: 8px 18px; font-size: 13.5px; }
@media (max-width: 560px) { .vp-grid { grid-template-columns: 1fr 1fr; } .vp-card { padding: 12px 10px; } .vp-sub { display: none; } }

.voice-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.voice-pick select { min-width: 220px; max-width: 100%; }
.voice-pick .btn-ghost { padding: 7px 12px; }

/* -------------------------- pictures and speech made by AFINA (/media) */
.content img[src^="/media/"] {
  display: block; max-width: min(100%, 560px); height: auto; margin: 8px 0 10px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--bg-hover); cursor: zoom-in;
}
.audio-card {
  display: flex; align-items: center; gap: 12px; max-width: 480px; margin: 8px 0 10px;
  padding: 8px 12px; border-radius: 14px; background: var(--bg-hover); border: 1px solid var(--border);
}
.audio-card audio { flex: 1; min-width: 0; height: 36px; }
.audio-dl { flex: none; font-size: 13px; color: var(--accent-fg); }
.img-viewer {
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 24px; background: rgba(10, 9, 8, .86); backdrop-filter: blur(6px);
}
.img-viewer img { max-width: min(94vw, 1100px); max-height: 80vh; border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.iv-bar { display: flex; gap: 10px; }
.iv-btn { padding: 8px 16px; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 14px; text-decoration: none; }
.iv-btn:hover { background: rgba(255, 255, 255, .2); text-decoration: none; }

/* ------------------------------------------- drag & drop zone for files */
.drop-zone {
  position: absolute; inset: 10px; z-index: 40; display: grid; place-items: center;
  border-radius: 24px; border: 2px dashed var(--accent); background: var(--accent-soft);
  backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drop-zone.show { opacity: 1; }
.dz-box { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--accent-fg); font-size: 16px; font-weight: 600; }
.dz-box .ico { width: 34px; height: 34px; stroke-width: 1.6; animation: dzbob 1.1s ease-in-out infinite; }
@keyframes dzbob { 50% { transform: translateY(-5px); } }
.composer.drag { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ------------------------------------- collapsed sidebar = icon rail (desktop) */
@media (min-width: 861px) {
  .sidebar { transition: width .35s var(--ease), flex-basis .35s var(--ease), margin-left .35s var(--ease); }
  .app.side-collapsed .sidebar { margin-left: 0; width: 56px; flex: 0 0 56px; overflow: visible; }
  .app.side-collapsed :is(.brand-name, .collapse-btn, .hist-section, .search-wrap, .acc-text, .acc-caret,
      .side-link span, .admin-bottom span, .new-btn > span:not(.ic)) { display: none; }
  .app.side-collapsed .brand { padding: 0; justify-content: center; }
  .app.side-collapsed .brand-logo { cursor: pointer; }
  .app.side-collapsed .side-nav { padding: 0; align-items: center; }
  .app.side-collapsed :is(.side-link, .admin-bottom, .account) { width: 44px; padding: 0; justify-content: center; margin: 0 auto; }
  .app.side-collapsed .new-btn { width: 44px; padding: 0; margin: 4px auto 6px; justify-content: center; }
  .app.side-collapsed .new-btn .ic { margin-left: 0; }
  .app.side-collapsed .sidebar-bottom { margin-top: auto; padding: 8px 0 10px; align-items: center; }
  .app.side-collapsed .acc-avatar { margin-left: 0; }
  .app.side-collapsed .desktop-menu-btn { display: none; }
}

/* --------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  .sidebar { box-shadow: 0 0 60px rgba(0, 0, 0, .3); }
  .main:has(#emptyState) { padding-bottom: 0; }
}
@media (max-width: 560px) {
  .composer-wrap { padding: 0 12px 6px; }
  .thread { padding: 12px 16px 28px; }
  .empty-state { padding: 0 16px 20px; }
  .web-btn:not(.active) span { display: none; }
  .web-btn:not(.active) { width: 32px; padding: 0; justify-content: center; }
  .msg.user .body { max-width: 90%; }
  .popover { left: 10px; right: 10px; width: auto; }
}
@media (max-height: 620px) { .main:has(#emptyState) { padding-bottom: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* speed / quality switch in the voice card */
.vp-mode { display: flex; gap: 6px; margin-bottom: 10px; }
.vp-mode:empty { display: none; }
.vp-m {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); text-align: left;
  transition: border-color .15s, background .15s, box-shadow .2s, transform .25s var(--spring);
}
.vp-m:hover:not(:disabled) { background: var(--bg-hover); }
.vp-m:active:not(:disabled) { transform: scale(.98); }
.vp-m.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.vp-m:disabled { opacity: .5; cursor: default; }
.vp-m-t { font-size: 13.5px; font-weight: 650; color: var(--text); }
.vp-m-h { font-size: 11.5px; color: var(--text-faint); }
.vp-eta { flex: none; font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vp-tabs[hidden] { display: none !important; }

/* ---- Inter (self-hosted) for the sidebar ---- */
@font-face { font-family: "Inter UI"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/assets/fonts/inter-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter UI"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/assets/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
.sidebar, .sidebar :is(button, input, a, span, small) {
  font-family: "Inter UI", var(--font); font-feature-settings: "cv11", "ss03"; letter-spacing: -.005em; }
.sidebar .side-link, .sidebar .new-btn { font-weight: 500; font-size: 13.5px; }
.sidebar .side-link.active { font-weight: 600; }
.vp-m-t { display: inline-flex; align-items: center; gap: 6px; }
.vp-m-i { width: 15px; height: 15px; color: var(--accent); }

/* ---- brand lockup: mark + live wordmark with blinking cursor ---- */
.brand-logo { gap: 9px; }
.bl-mark { display: block !important; height: 28px; }
.bl-word { display: inline-flex; align-items: center; gap: 4px; height: 28px; }
.bl-t { font: 700 17px/1 "Inter UI", var(--font); letter-spacing: .16em; color: var(--text); padding-left: 1px; }
.bl-cur { width: 6px; height: 17px; border-radius: 1.5px; background: #EE7340; animation: blcur 1.05s steps(1, end) infinite; }
@keyframes blcur { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
.app.side-collapsed .bl-word { display: none; }
.login-title .bl-word, .login-title .bl-mark { display: inline-flex !important; }

/* ---- chat list skeleton ---- */
.sk-row { height: 34px; padding: 0 12px; display: flex; align-items: center; opacity: 0; animation: skin .3s ease forwards; }
.sk-row i { display: block; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--sel) 50%, var(--bg-hover) 75%); background-size: 220% 100%;
  animation: skshim 1.2s linear infinite; }
@keyframes skin { to { opacity: 1; } }
@keyframes skshim { from { background-position: 120% 0; } to { background-position: -120% 0; } }
#history.fade-in > * { animation: histin .35s var(--ease) both; }
@keyframes histin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* the blinking cursor and skeleton are the page's "alive" signals: keep them even with reduced motion (soft, no movement) */
@media (prefers-reduced-motion: reduce) {
  .bl-cur { animation: blcur 1.05s steps(1, end) infinite !important; }
  .sk-row { animation: skin .3s ease forwards !important; animation-duration: .3s !important; animation-iteration-count: 1 !important; }
  .sk-row i { animation: skshim 1.6s linear infinite !important; animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}

/* ---- "Прочее": collapsible group ---- */
.more-toggle { width: 100%; }
.more-toggle .more-caret { margin-left: auto; width: 14px; height: 14px; transition: transform .25s var(--ease); }
.side-more.open .more-caret { transform: rotate(90deg); }
.side-more-list { position: relative; margin-left: 22px; max-height: 0; overflow: hidden; transition: max-height .3s var(--ease); display: flex; flex-direction: column; gap: 1px; }
.side-more.open .side-more-list { max-height: 200px; }
.side-more-list .side-link { height: 34px; font-size: 13.5px; opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .25s var(--ease); }
.side-more.open .side-more-list .side-link { opacity: 1; transform: none; }
.side-more:not(.open) .side-more-list .side-link { pointer-events: none; }
.side-more.open .side-more-list::before { content: ""; position: absolute; left: -9px; top: 2px; bottom: 2px; width: 1px; background: var(--border); }
.app.side-collapsed .more-toggle .more-caret { display: none; }
.app.side-collapsed .side-more-list { margin-left: 0; }

/* ---- model menu: minimal ---- */
#modelPop { width: 272px; padding: 5px; }
#modelPop .pop-title { padding: 5px 9px 4px; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
#modelList { display: flex; flex-direction: column; gap: 1px; }
.pop-item.mdl { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 9px; text-align: left; border: 0; background: none; }
.pop-item.mdl:hover { background: var(--bg-hover); }
.pop-item.mdl.active { background: var(--sel); }
.mdl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mdl-top { display: flex; align-items: center; gap: 7px; }
.mdl-body .pi-title { font-size: 13.5px; font-weight: 600; }
.mdl-body .pi-desc { font-size: 11.5px; line-height: 1.3; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mdl-tag { font-style: normal; font-size: 10.5px; line-height: 1; padding: 3px 6px; border-radius: 999px; color: var(--accent); background: var(--accent-soft); }
.mdl-chk { flex: none; width: 16px; height: 16px; color: var(--accent); }
.mdl-chk .ico { width: 16px; height: 16px; stroke-width: 2.2; }
#modelPop .pop-sep { margin: 4px 3px; }
#modelPop #reasonRow { padding: 7px 9px; border-radius: 9px; font-size: 13px; }
#modelPop .pop-note { margin: 0 3px 2px; padding: 6px 9px; font-size: 11.5px; line-height: 1.35; background: none; color: var(--text-faint); }
@media (max-width: 400px) { #modelPop { width: auto; } }
/* the open model menu must not sit on top of the suggestion chips */
.main:has(#modelPop:not([hidden])) #below { opacity: 0; pointer-events: none; transition: opacity .15s; }
#below { transition: opacity .15s; }

/* model menu: centred names, no "always thinks" note */
#reasonNote { display: none !important; }
#reasonSection:has(#reasonRow[hidden]) { display: none !important; }
.pop-item.mdl { position: relative; justify-content: center; text-align: center; padding: 8px 28px; }
.pop-item.mdl .mdl-body { align-items: center; text-align: center; }
.pop-item.mdl .mdl-top { justify-content: center; }
.pop-item.mdl .mdl-chk { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
#modelPop .pop-title { text-align: center; }

/* model menu: 2x2 grid */
#modelPop { width: 296px; padding: 8px; }
#modelPop .pop-title { padding: 2px 4px 8px; }
#modelList { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pop-item.mdl { flex-direction: column; justify-content: center; height: 64px; padding: 0 8px; gap: 0;
  border: 1px solid var(--border); border-radius: 12px; background: none; transition: background .15s, border-color .15s, transform .15s var(--ease); }
.pop-item.mdl:hover { background: var(--bg-hover); }
.pop-item.mdl:active { transform: scale(.98); }
.pop-item.mdl.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.pop-item.mdl .mdl-body { gap: 3px; width: 100%; }
.pop-item.mdl .pi-title { font-size: 14px; font-weight: 600; line-height: 1.1; }
.pop-item.mdl .pi-desc { font-size: 11.5px; line-height: 1.1; max-width: 100%; }
.pop-item.mdl .mdl-chk { right: 7px; top: 7px; transform: none; width: 14px; height: 14px; }
.pop-item.mdl .mdl-chk .ico { width: 14px; height: 14px; }
.pop-item.mdl .mdl-top { gap: 6px; }
.mdl-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
#modelPop .pop-sep { margin: 8px 0 6px; }
.pop-item.mdl { position: relative; }
.pop-item.mdl .mdl-dot { position: absolute; left: 9px; top: 9px; }

/* ---- model menu: reference-style list ---- */
#modelPop { width: 252px; padding: 5px; }
#modelPop .pop-title { display: none; }
#modelList { display: flex; flex-direction: column; gap: 0; }
.pop-item.mdl { flex-direction: row; align-items: center; justify-content: space-between; height: 36px; padding: 0 12px; gap: 12px;
  border: 0; border-radius: 9px; background: none; text-align: left; transform: none; }
.pop-item.mdl:hover { background: var(--bg-hover); }
.pop-item.mdl.active, .pop-item.mdl.active:hover { background: none; }
.pop-item.mdl .pi-title { font-size: 14px; font-weight: 500; color: var(--text); }
.pop-item.mdl .mdl-r { margin-left: auto; font-size: 12.5px; color: var(--text-faint); display: inline-flex; width: 18px; justify-content: flex-end; }
.pop-item.mdl .mdl-ck { width: 17px; height: 17px; stroke-width: 2.2; color: var(--accent); }
#modelPop .pop-sep { margin: 5px 4px; }
#modelPop #reasonRow { height: 36px; padding: 0 12px; border-radius: 9px; font-size: 14px; }
#modelPop #reasonRow .pr-val { font-size: 13px; }

/* ---- mic button ---- */
.mic-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: none; border: 0;
  color: var(--text-faint); cursor: pointer; transition: background .15s, color .15s; }
.mic-btn[hidden] { display: none; }
.mic-btn:hover { background: var(--bg-hover); color: var(--text); }
.mic-btn .ico { width: 19px; height: 19px; }
.mic-btn.rec { color: #fff; background: #e5484d; animation: micpulse 1.4s ease-out infinite; }
@keyframes micpulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 100% { box-shadow: 0 0 0 10px rgba(229,72,77,0); } }
@media (prefers-reduced-motion: reduce) { .mic-btn.rec { animation: micpulse 1.4s ease-out infinite !important; } }

/* ---- reasoning depth: label + always-visible segmented control ---- */
#modelPop #reasonRow { height: 26px; padding: 0 12px; pointer-events: none; cursor: default; background: none; }
#modelPop #reasonRow .pr-name { font-size: 11.5px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
#modelPop #reasonRow :is(.pr-val, .pr-chev) { display: none; }
#modelPop .reason-slider:not(.open) { display: block !important; }
#modelPop .reason-slider { padding: 0 8px 6px; }
#modelPop .reason-slider .rs-labels { gap: 2px; padding: 3px; border-radius: 10px; }
#modelPop .reason-slider .rs-tick { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; padding: 6px 0; font-size: 12.5px; border-radius: 8px; }
#modelPop { width: 280px; }
#modelPop .reason-slider .rs-tick { font-size: 12px; }

/* ---- reasoning depth: slider with caption ---- */
#modelPop .reason-slider .rs-labels { display: none; }
#modelPop .reason-slider input[type=range] { display: block; width: 100%; margin: 4px 0 0; height: 22px; padding: 0; background: none; -webkit-appearance: none; appearance: none; cursor: pointer; --p: 33%; }
#modelPop .reason-slider input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--border-strong, rgba(255,255,255,.14)) var(--p)); }
#modelPop .reason-slider input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--border-strong, rgba(255,255,255,.14)); }
#modelPop .reason-slider input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
#modelPop .reason-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); transition: transform .12s; }
#modelPop .reason-slider input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
#modelPop .reason-slider input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }
#modelPop .reason-slider { padding: 0 14px 10px; }
.rs-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 12px; color: var(--text-faint); }
.rs-caption b { font-weight: 600; font-size: 13px; color: var(--text); }

/* =====================================================================
   Model menu v3 — follows the reference: name (+badge) / description,
   check on the right, then a "Рассуждение  Высокий ›" row that expands
   the depth slider. Model chip lives inside the composer, next to the mic.
   ===================================================================== */
.composer .tools .model-chip { height: 34px; padding: 0 12px; gap: 7px; border-radius: 10px; border: 0;
  background: var(--bg-hover); color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; transition: background .15s; }
.composer .tools .model-chip:hover, .composer .tools .model-chip[aria-expanded=true] { background: var(--sel); }
.composer .tools .model-chip .reason-chip { color: var(--text-faint); font-size: 14px; font-weight: 400; }
.composer .tools .mic-btn { margin-left: 2px; }
body.audio-mode .composer .tools .model-chip { display: none !important; }
.main:has(#emptyState) .composer-wrap + .below .chips, .main:has(#emptyState) #below .chips { padding-top: 18px; }

#modelPop { width: 400px; padding: 6px; border-radius: 14px; }
#modelPop .pop-title { display: none; }
#modelList { display: flex; flex-direction: column; gap: 0; }
#modelPop .pop-item.mdl { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 14px;
  height: auto; min-height: 0; padding: 8px 14px; border: 0; border-radius: 10px; background: none; text-align: left; transform: none; position: relative; }
#modelPop .pop-item.mdl:hover { background: var(--bg-hover); }
#modelPop .pop-item.mdl.active, #modelPop .pop-item.mdl.active:hover { background: none; }
#modelPop .pop-item.mdl.active:hover { background: var(--bg-hover); }
#modelPop .mdl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
#modelPop .mdl-top { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
#modelPop .mdl-body .pi-title { font-size: 15px; font-weight: 500; line-height: 1.3; color: var(--text); }
#modelPop .mdl-body .pi-desc { font-size: 13px; line-height: 1.3; color: var(--text-faint); white-space: normal; overflow: visible; max-width: none; }
#modelPop .mdl-badge { font-style: normal; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-faint); }
#modelPop .mdl-r { flex: none; width: 20px; height: 20px; display: grid; place-items: center; margin: 0; position: static; transform: none; }
#modelPop .mdl-ck { width: 18px; height: 18px; stroke-width: 2.2; color: var(--accent); }
#modelPop .mdl-dot, #modelPop .mdl-chk { display: none; }
#modelPop .pop-sep { margin: 6px 8px; height: 1px; }

#modelPop #reasonRow { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px; border-radius: 10px;
  pointer-events: auto; cursor: pointer; background: none; width: 100%; }
#modelPop #reasonRow:hover { background: var(--bg-hover); }
#modelPop #reasonRow .pr-name { flex: 1; font-size: 15px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text); text-align: left; }
#modelPop #reasonRow .pr-val { display: inline; font-size: 14px; color: var(--text-faint); }
#modelPop #reasonRow .pr-chev { display: inline-block; width: 16px; height: 16px; color: var(--text-faint); transition: transform .2s var(--ease); }
#modelPop #reasonRow.open .pr-chev { transform: rotate(90deg); }
#modelPop #reasonRow.static { cursor: default; }
#modelPop #reasonRow.static:hover { background: none; }
#modelPop #reasonRow.static .pr-chev { display: none; }
#modelPop .reason-slider:not(.open) { display: none !important; }
#modelPop .reason-slider.open { display: block; padding: 2px 14px 10px; }

@media (max-width: 560px) {
  #modelPop { width: auto; left: 10px !important; right: 10px !important; }
  .composer .tools .model-chip .reason-chip { display: none; }
  .composer .tools .model-chip { padding: 0 10px; }
}

/* ---- chat list: audio marker + lazy "more" placeholder ---- */
.chat-item .ct-audio { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 7px;
  border-radius: 6px; color: var(--accent); background: var(--accent-soft); }
.chat-item .ct-audio .ico { width: 12px; height: 12px; stroke-width: 2; }
.chat-item.active .ct-audio { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.hist-more { padding-bottom: 6px; }
/* audio marker: plain glyph after the title */
.chat-item .ct-audio { margin: 0 4px 0 6px; width: 14px; height: 14px; border-radius: 0; background: none !important; color: var(--text-faint); flex: none; display: inline-grid; place-items: center; }
.chat-item .ct-audio .ico { width: 14px; height: 14px; stroke-width: 1.6; }
.chat-item.active .ct-audio, .chat-item:hover .ct-audio { color: var(--accent); }
.chat-item .ct { flex: 0 1 auto; min-width: 0; }
.chat-item .row-act:first-of-type { margin-left: auto; }

/* =====================================================================
   Voice sheet ("Кто озвучит?") — centred over the chat, minimal
   ===================================================================== */
.vx-layer { position: absolute; inset: 52px 0 0 0; z-index: 40; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.vx-back { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity .22s ease; pointer-events: auto; }
.vx-card { position: relative; width: min(460px, 100%); max-height: calc(100% - 8px); overflow: auto;
  padding: 18px 18px 16px; border-radius: 20px; background: var(--comp); border: 1px solid var(--border);
  box-shadow: 0 24px 60px -12px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.18); pointer-events: auto;
  opacity: 0; transform: translateY(14px) scale(.96); transform-origin: 50% 60%;
  transition: opacity .22s ease, transform .38s cubic-bezier(.2, 1.15, .35, 1); }
.vx-layer.in .vx-back { opacity: 1; }
.vx-layer.in .vx-card { opacity: 1; transform: none; }
.vx-layer.out .vx-back { opacity: 0; transition-duration: .18s; }
.vx-layer.out .vx-card { opacity: 0; transform: translateY(8px) scale(.97); transition: opacity .16s ease, transform .2s ease; }

.vx-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vx-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.vx-x { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; border: 0; background: none; color: var(--text-faint); cursor: pointer; margin-right: -6px; }
.vx-x:hover { background: var(--bg-hover); color: var(--text); }
.vx-x .ico { width: 16px; height: 16px; }
.vx-sub { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 14px; font-size: 13px; color: var(--text-faint); min-width: 0; }
.vx-quote { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vx-len { flex: none; font-variant-numeric: tabular-nums; }

/* Быстро / Качество */
.vx-seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 11px; background: var(--bg-hover); margin-bottom: 12px; }
.vx-seg[hidden] { display: none; }
.vx-seg-pill { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 8px; background: var(--comp);
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform .3s cubic-bezier(.3, 1.2, .4, 1); }
.vx-seg-b { position: relative; z-index: 1; height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: none; color: var(--text-faint); font-size: 13.5px; font-weight: 500; cursor: pointer; border-radius: 8px; transition: color .15s; }
.vx-seg-b .ico { width: 14px; height: 14px; }
.vx-seg-b.on { color: var(--text); }
.vx-seg-b.on .ico { color: var(--accent); }
.vx-seg-b:disabled { opacity: .45; cursor: not-allowed; }

/* group tabs: plain text, underline */
.vx-tabs { display: flex; gap: 16px; margin: 0 2px 10px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.vx-tabs::-webkit-scrollbar { display: none; }
.vx-tabs[hidden] { display: none; }
.vx-tab { position: relative; flex: none; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0; border: 0; background: none;
  color: var(--text-faint); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.vx-tab:hover { color: var(--text-soft); }
.vx-tab.on { color: var(--text); }
.vx-tab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.vx-cnt { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* voice tiles */
.vx-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.vx-v { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 8px; border-radius: 12px; border: 1px solid transparent;
  background: none; color: var(--text); text-align: left; cursor: pointer; transition: background .15s, border-color .15s;
  animation: vxin .32s cubic-bezier(.2, 1, .3, 1) both; animation-delay: var(--d, 0ms); }
.vx-v:hover { background: var(--bg-hover); }
.vx-v.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.vx-v:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@keyframes vxin { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.vx-av { position: relative; flex: none; width: 34px; height: 34px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: hsl(var(--h, 30) 55% 45%); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.vx-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.vx-ov { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .15s; }
.vx-ov svg { width: 16px; height: 16px; fill: #fff; display: none; }
.vx-av:hover .vx-ov, .vx-av.loading .vx-ov, .vx-av.playing .vx-ov { opacity: 1; }
.vx-av:not(.loading):not(.playing) .vx-ic-play { display: block; }
.vx-av.playing .vx-ic-stop { display: block; }
.vx-spin { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: vxspin .7s linear infinite; }
.vx-av.loading .vx-spin { display: block; }
@keyframes vxspin { to { transform: rotate(360deg); } }
.vx-vt { display: flex; flex-direction: column; min-width: 0; }
.vx-name { font-size: 13.5px; font-weight: 500; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vx-note { font-size: 11.5px; line-height: 1.25; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* footer */
.vx-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.vx-speed { display: flex; align-items: center; gap: 2px; }
.vx-speed-l { font-size: 12.5px; color: var(--text-faint); margin-right: 6px; }
.vx-sp { height: 28px; min-width: 38px; padding: 0 7px; border-radius: 8px; border: 0; background: none; color: var(--text-faint);
  font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer; transition: background .15s, color .15s; }
.vx-sp:hover { color: var(--text); background: var(--bg-hover); }
.vx-sp.on { color: var(--text); background: var(--bg-hover); font-weight: 600; }
.vx-go { height: 38px; padding: 0 16px; border: 0; border-radius: 11px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; transition: filter .15s, transform .12s; white-space: nowrap; }
.vx-go:hover { filter: brightness(1.08); }
.vx-go:active { transform: scale(.97); }
.vx-eta { font-weight: 400; opacity: .8; font-size: 12.5px; }

@media (max-width: 520px) {
  .vx-layer { padding: 10px; align-items: end; }
  .vx-card { padding: 16px 14px 14px; border-radius: 18px; }
  .vx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vx-foot { flex-wrap: wrap; }
  .vx-go { flex: 1; justify-content: center; }
  .vx-speed-l { display: none; }
}
/* the sheet's open/close motion is short and soft: keep it even with reduced motion */
@media (prefers-reduced-motion: reduce) {
  .vx-layer .vx-back { transition-duration: .22s !important; }
  .vx-layer .vx-card { transition-duration: .22s, .38s !important; }
  .vx-layer.out .vx-card { transition-duration: .16s, .2s !important; }
  .vx-layer .vx-seg-pill { transition-duration: .3s !important; }
  .vx-layer .vx-v { animation-duration: .32s !important; }
  .vx-layer .vx-spin { animation-duration: .7s !important; animation-iteration-count: infinite !important; }
}

/* voice choice as an in-chat message (no overlay) */
.vx-inline { display: flex; justify-content: center; margin: 6px 0 22px; overflow: visible; transition: height .26s ease, margin .26s ease; }
.vx-inline .vx-card { width: min(480px, 100%); max-height: none; overflow: visible; box-shadow: 0 10px 30px -14px rgba(0,0,0,.45); }
.vx-inline.in .vx-card { opacity: 1; transform: none; }
.vx-inline.out { overflow: hidden; margin: 0; }
.vx-inline.out .vx-card { opacity: 0; transform: translateY(-6px) scale(.97); transition: opacity .18s ease, transform .22s ease; }
@media (prefers-reduced-motion: reduce) {
  .vx-inline .vx-card { transition-duration: .22s, .38s !important; }
  .vx-inline.out .vx-card { transition-duration: .18s, .22s !important; }
  .vx-inline { transition-duration: .26s !important; }
  .vx-inline .vx-seg-pill { transition-duration: .3s !important; }
  .vx-inline .vx-v { animation-duration: .32s !important; }
  .vx-inline .vx-spin { animation-duration: .7s !important; animation-iteration-count: infinite !important; }
}

/* ---- audio player ---- */
.ap { display: flex; align-items: center; gap: 12px; width: min(440px, 100%); margin: 6px 0 4px; padding: 8px 10px 8px 8px;
  border-radius: 16px; background: var(--comp); border: 1px solid var(--border); font-family: var(--font); }
.ap audio { display: none; }
.ap-play { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: #fff; transition: transform .12s, filter .15s; }
.ap-play:hover { filter: brightness(1.08); }
.ap-play:active { transform: scale(.94); }
.ap-play svg { width: 18px; height: 18px; fill: currentColor; }
.ap-play .ap-i-pause, .ap.playing .ap-play .ap-i-play { display: none; }
.ap.playing .ap-play .ap-i-pause { display: block; }
.ap-wave { flex: 1; min-width: 0; height: 30px; display: flex; align-items: center; gap: 2px; cursor: pointer; touch-action: none; border-radius: 6px; }
.ap-wave:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ap-wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: var(--text-faint); opacity: .45;
  transition: background .12s, opacity .12s, height .35s ease; }
.ap-wave i.on { background: var(--accent); opacity: 1; }
.ap-wave:hover i:not(.on) { opacity: .6; }
.ap-time { flex: none; min-width: 34px; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; text-align: right; }
.ap-dl { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--text-faint); transition: background .15s, color .15s; }
.ap-dl:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.ap-dl svg { width: 18px; height: 18px; }
.msg.assistant .content .ap * { font-family: var(--font); }

/* ---- right-click menu + selection toolbar ---- */
.ctx { position: fixed; z-index: 300; min-width: 232px; max-width: 320px; padding: 5px; border-radius: 13px; background: var(--comp);
  border: 1px solid var(--border); box-shadow: 0 18px 44px -12px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.2);
  opacity: 0; transform: scale(.96); transition: opacity .12s ease, transform .16s cubic-bezier(.2, 1, .3, 1); font-family: var(--font); }
.ctx.in { opacity: 1; transform: none; }
.ctx.out { opacity: 0; transform: scale(.97); transition-duration: .1s; }
.ctx-i { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; min-height: 34px; padding: 6px 11px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 13.5px; text-align: left; cursor: pointer; }
.ctx-i:hover, .ctx-i:focus-visible { background: var(--bg-hover); outline: none; }
.ctx-i:disabled { color: var(--text-faint); opacity: .55; cursor: default; background: none; }
.ctx-i.danger { color: #e5484d; }
.ctx-l { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ctx-s { font-size: 11.5px; line-height: 1.3; color: var(--text-faint); white-space: normal; }
.ctx-h { flex: none; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--border); }

.selbar { position: fixed; z-index: 290; display: flex; align-items: center; padding: 3px; border-radius: 11px; background: var(--comp);
  border: 1px solid var(--border); box-shadow: 0 10px 28px -10px rgba(0,0,0,.5); opacity: 0; transform: translateY(4px) scale(.97);
  transition: opacity .14s ease, transform .18s cubic-bezier(.2, 1, .3, 1); font-family: var(--font); }
.selbar.in { opacity: 1; transform: none; }
.selbar-b { height: 30px; padding: 0 11px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap; }
.selbar-b:hover { background: var(--bg-hover); }
.selbar-sep { width: 1px; height: 16px; background: var(--border); }
.chat-item .ct-edit { flex: 1; min-width: 0; height: 28px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--accent); background: var(--bg); color: var(--text); font: inherit; outline: none; }
@media (prefers-reduced-motion: reduce) {
  .ctx, .selbar { transition-duration: .14s !important; }
}
.brand-logo { cursor: pointer; border-radius: 8px; transition: opacity .15s; }
.brand-logo:hover { opacity: .85; }
.brand-logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.main:has(#emptyState) #scrollDown { display: none !important; }

/* ---- "Новый чат": soft accent card with a chat+plus glyph ---- */
.new-btn { position: relative; display: flex; align-items: center; gap: 11px; height: 44px; margin: 4px 8px 8px; padding: 0 12px 0 7px;
  border-radius: 14px; border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border)); color: var(--text); font-weight: 600;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent) 5%, transparent));
  cursor: pointer; overflow: hidden; transition: border-color .2s, box-shadow .25s, background .25s, transform .12s; }
.new-btn::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120px 60px at var(--mx, 20%) 0%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%);
  opacity: 0; transition: opacity .25s; pointer-events: none; }
.new-btn:hover { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent) 8%, transparent));
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border)); box-shadow: 0 6px 18px -10px var(--accent); }
.new-btn:hover::before { opacity: 1; }
.new-btn:active { transform: scale(.985); }
.new-btn .ic { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; margin: 0; color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 92%, #fff), color-mix(in srgb, var(--accent) 78%, #000));
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.28); transition: transform .35s cubic-bezier(.3, 1.4, .5, 1); }
.new-btn:hover .ic { transform: rotate(-8deg) scale(1.07); }
.new-btn .ic .ico { width: 18px; height: 18px; stroke-width: 1.9; }
.new-btn .nb-t { flex: 1; text-align: left; font-size: 14px; color: var(--text); }
.new-btn .nb-k { flex: none; font: 500 10.5px/1 var(--font); padding: 4px 6px; border-radius: 6px; color: var(--text-faint);
  background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid var(--border); }
.app.side-collapsed .new-btn { width: 44px; height: 44px; padding: 0; margin: 4px auto 8px; justify-content: center; border-radius: 14px; }
.app.side-collapsed .new-btn .nb-t, .app.side-collapsed .new-btn .nb-k { display: none; }

/* "Новый чат": minimal — no outline, just a soft tint */
.new-btn { border: 0; box-shadow: none; background: var(--accent-soft); }
.new-btn::before { display: none; }
.new-btn:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); border: 0; box-shadow: none; }
.new-btn .ic { background: var(--accent); box-shadow: none; width: 28px; height: 28px; border-radius: 9px; }
.new-btn:hover .ic { transform: scale(1.06); }

/* collapsed rail: a visible "show panel" button in the top bar */
.app.side-collapsed .desktop-menu-btn { display: inline-grid !important; }

/* model chip: no fill at rest, a soft highlight only on hover / while the menu is open */
.composer .tools .model-chip { background: transparent; }
.composer .tools .model-chip:hover, .composer .tools .model-chip[aria-expanded=true] { background: var(--bg-hover); }

/* voice names: smaller, up to two lines, never cut with "…" */
.vx-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.vx-v { align-items: center; padding: 7px 6px; gap: 7px; }
.vx-av { width: 32px; height: 32px; }
.vx-vt { flex: 1; min-width: 0; }
.vx-name { font-size: 12px; font-weight: 500; line-height: 1.2; letter-spacing: -.005em; white-space: normal; overflow: hidden; text-overflow: clip;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; hyphens: auto; word-break: break-word; }
@media (max-width: 520px) { .vx-name { font-size: 12.5px; } }

/* chat row: title, marker(s) | link, delete. Delete is always the rightmost control. */
.chat-item .row-act:first-of-type { margin-left: 0; }
.chat-item .row-link { margin-left: auto; }
.chat-item .row-del { margin-left: 0; margin-right: 0; order: 99; flex: none; }
.chat-item .row-link { flex: none; }
.chat-item .ct { flex: 0 1 auto; }

/* ---- confirm / prompt dialogs ---- */
.dlg-back { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 62%, transparent); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .18s ease; }
.dlg-back.in { opacity: 1; }
.dlg-back.out { opacity: 0; }
.dlg { width: min(380px, 100%); padding: 20px 20px 16px; border-radius: 18px; background: var(--comp); border: 1px solid var(--border);
  box-shadow: 0 28px 70px -14px rgba(0,0,0,.6); font-family: var(--font); transform: translateY(10px) scale(.96); opacity: 0;
  transition: transform .32s cubic-bezier(.2, 1.15, .35, 1), opacity .18s ease; }
.dlg-back.in .dlg { transform: none; opacity: 1; }
.dlg-back.out .dlg { transform: translateY(6px) scale(.98); opacity: 0; transition-duration: .16s; }
.dlg-title { font-size: 16.5px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.dlg-text { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--text-faint); }
.dlg-input { width: 100%; margin-top: 12px; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.dlg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dlg-b { height: 36px; padding: 0 16px; border-radius: 10px; border: 0; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .15s, filter .15s, transform .1s; }
.dlg-b:active { transform: scale(.97); }
.dlg-no { background: var(--bg-hover); color: var(--text); }
.dlg-no:hover { filter: brightness(1.12); }
.dlg-yes { background: var(--accent); color: #fff; }
.dlg-yes.danger { background: #d8444a; }
.dlg-yes:hover { filter: brightness(1.08); }
.dlg-b:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .dlg-back, .dlg { transition-duration: .18s !important; }
}

/* ---- attached photos ---- */
.att-chip.att-img { display: inline-flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; border-radius: 12px; max-width: 280px; }
.att-th { flex: none; width: 40px; height: 40px; border-radius: 9px; overflow: hidden; background: var(--bg); }
.att-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-tx { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.att-name { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.att-st { font-size: 11.5px; color: var(--text-faint); }
.att-st.reading::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%;
  border: 1.5px solid var(--text-faint); border-top-color: var(--accent); animation: vxspin .8s linear infinite; vertical-align: -1px; }
.att-st.ready { color: #5cc08a; }
.att-st.noread { color: #e8a23c; }
.att-edit { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--border);
  background: none; color: var(--text-soft); font-size: 12.5px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.att-edit .ico { width: 14px; height: 14px; }
.att-edit:hover { background: var(--bg-hover); color: var(--text); }
.att-edit.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--text); }
.att-edit.on .ico { color: var(--accent); }
.msg.user .content img { max-width: min(320px, 100%); border-radius: 12px; display: block; margin: 6px 0; cursor: zoom-in; }
@media (prefers-reduced-motion: reduce) { .att-st.reading::before { animation: vxspin .8s linear infinite !important; } }

/* ---- login / sign-up tabs ---- */
.lg-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin: 0 0 18px; border-radius: 11px; background: var(--bg-hover); }
.lg-tabs[hidden], .lg-view[hidden] { display: none; }
.lg-tab { height: 34px; border: 0; border-radius: 8px; background: none; color: var(--text-faint); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s; }
.lg-tab.on { background: var(--comp); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.22); }
.lg-link { display: block; width: 100%; margin: 12px 0 0; padding: 4px; border: 0; background: none; color: var(--text-faint); font: inherit; font-size: 13px; cursor: pointer; text-align: center; }
.lg-link:hover { color: var(--accent); }
.lg-hint { margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; color: var(--text-faint); text-align: center; }
.lg-code { text-align: center; font-size: 22px !important; letter-spacing: .5em; font-variant-numeric: tabular-nums; padding-left: 20px !important; }
.login-err:not(:empty) { margin-top: 12px; text-align: center; }

/* ---- plan / limits / pricing ---- */
.mdl-lock { width: 15px; height: 15px; color: var(--text-faint); }
#modelPop .pop-item.mdl.locked .pi-title { color: var(--text-faint); }
.bill { display: flex; flex-direction: column; gap: 14px; min-width: min(640px, 80vw); }
.bill-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bill-h-l { font-size: 13px; color: var(--text-faint); }
.bill-plan { padding: 3px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }
.bill-exp { font-size: 12.5px; color: var(--text-faint); }
.bill-meter { padding: 12px 14px; border-radius: 13px; background: var(--bg-hover); }
.bill-m-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13.5px; }
.bill-m-t { font-weight: 600; color: var(--text); }
.bill-m-v { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.bill-bar { height: 7px; margin: 9px 0 7px; border-radius: 6px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.bill-bar i { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .5s var(--ease); }
.bill-bar i.hot { background: #e5484d; }
.bill-m-s { font-size: 12px; color: var(--text-faint); min-height: 14px; }
.bill-note { margin: -2px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-faint); }
.bill-promo { display: flex; gap: 8px; }
.bill-in { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font: inherit; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; outline: none; }
.bill-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bill-btn { height: 38px; padding: 0 15px; border-radius: 10px; border: 0; background: var(--bg-hover); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s; }
.bill-btn:hover:not(:disabled) { filter: brightness(1.12); }
.bill-btn.is-primary { background: var(--accent); color: #fff; }
.bill-btn.ghost { background: none; border: 1px solid var(--border); color: var(--text-faint); }
.bill-btn:disabled { opacity: .6; cursor: default; }
.bill-sec { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; font-weight: 600; font-size: 14px; }
.bill-months { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--bg-hover); }
.bill-mon { height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--text-faint); font: inherit; font-size: 12.5px; cursor: pointer; }
.bill-mon.on { background: var(--comp); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.bill-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.bill-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 14px; border: 1px solid var(--border); }
.bill-card.cur { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft); }
.bill-c-n { font-size: 15px; font-weight: 700; }
.bill-c-p { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.bill-c-p span:last-child { font-size: 13px; font-weight: 500; color: var(--text-faint); }
.bill-c-l { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 12.5px; line-height: 1.4; color: var(--text-soft); }
.bill-notice { padding: 14px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); max-width: 460px; font-family: var(--font); }
.bill-n-t { font-weight: 700; font-size: 15px; color: var(--text); }
.bill-n-s { margin: 4px 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--text-soft); }
.bill-n-b { display: flex; gap: 8px; flex-wrap: wrap; }
.bill { min-width: 0; width: 100%; }
.modal-card:has(.bill) { width: min(780px, 94vw); max-width: none; }
.bill-meter, .bill-promo, .bill-plans { min-width: 0; }

/* =====================================================================
   Limits: ring next to the model chip, popover, cost under answers,
   and the redesigned "Лимиты и тарифы" window (everything in percent)
   ===================================================================== */
.lim-ring { width: 30px; height: 30px; margin-left: 2px; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; cursor: pointer; color: var(--accent); transition: background .15s; }
.lim-ring[hidden] { display: none; }
.lim-ring:hover { background: var(--bg-hover); }
.lim-ring svg { width: 22px; height: 22px; transform: rotate(-90deg); }
.lim-ring circle { fill: none; stroke-width: 3; }
.lim-ring .lr-bg { stroke: color-mix(in srgb, var(--text) 16%, transparent); }
.lim-ring .lr-fg { stroke: currentColor; stroke-linecap: round; stroke-dasharray: var(--p, 0) 100; transition: stroke-dasharray .6s var(--ease), color .3s; }
.lim-ring.hot { color: #e5484d; }
body.audio-mode .lim-ring { display: none !important; }

.lim-pop { position: fixed; z-index: 120; width: min(360px, calc(100vw - 16px)); padding: 14px 16px 6px; border-radius: 16px; background: var(--comp); border: 1px solid var(--border);
  box-shadow: 0 20px 50px -14px rgba(0,0,0,.55); font-family: var(--font); animation: limin .18s cubic-bezier(.2, 1, .3, 1) both; }
.lim-pop[hidden] { display: none; }
@keyframes limin { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.lim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.lim-h { font-size: 13px; color: var(--text-faint); }
.lim-all { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.lim-all .ico { width: 14px; height: 14px; }
.lim-all:hover { color: var(--accent); }
.lim-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 44px; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.lim-t { font-size: 14px; font-weight: 500; color: var(--text); }
.lim-s { margin-top: 1px; font-size: 12px; color: var(--text-faint); }
.lim-bar { height: 6px; border-radius: 6px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; }
.lim-bar i { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .5s var(--ease); }
.lim-bar i.hot { background: #e5484d; }
.lim-v { text-align: right; font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.ma-limit { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.ma-limit .ico { width: 13px; height: 13px; }
.ma-limit-w { opacity: .8; }

/* window */
.modal-card:has(.bill) { width: min(860px, 95vw); }
.bill { gap: 18px; }
.bill-sec-box { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; border-radius: 16px; background: var(--bg-hover); }
.bill-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bill-h-l { font-size: 15px; font-weight: 600; color: var(--text); margin-right: auto; }
.bill-meter { padding: 0; background: none; border-radius: 0; }
.bill-m-top { align-items: center; }
.bill-m-l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bill-m-t { font-size: 14px; font-weight: 500; color: var(--text); }
.bill-m-s { font-size: 12px; color: var(--text-faint); min-height: 0; }
.bill-m-v { font-size: 15px; font-weight: 600; color: var(--text); }
.bill-bar { height: 8px; margin: 9px 0 0; }
.bill-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.bill-promo { display: flex; gap: 8px; }
.bill-in { text-transform: none; letter-spacing: 0; font-size: 14px; }
.bill-sec { display: flex; align-items: center; justify-content: space-between; margin: 0; }
.bill-sec-t { font-size: 15px; font-weight: 600; color: var(--text); }
.bill-plans { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 12px; }
.bill-card { position: relative; gap: 4px; padding: 16px; border-radius: 16px; transition: border-color .2s, transform .2s var(--ease); }
.bill-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
.bill-card.pop { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.bill-card.cur { border-color: var(--accent); background: var(--accent-soft); }
.bill-ribbon { position: absolute; top: 12px; right: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 600; }
.bill-c-n { font-size: 15px; font-weight: 600; }
.bill-c-p { margin-top: 6px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.bill-cur { font-size: 13px; font-weight: 500; color: var(--text-faint); letter-spacing: 0; }
.bill-per { font-size: 12px; color: var(--text-faint); margin-bottom: 10px; }
.bill-c-l { gap: 6px; margin: 2px 0 8px; font-size: 13px; color: var(--text); }
.bill-c-l li.muted { color: var(--text-faint); font-size: 12px; }
.bill-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; flex: 1; align-content: flex-start; }
.bill-chip { padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); font-size: 11.5px; color: var(--text-soft); }
.bill-card .bill-btn { width: 100%; }
.bill-card .bill-btn { flex: none; height: 40px; margin-top: auto; }
.bill-chips { flex: 1 0 auto; }
.lim-pop { width: min(400px, calc(100vw - 16px)); }
/* Agent workspace: same paper palette across overlays and the conversation. */
:root { --action: color-mix(in srgb, var(--accent) 85%, #000); --panel: var(--bg-elev); }
[hidden] { display: none !important; }
html, body { overscroll-behavior: none; }
.app { height: 100vh; height: 100dvh; overflow: hidden; }
.main { min-height: 0; }
.chat { scroll-behavior: auto; overflow-anchor: none; overscroll-behavior-y: contain; scrollbar-gutter: stable; }
.thread { min-width: 0; }
.msg { animation: none; }
.msg.assistant .content { font-family: var(--font); font-size: var(--base-font,15px); line-height: 1.7; }
.msg .body { min-width: 0; max-width: 100%; }
.msg.assistant .content h1 { font-size: 1.5em; }
.msg.assistant .content h2 { font-size: 1.3em; }
.msg.assistant .content h3 { font-size: 1.12em; }
.content pre { max-width: 100%; overscroll-behavior: contain; }
.content p { margin-bottom: 13px; }
.composer-wrap { padding-bottom: max(8px,env(safe-area-inset-bottom)); flex: none; }
.agent-context { max-width: var(--measure); margin: 0 auto 8px; display: flex; align-items: center; gap: 10px; min-height: 30px; font-size: 12px; color: var(--text-faint); }
.agent-context button { flex: none; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-soft); padding: 6px 10px; border-radius: 8px; font: inherit; min-height: 32px; cursor: pointer; }
.agent-context button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-fg); border-color: var(--accent-fg); }
#chatConnections { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#agentStatus { margin-left: auto; flex: none; color: var(--accent-fg); }
.project-context { max-width: 180px; flex: none; padding: 5px 9px; background: var(--accent-soft); color: var(--accent-fg); border: 0; border-radius: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; cursor: pointer; }
.chat-project { display: inline-flex; color: var(--accent-fg); margin-left: auto; flex: none; }
.chat-project .ico { width: 14px; height: 14px; }
.chat-group { padding: 17px 12px 7px; font-size: 11px; font-weight: 600; letter-spacing: .01em; color: var(--text-faint); }
.chat-group:first-child { padding-top: 8px; }
.history .fade-in, .history.fade-in { animation: none; }
#modelPop { width: 320px; max-height: min(560px,80dvh); overflow-y: auto; }
#modelPop .pop-item.mdl { min-height: 52px; height: auto; padding: 10px; gap: 8px; }
#modelPop .pop-item.mdl .pi-title { white-space: normal; line-height: 1.4; }
#modelPop .pop-item.mdl .pi-desc { display: block; white-space: normal; line-height: 1.4; margin-top: 3px; }
#modelPop .pop-item.mdl:disabled { opacity: .6; cursor: wait; }
#modelPop #reasonRow { pointer-events: none; height: 30px; padding: 0 10px; }
#modelPop #reasonRow .pr-name { letter-spacing: 0; text-transform: none; font-size: 12px; }
#modelPop .reason-slider input[type=range] { display: none; }
#modelPop .reason-slider .rs-labels { display: flex; gap: 3px; padding: 4px; background: var(--bg); border-radius: 9px; }
#modelPop .reason-slider .rs-tick { appearance: none; border: 0; flex: 1; min-width: 0; min-height: 36px; padding: 7px 2px; border-radius: 6px; background: none; color: var(--text-faint); font: inherit; font-size: 12px; cursor: pointer; }
#modelPop .reason-slider .rs-tick.active { background: var(--accent-soft); color: var(--accent-fg); font-weight: 600; }
#modelPop .rs-caption { margin-top: 9px; }
:where(.popover,.modal-card,.dlg-card,.ctx-menu,.vx-card,.vp-card,.sources-panel) { background: var(--panel); color: var(--text); }
.modal { padding: 20px; background: rgb(0 0 0 / .42); }
.modal-card { background: var(--panel); border-color: var(--border); border-radius: 14px; max-height: calc(100dvh - 40px); min-width: 0; overflow: hidden; animation: none; }
.modal-head { flex: none; background: var(--panel); color: var(--text); }
.modal-body { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.modal-body .field :is(input,textarea,select), .settings-grid select { background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; min-height: 40px; font: inherit; max-width: 100%; }
.modal-body textarea { resize: vertical; min-height: 90px; }
.modal-body :is(.btn-primary,.btn-ghost,.btn-danger) { min-height: 38px; padding: 9px 13px; border-radius: 8px; font: inherit; font-size: 13px; line-height: 1.3; white-space: normal; }
.btn-primary, .bill-btn.is-primary { background: var(--action); color: white; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.server-form { display: flex; flex-direction: column; gap: 10px; }
.server-form .field { margin-bottom: 0; }
.server-form-grid { display: grid; grid-template-columns: 100px minmax(0,1fr); gap: 14px; }
.server-form-grid .field { min-width: 0; }
.server-form input, .server-form textarea { width: 100%; }
.server-form .muted { margin: 4px 0; font-size: 12px; }
.server-item { align-items: start; gap: 12px; flex-wrap: wrap; }
.server-item .li-main { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.server-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; overflow-wrap: anywhere; }
.form-error:empty { display: none; }
.server-empty { padding: 24px 0; color: var(--text-soft); }
.bill-card { min-width: 0; background: var(--bg); }
.bill-card .bill-btn { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 100%; min-height: 42px; height: auto; padding: 10px 12px; text-align: center; white-space: normal; line-height: 1.35; text-decoration: none; }
.bill-btn.is-primary { background: var(--action); }
.bill-card .bill-btn + .bill-btn { margin-top: 7px; }
.bill-row { min-width: 0; flex-wrap: wrap; }
.bill-promo { min-width: 0; flex-wrap: wrap; }
.bill-promo input { min-width: 0; }
.q-item { gap: 8px; align-items: center; }
.q-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-now-btn { min-height: 34px; font-size: 12px; padding: 6px 9px; color: var(--text-soft); background: var(--bg-hover); border-radius: 8px; }
.send-btn:disabled { cursor: default; opacity: .5; }
.reasoning .rbody { overflow-anchor: none; overscroll-behavior: contain; }
:focus-visible { outline: 2px solid var(--accent-fg); outline-offset: 3px; }
textarea:focus-visible,input:focus-visible { outline: 2px solid var(--accent-fg); outline-offset: 2px; }
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
input,textarea { caret-color: var(--accent-fg); }
@media(max-width:600px) {
 .modal { padding: 10px; }
 .modal-card { width: 100%; max-height: calc(100dvh - 20px); border-radius: 12px; }
 .modal-body { padding: 14px; }
 .agent-context { gap: 7px; font-size: 11px; }
 #chatConnections { display: none; }
 .project-context { max-width: 115px; }
 .tools { flex-wrap: wrap; gap: 5px; }
 .model-chip { max-width: min(230px,60vw); }
 .bill-grid { grid-template-columns: 1fr; }
 .server-actions { width: 100%; }
 .server-form .row-actions { justify-content: flex-end; }
 .content pre { font-size: 12px; }
}
@media(prefers-reduced-motion:reduce) {
 *,*::before,*::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.server-form .row-actions { position: sticky; bottom: -16px; padding: 12px 0; margin-top: 4px; background: var(--panel); z-index: 1; }
/* Contrast and calm status treatment, including the inherited paper controls. */
:root.theme-dark { --text-faint: #a19c90; }
:root.theme-light { --text-faint: #69655d; }
@media(prefers-color-scheme:dark) { :root:not(.theme-light) { --text-faint: #a19c90; } }
@media(prefers-color-scheme:light) { :root:not(.theme-dark) { --text-faint: #69655d; } }
.reasoning .rlabel.thinking { background: none; color: var(--text-soft); -webkit-text-fill-color: currentColor; animation: none; }
.new-btn .ic { box-shadow: none; }
.sp-head { padding: 14px 16px; }
#modelPop .reason-slider:not([hidden]) { display: block !important; padding: 4px 8px 10px; }
#modelPop #reasonRow :is(.pr-val,.pr-chev) { display: none; }
.composer .input:focus-visible { outline: none; }
/* Model and effort menus follow the supplied compact list reference. */
#modelPop { width: 360px; padding: 6px; overflow: visible; }
#modelPop .pop-item.mdl { padding: 9px 10px; min-height: 53px; border-radius: 7px; }
#modelPop .pop-item.mdl.active { background: none; }
#modelPop .pop-item.mdl:hover { background: var(--bg-hover); }
#modelPop #reasonRow { pointer-events: auto; cursor: pointer; padding: 9px 10px; min-height: 36px; height: auto; }
#modelPop #reasonRow .pr-name { font-size: 13px; color: var(--text); }
#modelPop #reasonRow :is(.pr-val,.pr-chev) { display: inline-flex; }
#modelPop #reasonRow:hover, #modelPop #reasonRow.open { background: var(--bg-hover); }
#modelPop #reasonRow .pr-chev { transform: none; }
.reason-menu, .approval-menu { position: fixed; z-index: 90; width: 300px; max-width: calc(100vw - 20px); padding: 6px; overflow-y: auto; background: var(--menu); color: var(--text); }
.reason-help { margin: 6px 8px 10px; color: var(--text-soft); font-size: 12px; line-height: 1.5; }
.reason-option { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 42px; gap: 12px; padding: 8px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.reason-option:hover, .reason-option:focus-visible { background: var(--bg-hover); }
.reason-option .reason-name { display: block; font-size: 13px; }
.reason-option small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }
.reason-check { width: 17px; height: 17px; color: var(--accent-fg); flex: none; visibility: hidden; }
.reason-option[aria-checked=true] .reason-check { visibility: visible; }
.reason-back { display: none; width: 100%; padding: 9px; margin-bottom: 6px; border: 0; border-bottom: 1px solid var(--border); color: var(--text-soft); background: none; text-align: left; font: inherit; font-size: 12px; cursor: pointer; }
.reason-menu.compact .reason-back { display: block; }
.approval-trigger { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 5px 8px; border: 0; border-radius: 8px; background: none; color: var(--text-faint); font: inherit; font-size: 12px; cursor: pointer; }
.approval-trigger:hover, .approval-trigger[aria-expanded=true] { background: var(--bg-hover); color: var(--text); }
.approval-trigger .ico { width: 13px; height: 13px; }
.agent-status { font-size: 12px; color: var(--accent-fg); }
@media(max-width:600px) { #modelPop { width: min(360px,calc(100vw - 20px)); } .approval-trigger { max-width: 155px; } .approval-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
.reason-menu, .approval-menu { right: auto; bottom: auto; height: auto; }
#modelPop .pop-item.mdl { min-height: 38px; padding: 9px 10px; }
#modelPop .pop-item.mdl :is(.pi-desc,.mdl-badge) { display: none; }
.reason-menu .reason-option { min-height: 36px; }
.reason-menu .reason-option small { display: none; }
#modelPop .pop-item.mdl { min-height: 29px; padding: 5px 10px; }
#modelPop .pop-item.mdl .pi-title { font-size: 13px; line-height: 1.35; }
#modelPop .pop-item.mdl .mdl-body { gap: 0; }
#modelPop .pop-item.mdl .pi-title { color: color-mix(in srgb,var(--text) 90%,#fff); }
#modelPop .pop-item.mdl .pi-desc { display: block; margin-top: 1px; color: var(--text-faint); font-size: 11.5px; line-height: 1.4; }
