/* AgentSquad: вид Вайфу (23.11.2026). Пять тем + своя: Ночь (по умолчанию), Дрим, Линия, Апекс, Терминал.
   Тема = набор токенов на <html data-theme>; дальше в CSS только var(--…). Своя тема: токены считает chat.js из трёх
   цветов и кладёт прямо на <html>. Иконки живые (как в CRM «Линия»): части иконки двигаются на наведение и нажатие.
   Движение: окна 200 мс, листы снизу 260 мс, сообщения 180 мс; при «уменьшить движение» остаётся только прозрачность. */

:root {
  color-scheme: dark;
  --canvas: oklch(19.5% .016 255);
  --rail: oklch(16.5% .015 255);
  --surface: oklch(22% .018 255);
  --raised: oklch(25.5% .02 255);
  --field: oklch(24% .019 255);
  --hover: oklch(23% .019 255);
  --line: oklch(31% .02 255);
  --line-soft: oklch(26% .018 255);
  --text: oklch(93.5% .008 250);
  --muted: oklch(74% .018 250);
  --faint: oklch(63% .02 250);
  --accent: oklch(80% .105 228);
  --accent-strong: oklch(86% .09 228);
  --accent-bg: oklch(30% .055 235);
  --accent-text: oklch(90% .05 228);
  --on-accent: oklch(22% .05 240);
  --focus: var(--accent);
  --link: var(--accent);
  --unread: oklch(64% .2 20);
  --on-unread: oklch(99% 0 0);
  --danger: oklch(80% .1 18);
  --signal: oklch(76% .15 155);
  --rail-text: var(--text);
  --rail-muted: var(--muted);
  --rail-hover: oklch(22% .02 255);
  --rail-active-bg: var(--accent-bg);
  --rail-active-text: var(--accent-text);
  --rail-line: var(--line-soft);
  --rail-image: none;
  --code-bg: oklch(28% .02 255);
  --pre-bg: oklch(15.5% .014 255);
  --scrim: oklch(10% .02 255 / .72);
  --shadow-pop: 0 14px 36px -10px oklch(5% .02 255 / .6), 0 2px 6px oklch(5% .02 255 / .3);
  --view-bg: oklch(27% .05 300);
  --view-text: oklch(88% .06 300);
  --who-strength: 100%;
  --font-ui: "Golos Text", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-head: "Geologica", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", ui-monospace, monospace;
  --head-weight: 650;
  --head-track: -.01em;
  --r-s: 8px;
  --r-m: 10px;
  --r-l: 14px;
  --send-r: 11px;
  --avatar-r: 50%;
  --agent-r: 28%;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --fast: 120ms;
  --mid: 200ms;
  --slow: 260ms;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);
  background: var(--canvas);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--accent);
}

/* Дрим: светлая бумага, рельс из тёмно-синего бархата кабинета Coffee Dream, ярко-синее действие. */
html[data-theme="dream"] {
  color-scheme: light;
  --canvas: oklch(96.9% .012 252);
  --rail: oklch(30.5% .115 258);
  --surface: oklch(99.6% .003 252);
  --raised: oklch(99.8% .002 252);
  --field: oklch(98.3% .007 252);
  --hover: oklch(95.2% .016 252);
  --line: oklch(90.6% .017 252);
  --line-soft: oklch(93.9% .012 252);
  --text: oklch(24% .065 258);
  --muted: oklch(44% .05 258);
  --faint: oklch(52% .045 258);
  --accent: oklch(54% .19 259);
  --accent-strong: oklch(47% .18 259);
  --accent-bg: oklch(94.2% .038 259);
  --accent-text: oklch(42% .17 259);
  --on-accent: oklch(99.5% .005 259);
  --unread: oklch(56% .2 25);
  --danger: oklch(52% .19 25);
  --signal: oklch(60% .14 155);
  --rail-text: oklch(99% .004 252);
  --rail-muted: oklch(100% 0 0 / .74);
  --rail-hover: oklch(100% 0 0 / .1);
  --rail-active-bg: oklch(99.7% .003 252);
  --rail-active-text: oklch(30.5% .115 258);
  --rail-line: oklch(100% 0 0 / .13);
  --rail-image: linear-gradient(180deg, oklch(31% .115 258 / .5), oklch(21% .09 258 / .86)), url("img/fabric-velvet.webp");
  --code-bg: oklch(93.5% .018 252);
  --pre-bg: oklch(97.6% .008 252);
  --scrim: oklch(20% .07 258 / .45);
  --shadow-pop: 0 18px 40px -18px oklch(22% .09 258 / .42), 0 1px 3px oklch(22% .09 258 / .1);
  --view-bg: oklch(92% .04 259);
  --view-text: oklch(36% .14 259);
  --who-strength: 52%;
  --font-ui: "Onest", "Segoe UI", system-ui, sans-serif;
  --font-head: "Unbounded", "Onest", system-ui, sans-serif;
  --head-weight: 600;
  --head-track: -.015em;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;
  --send-r: 999px;
}

/* Линия: как CRM Александра. Тёплая бумага, тонкие линии, чёрная главная кнопка, зелёная жаба. */
html[data-theme="line"] {
  color-scheme: light;
  --canvas: #f6f5f2;
  --rail: #ffffff;
  --surface: #ffffff;
  --raised: #ffffff;
  --field: #fbfaf8;
  --hover: #f1efea;
  --line: #e2dfd9;
  --line-soft: #eeece7;
  --text: #151515;
  --muted: #5e5c58;
  --faint: #75726c;
  --accent: #151515;
  --accent-strong: #333230;
  --accent-bg: #efede7;
  --accent-text: #151515;
  --on-accent: #ffffff;
  --focus: #4c9443;
  --link: #2f6f3a;
  --unread: #c2271f;
  --danger: #b42318;
  --signal: #69b35c;
  --rail-text: #151515;
  --rail-muted: #5e5c58;
  --rail-hover: #f6f5f2;
  --rail-active-bg: #efede7;
  --rail-active-text: #151515;
  --rail-line: #e2dfd9;
  --code-bg: #efede7;
  --pre-bg: #faf9f7;
  --scrim: oklch(22% .01 85 / .32);
  --shadow-pop: 0 14px 34px -14px oklch(20% .01 85 / .28), 0 1px 2px oklch(20% .01 85 / .08);
  --view-bg: #dcefc6;
  --view-text: #2f5a29;
  --who-strength: 48%;
  --font-ui: "Onest", "Segoe UI", system-ui, sans-serif;
  --font-head: "Prata", Georgia, serif;
  --head-weight: 400;
  --head-track: 0;
  --r-s: 6px;
  --r-m: 8px;
  --r-l: 12px;
  --send-r: 8px;
}

