/* Algorithm Desk. Монохром бренда Algorithm и салатовый #BDFF12 как сигнал: «идет», главная кнопка, фокус. */

:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --raised: #fafbf8;
  --sunken: #eceee9;
  --ink: #121411;
  --ink-2: #3a3e37;
  --muted: #6b7067;
  --line: #e1e3dd;
  --line-strong: #cdd0c7;
  --accent: #bdff12;
  --accent-ink: #121411;
  --accent-text: #4c6d00;
  --accent-soft: #f1ffd0;
  --ok: #1f7a3d;
  --warn: #a45a00;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn-soft: #fff4e0;
  --code-bg: #f1f2ee;
  --shadow: 0 1px 2px rgb(18 20 17 / 6%), 0 8px 24px rgb(18 20 17 / 6%);
  --radius: 10px;
  --radius-sm: 7px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --side-w: 272px;
  --panel-w: 380px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e0c;
    --surface: #151714;
    --raised: #1b1d19;
    --sunken: #101210;
    --ink: #eceee8;
    --ink-2: #c9ccc3;
    --muted: #949a8e;
    --line: #262923;
    --line-strong: #353a31;
    --accent: #bdff12;
    --accent-ink: #0d0e0c;
    --accent-text: #bdff12;
    --accent-soft: #1f2a08;
    --ok: #5fd38a;
    --warn: #f0b04a;
    --bad: #ff7a6b;
    --bad-soft: #2a1513;
    --warn-soft: #2a2010;
    --code-bg: #1d201b;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 30px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d0e0c;
  --surface: #151714;
  --raised: #1b1d19;
  --sunken: #101210;
  --ink: #eceee8;
  --ink-2: #c9ccc3;
  --muted: #949a8e;
  --line: #262923;
  --line-strong: #353a31;
  --accent: #bdff12;
  --accent-ink: #0d0e0c;
  --accent-text: #bdff12;
  --accent-soft: #1f2a08;
  --ok: #5fd38a;
  --warn: #f0b04a;
  --bad: #ff7a6b;
  --bad-soft: #2a1513;
  --warn-soft: #2a2010;
  --code-bg: #1d201b;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 30px rgb(0 0 0 / 35%);
  color-scheme: dark;
}

:root[data-theme="graphite"] {
  --bg: #1b1f26;
  --surface: #222731;
  --raised: #262c37;
  --sunken: #1e232b;
  --ink: #e3e7ee;
  --ink-2: #c2c9d4;
  --muted: #8e98a8;
  --line: #313845;
  --line-strong: #3e4656;
  --accent: #bdff12;
  --accent-ink: #14171c;
  --accent-text: #c8ff4a;
  --accent-soft: #2a3320;
  --ok: #6fd69a;
  --warn: #f2bc5e;
  --bad: #ff8a7d;
  --bad-soft: #3a2326;
  --warn-soft: #3a3020;
  --code-bg: #1c2029;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px rgb(0 0 0 / 28%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.boot-splash { display: grid; place-items: center; height: 100vh; color: var(--muted); letter-spacing: .04em; }

/* --- кнопки и поля ------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--raised); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(0.95); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn.on { color: var(--ink); background: var(--sunken); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
}
.textarea { height: auto; min-height: 90px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; background: var(--sunken); color: var(--ink-2); white-space: nowrap;
}
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.live { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot.pulse { animation: none; } }

/* --- вход ---------------------------------------------------------------------------------------- */
body.gate { display: grid; place-items: center; min-height: 100%; padding: 24px 16px; }
.gate-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow);
}
.gate-logo img { display: block; width: 220px; height: auto; max-width: 100%; }
.gate-card h1 { font-size: 22px; margin: 28px 0 16px; letter-spacing: -.01em; }
.gate-form { display: flex; flex-direction: column; gap: 6px; }
.gate-form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.gate-form input { height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); }
.gate-form button { margin-top: 18px; height: 40px; }
.gate-error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--radius-sm); }
.gate-note { color: var(--muted); font-size: 13px; margin-top: 18px; }