/* Апекс: лёд и вино. Винное меню и кнопки, ледяное выделение, бирюзовый фокус, Geist с моноширинными цифрами. */
html[data-theme="apex"] {
  color-scheme: light;
  --canvas: #f3fafc;
  --rail: #4b1716;
  --surface: #ffffff;
  --raised: #ffffff;
  --field: #f7fcfd;
  --hover: #e9f5f9;
  --line: #d6eaf0;
  --line-soft: #e4f2f6;
  --text: #1a0e0e;
  --muted: #6d6466;
  --faint: #7d7375;
  --accent: #4b1716;
  --accent-strong: #5e1d1c;
  --accent-bg: #d3eff7;
  --accent-text: #4b1716;
  --on-accent: #e3f4f9;
  --focus: #1f8fa8;
  --link: #17788e;
  --unread: #b3261e;
  --danger: #a8261f;
  --signal: #2e8b57;
  --rail-text: #efe3e2;
  --rail-muted: #cdb0ae;
  --rail-hover: #5e1d1c;
  --rail-active-bg: #a4dfef;
  --rail-active-text: #4b1716;
  --rail-line: oklch(100% 0 0 / .1);
  --code-bg: #e9f5f9;
  --pre-bg: #f7fcfd;
  --scrim: oklch(22% .06 25 / .4);
  --shadow-pop: 0 18px 40px -18px oklch(25% .08 25 / .35), 0 1px 3px oklch(25% .08 25 / .1);
  --view-bg: #efe3e2;
  --view-text: #4b1716;
  --who-strength: 50%;
  --font-ui: "Geist", "Segoe UI", system-ui, sans-serif;
  --font-head: "Geist", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;
  --head-weight: 600;
  --head-track: -.02em;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;
  --send-r: 50%;
}

/* Терминал: янтарный экран старых машин. Всё моноширинным, углы прямые, выделение инверсией. */
html[data-theme="terminal"] {
  color-scheme: dark;
  --canvas: oklch(16.5% .01 75);
  --rail: oklch(13% .008 75);
  --surface: oklch(18.5% .012 75);
  --raised: oklch(21.5% .016 75);
  --field: oklch(19.5% .013 75);
  --hover: oklch(20% .014 75);
  --line: oklch(33% .04 72);
  --line-soft: oklch(25% .025 72);
  --text: oklch(86% .11 78);
  --muted: oklch(72% .1 72);
  --faint: oklch(62% .085 68);
  --accent: oklch(81% .155 72);
  --accent-strong: oklch(87% .13 76);
  --accent-bg: oklch(28% .05 70);
  --accent-text: oklch(89% .12 78);
  --on-accent: oklch(16.5% .01 75);
  --unread: oklch(70% .18 38);
  --on-unread: oklch(16.5% .01 75);
  --danger: oklch(74% .16 32);
  --signal: oklch(80% .16 140);
  --rail-hover: oklch(19% .014 75);
  --rail-active-bg: var(--accent);
  --rail-active-text: var(--on-accent);
  --code-bg: oklch(25% .035 70);
  --pre-bg: oklch(12% .008 75);
  --scrim: oklch(6% .01 75 / .8);
  --shadow-pop: 0 0 0 1px var(--line);
  --view-bg: oklch(26% .05 70);
  --view-text: var(--accent-text);
  --who-strength: 62%;
  --font-ui: "JetBrains Mono", ui-monospace, monospace;
  --font-head: "JetBrains Mono", ui-monospace, monospace;
  --head-weight: 700;
  --head-track: 0;
  --r-s: 0;
  --r-m: 2px;
  --r-l: 3px;
  --send-r: 2px;
  --avatar-r: 2px;
  --agent-r: 2px;
  font-size: 14px;
}
html[data-theme="terminal"] textarea, html[data-theme="terminal"] input { caret-shape: block; }
html[data-light] { color-scheme: light; }
html[data-dark] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button, .attach, .upload { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { border: 0; border-radius: var(--r-s); background: transparent; }
button:disabled { opacity: .45; cursor: default; }
:is(button, a, input, textarea, select, .attach, .upload):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: var(--head-weight); letter-spacing: var(--head-track); }
h1, h2, h3, p { margin: 0; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--field); padding: .65rem .8rem; transition: border-color var(--fast);
}
input:hover, textarea:hover, select:hover { border-color: color-mix(in oklch, var(--line), var(--text) 18%); }
input::placeholder, textarea::placeholder { color: var(--faint); }
pre, code, .message-number, kbd { font-family: var(--font-mono); }
kbd {
  display: inline-block; min-width: 1.4em; padding: 0 .35em; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; font-size: .75em; line-height: 1.5; text-align: center; color: var(--muted); background: var(--field);
}
.primary {
  background: var(--accent); color: var(--on-accent); padding: .6rem 1.05rem; font-weight: 650;
  transition: background var(--fast), transform var(--fast) var(--ease-out);
}
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.primary:active:not(:disabled), .quiet:active, .icon:active, .room-button:active, .actor-entry:active { transform: scale(.97); }
.primary.small, .quiet.small { padding: .35rem .75rem; font-size: .85rem; }
.quiet, .upload {
  background: transparent; color: var(--muted); border-radius: var(--r-s); padding: .5rem .7rem; text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem; transition: background var(--fast), color var(--fast), transform var(--fast) var(--ease-out);
}
.quiet:hover, .upload:hover { background: var(--hover); color: var(--text); }
.muted { color: var(--muted); }
.small-text { font-size: .8rem; }
.error { color: var(--danger); font-size: .9rem; }
.error:empty { display: none; }
.icon {
  display: inline-grid; place-items: center; color: var(--muted); position: relative;
  width: 2.15rem; height: 2.15rem; padding: 0; border-radius: var(--r-s);
  transition: background var(--fast), color var(--fast), transform var(--fast) var(--ease-out);
}
.icon:hover { background: var(--hover); color: var(--text); }
.icon.active { color: var(--accent-text); }

/* живые иконки: штрих 1.7, части двигаются (см. ICONS в chat.js) */
.svg-icon { display: inline-grid; place-items: center; flex: 0 0 auto; }
svg.i { display: block; overflow: visible; }
svg.i * { transform-box: fill-box; transform-origin: center; }
svg.i .write { transform-origin: 15% 85%; }
svg.i .tilt { transform-origin: 30% 70%; }
svg.i .ring { transform-origin: 50% 8%; }
svg.i .hands { transform-box: view-box; transform-origin: 12px 12px; }
@keyframes ic-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ic-hop { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(-3px); } 62% { transform: translateY(.5px); } }
@keyframes ic-tile { 0%, 100% { transform: none; } 35% { transform: translateY(-2.5px); } 65% { transform: translateY(.5px); } }
@keyframes ic-fly { 0% { transform: none; opacity: 1; } 42% { transform: translate(7px, -7px); opacity: 0; } 43% { transform: translate(-7px, 7px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ic-turn { from { transform: rotate(0); } to { transform: rotate(90deg); } }
@keyframes ic-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes ic-up { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-3px); } }
@keyframes ic-dn { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(3px); } }
@keyframes ic-blink { 0%, 100% { transform: scaleY(1); } 45% { transform: scaleY(.1); } }
@keyframes ic-write { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-14deg); } 65% { transform: rotate(9deg); } }
@keyframes ic-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-1.8px); } 50% { transform: translateX(1.8px); } 75% { transform: translateX(-1px); } }
@keyframes ic-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 45% { transform: rotate(-11deg); } 70% { transform: rotate(6deg); } }
@keyframes ic-scan { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(-1.6px, -1px); } 65% { transform: translate(1.6px, 1px); } }
@keyframes ic-slide-l { 0%, 100% { transform: translateX(0); } 45% { transform: translateX(-3px); } }
@keyframes ic-slide-r { 0%, 100% { transform: translateX(0); } 45% { transform: translateX(3px); } }
@keyframes ic-tilt { 0%, 100% { transform: none; } 30% { transform: rotate(-16deg); } 65% { transform: rotate(8deg); } }
@keyframes ic-pulse { 0%, 100% { transform: none; } 40% { transform: scale(1.18); } }
@keyframes ic-nod { 0%, 100% { transform: none; } 40% { transform: translateY(-1.5px) scale(1.08); } }
svg.i.play-ic .draw { stroke-dasharray: 1; animation: ic-draw .55s var(--ease-out) .05s both; }
svg.i.play-ic .draw.d2 { animation-delay: .17s; }
svg.i.play-ic .hop { animation: ic-hop .55s var(--ease-out); }
svg.i.play-ic .hop.d2 { animation-delay: .12s; }
svg.i.play-ic .tile { animation: ic-tile .5s var(--ease-out); }
svg.i.play-ic .tile.d2 { animation-delay: .07s; }
svg.i.play-ic .tile.d3 { animation-delay: .14s; }
svg.i.play-ic .tile.d4 { animation-delay: .21s; }
svg.i.play-ic .fly { animation: ic-fly .62s var(--ease-out); }
svg.i.play-ic .turn { animation: ic-turn .45s var(--ease-out); }
svg.i.play-ic .spin { animation: ic-spin .7s var(--ease-out); }
svg.i.play-ic .up { animation: ic-up .5s var(--ease-out); }
svg.i.play-ic .dn { animation: ic-dn .5s var(--ease-out); }
svg.i.play-ic .blink { animation: ic-blink .4s ease-in-out; }
svg.i.play-ic .write { animation: ic-write .6s var(--ease-out); }
svg.i.play-ic .shake { animation: ic-shake .45s ease-in-out; }
svg.i.play-ic .ring { animation: ic-ring .6s ease-in-out; }
svg.i.play-ic .scan { animation: ic-scan .6s ease-in-out; }
svg.i.play-ic .slide-l { animation: ic-slide-l .45s var(--ease-out); }
svg.i.play-ic .slide-r { animation: ic-slide-r .45s var(--ease-out); }
svg.i.play-ic .tilt { animation: ic-tilt .6s var(--ease-out); }
svg.i.play-ic .pulse { animation: ic-pulse .45s var(--ease-out); }
svg.i.play-ic .hands { animation: ic-spin .8s var(--ease-out); }
svg.i.play-ic.plain { animation: ic-nod .45s var(--ease-out); }