/* --- каркас ---------------------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100%; height: 100dvh; }
.shell.with-panel { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--panel-w); }
.side {
  display: flex; flex-direction: column; min-height: 0; background: var(--raised);
  border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 8px 16px; }
.brand { display: block; line-height: 0; }
.brand img { width: 150px; height: auto; }
.brand .logo-dark { display: none; }
:root[data-theme="dark"] .brand .logo-light, :root[data-theme="graphite"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark, :root[data-theme="graphite"] .brand .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
.side-actions { display: flex; flex-direction: column; gap: 6px; padding: 6px 12px 10px; }
.side-search { position: relative; }
.side-search .icon { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--muted); }
.side-search input { padding-left: 32px; height: 34px; background: var(--surface); }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.side-group { margin-top: 10px; }
.side-label {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 6px 8px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.side-label button { opacity: 0; }
.side-group:hover .side-label button, .side-label button:focus-visible { opacity: 1; }
.project-row { display: flex; align-items: center; gap: 2px; }
.project-row .project-link { flex: 1; min-width: 0; }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 5px 8px;
  border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; cursor: pointer;
  color: var(--ink-2); text-decoration: none;
}
.nav-item:hover { background: var(--sunken); color: var(--ink); }
.nav-item.on { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .badge { font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; background: var(--ink); color: var(--bg); }
.nav-item .state-dot, .side-toggle .state-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.state-dot.running, .state-dot.queued { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); animation: pulse 1.2s infinite; }
.state-dot.waiting { background: var(--warn); }
.state-dot.unread { background: var(--ink); }
.chat-children { padding-left: 14px; }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 12.5px;
}
.me .who { flex: 1; min-width: 0; line-height: 1.25; text-decoration: none; color: inherit; }
.me .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who small { color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.topbar {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px 8px 18px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumb { color: var(--muted); font-weight: 400; }
.topbar .title-input { flex: 1; height: 32px; font-weight: 600; }
.menu-btn { display: none; }

.panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line); background: var(--raised); }
.panel-tabs { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.panel-tabs button {
  border: 0; background: transparent; padding: 8px 10px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.panel-tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.panel-tabs .spacer { flex: 1; }
.panel-body { flex: 1; overflow: auto; padding: 10px; }

/* --- чат ----------------------------------------------------------------------------------------- */
.thread { flex: 1; overflow-y: auto; }
.thread-inner { max-width: 820px; margin: 0 auto; padding: 24px 24px 12px; display: flex; flex-direction: column; gap: 14px; }
.msg-user { align-self: flex-end; max-width: 85%; background: var(--sunken); border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-user .author { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg-text { overflow-wrap: anywhere; }
.msg-text > :first-child { margin-top: 0; }
.msg-text > :last-child { margin-bottom: 0; }
.msg-text p { margin: 0 0 10px; }
.msg-text h1, .msg-text h2, .msg-text h3 { font-size: 15.5px; margin: 16px 0 8px; }
.msg-text ul, .msg-text ol { margin: 0 0 10px; padding-left: 22px; }
.msg-text code { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.msg-text pre { background: var(--code-bg); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; }
.msg-text pre code { background: none; padding: 0; }
.msg-text table { border-collapse: collapse; display: block; overflow-x: auto; margin: 0 0 10px; }
.msg-text th, .msg-text td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.msg-text blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.msg-text a { color: var(--accent-text); }
.thinking { color: var(--muted); font-size: 13px; border-left: 2px solid var(--line-strong); padding-left: 10px; white-space: pre-wrap; }
.thinking summary { cursor: pointer; list-style: none; }
.thinking summary::-webkit-details-marker { display: none; }

.tools { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--raised); }
.tool { border-top: 1px solid var(--line); }
.tool:first-child { border-top: 0; }
.tool > summary {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2);
}
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary .tname { font-weight: 600; color: var(--ink); flex: none; }
.tool > summary .targ { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tool > summary .glyph { width: 14px; text-align: center; flex: none; }
.tool .glyph.wait { color: var(--accent-text); }
.tool .glyph.err { color: var(--bad); }
.tool .glyph.ok { color: var(--ok); }
.tool pre { margin: 0; padding: 8px 12px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; background: var(--sunken); border-top: 1px dashed var(--line); }
.tool.sub > summary { padding-left: 26px; }

.approval { border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.approval.done { border-color: var(--line); background: var(--raised); }
.approval .q { font-weight: 600; overflow-wrap: anywhere; }
.approval .q code { font-family: var(--mono); font-size: 12.5px; font-weight: 500; background: var(--surface); padding: 1px 6px; border-radius: 4px; }
.approval pre { margin: 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; background: var(--surface); padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.approval .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.notice { align-self: center; font-size: 12.5px; color: var(--muted); background: var(--sunken); padding: 4px 12px; border-radius: 999px; }
.error-box { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius); padding: 10px 14px; }
.result-line { font-size: 12px; color: var(--muted); display: flex; gap: 12px; }
.typing { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-size: 13px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-text); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.composer-wrap { padding: 8px 24px 18px; }
.composer {
  max-width: 820px; margin: 0 auto; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow); padding: 10px 10px 8px 14px;
}
.composer:focus-within { border-color: var(--ink-2); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; min-height: 26px; max-height: 260px; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.composer-bar .grow { flex: 1; }
.composer-bar select { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 6px; font-size: 13px; color: var(--ink-2); max-width: 170px; }
.send-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--ink); color: var(--bg); }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn.stop { background: var(--bad); color: #fff; }
.composer-note { max-width: 820px; margin: 6px auto 0; font-size: 12px; color: var(--muted); display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.ctx-gauge { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 4px; border-radius: 6px; color: inherit; cursor: pointer; font-size: 12px; }
.ctx-gauge:hover { background: var(--sunken); color: var(--ink); }
.ctx-gauge svg { width: 16px; height: 16px; }

.empty { flex: 1; display: grid; place-items: center; padding: 24px; }
.empty-inner { max-width: 640px; width: 100%; text-align: center; }
.empty-inner h2 { font-size: 26px; letter-spacing: -.015em; margin: 0 0 6px; }
.empty-inner p { color: var(--muted); margin: 0 0 22px; }
.empty-inner .composer { text-align: left; }
.starter-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }

/* --- файлы --------------------------------------------------------------------------------------- */
.file-crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font-size: 13px; padding: 0 2px 8px; }
.file-crumbs button { border: 0; background: none; padding: 2px 4px; cursor: pointer; color: var(--muted); border-radius: 4px; }
.file-crumbs button:hover { background: var(--sunken); color: var(--ink); }
.file-list { display: flex; flex-direction: column; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.file-row:hover { background: var(--sunken); }
.file-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row.hidden-file { opacity: .55; }
.file-row small { color: var(--muted); font-size: 11.5px; flex: none; }
.file-view { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.file-view pre, .file-view textarea { flex: 1; margin: 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; min-height: 200px; }
.file-view img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.drop-hint { display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.drop-hint.over { border-color: var(--accent-text); background: var(--accent-soft); color: var(--ink); }

/* --- страницы: автоматизации, админка, аккаунт ---------------------------------------------------------- */
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 1040px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.page-inner.narrow { max-width: 680px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -6px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }

.auto-list { display: flex; flex-direction: column; gap: 10px; }
.auto-item { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.auto-item.attention { border-left: 3px solid var(--bad); }
.auto-item h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auto-item .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.auto-item .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding-top: 2px; }
.auto-item .actions .spacer { flex: 1; }
.auto-item .summary { color: var(--ink-2); font-size: 13px; }
.owner-group { display: flex; flex-direction: column; gap: 10px; }
.owner-group > h3 { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--raised); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.day-chart { width: 100%; height: auto; display: block; overflow: visible; }
.day-chart .grid { stroke: var(--line); stroke-width: 1; }
.day-chart .col { fill: var(--ink-2); }
.day-chart .col.today { fill: var(--accent-text); }
.day-chart .hit { fill: transparent; }
.day-chart .day:hover .col { fill: var(--ink); }
.day-chart .day:hover .hit { fill: var(--sunken); }
.day-chart text { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }

.secret-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copy-box { display: flex; gap: 8px; align-items: center; background: var(--sunken); border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.copy-box span { flex: 1; min-width: 0; }
.banner { border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--sunken); color: var(--ink-2); }
.card.stack { display: flex; flex-direction: column; gap: 12px; }
.card.stack h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.usage-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.usage-row .num { text-align: right; min-width: 110px; }
.howto { background: var(--sunken); border-radius: var(--radius-sm); padding: 10px 12px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { margin: 10px 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.howto code { font-family: var(--mono); font-size: 12.5px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.howto p { font-size: 12.5px; }
.side-scrim { display: none; }

/* --- окна и уведомления ------------------------------------------------------------------------------ */
.modal-back { position: fixed; inset: 0; background: rgb(0 0 0 / 35%); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--line); }
.modal h3 { margin: 0; font-size: 17px; }
.modal .row-end { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 13.5px; }
.toast.bad { background: var(--bad); color: #fff; }

/* --- телефон ----------------------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .shell.with-panel { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .shell.with-panel .panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(var(--panel-w), 100vw); z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 760px) {
  .shell, .shell.with-panel { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .shell.side-open .side { transform: none; }
  .side-scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / 30%); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .thread-inner, .composer-wrap { padding-left: 16px; padding-right: 16px; }
  .page-inner { padding: 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .auto-item .actions .spacer { display: none; }
  .msg-user { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* === общие мелочи ========================================================================================= */
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.center { text-align: center; }
td.right, th.right { text-align: right; }
.dim { opacity: .55; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead { margin: 0; font-size: 15px; color: var(--ink-2); max-width: 70ch; }
.loading { padding: 32px 0; text-align: center; }
mark { background: var(--accent-soft); color: var(--ink); border-radius: 3px; padding: 0 1px; box-shadow: inset 0 -2px 0 var(--accent); }
kbd { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface); color: var(--ink-2); }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: var(--ink); }

.btn.tiny { height: 24px; padding: 0 8px; font-size: 12px; gap: 4px; border-radius: 6px; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { filter: brightness(0.95); background: var(--bad); }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 6px; }
.icon-btn.xs .icon { width: 14px; height: 14px; }
.icon-btn:disabled { opacity: .45; cursor: default; }

.avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.avatar.xxs { width: 18px; height: 18px; font-size: 9px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
a.avatar { text-decoration: none; }

.pill-btn { border: 0; cursor: pointer; }
.pill-btn:hover { background: var(--line); color: var(--ink); }
.pill.level-write { background: var(--accent-soft); color: var(--accent-text); }
.pill.level-read { background: var(--sunken); color: var(--ink-2); }
.pill.level-none { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 13px;
  text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); background: var(--raised); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.mini-select {
  height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  padding: 0 22px 0 8px; font-size: 13px; color: var(--ink-2); max-width: 180px; cursor: pointer;
}
.mini-select:hover { border-color: var(--line-strong); color: var(--ink); }
.mini-select:disabled { opacity: .6; cursor: default; }
.mini-select.level.write { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.mini-select.level.none { color: var(--muted); }
.select.auto-width { width: auto; }
.textarea.tall { min-height: 200px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.search-input { width: 220px; max-width: 100%; height: 32px; }

.empty-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 36px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-2);
}
.empty-card .icon { color: var(--muted); }
.empty-card b { font-size: 15px; color: var(--ink); }
.empty-card .muted { max-width: 46ch; }

.banner.left { text-align: left; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.foot-note { margin: 8px 0 0; }

/* --- окна, меню ---------------------------------------------------------------------------------------- */
.modal.wide { width: min(780px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -4px -6px -2px 0; }
.modal-head h3 { min-width: 0; overflow-wrap: anywhere; }
.modal-text { margin: 0; color: var(--ink-2); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }

.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; top: calc(100% + 6px); z-index: 45; min-width: 220px; max-width: min(320px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 5px; display: flex; flex-direction: column;
}
.menu.right { right: 0; }
.menu.left { left: 0; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 32px; padding: 5px 9px; border: 0; border-radius: 6px;
  background: none; text-align: left; cursor: pointer; color: var(--ink-2); font-size: 13.5px;
}
.menu-item:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-item span { flex: 1; min-width: 0; }
.menu-item small { color: var(--muted); font-size: 11.5px; }
.menu-item.danger { color: var(--bad); }
.menu-item .icon { color: var(--muted); }
.menu-item.danger .icon { color: var(--bad); }

.offline {
  position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 70;
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

/* --- шапка экрана -------------------------------------------------------------------------------------- */
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.topbar-title h1 { flex: 0 1 auto; }
.topbar-title .crumb { color: var(--muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; flex: none; }
.topbar-title .crumb::after { content: "/"; margin-left: 8px; color: var(--line-strong); }
a.crumb:hover { color: var(--ink); }
.vis-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.presence { display: flex; align-items: center; }
.presence .avatar { box-shadow: 0 0 0 2px var(--surface); }
.presence .avatar + .avatar { margin-left: -6px; }

/* --- боковая панель ------------------------------------------------------------------------------------ */
.side-head .menu-wrap .menu { left: auto; right: 0; }
/* окно уведомлений шире левой панели: от колокольчика влево оно уходило за край экрана - ставим от края */
.side-head .menu-wrap .menu.notes-pop { position: fixed; top: 52px; left: 12px; right: auto; width: min(360px, calc(100vw - 24px)); max-width: none; }
.side-search input { padding-right: 46px; }
.side-kbd { position: absolute; right: 8px; top: 7px; pointer-events: none; font-size: 10.5px; padding: 0 5px; }
.side-group.nav-top { margin-top: 2px; }
.side-label.top-gap { margin-top: 14px; }
.chevron .icon { transition: transform .15s; }
.chevron[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.chat-link .chat-kind { display: inline-flex; color: var(--muted); }
.chat-children { padding-left: 22px; }
.side-empty { padding: 4px 8px 6px; font-size: 12.5px; color: var(--muted); }
.side-more {
  display: block; width: 100%; padding: 5px 8px; border: 0; background: none; text-align: left; cursor: pointer;
  font-size: 12.5px; color: var(--muted); text-decoration: none; border-radius: var(--radius-sm);
}
.side-more:hover { color: var(--ink); background: var(--sunken); }
.search-all { color: var(--accent-text); }
.bell { position: relative; }
.bell-count {
  position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1;
}

/* --- уведомления и входящие ---------------------------------------------------------------------------- */
.notes-pop { width: 360px; padding: 0; overflow: hidden; }
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.notes-list { display: flex; flex-direction: column; max-height: min(420px, 60vh); overflow-y: auto; padding: 4px; }
.notes-list.flat { max-height: none; padding: 0; gap: 2px; }
.notes-empty { padding: 18px 12px; margin: 0; text-align: center; }
.notes-foot { display: block; padding: 9px 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); text-decoration: none; }
.notes-foot:hover { color: var(--ink); background: var(--raised); }
.note-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: start; width: 100%;
  padding: 8px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; cursor: pointer; color: var(--ink-2);
}
.note-row:hover { background: var(--sunken); }
.note-row.unread { color: var(--ink); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.note-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); }
.note-row.unread .note-icon { background: var(--accent); color: var(--accent-ink); }
.note-main { display: flex; flex-direction: column; min-width: 0; }
.note-main b { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.note-main small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-time { font-size: 11.5px; white-space: nowrap; padding-top: 2px; }

.inbox-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.inbox-row + .inbox-row { margin-top: 0; }
.inbox-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.inbox-main .state-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.inbox-main .icon { color: var(--muted); }
.inbox-text { display: flex; flex-direction: column; min-width: 0; }
.inbox-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-text small { font-size: 12.5px; }
.inbox-main:hover b { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

/* --- поиск --------------------------------------------------------------------------------------------- */
.pal-back { align-items: start; padding-top: min(12vh, 110px); }
.palette {
  width: min(640px, 100%); max-height: min(560px, calc(100dvh - 120px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.pal-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-input input { flex: 1; min-width: 0; height: 50px; border: 0; outline: none; background: transparent; font-size: 15.5px; color: var(--ink); }
.pal-input.page-search { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.pal-input.page-search:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.pal-input.page-search input { height: 44px; font-size: 15px; }
.pal-list { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.pal-list.flat { padding: 0; gap: 4px; overflow: visible; }
.pal-list .section-title { margin: 8px 8px 2px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; text-align: left; cursor: pointer; color: var(--ink-2);
}
.pal-list.flat .pal-item { border: 1px solid var(--line); background: var(--surface); }
.pal-item:hover, .pal-item.on { background: var(--sunken); color: var(--ink); }
.pal-item .icon { color: var(--muted); }
.pal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pal-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-snippet { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pal-sub { flex: none; font-size: 11.5px; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-empty { padding: 18px 12px; margin: 0; text-align: center; }
.pal-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; }

/* --- лента чата ---------------------------------------------------------------------------------------- */
[data-ev].focused { animation: focus-flash 2.4s ease-out; border-radius: var(--radius-sm); }
@keyframes focus-flash { 0%, 40% { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 5px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.thread-inner.older { padding-top: 14px; padding-bottom: 0; align-items: center; }
.thread-inner.banner-row { padding-top: 14px; padding-bottom: 0; }
.tool-cmd { color: var(--ink); }
.tool pre.tool-err { color: var(--bad); background: var(--bad-soft); }
.tools-more { border: 0; border-bottom: 1px solid var(--line); background: none; padding: 6px 10px; text-align: left; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.tools-more:hover { color: var(--ink); background: var(--sunken); }
.diff { font-family: var(--mono); font-size: 12px; border-top: 1px dashed var(--line); max-height: 320px; overflow: auto; background: var(--sunken); padding: 6px 0; }
.diff > div { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 12px 0 8px; display: flex; gap: 8px; }
.diff > div > span { flex: none; width: 10px; color: var(--muted); user-select: none; }
.diff .del { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--ink-2); }
.diff .add { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ink); }
.diff .del > span { color: var(--bad); }
.diff .add > span { color: var(--ok); }

.question { border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.question.done { border-color: var(--line); background: var(--raised); }
.question .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.q-block { display: flex; flex-direction: column; gap: 8px; }
.q-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.q-options { display: flex; flex-direction: column; gap: 6px; }
.q-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); text-align: left; cursor: pointer;
}
.q-option small { color: var(--muted); font-size: 12.5px; }
.q-option:hover { border-color: var(--ink-2); }
.q-option.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.q-answer { font-weight: 500; }

.todo-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); padding: 10px 14px; }
.todo-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.todo-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.todo-card li { display: flex; gap: 8px; align-items: baseline; color: var(--ink-2); }
.todo-card li.completed { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.todo-card li.in_progress { color: var(--ink); font-weight: 600; }
.todo-mark { width: 14px; flex: none; text-align: center; color: var(--muted); }
.todo-card li.completed .todo-mark { color: var(--ok); }
.todo-card li.in_progress .todo-mark { color: var(--accent-text); }

.msg-team { align-self: flex-start; max-width: 85%; border: 1px solid var(--line); border-left: 3px solid var(--ink-2); border-radius: 4px 14px 14px 4px; padding: 8px 12px; background: var(--surface); }
.msg-team.mine { align-self: flex-end; border-left-color: var(--accent); }
.team-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.team-head .icon-btn { margin-left: auto; }
.team-quote { margin: 6px 0 2px; padding: 4px 10px; border-left: 2px solid var(--line-strong); color: var(--muted); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.team-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.mention { color: var(--accent-text); font-weight: 600; }
.msg-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; white-space: normal; }
.notice-block { border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.checkpoint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); padding-left: 2px; }
.thinking.live { opacity: .8; }
.typing.waiting { color: var(--warn); font-weight: 500; }

/* --- поле ввода ---------------------------------------------------------------------------------------- */
.composer { position: relative; }
.composer.team { border-color: var(--ink-2); border-style: dashed; }
.composer.compact { box-shadow: none; }
.mode-switch { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: 8px; border-radius: 8px; background: var(--sunken); }
.mode-switch button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 3px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.mode-switch button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }
.quote-chip { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; padding: 4px 6px 4px 10px; border-left: 2px solid var(--accent); background: var(--sunken); border-radius: 0 6px 6px 0; font-size: 12.5px; color: var(--ink-2); }
.quote-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-list {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); z-index: 20; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px;
}
.pop-item { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 6px 10px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.pop-item small { color: var(--muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item.on, .pop-item:hover { background: var(--sunken); }
.pickers { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
.composer-bar { flex-wrap: wrap; }
.note-right { display: inline-flex; align-items: center; gap: 8px; }
.starter-row { align-items: center; }
.starter-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }

/* --- память разговора ---------------------------------------------------------------------------------- */
.ctx-total { display: flex; align-items: baseline; gap: 4px; }
.ctx-total b { font-size: 22px; letter-spacing: -.01em; }
.bar.big { height: 10px; border-radius: 5px; }
.ctx-cats { display: flex; flex-direction: column; gap: 6px; }
.ctx-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 56px; gap: 10px; align-items: center; font-size: 13px; }
.ctx-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-row .num { text-align: right; }

/* --- проекты ------------------------------------------------------------------------------------------- */
.layer-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.list-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: var(--raised); }
.list-row .grow { display: flex; flex-direction: column; }
.list-row .grow b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .grow small { font-size: 12.5px; }
.list-row .icon { color: var(--muted); }
.list-row .state-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.files-page { padding: 12px; min-height: 360px; }
.add-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.add-row > .select, .add-row > .input { flex: 1 1 180px; width: auto; }
.mini-field { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.rule-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 32px; gap: 8px; align-items: center; }

/* --- админка и аккаунт --------------------------------------------------------------------------------- */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.subnav { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; border-right: 1px solid var(--line); background: var(--raised); overflow-y: auto; }
.subnav .nav-item .icon { width: 17px; height: 17px; color: var(--muted); }
.subnav .nav-item.on .icon { color: var(--ink); }
.split > .page { min-width: 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.section-head p { margin: 4px 0 0; max-width: 62ch; }
.section-head .row { justify-content: flex-end; }
.narrow-block { max-width: 680px; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--raised); }
table.data .muted.mono { font-size: 11.5px; }
.bar-num { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tile b { font-size: 24px; letter-spacing: -.015em; font-weight: 650; }
.tile small { font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.project-card { display: flex; flex-direction: column; gap: 10px; }
.project-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.project-card-head h3 { margin: 0; font-size: 15.5px; overflow-wrap: anywhere; }
.project-card-head h3 a { text-decoration: none; }
.project-card-head h3 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.project-card .row.wrap { gap: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.legend b { margin-right: 4px; }
table.matrix th:not(:first-child), table.matrix td:not(:first-child) { text-align: center; }
table.matrix td:first-child { min-width: 180px; }
.cell-btn {
  display: inline-flex; gap: 2px; align-items: center; justify-content: center; min-width: 58px; height: 28px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-family: var(--mono); font-size: 12px;
}
.cell-btn:hover { border-color: var(--ink-2); }
.cell-btn.empty { border-style: dashed; color: var(--muted); }
.lv { display: inline-grid; place-items: center; width: 16px; height: 18px; border-radius: 4px; font-weight: 600; font-family: var(--mono); font-size: 11.5px; }
.lv.write { background: var(--accent-soft); color: var(--accent-text); }
.lv.read { background: var(--sunken); color: var(--ink-2); }
.lv.none { color: var(--muted); }

.caps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; align-items: start; }
fieldset.field, .caps-list { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field > legend, .caps-list > legend { font-size: 12.5px; color: var(--muted); padding: 0; margin-bottom: 6px; }

.pref { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-head + .pref { border-top: 0; padding-top: 0; }
.pref .check { font-weight: 500; }
.pref-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pref-meta .muted { max-width: 72ch; }

.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head b { font-size: 16px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer; background: var(--surface);
}
.choice input { accent-color: var(--ink); margin: 0; }
.choice.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.notify-table td.center input { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }

/* --- справка ------------------------------------------------------------------------------------------- */
.page-inner.help { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 28px; align-items: start; max-width: 980px; }
.help-toc { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.help-toc a { padding: 5px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-size: 13.5px; }
.help-toc a:hover { background: var(--sunken); color: var(--ink); }
.help-body { display: flex; flex-direction: column; gap: 26px; max-width: 70ch; }
.help-section h2 { font-size: 18px; margin: 0 0 10px; letter-spacing: -.01em; }
.help-section li { margin-bottom: 4px; }
.keys { list-style: none; padding-left: 0 !important; }
.keys kbd { margin-right: 6px; }

/* --- плотная раскладка --------------------------------------------------------------------------------- */
:root[data-density="compact"] .thread-inner { gap: 9px; padding-top: 16px; }
:root[data-density="compact"] .nav-item { min-height: 28px; padding-top: 3px; padding-bottom: 3px; }
:root[data-density="compact"] table.data td { padding: 6px 10px; }
:root[data-density="compact"] .page-inner { gap: 12px; }
:root[data-density="compact"] .card { padding: 12px 14px; }
:root[data-density="compact"] body, :root[data-density="compact"] .msg-text { font-size: 13.5px; }

@media (prefers-reduced-motion: reduce) {
  [data-ev].focused { animation: none; box-shadow: 0 0 0 2px var(--accent); }
  .chevron .icon { transition: none; }
}

/* --- узкие экраны для новых частей --------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .subnav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 4px; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav .nav-item { width: auto; flex: none; white-space: nowrap; }
  .subnav .nav-item .grow { overflow: visible; }
  .page-inner.help { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .hide-sm { display: none; }
  .search-input { width: 100%; }
  .section-head .row { width: 100%; justify-content: flex-start; }
  .pal-back { padding-top: 16px; }
  .pal-foot { display: none; }
  .topbar-title .crumb { display: none; }
  .msg-team { max-width: 92%; }
  .rule-row { grid-template-columns: minmax(0, 1fr) 120px 32px; }
  .ctx-row { grid-template-columns: minmax(0, 1fr) 70px 48px; }
  .usage-row { grid-template-columns: 70px minmax(0, 1fr); }
  .usage-row .num { grid-column: 1 / -1; text-align: left; min-width: 0; }
  .composer-bar .pickers .mini-select { max-width: 120px; }
}

/* группа «От автоматизаций» в боковой панели: заголовок-кнопка */
.side-label.side-toggle { width: 100%; background: none; border: 0; cursor: pointer; text-align: left; font-family: inherit; border-radius: 6px; }
.side-label.side-toggle:hover { color: var(--ink); }
.side-label.side-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.side-label.side-toggle .row-gap { display: inline-flex; align-items: center; gap: 6px; }
.side-count { font-weight: 500; letter-spacing: 0; text-transform: none; opacity: .8; }