/* бренд и вход */
.brand { display: flex; align-items: center; gap: .65rem; font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.08rem; letter-spacing: var(--head-track); }
.brand-mark {
  width: 2rem; height: 2rem; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--accent-bg); color: var(--accent-text); border-radius: var(--r-s);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent) 35%, transparent);
}
.brand-mark .frog { display: none; }
html[data-theme="line"] .brand-mark { background: #dcefc6; color: #4c9443; box-shadow: none; }
html[data-theme="line"] .brand-mark .squad { display: none; }
html[data-theme="line"] .brand-mark .frog { display: block; }
html[data-theme="dream"] .navigation .brand-mark, html[data-theme="apex"] .navigation .brand-mark {
  background: var(--rail-active-bg); color: var(--rail-active-text); box-shadow: none;
}
.signin { display: grid; min-height: 100dvh; place-items: center; padding: 1.25rem; }
.signin-card {
  width: min(100%, 27rem); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: clamp(1.3rem, 5vw, 2.2rem); box-shadow: var(--shadow-pop);
  animation: rise var(--slow) var(--ease-out);
}
.signin h1 { font-size: 1.5rem; margin: 2rem 0 1.3rem; }
.signin form { display: grid; gap: .65rem; }
.signin .primary { margin-top: .65rem; }

/* раскладка */
.workspace {
  display: grid; grid-template-columns: 15.5rem minmax(0, 1fr) 14.5rem; height: 100dvh;
  transition: grid-template-columns var(--mid) var(--ease-in-out);
}
.workspace.office-hidden { grid-template-columns: 15.5rem minmax(0, 1fr) 0; }
.workspace.office-hidden .office { visibility: hidden; padding: 0; border: 0; }
.navigation, .office { background: var(--rail); min-width: 0; }
.navigation {
  border-right: 1px solid var(--rail-line); display: flex; flex-direction: column; min-height: 0;
  color: var(--rail-text); background-image: var(--rail-image); background-size: cover; background-position: center;
}
.office { background: var(--surface); }
html[data-theme="terminal"] .office, html[data-theme="night"] .office, html:not([data-theme]) .office { background: var(--rail); }
.navigation .brand { min-height: 4rem; padding: .9rem 1rem; border-bottom: 1px solid var(--rail-line); }
.room-scroll { overflow: auto; padding: .55rem; flex: 1; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin: .8rem .2rem .25rem .55rem; }
.section-head h2, .office h3 {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-ui); font-weight: 650;
}
.section-head h2 { color: var(--rail-muted); }
.office h3 { color: var(--faint); }
.section-head .icon { width: 1.75rem; height: 1.75rem; color: var(--rail-muted); }
.section-head .icon:hover { background: var(--rail-hover); color: var(--rail-text); }
.room-list { display: grid; gap: 2px; }
.room-button {
  position: relative; display: flex; width: 100%; color: var(--rail-muted); align-items: center;
  gap: .55rem; padding: .45rem .55rem; min-width: 0; text-align: left; border-radius: var(--r-s);
  transition: background var(--fast), color var(--fast), transform var(--fast) var(--ease-out);
}
.room-button:hover { background: var(--rail-hover); color: var(--rail-text); }
.room-button[aria-current] { background: var(--rail-active-bg); color: var(--rail-active-text); font-weight: 600; }
.room-button.has-unread { color: var(--rail-text); font-weight: 650; }
.room-button.has-unread::before {
  content: ""; position: absolute; left: -.55rem; top: 50%; width: 4px; height: .5rem; margin-top: -.25rem;
  border-radius: 0 4px 4px 0; background: var(--rail-text);
}
.room-lead { color: inherit; opacity: .8; }
.room-button[aria-current] .room-lead { opacity: 1; }
.room-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.badge {
  min-width: 1.25rem; height: 1.25rem; padding: 0 .38rem; border-radius: 999px;
  background: var(--unread); color: var(--on-unread); font-size: .72rem; font-weight: 700;
  display: inline-grid; place-items: center; line-height: 1; font-variant-numeric: tabular-nums;
  animation: pop var(--mid) var(--ease-out);
}
.me-bar {
  display: flex; align-items: center; gap: .3rem; border-top: 1px solid var(--rail-line); padding-right: .5rem;
  background: color-mix(in oklch, var(--rail), var(--rail-text) 4%);
}
.profile-button {
  display: flex; flex: 1; min-width: 0; gap: .65rem; align-items: center; text-align: left; border-radius: 0;
  padding: .75rem .9rem; color: var(--rail-text); transition: background var(--fast);
}
.profile-button:hover { background: var(--rail-hover); }
.profile-button .actor-info :is(strong, small) { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-button .actor-info small { color: var(--rail-muted); }
.me-bar .icon { color: var(--rail-muted); }
.me-bar .icon:hover { background: var(--rail-hover); color: var(--rail-text); }
.view-chip {
  display: inline-flex; align-items: center; gap: .3rem; flex: 0 0 auto; max-width: 6.5rem;
  padding: .3rem .5rem; border: 1px solid var(--rail-line); border-radius: var(--r-s);
  color: var(--rail-muted); font-size: .75rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  transition: color var(--fast), border-color var(--fast), background var(--fast);
}
.view-chip:hover { color: var(--rail-text); border-color: var(--rail-muted); }
.view-chip.active { color: var(--rail-active-text); background: var(--rail-active-bg); border-color: var(--rail-active-bg); }
.view-bar {
  display: flex; align-items: center; gap: .5rem; padding: .45rem 1.25rem; font-size: .85rem;
  background: var(--view-bg); color: var(--view-text); border-bottom: 1px solid var(--line-soft);
  animation: drop var(--mid) var(--ease-out);
}
.view-bar .quiet { margin-left: auto; color: var(--view-text); }
.actor-entry.chosen { background: var(--accent-bg); }
.actor-entry .mode { margin-left: auto; color: var(--faint); font-size: .72rem; }

/* разговор */
.conversation { position: relative; display: grid; min-width: 0; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr) auto; background: var(--canvas); }
.conversation > .channel-header { grid-row: 1; }
.conversation > .view-bar { grid-row: 2; }
.conversation > .feed { grid-row: 3; }
.conversation > .compose { grid-row: 4; }
.channel-header {
  min-height: 4rem; display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem .55rem 1.25rem;
  border-bottom: 1px solid var(--line-soft); background: var(--surface);
}
.back-button { display: none; }
.channel-symbol {
  flex: 0 0 auto; display: grid; place-items: center; width: 2.15rem; height: 2.15rem;
  background: var(--accent-bg); color: var(--accent-text); border-radius: var(--r-s);
}
.channel-label { flex: 1; min-width: 0; margin-left: .15rem; }
.channel-label h1 { font-size: 1.05rem; overflow-wrap: anywhere; }
.channel-label p { font-size: .8rem; }
.header-sep { width: 1px; height: 1.4rem; background: var(--line); margin: 0 .2rem; }
.search-key { display: inline-flex; align-items: center; gap: .45rem; height: 2.15rem; padding: 0 .55rem 0 .6rem; color: var(--faint); border: 1px solid var(--line-soft); border-radius: var(--r-s); font-size: .8rem; transition: border-color var(--fast), color var(--fast); }
.search-key:hover { border-color: var(--line); color: var(--text); }
.feed { overflow: auto; padding: 1rem 1.25rem .5rem; overscroll-behavior: contain; scroll-behavior: auto; }
.feed.entering .messages { animation: fade var(--mid) var(--ease-out); }
.older { display: flex; margin: 0 auto 1rem; }
.empty { display: grid; justify-items: center; text-align: center; min-height: 100%; align-content: center; color: var(--muted); gap: .45rem; animation: rise var(--slow) var(--ease-out); }
.empty .svg-icon { color: var(--accent-text); width: 3.2rem; height: 3.2rem; border-radius: var(--r-l); background: var(--accent-bg); margin-bottom: .3rem; }
.empty h2 { color: var(--text); font-size: 1.1rem; }
.messages { display: grid; }
.day-line, .unread-line {
  display: flex; align-items: center; gap: .75rem; margin: 1rem 0 .4rem; font-size: .75rem; color: var(--faint);
}
.day-line::before, .day-line::after, .unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.unread-line { color: var(--unread); font-weight: 650; }
.unread-line::before, .unread-line::after { background: color-mix(in oklch, var(--unread) 45%, transparent); }
.message {
  --who: var(--accent);
  position: relative; display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); gap: .75rem;
  padding: .4rem .55rem; border-radius: var(--r-m); margin-top: .45rem; transition: background var(--fast);
}
.message.grouped { margin-top: 0; padding-top: .1rem; }
.message.arrive { animation: arrive 180ms var(--ease-out); }
.message.mention-me { background: color-mix(in oklch, var(--accent) 9%, transparent); box-shadow: inset 2px 0 0 var(--accent); border-radius: 0 var(--r-m) var(--r-m) 0; }
.message.flash { animation: flash 1.4s var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .message:hover { background: var(--hover); }
  .message.mention-me:hover { background: color-mix(in oklch, var(--accent) 13%, transparent); }
  .message:hover .message-tools { opacity: 1; pointer-events: auto; transform: none; }
}
.gutter { display: flex; justify-content: center; }
.gutter time { font-size: .68rem; color: transparent; padding-top: .25rem; font-family: var(--font-mono); transition: color var(--fast); }
.message:hover .gutter time { color: var(--faint); }
.message-main { min-width: 0; }
.message-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.message-head .author { color: color-mix(in oklch, var(--who) var(--who-strength), var(--text)); font-weight: 650; overflow-wrap: anywhere; }
.agent-tag {
  font-size: .68rem; color: color-mix(in oklch, var(--who) var(--who-strength), var(--text));
  border: 1px solid color-mix(in srgb, var(--who) 45%, transparent);
  border-radius: 999px; padding: 0 .45rem; line-height: 1.4;
}
html[data-theme="terminal"] .agent-tag { border-radius: 0; }
.message-head time { color: var(--faint); font-size: .74rem; font-family: var(--font-mono); }
.message-body { overflow-wrap: anywhere; }
.message-body :is(p, pre, ul, ol) { margin: .15rem 0; }
.message-body > :first-child { margin-top: 0; }
.message-body code, .docs code { padding: .1rem .3rem; background: var(--code-bg); border-radius: 5px; font-size: .88em; }
.code-wrap { position: relative; }
.message-body pre { overflow: auto; padding: .75rem .85rem; background: var(--pre-bg); border: 1px solid var(--line-soft); border-radius: var(--r-s); }
.message-body pre code { background: transparent; padding: 0; }
.code-copy {
  position: absolute; top: .35rem; right: .35rem; display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .45rem; font-size: .72rem; color: var(--muted); background: var(--raised); border: 1px solid var(--line);
  border-radius: 6px; opacity: 0; transition: opacity var(--fast), color var(--fast);
}
.code-wrap:hover .code-copy, .code-copy:focus-visible, .code-copy.done { opacity: 1; }
.code-copy:hover { color: var(--text); }
.code-copy.done { color: var(--signal); }
@media (hover: none) { .code-copy { opacity: 1; } }
.message-body blockquote { margin: .35rem 0; padding-left: .75rem; border-left: 2px solid var(--line); color: var(--muted); }
.mention { color: var(--accent-text); background: color-mix(in oklch, var(--accent) 16%, transparent); border-radius: 4px; padding: 0 .2rem; font-weight: 600; }
.mention.me { color: var(--on-accent); background: var(--accent); }
.edited { font-size: .72rem; color: var(--faint); margin-left: .35rem; }
.message-tools {
  position: absolute; top: -.95rem; right: .7rem; display: flex; gap: 1px; padding: 2px;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transform: translateY(3px); z-index: 3;
  transition: opacity var(--fast) var(--ease-out), transform var(--fast) var(--ease-out);
}
.message:focus-within .message-tools, .message.show-tools .message-tools { opacity: 1; pointer-events: auto; transform: none; }
.message.show-tools { background: var(--hover); }
.message-tools .icon { width: 1.85rem; height: 1.85rem; }
.message-tools .sep { width: 1px; margin: .3rem .1rem; background: var(--line); }
.reply-ref { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .8rem; margin-bottom: .1rem; cursor: pointer; }
.reply-ref:hover { color: var(--text); }
.edit-box { display: grid; gap: .4rem; margin-top: .2rem; }
.edit-box textarea { resize: vertical; min-height: 2.6rem; border-color: var(--accent); }
.edit-actions { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.edit-actions .muted { margin-right: auto; }

/* реакции-сигналы */
.reactions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.reaction {
  display: inline-flex; align-items: center; gap: .3rem; height: 1.7rem; padding: 0 .5rem 0 .4rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted);
  font-size: .78rem; font-variant-numeric: tabular-nums; transition: border-color var(--fast), background var(--fast), color var(--fast), transform var(--fast) var(--ease-out);
}
html[data-theme="terminal"] .reaction { border-radius: 0; }
.reaction:hover { border-color: color-mix(in oklch, var(--line), var(--text) 25%); color: var(--text); }
.reaction.mine { border-color: color-mix(in oklch, var(--accent) 60%, transparent); background: var(--accent-bg); color: var(--accent-text); }
.reaction.bump { animation: pop var(--mid) var(--ease-out); }
.reaction-picker { display: flex; gap: 2px; padding: 2px; }
.reaction-picker .icon { width: 2rem; height: 2rem; }

/* аватары */
.avatar {
  --who: var(--accent);
  position: relative; display: inline-grid; place-items: center; width: 2.3rem; height: 2.3rem;
  flex: 0 0 auto; font-weight: 700; font-size: .95rem; border-radius: var(--avatar-r); overflow: hidden;
  color: color-mix(in oklch, var(--who) var(--who-strength), var(--text));
  background: color-mix(in srgb, var(--who) 18%, var(--surface));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--who) 60%, transparent);
}
.avatar.is-agent { border-radius: var(--agent-r); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.small { width: 1.9rem; height: 1.9rem; font-size: .8rem; }
.avatar.tiny { width: 1.25rem; height: 1.25rem; font-size: .62rem; }
.avatar.large { width: 3.4rem; height: 3.4rem; font-size: 1.35rem; }
.avatar.zoomable { cursor: zoom-in; transition: box-shadow var(--fast); }
.avatar.zoomable:hover { box-shadow: inset 0 0 0 2px var(--who), 0 0 0 2px color-mix(in srgb, var(--who) 35%, transparent); }
.lightbox { padding: 0; border: 0; background: transparent; max-width: 94vw; overflow: visible; cursor: zoom-out; box-shadow: none; }
.lightbox::backdrop { background: oklch(8% .01 255 / .9); }
.lightbox img { display: block; max-width: 94vw; max-height: 84vh; width: auto; height: auto; border-radius: var(--r-l); box-shadow: 0 20px 60px oklch(0% 0 0 / .6); }
.lightbox img.square { width: min(92vw, 34rem); aspect-ratio: 1; object-fit: cover; }
.lightbox p { text-align: center; margin-top: .8rem; color: oklch(95% 0 0); font-weight: 600; }
.picture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .4rem; margin-top: .35rem; max-width: 46rem; }
.picture-grid.single { grid-template-columns: minmax(0, 22rem); }
.picture { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-s); background: var(--raised); cursor: zoom-in; display: block; transition: outline-color var(--fast); outline: 2px solid transparent; }
.picture-grid.single .picture { aspect-ratio: auto; max-height: 22rem; object-fit: contain; }
@media (hover: hover) { .picture:hover { outline-color: color-mix(in srgb, var(--who) 70%, transparent); } }
.picture.expired {
  display: grid; place-items: center; align-content: center; gap: .3rem; text-align: center; padding: .5rem;
  color: var(--faint); font-size: .72rem; border: 1px dashed var(--line); background: transparent; cursor: default;
}
.crop { justify-items: center; }
.crop-canvas { width: 288px; height: 288px; border-radius: var(--r-l); background: oklch(14% .01 255); touch-action: none; cursor: grab; }
.crop-canvas:active { cursor: grabbing; }
.crop-row { display: flex; align-items: center; gap: .6rem; width: 100%; }
.crop-zoom { flex: 1; padding: 0; background: transparent; border: 0; }
.crop .look-actions { width: 100%; justify-content: flex-end; }

/* файлы и поле ввода */
.file-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
.file-chip, .reply-chip {
  display: inline-flex; align-items: center; gap: .4rem; max-width: 100%;
  color: var(--accent-text); background: var(--accent-bg); border-radius: var(--r-s); padding: .25rem .5rem;
  font-size: .84rem; overflow-wrap: anywhere; text-decoration: none; animation: pop var(--mid) var(--ease-out);
}
.reply-chip { color: var(--muted); background: var(--raised); justify-self: start; }
.chip-close { color: inherit; padding: .1rem; display: inline-grid; place-items: center; border-radius: 5px; }
.chip-close:hover { color: var(--text); background: var(--hover); }
.compose {
  position: relative; margin: .2rem 1.25rem .9rem; padding: .35rem .4rem .3rem; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--r-l); display: grid; gap: .3rem;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.compose:focus-within { border-color: color-mix(in oklch, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 14%, transparent); }
.compose-row { display: flex; align-items: flex-end; gap: .3rem; }
.compose textarea {
  border: 0; background: transparent; resize: none; min-height: 2.4rem; max-height: 35vh;
  padding: .55rem .35rem; line-height: 1.4;
}
.compose textarea:hover { border: 0; }
.compose textarea:focus-visible { outline: none; }
.compose .error { padding: 0 .55rem; }
.attach { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; }
.send {
  flex: 0 0 auto; height: 2.4rem; min-width: 2.4rem; padding: 0 .7rem; border-radius: var(--send-r);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  background: var(--accent); color: var(--on-accent); font-weight: 650; font-size: .88rem;
  transition: background var(--fast), color var(--fast), transform var(--fast) var(--ease-out), box-shadow var(--fast);
}
.send .send-label { display: none; }
html[data-theme="dream"] .send, html[data-theme="terminal"] .send { padding: 0 .95rem 0 .8rem; }
html[data-theme="dream"] .send .send-label, html[data-theme="terminal"] .send .send-label { display: inline; }
html[data-theme="terminal"] .send { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); text-transform: uppercase; letter-spacing: .04em; }
html[data-theme="terminal"] .send:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); }
.send:hover:not(:disabled) { background: var(--accent-strong); }
.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { background: var(--hover); color: var(--faint); opacity: 1; box-shadow: none; }
.compose-hint { display: flex; gap: .9rem; font-size: .7rem; color: var(--faint); padding: 0 .5rem .1rem; }
.compose-hint span { display: inline-flex; align-items: center; gap: .3rem; }
.jump {
  position: absolute; right: 1.6rem; bottom: 6.4rem; display: inline-flex; align-items: center; gap: .35rem;
  background: var(--raised); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: .4rem .8rem; font-size: .8rem; box-shadow: var(--shadow-pop); animation: pop var(--mid) var(--ease-out);
}
html[data-theme="terminal"] .jump { border-radius: 0; }

/* подсказка @упоминаний */
.suggest {
  position: absolute; left: .4rem; bottom: calc(100% + .4rem); width: min(19rem, calc(100% - .8rem)); padding: .3rem;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-pop);
  display: grid; gap: 1px; z-index: 5; transform-origin: bottom left; animation: pop-up var(--mid) var(--ease-out);
}
.suggest-title { font-size: .7rem; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding: .3rem .5rem .2rem; }
.suggest button { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem; text-align: left; border-radius: var(--r-s); }
.suggest button[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-text); }
.suggest small { margin-left: auto; color: var(--faint); font-size: .72rem; }

/* команда */
.office { padding: 1rem .75rem; border-left: 1px solid var(--line-soft); overflow: auto; }
.office h2 { font-size: .95rem; margin: .1rem .25rem 1rem; }
.office h3 { margin: 1rem .25rem .4rem; }
.person-list { display: grid; gap: 2px; }
.actor-entry {
  display: flex; gap: .55rem; align-items: center; width: 100%; text-align: left;
  padding: .35rem .4rem; border-radius: var(--r-s); transition: background var(--fast), transform var(--fast) var(--ease-out);
}
.actor-entry:hover { background: var(--hover); }
.actor-info { overflow-wrap: anywhere; min-width: 0; line-height: 1.25; }
.actor-info strong { font-size: .9rem; font-weight: 600; }
.actor-info strong.agent { color: color-mix(in oklch, var(--who) var(--who-strength), var(--text)); }
.actor-info small { color: var(--faint); display: block; font-size: .74rem; }

/* уведомления */
.toasts { position: fixed; right: 1rem; bottom: 6.5rem; display: grid; gap: .5rem; z-index: 20; width: min(22rem, calc(100vw - 2rem)); }
.toast {
  --who: var(--accent);
  display: flex; gap: .6rem; align-items: center; text-align: left; padding: .7rem .8rem;
  background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  border-radius: var(--r-m); animation: toast-in 260ms var(--ease-out);
}
.toast.leaving { animation: toast-out 180ms var(--ease-in-out) forwards; }
.toast-text { display: grid; min-width: 0; font-size: .85rem; }
.toast-text span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* окна */
.mobile-tabs { display: none; }
.tab-badge { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--unread); margin-left: .3rem; font-size: 0; vertical-align: super; }
.visually-hidden { position: absolute; clip: rect(0, 0, 0, 0); width: 1px; height: 1px; margin: -1px; overflow: hidden; }
dialog {
  color: var(--text); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  border-radius: var(--r-l); width: min(31rem, calc(100vw - 1.8rem)); max-height: 85dvh; padding: 1.1rem;
}
dialog[open] { animation: window-in var(--mid) var(--ease-out); }
dialog.closing { animation: window-out 150ms var(--ease-in-out) forwards; }
dialog::backdrop { background: var(--scrim); }
dialog[open]::backdrop { animation: fade var(--mid) var(--ease-out); }
dialog.closing::backdrop { animation: fade-out 150ms var(--ease-in-out) forwards; }
.lightbox[open] { animation: zoom-in var(--slow) var(--ease-out); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.dialog-head h2 { font-size: 1.12rem; }
.dialog-form, .dialog-stack { display: grid; gap: .65rem; }
.dialog-sub { font-size: .72rem; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin-top: .5rem; font-family: var(--font-ui); font-weight: 650; }
.dialog-form fieldset { border: 1px solid var(--line); border-radius: var(--r-s); margin: 0; min-width: 0; }
.checks { display: grid; gap: .3rem; max-height: 13rem; overflow: auto; }
.checks label { display: flex; align-items: center; gap: .55rem; }
.checks input { width: auto; }
.pick-list { display: grid; gap: 2px; }
.look-card { display: grid; gap: .6rem; padding: .8rem; border: 1px solid var(--line-soft); border-radius: var(--r-m); background: var(--canvas); }
.look-head { display: flex; align-items: center; gap: .75rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; }
.swatch {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--swatch); color: oklch(18% .01 255);
  display: grid; place-items: center; box-shadow: inset 0 0 0 2px oklch(0% 0 0 / .18);
  transition: transform var(--fast) var(--ease-out);
}
.swatch:hover { transform: scale(1.12); }
.look-actions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.link { display: inline-flex; }
#dialog-error { margin-top: .6rem; }
.token-result { font: .85rem var(--font-mono); resize: vertical; }
.docs { width: min(100% - 2rem, 44rem); margin: 3rem auto; }
.docs h1, .docs li { margin: 1rem 0; }

/* выбор темы */
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.theme-card {
  display: grid; gap: .4rem; padding: .35rem .35rem .5rem; border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--canvas); text-align: left; transition: border-color var(--fast), transform var(--fast) var(--ease-out), box-shadow var(--fast);
}
.theme-card:hover { border-color: color-mix(in oklch, var(--line), var(--text) 30%); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent) 30%, transparent); }
.theme-card:active { transform: scale(.97); }
.theme-card strong { font-size: .82rem; font-weight: 650; padding: 0 .2rem; display: flex; align-items: center; gap: .3rem; }
.theme-card small { font-size: .7rem; color: var(--faint); padding: 0 .2rem; line-height: 1.25; }
.mini { display: grid; grid-template-columns: 30% 1fr; height: 3.6rem; border-radius: calc(var(--r-m) - 3px); overflow: hidden; background: var(--m-canvas); }
.mini-rail { background: var(--m-rail); padding: 6px 5px; display: grid; align-content: start; gap: 3px; }
.mini-rail i { display: block; height: 4px; border-radius: 2px; background: var(--m-rail-ink); opacity: .45; }
.mini-rail i:first-child { opacity: 1; background: var(--m-accent); }
.mini-main { display: grid; align-content: end; gap: 4px; padding: 6px; }
.mini-main i { display: block; height: 4px; border-radius: 2px; background: var(--m-ink); opacity: .35; width: 70%; }
.mini-main i:nth-child(2) { width: 45%; }
.mini-main b { justify-self: end; width: 14px; height: 10px; border-radius: 3px; background: var(--m-accent); }
.builder { display: grid; gap: .6rem; padding: .8rem; border: 1px solid var(--line-soft); border-radius: var(--r-m); background: var(--canvas); animation: rise var(--mid) var(--ease-out); }
.builder-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.color-field { display: grid; gap: .3rem; font-size: .78rem; color: var(--muted); }
.color-field input { height: 2.4rem; padding: .2rem; cursor: pointer; }
.builder select { padding: .5rem .6rem; }
.builder .warn { font-size: .78rem; color: var(--danger); }
.code-row { display: flex; gap: .4rem; }
.code-row input { font: .8rem var(--font-mono); }

/* быстрый переход Ctrl+K */
.palette { width: min(34rem, calc(100vw - 1.8rem)); padding: .5rem; margin-top: 12vh; }
.palette input { border: 0; background: transparent; font-size: 1.02rem; padding: .7rem .7rem; }
.palette input:hover { border: 0; }
.palette input:focus-visible { outline: none; }
.palette-head { display: flex; align-items: center; gap: .4rem; padding: 0 .3rem; border-bottom: 1px solid var(--line-soft); color: var(--faint); }
.palette-list { display: grid; gap: 1px; max-height: min(55vh, 26rem); overflow: auto; padding-top: .4rem; }
.palette-list button { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; text-align: left; border-radius: var(--r-s); min-height: 2.6rem; }
.palette-list button[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-text); }
.palette-list small { margin-left: auto; color: var(--faint); font-size: .74rem; }
.palette-list .group { font-size: .7rem; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding: .5rem .6rem .2rem; }
.palette-foot { display: flex; gap: 1rem; padding: .5rem .6rem .2rem; font-size: .72rem; color: var(--faint); border-top: 1px solid var(--line-soft); margin-top: .3rem; }
.palette-foot span { display: inline-flex; gap: .3rem; align-items: center; }

/* поиск по комнате */
.search-panel { display: grid; gap: .6rem; }
.search-results { display: grid; gap: 2px; max-height: 55vh; overflow: auto; }
.search-hit { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .6rem; padding: .5rem .55rem; text-align: left; border-radius: var(--r-s); }
.search-hit:hover { background: var(--hover); }
.search-hit .hit-head { display: flex; gap: .5rem; align-items: baseline; font-size: .82rem; }
.search-hit .hit-head strong { color: color-mix(in oklch, var(--who) var(--who-strength), var(--text)); }
.search-hit .hit-head time { color: var(--faint); font-size: .72rem; }
.search-hit p { font-size: .86rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-hit mark { background: color-mix(in oklch, var(--accent) 28%, transparent); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* переключатель из двух-трёх вариантов */
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: calc(var(--r-s) + 3px); background: var(--field); border: 1px solid var(--line-soft); }
.seg { flex: 1; padding: .45rem .6rem; border-radius: var(--r-s); color: var(--muted); font-size: .86rem; transition: background var(--fast), color var(--fast); }
.seg:hover { color: var(--text); }
.seg.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px oklch(0% 0 0 / .12), 0 0 0 1px var(--line-soft); }
.signin-tabs { margin-bottom: 1rem; }
.channel-symbol.face { background: transparent; }
.brand-mark svg.frog { display: none; }
html[data-theme="line"] .brand-mark svg.squad { display: none; }
html[data-theme="line"] .brand-mark svg.frog { display: block; }

/* шашки */
.game { display: grid; gap: .55rem; margin-top: .5rem; width: min(100%, 23rem); padding: .7rem; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); }
.game-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }
.game-side { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .5rem .2rem .3rem; border-radius: 999px; color: var(--muted); }
.game-side.turn { background: var(--accent-bg); color: var(--accent-text); font-weight: 650; }
.game-side .piece { width: .95rem; height: .95rem; position: static; }
.game-vs { color: var(--faint); font-size: .75rem; }
.board {
  --cell-dark: color-mix(in oklch, var(--accent) 26%, var(--raised));
  --cell-light: color-mix(in oklch, var(--canvas), var(--text) 4%);
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; border-radius: var(--r-m); overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
html[data-theme="line"] .board { --cell-dark: #c9d9be; --cell-light: #faf9f7; }
html[data-theme="apex"] .board { --cell-dark: #b9dbe5; --cell-light: #f7fcfd; }
html[data-theme="dream"] .board { --cell-dark: oklch(80% .07 259); --cell-light: oklch(98.5% .006 252); }
html[data-theme="terminal"] .board { --cell-dark: oklch(26% .045 70); --cell-light: oklch(16% .01 75); }
.cell { position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 0; border-radius: 0; }
.cell.light { background: var(--cell-light); }
.cell.dark { background: var(--cell-dark); cursor: default; transition: background var(--fast); }
.cell.dark.movable { cursor: pointer; }
.cell.dark.movable:hover { background: color-mix(in oklch, var(--cell-dark), var(--accent) 22%); }
.cell.last { background: color-mix(in oklch, var(--cell-dark), var(--signal) 30%); }
.cell.picked { background: color-mix(in oklch, var(--cell-dark), var(--accent) 45%); }
.cell.target { cursor: pointer; }
.cell.target::after { content: ""; width: 28%; height: 28%; border-radius: 50%; background: var(--accent); opacity: .75; animation: pop var(--mid) var(--ease-out); }
.cell.target:hover::after { opacity: 1; transform: scale(1.15); }
.cell[data-rank]::before, .cell[data-file]::before { position: absolute; font-size: .55rem; color: color-mix(in oklch, var(--text) 55%, transparent); font-family: var(--font-mono); pointer-events: none; }
.cell[data-rank]::before { content: attr(data-rank); left: 3px; top: 2px; }
.cell[data-file]::before { content: attr(data-file); right: 3px; bottom: 1px; }
.cell[data-rank][data-file]::before { content: attr(data-rank); }
.cell[data-rank][data-file]::after { content: attr(data-file); position: absolute; right: 3px; bottom: 1px; font-size: .55rem; color: color-mix(in oklch, var(--text) 55%, transparent); font-family: var(--font-mono); }
.piece {
  position: absolute; inset: 14%; border-radius: 50%; display: grid; place-items: center;
  transition: transform var(--mid) var(--ease-out);
}
.piece.w { background: oklch(97% .008 85); box-shadow: inset 0 -3px 0 oklch(80% .02 85), 0 1px 3px oklch(0% 0 0 / .35); color: oklch(45% .1 75); }
.piece.b { background: oklch(28% .02 30); box-shadow: inset 0 -3px 0 oklch(16% .02 30), inset 0 1px 0 oklch(45% .02 30), 0 1px 3px oklch(0% 0 0 / .4); color: oklch(85% .12 80); }
html[data-theme="apex"] .piece.b { background: #4b1716; box-shadow: inset 0 -3px 0 #2d0d0c, 0 1px 3px oklch(0% 0 0 / .35); color: #a4dfef; }
html[data-theme="terminal"] .piece.w { background: var(--accent); box-shadow: none; color: var(--on-accent); }
html[data-theme="terminal"] .piece.b { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
html[data-theme="terminal"] .piece, html[data-theme="terminal"] .board { border-radius: 0; }
.piece.x { background: transparent; box-shadow: inset 0 0 0 2px color-mix(in oklch, var(--text) 35%, transparent); opacity: .6; }
.piece.landed { animation: land var(--slow) var(--ease-out); }
.cell.movable:hover .piece { transform: translateY(-2px); }
.cell.picked .piece { transform: translateY(-3px) scale(1.04); }
.game-side .piece.w, .game-side .piece.b { box-shadow: 0 0 0 1px var(--line); }
.game-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.game-status { font-size: .86rem; color: var(--muted); }
.game-status.mine { color: var(--accent-text); font-weight: 650; }
.game-status { display: grid; gap: .1rem; }
.game-last { font-size: .74rem; color: var(--faint); font-family: var(--font-mono); font-weight: 400; }
.message-body.game-move { color: var(--muted); font-size: .88rem; font-family: var(--font-mono); }
@keyframes land { from { transform: scale(.7); opacity: .4; } }

/* движение */
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
@keyframes pop-up { from { opacity: 0; transform: translateY(6px) scale(.97); } }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
@keyframes window-in { from { opacity: 0; transform: translateY(6px) scale(.97); } }
@keyframes window-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes zoom-in { from { opacity: 0; transform: scale(.94); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(1rem); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes flash { 0%, 30% { background: color-mix(in oklch, var(--accent) 22%, transparent); } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 240ms; animation-timing-function: var(--ease-in-out); }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 13.5rem minmax(0, 1fr) 12.5rem; }
  .workspace.office-hidden { grid-template-columns: 13.5rem minmax(0, 1fr) 0; }
  .search-key .search-label, .search-key kbd { display: none; }
  .search-key { width: 2.15rem; padding: 0; justify-content: center; border-color: transparent; }
}
@media (max-width: 780px) {
  :root { font-size: 15px; }
  .workspace, .workspace.office-hidden {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh;
  }
  .workspace.office-hidden .office { visibility: visible; padding: 1rem .75rem; }
  .workspace[data-view="chat"] > :is(.navigation, .office),
  .workspace[data-view="channels"] > :is(.conversation, .office),
  .workspace[data-view="office"] > :is(.conversation, .navigation) { display: none; }
  .workspace > :is(.navigation, .office, .conversation) { animation: fade var(--mid) var(--ease-out); }
  #office-toggle, .header-sep, .search-key { display: none; }
  .navigation .brand { min-height: 3.4rem; padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; }
  .room-scroll { padding: .5rem .6rem; }
  .room-button { min-height: 48px; padding: .5rem .7rem; font-size: 1rem; }
  .section-head .icon { width: 44px; height: 44px; }
  .me-bar { padding-right: .6rem; }
  .profile-button { min-height: 56px; }
  .view-chip { min-height: 36px; }
  .channel-header { padding: calc(.35rem + env(safe-area-inset-top)) .4rem .35rem .25rem; min-height: 3.4rem; gap: .2rem; }
  .back-button { display: inline-grid; }
  .channel-header .icon, .search-key { width: 44px; height: 44px; }
  .channel-symbol { width: 2rem; height: 2rem; }
  .channel-label h1 { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .view-bar { padding: .4rem .75rem; font-size: .8rem; }
  .feed { padding: .5rem .35rem .4rem; }
  .message { grid-template-columns: 2.1rem minmax(0, 1fr); gap: .55rem; padding: .35rem .4rem; }
  .avatar { width: 2.1rem; height: 2.1rem; }
  .message-tools { top: auto; bottom: -.9rem; right: .5rem; }
  .message-tools .icon { width: 40px; height: 40px; }
  .message-head time { font-size: .7rem; }
  .agent-tag { display: none; }
  .picture-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .picture-grid.single { grid-template-columns: minmax(0, 16rem); }
  .compose { margin: .2rem .4rem calc(.4rem + env(safe-area-inset-bottom)); border-radius: max(var(--r-l), 1.2rem); padding: .3rem .35rem; }
  html[data-theme="terminal"] .compose { border-radius: 2px; }
  .compose textarea { font-size: max(16px, 1rem); min-height: 2.6rem; }
  .compose-hint { display: none; }
  .attach, .send { height: 44px; min-height: 44px; min-width: 44px; }
  .attach { width: 44px; }
  html[data-theme="dream"] .send .send-label, html[data-theme="terminal"] .send .send-label { display: none; }
  html[data-theme="dream"] .send, html[data-theme="terminal"] .send { padding: 0 .7rem; }
  .jump { bottom: calc(5.5rem + env(safe-area-inset-bottom)); right: .8rem; }
  input, select, textarea { font-size: max(16px, 1rem); }
  .mobile-tabs {
    display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line);
    background: var(--surface); padding-bottom: env(safe-area-inset-bottom);
  }
  .workspace[data-view="chat"] .mobile-tabs { display: none; }
  .mobile-tabs button {
    position: relative; display: grid; justify-items: center; gap: 2px; min-height: 56px; border-radius: 0;
    color: var(--faint); padding: .45rem .2rem; font-size: .72rem; transition: color var(--fast);
  }
  .mobile-tabs button[aria-current] { color: var(--accent-text); font-weight: 650; }
  .tab-badge { position: absolute; top: .45rem; left: calc(50% + .45rem); margin: 0; }
  .toasts { bottom: calc(4.5rem + env(safe-area-inset-bottom)); right: .6rem; left: .6rem; width: auto; }
  dialog {
    margin: auto 0 0; width: 100%; max-width: 100%; max-height: 88dvh; border-radius: var(--r-l) var(--r-l) 0 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); overscroll-behavior: contain; border-bottom: 0;
  }
  dialog[open] { animation: sheet-in var(--slow) var(--ease-drawer); }
  dialog.closing { animation: sheet-out 200ms var(--ease-in-out) forwards; }
  .palette { margin: auto 0 0; }
  .lightbox { margin: auto; padding: 0; border-radius: 0; max-height: none; }
  .lightbox[open] { animation: zoom-in var(--slow) var(--ease-out); }
  .crop-canvas { width: min(288px, 80vw); height: min(288px, 80vw); }
  .look-actions .quiet, .look-actions .upload { min-height: 44px; }
  .swatch { width: 2.1rem; height: 2.1rem; }
  .message-tools .icon::after { content: ""; position: absolute; inset: -6px; }
  .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder-row { grid-template-columns: minmax(0, 1fr); }
  .reaction { height: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  dialog[open], .message.arrive, .toast, .empty, .signin-card, .suggest { animation: fade var(--mid) linear !important; }
  svg.i.play-ic * { animation: none !important; }
}
