/* ───────────────────────────── Design system ─────────────────────────────
   Light / dark / system themes via [data-theme] on <html>. All surfaces and text
   read from CSS variables so a single attribute flip restyles the whole app.        */

:root {
  color-scheme: light;       /* нативные виджеты светлые в светлой теме независимо от темы ОС */
  /* Brand typography — mirrors scitechnews.ru: Oswald (condensed, uppercase) for headings,
     Roboto for body. System fallbacks keep the app usable if Google Fonts can't load. */
  --font-head: "Oswald", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-body: "Roboto", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e6ebf2;
  --border: #d7dee8;
  --border-strong: #c2cdda;
  --ink: #121a28;
  --ink-2: #36435a;
  --muted: #6a7686;
  /* Scientific-terminal accent: a single cyan, used sparingly. Navy chrome from the brand. */
  --accent: #0d7da3;
  --accent-2: #0f93bf;
  --accent-weak: #e0f0f5;
  --accent-ink: #ffffff;
  --cyan: #0d7da3;
  --navy: #141a33;           /* brand navy — header/footer chrome on the site */
  --brand-orange: #ff5a1f;   /* rare highlight, echoes the site's orange CTA */
  --ok: #1a8f53; --ok-bg: #e4f5ec;
  --warn: #b4690e; --warn-bg: #fbefdd;
  --err: #cf3b3b; --err-bg: #fbe9e9;
  --info: #1f6f93; --info-bg: #e2f0f5;
  /* Flat surfaces — borders carry elevation, not shadows (instrument aesthetic). */
  --shadow: none;
  --shadow-lg: none;
  --radius: 3px; --radius-sm: 2px; --radius-lg: 4px;
  --sidebar-w: 244px;
  --speed: .18s;
}

[data-theme="dark"] {
  color-scheme: dark;        /* нативные виджеты (стрелки number, пикеры) рендерятся тёмными */
  --bg: #0a0f1c;
  --surface: #111729;        /* deep navy panel */
  --surface-2: #161d34;
  --surface-3: #1f2842;      /* brand alt-navy */
  --border: #28324e;
  --border-strong: #3a4768;
  --ink: #e7ecf6;
  --ink-2: #b2bdd4;
  --muted: #8090a8;
  --accent: #3fb9d4;
  --accent-2: #5ad0ea;
  --accent-weak: #0e2832;
  --accent-ink: #04222b;
  --cyan: #5ac8fa;
  --ok: #43c281; --ok-bg: #122a20;
  --warn: #e0a64a; --warn-bg: #2c2113;
  --err: #f0767a; --err-bg: #2e1719;
  --info: #5ac8fa; --info-bg: #0e2433;
  --shadow: none;
  --shadow-lg: none;
}

/* Smooth cross-page navigation where the browser supports it (Chrome/Edge). */
@view-transition { navigation: auto; }

* { box-sizing: border-box; }
/* The `hidden` attribute must win over component `display:flex/grid` rules (otherwise a hidden
   flex element stays visible). A global reset prevents this whole class of bug. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 var(--font-body);
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--speed) ease, color var(--speed) ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Oswald, uppercase section headings — the site's signature typographic move. */
h1 { font-family: var(--font-head); font-size: 25px; font-weight: 600; margin: 0 0 4px; letter-spacing: .01em; text-transform: uppercase; }
h2 { font-family: var(--font-head); font-size: 17px; font-weight: 600; margin: 0 0 14px; letter-spacing: .02em; text-transform: uppercase; }
::selection { background: var(--accent-weak); }

/* ───────────────────────────── App shell ───────────────────────────── */
/* Ambient starfield canvas (bg.js) sits above the base bg, below all content. */
#bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* Toast — transient success feedback, bottom-right. Hidden until given a class. */
#toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  max-width: min(360px, calc(100vw - 44px));
  padding: 11px 15px 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--accent);
  box-shadow: 0 8px 28px rgba(6, 10, 20, .22);
  font-size: 13.5px; font-weight: 500; line-height: 1.35;
  opacity: 0; transform: translateY(10px) scale(.98); pointer-events: none;
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, .8, .3, 1);
}
#toast.show { opacity: 1; transform: none; }
#toast.ok { border-left-color: var(--ok); }
#toast::before {
  content: "✓ "; color: var(--ok); font-weight: 700;
}
@media (max-width: 560px) { #toast { left: 14px; right: 14px; bottom: 14px; max-width: none; } }
@media (prefers-reduced-motion: reduce) { #toast { transition: opacity .15s ease; transform: none; } }

/* Note band — inline contextual explanation (e.g. why a run shows 0 results). */
.note-band {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 15px; border-radius: var(--radius-sm);
  background: var(--accent-weak); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); color: var(--ink);
  font-size: 13.5px; line-height: 1.45;
}
.note-band svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.note-band b { font-weight: 600; }
.note-band.warn { background: var(--warn-bg); border-left-color: var(--warn); }
.note-band.warn svg { color: var(--warn); }
.note-band.err { background: var(--err-bg); border-color: var(--err); border-left-color: var(--err); }
.note-band.err svg { color: var(--err); }
.note-band code { font-family: var(--font-mono); background: var(--surface-2); padding: 1px 5px; border-radius: var(--radius-sm); }

/* Mini inline tag — e.g. "только новые" marker in a table cell. */
.tag-mini {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  background: var(--accent-weak); color: var(--accent);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; white-space: nowrap; vertical-align: middle;
}
.tag-mini.warn { background: var(--warn-bg); color: var(--warn); }

/* Help affordance — a term with an explanatory native tooltip. Dotted underline signals "hover me". */
.help { border-bottom: 1px dotted currentColor; cursor: help; }

/* Onboarding — 3-step getting-started guide, shown only on a fresh (run-less) dashboard. */
.onboard .ob-head {
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: .04em;
  font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px;
}
.ob-steps { display: flex; align-items: stretch; gap: 10px; }
.ob-step {
  flex: 1; display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); text-decoration: none;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.ob-step:hover { border-color: var(--accent); background: var(--accent-weak); transform: translateY(-2px); text-decoration: none; }
.ob-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-mono); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.ob-txt { display: flex; flex-direction: column; gap: 2px; }
.ob-txt b { font-weight: 600; font-size: 14px; }
.ob-txt span { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.ob-arrow { display: flex; align-items: center; color: var(--ink-2); opacity: .55; font-size: 18px; flex-shrink: 0; }
@media (max-width: 720px) {
  .ob-steps { flex-direction: column; }
  .ob-arrow { display: none; }
}
/* User-chosen UI scale (Settings → Оформление → Размер). Applied to the content only —
   NOT to .app, whose `zoom` would re-root the fixed off-canvas sidebar's containing block
   and break the mobile burger menu on some browsers (Safari). */
.content, .auth-card { zoom: var(--ui-zoom, 1); }

/* Settings: label + control rows */
.set-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.set-row .set-lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; min-width: 60px; text-transform: uppercase; letter-spacing: .03em; }
input[type=time] { font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
input[type=time]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  transition: background var(--speed) ease, border-color var(--speed) ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand .logo { width: 34px; height: 34px; flex-shrink: 0; }
.brand .brand-name { font-family: var(--font-head); font-weight: 600; font-size: 16px; line-height: 1.1; letter-spacing: .03em; text-transform: uppercase; }
.brand .brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; font-size: 14.5px; transition: all .15s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent); }
.nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 6px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.topbar .crumb { font-size: 13px; color: var(--muted); }
.topbar .tb-actions { display: flex; align-items: center; gap: 12px; }
/* Active-workspace switcher in the topbar. */
.ws-switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.ws-switch svg { width: 16px; height: 16px; flex-shrink: 0; }
.ws-switch select {
  font-size: 12.5px; padding: 4px 28px 4px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background-color: var(--surface-2); color: var(--text);
  max-width: 220px; background-position: right 8px center;
}
@media (max-width: 560px) { .ws-switch select { max-width: 130px; } }
.content { padding: 28px 32px 64px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head p.sub { color: var(--muted); margin: 0; font-size: 14px; }

/* ───────────────────────────── Cards ───────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  transition: background var(--speed) ease, border-color var(--speed) ease, transform .15s ease;
}
.card.hover:hover { border-color: var(--accent); }
.grid { display: grid; gap: 20px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* Settings: balanced masonry — cards flow across two columns and the browser equalises column
   heights, so a tall card (Модель ИИ) can't leave the other side empty. break-inside keeps each
   card whole. Collapses to one column on narrow screens. */
/* Two explicit columns (not CSS multi-column): a card growing/shrinking — e.g. the calibration
   card expanding into sliders — stays in its own column and never reshuffles the others. CSS
   `columns` reflowed the whole flow on any height change, making cards jump between columns. */
.settings-masonry { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.settings-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.advanced-setting { order: 10; }
.settings-advanced-toggle { flex-shrink: 0; }
.settings-advanced-toggle .adv-caret { display: inline-block; transition: transform .18s ease; }
.settings-advanced-toggle.open .adv-caret { transform: rotate(180deg); }
@media (max-width: 900px) { .settings-masonry { grid-template-columns: 1fr; } }

.stat { position: relative; overflow: hidden; }
/* Flat 2px accent hairline above the card — instrument marker, not a gradient. */
.stat::after { content: ""; position: absolute; top: -1px; left: -1px; width: 36px; height: 2px; background: var(--accent); }
.stat .stat-label { font-size: 11.5px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: .05em; }
.stat .stat-label svg { width: 15px; height: 15px; color: var(--accent); }
.stat .stat-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-top: 10px; line-height: 1; }
.stat .stat-foot { font-size: 12.5px; color: var(--muted); margin-top: 7px; }
.stat .stat-accent { position: absolute; right: -10px; bottom: -14px; opacity: .07; }
.stat .stat-accent svg { width: 84px; height: 84px; color: var(--accent); }

/* Expandable stat cards → a detail panel eases open below the row. */
.stat.expandable { cursor: pointer; }
.stat-caret { position: absolute; top: 12px; right: 12px; color: var(--muted); opacity: .5;
  transition: transform .25s ease, opacity .15s ease, color .15s ease; }
.stat-caret svg { width: 16px; height: 16px; display: block; }
.stat.expandable:hover .stat-caret { opacity: 1; color: var(--accent); }
.stat.active { border-color: var(--accent); }
.stat.active .stat-caret { transform: rotate(180deg); color: var(--accent); opacity: 1; }
.stat-detail { padding: 16px 18px; }
.stat-detail .sd-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.stat-detail .sd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 44px; }
.sd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 5px 0; border-bottom: 1px solid var(--border); }
.sd-row:last-child { border-bottom: none; }
.sd-name { color: var(--ink-2); font-size: 13.5px; }
.sd-barrow { display: grid; grid-template-columns: minmax(64px, auto) 1fr auto; align-items: center;
  gap: 12px; padding: 7px 0; }
.sd-track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.sd-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.sd-num { font-size: 13px; white-space: nowrap; }
@media (max-width: 760px) { .stat-detail .sd-cols { grid-template-columns: 1fr; } }

/* ───────────────────────────── Buttons / inputs ───────────────────────────── */
button, .btn {
  font: inherit; font-weight: 550; cursor: pointer; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm);
  padding: 10px 18px; display: inline-flex; align-items: center; gap: 8px;
  transition: filter .15s ease, transform .1s ease, background .15s ease, border-color .15s ease;
}
:where(a, button, [role="button"], input, select, textarea):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 68%, white 12%);
  outline-offset: 2px;
}
button:hover, .btn:hover { background: var(--accent-2); text-decoration: none; }
button:active, .btn:active { transform: scale(.985); }
button:disabled { opacity: .5; cursor: not-allowed; }
button svg, .btn svg { width: 18px; height: 18px; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); filter: none; }
.btn.soft { background: var(--accent-weak); color: var(--accent); }
.btn.soft:hover { filter: none; background: color-mix(in srgb, var(--accent-weak) 80%, var(--accent) 12%); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--ink-2);
  width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 10px;
}
.icon-btn:hover { background: var(--surface-2); filter: none; color: var(--ink); }

select, input[type=text], input[type=password], input[type=date], input[type=search],
input[type=number], input[type=email] {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* Custom select: drop the native chevron for a consistent branded caret. */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none; cursor: pointer;
  max-width: 100%;  /* never let a long option widen past its container (mobile overflow) */
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23687689' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}

/* API-key library rows. */
.key-list { display: flex; flex-direction: column; gap: 8px; }
.key-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.key-row .key-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.key-row .key-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Email recipient widget — name field flush against a domain dropdown ("[ имя ][ @домен ▾ ]"). */
.email-widget { display: inline-flex; align-items: stretch; max-width: 100%; }
.email-widget .email-local {
  min-width: 130px; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none;
}
.email-widget .email-domain {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  background-color: var(--surface-2); color: var(--muted); min-width: 120px;
}
.email-widget .email-local:focus { position: relative; z-index: 1; }

/* Custom checkbox — branded box with a drawn tick, replaces the native control everywhere. */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 19px; height: 19px; margin: 0; border: 2px solid var(--border-strong);
  border-radius: 6px; background: var(--surface); cursor: pointer; position: relative;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
input[type="checkbox"]:hover { border-color: var(--accent); }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(43deg);
}
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }

/* Custom range slider — branded track + thumb (the "крутишка"). */
input[type="range"] {
  appearance: none; -webkit-appearance: none; height: 6px; border-radius: 99px;
  background: var(--surface-3); cursor: pointer; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
input[type="range"]:focus-visible { box-shadow: 0 0 0 3px var(--accent-weak); }

label.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--ink-2); }

/* ───────────────────────────── Badges / pills ───────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.badge.done { color: var(--ok); background: var(--ok-bg); }
.badge.running { color: var(--info); background: var(--info-bg); }
.badge.failed { color: var(--err); background: var(--err-bg); }
.badge.pending { color: var(--muted); background: var(--surface-3); }
.badge.cancelled { color: var(--warn); background: var(--warn-bg); }
.badge.yes { color: var(--ok); background: var(--ok-bg); }
.badge.no { color: var(--muted); background: var(--surface-3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* significance category A/B/C/D — A highest value, D lowest */
.cat-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; padding: 1px 7px; border-radius: 3px; font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
.cat-badge.cat-A { color: var(--ok); background: var(--ok-bg); }
.cat-badge.cat-B { color: var(--info); background: var(--info-bg); }
.cat-badge.cat-C { color: var(--warn); background: var(--warn-bg); }
.cat-badge.cat-D { color: var(--muted); background: var(--surface-3); }

/* ───────────────────────────── Tables ───────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: var(--surface-2); }
.nums { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 28px 6px; text-align: center; }

/* ───────────────────────────── Theme switch ───────────────────────────── */
.theme-switch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.theme-switch button {
  background: transparent; color: var(--muted); border: none; width: 32px; height: 30px;
  padding: 0; justify-content: center; border-radius: 7px;
}
.theme-switch button svg { width: 17px; height: 17px; }
.theme-switch button:hover { filter: none; color: var(--ink); background: var(--surface-3); }
.theme-switch button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.user-chip { display: inline-flex; align-items: center; gap: 9px; padding: 5px 6px; border-radius: 10px; }
.avatar { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 13px; }

/* ───────────────────────────── Animations ───────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .4s ease both; }
.fade-up.d1 { animation-delay: .05s; } .fade-up.d2 { animation-delay: .1s; }
.fade-up.d3 { animation-delay: .15s; } .fade-up.d4 { animation-delay: .2s; }

/* Scroll reveal — with JS, blocks and repeating rows start hidden and ease in as they enter the
   viewport (a single load-burst becomes progressive reveals all the way down the page). No FOUC:
   `.js` is set synchronously in <head>; without JS the load animation above still plays. */
.js .fade-up { opacity: 0; transform: translateY(15px); animation: none; transition: opacity .5s ease, transform .6s cubic-bezier(.2,.7,.3,1); }
.js .fade-up.in { opacity: 1; transform: none; }
.js .fade-up.d1 { transition-delay: .05s; } .js .fade-up.d2 { transition-delay: .1s; }
.js .fade-up.d3 { transition-delay: .16s; } .js .fade-up.d4 { transition-delay: .22s; }
/* Прогон с прорывными — тонкая акцентная подсветка, чтобы реальные находки не терялись */
.runs-table tbody tr.has-breaks td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.runs-table tbody tr.has-breaks { background: var(--accent-weak); }

.js .reveal,
.js .results-table .res-row, .js .runs-table tbody tr, .js .src-item,
.js .rank-list li, .js .role-row, .js .preset-chip, .js .ob-step, .js .api-ep,
.js .ws-row, .js .key-row, .js .ws-member {
  opacity: 0; transform: translateY(12px); transition: opacity .45s ease, transform .5s cubic-bezier(.2,.7,.3,1);
}
.js .reveal.in,
.js .results-table .res-row.in, .js .runs-table tbody tr.in, .js .src-item.in,
.js .rank-list li.in, .js .role-row.in, .js .preset-chip.in, .js .ob-step.in, .js .api-ep.in,
.js .ws-row.in, .js .key-row.in, .js .ws-member.in {
  opacity: 1; transform: none;
}

/* Expand / appear — panels and disclosed content pop in instead of snapping. */
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes popOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.985); } }
.nova-panel:not([hidden]) { animation: popIn .28s cubic-bezier(.2,.8,.3,1) both; }
.nova-panel.nova-closing { animation: popOut .2s cubic-bezier(.4,0,.6,1) both; }
.nova-inline-chat { position: relative; }
/* Smoothly grow/collapse native <details> where supported (recent Chrome/Edge); older browsers just
   toggle instantly — no regression. interpolate-size lets block-size animate to/from `auto`. The
   content fades together with the height (one motion) so opening doesn't fight a second animation and
   closing doesn't cut off — it fades out as it shrinks. */
:root { interpolate-size: allow-keywords; }
/* THE expand/collapse primitive: a block that eases height 0 ⇄ auto with its content fading in step
   (one motion, no jolt, no cut-off, no JS measurement). Toggle the `.open` class. Used for plain
   open/close from nothing (e.g. the dashboard stat-detail panel); `<details>` is the native twin
   below, and `morphHeight()` (theme.js) covers the "switch between two states" case. */
.collapse { height: 0; opacity: 0; overflow: clip;
  transition: height .34s cubic-bezier(.3,0,.2,1), opacity .26s ease; }
.collapse.open { height: auto; opacity: 1; }
details::details-content {
  block-size: 0; overflow: clip; opacity: 0;
  transition: block-size .34s cubic-bezier(.3,0,.2,1), opacity .26s ease,
              content-visibility .34s allow-discrete;
}
details[open]::details-content { block-size: auto; opacity: 1; }
.detail-row { animation: fadeUp .26s ease both; }
.greet-btn .bubble { animation: fadeUp .3s ease both; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }
.htmx-indicator { opacity: 0; transition: opacity .2s; } .htmx-request .htmx-indicator { opacity: 1; }

/* ── Motion layer: micro-interactions across nav, buttons, icons, dashboard ── */
.nav a { transition: background .15s ease, color .15s ease, padding-left .18s ease, box-shadow .18s ease; }
.nav a svg, button svg, .btn svg, .icon-btn svg { transition: transform .18s ease; }
.nav a:hover { padding-left: 15px; }
.nav a:hover svg { transform: scale(1.14); }
.nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
button:hover svg, .btn:hover svg { transform: scale(1.12); }
.card.hover { transition: border-color .15s ease, transform .2s ease; }
.card.hover:hover { transform: translateY(-3px); }
.theme-switch button svg, .user-chip, .badge, .cat-badge { transition: transform .15s ease, background .15s ease, color .15s ease; }
.res-row:hover .cat-badge { transform: scale(1.06); }
.prompt-area { width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; padding: 12px; resize: vertical; min-height: 220px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color .15s ease, box-shadow .15s ease; }
.prompt-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft, rgba(63,185,212,.15)); }
.badge:hover { transform: translateY(-1px); }

/* Reveal-on-load: stat accent ticks draw in, all bar fills grow from their base. */
.stat::after { animation: tickIn .55s ease both; }
@keyframes tickIn { from { width: 0; } }
.rank-fill, .pbar-fill { transform-origin: left center; animation: growX .6s cubic-bezier(.2,.7,.3,1) both; }
@keyframes growX { from { transform: scaleX(0); } }
.ybar-fill { transform-origin: bottom; animation: growY .55s cubic-bezier(.2,.7,.3,1) both; }
@keyframes growY { from { transform: scaleY(0); } }

/* HTMX fragment swaps fade in on settle. */
.htmx-added { animation: fadeUp .3s ease both; }

/* List-row liveness — workspace rows, members and key-library rows respond on hover. */
.ws-row, .key-row { transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.key-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.ws-row:hover { background: var(--surface-2); }
.ws-member { padding: 4px 6px; margin: 0 -6px; border-radius: var(--radius-sm); transition: background .12s ease; }
.ws-member:hover { background: var(--surface-2); }
/* Active-workspace switcher — gentle entrance + focus glow. */
.ws-switch { animation: fadeUp .45s ease both; }
.ws-switch select { transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
.ws-switch select:hover { border-color: var(--accent); }
.ws-switch select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); outline: none; }

/* ── Sidebar icons come alive: a signature motion per icon on hover, gentle breath when active ── */
.nav a svg rect, .nav a svg circle, .nav a svg path, .nav a svg ellipse { transition: transform .25s ease; }
/* Dashboard — the four tiles ripple in sequence. */
.nav a[href="/"]:hover svg rect { transform-box: fill-box; transform-origin: center; animation: navTile .5s ease both; }
.nav a[href="/"]:hover svg rect:nth-of-type(2) { animation-delay: .06s; }
.nav a[href="/"]:hover svg rect:nth-of-type(3) { animation-delay: .12s; }
.nav a[href="/"]:hover svg rect:nth-of-type(4) { animation-delay: .18s; }
@keyframes navTile { 0% { transform: scale(1); } 45% { transform: scale(.55); } 100% { transform: scale(1); } }
/* Launch — the radar line sweeps a full turn. */
.nav a[href="/launch"]:hover svg path:nth-of-type(2) { transform-box: view-box; transform-origin: center; animation: navSweep .9s ease-in-out; }
@keyframes navSweep { to { transform: rotate(360deg); } }
/* History — the clock hands tick around once. */
.nav a[href="/history"]:hover svg path:nth-of-type(3) { transform-box: view-box; transform-origin: center; animation: navSweep .9s ease-in-out; }
/* Sources — the database rings pulse downward like landing data. */
.nav a[href="/sources"]:hover svg path { animation: navRing .6s ease; }
.nav a[href="/sources"]:hover svg path:nth-of-type(2) { animation-delay: .08s; }
@keyframes navRing { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(1.3px); } }
/* Users — the front head gives a little nod. */
.nav a[href="/users"]:hover svg circle { transform-box: fill-box; transform-origin: center; animation: navHead .5s ease; }
@keyframes navHead { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
/* Settings — the slider knobs slide along their tracks in sequence. */
.nav a[href="/settings"]:not(.user-chip):hover svg circle { animation: navKnob .7s ease; }
.nav a[href="/settings"]:not(.user-chip):hover svg circle:nth-of-type(2) { animation-delay: .08s; }
.nav a[href="/settings"]:not(.user-chip):hover svg circle:nth-of-type(3) { animation-delay: .16s; }
@keyframes navKnob { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
/* The active item breathes gently so "you are here" reads at a glance. */
.nav a.active svg { animation: navBreath 3.4s ease-in-out infinite; }
@keyframes navBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* ── Liveness pass: entrances + tactile feedback across the rest of the app ── */
/* Login brand panel — staggered cascade as the screen opens. */
.auth-brand .ab-top, .auth-brand .ab-title, .auth-brand .ab-lead,
.auth-brand .ab-points li, .auth-brand .ab-foot { animation: fadeUp .55s ease both; }
.auth-brand .ab-title { animation-delay: .08s; }
.auth-brand .ab-lead { animation-delay: .16s; }
.auth-brand .ab-points li:nth-child(1) { animation-delay: .24s; }
.auth-brand .ab-points li:nth-child(2) { animation-delay: .31s; }
.auth-brand .ab-points li:nth-child(3) { animation-delay: .38s; }
.auth-brand .ab-foot { animation-delay: .48s; }

/* Banners (alerts, run notes) and empty states ease in instead of snapping. */
.note-band, .empty { animation: fadeUp .4s ease both; }

/* Assistant chat messages pop in as they arrive. */
.ai-msg { animation: popIn .3s cubic-bezier(.2,.8,.3,1) both; }

/* Progress stepper — the active step breathes; dots/lines ease between states. */
.stepper .step .s-dot, .stepper .step .s-line, .stepper .step .s-name {
  transition: background .3s ease, color .3s ease, box-shadow .3s ease;
}
.stepper .step.active .s-dot { animation: stepPulse 1.6s ease-in-out infinite; }
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-weak); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

/* Tactile feedback — every button dips when pressed; inputs warm their border on hover. */
button:active, .btn:active, .icon-btn:active { transform: translateY(1px) scale(.985); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover:not(:focus),
select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--border-strong); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ───────────────────────────── Mascot ───────────────────────────── */
.mascot { width: 96px; height: 96px; flex-shrink: 0; }
.mascot .m-body { transform-origin: center; animation: mFloat 3.4s ease-in-out infinite; }
@keyframes mFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.mascot .m-shadow { transform-box: fill-box; transform-origin: center; animation: mShadow 3.4s ease-in-out infinite; }
@keyframes mShadow { 0%,100% { transform: scale(1); opacity: .09; } 50% { transform: scale(.78); opacity: .05; } }
.mascot.busy .m-shadow { animation-duration: .8s; }
.mascot .m-eye { transform-origin: center; animation: mBlink 4.2s infinite; }
@keyframes mBlink { 0%,92%,100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.mascot .m-spark { transform-origin: center; animation: mSpark 2.4s ease-in-out infinite; }
@keyframes mSpark { 0%,100% { opacity: .55; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.12); } }
.mascot.busy .m-eye { animation: mScan 1.1s ease-in-out infinite; }
@keyframes mScan { 0%,100% { transform: translateX(-2px); } 50% { transform: translateX(2px); } }
.mascot.busy .m-spark { animation: mSpark .8s ease-in-out infinite; }
.mascot.happy .m-body { animation: mHop .5s ease-in-out 3; }
@keyframes mHop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-10px); } }

.greet { display: flex; align-items: center; gap: 18px; }
.greet .bubble { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); position: relative; }
.greet .bubble::before { content: ""; position: absolute; left: -7px; top: 26px; width: 12px; height: 12px; background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: rotate(45deg); }
.greet .bubble .g-title { font-weight: 600; font-size: 15px; }
.greet .bubble .g-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.greet .bubble .g-cta { color: var(--accent); font-size: 12.5px; font-weight: 600; margin-top: 8px; opacity: 0; transition: opacity .15s ease; }
/* The dashboard greeting doubles as the assistant entry point — affordance on hover/focus. */
.greet-btn { cursor: pointer; }
.greet-btn .bubble { transition: border-color .15s ease, transform .15s ease; }
.greet-btn:hover .bubble, .greet-btn:focus-visible .bubble { border-color: var(--accent); transform: translateY(-1px); }
.greet-btn:hover .g-cta, .greet-btn:focus-visible .g-cta { opacity: 1; }
.greet-btn:focus-visible { outline: none; }

/* ───────────────────────────── Results: summary + expandable rows ───────────────────────────── */
.rank-list { display: flex; flex-direction: column; gap: 9px; }
.rank { display: grid; grid-template-columns: minmax(0,1fr) 90px 28px; align-items: center; gap: 10px; }
.rank-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.rank-fill { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.rank-num { text-align: right; font-weight: 600; font-size: 13px; color: var(--ink-2); }

.results-table .res-row { cursor: pointer; }
.results-table .res-row:focus-visible { position: relative; z-index: 1; }
.results-table .res-row .caret { display: inline-block; color: var(--muted); transition: transform .15s ease; font-size: 11px; }
.results-table .res-row.open .caret { transform: rotate(90deg); color: var(--accent); }
.results-table .res-row.open td { background: var(--accent-weak); }
.results-table .detail-row td { background: var(--surface-2); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 22px; padding: 6px 2px 8px; }
.detail-grid .d-full { grid-column: 1 / -1; }
.d-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }

.conf-slider { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.conf-slider input[type=range] { width: 130px; }
.result-counts { margin-top: 5px; color: var(--muted); font-size: 13px; }
.result-counts strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.filter-field { display: inline-flex; flex-direction: column; gap: 5px; min-width: 145px; }
.filter-field > span { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.filter-search { flex: 1; min-width: 200px; }
.filter-search input { width: 100%; }
.results-scroll { overflow-x: auto; }

/* ───────────────────────────── Live run progress ───────────────────────────── */
.prog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.prog-head .p-title { font-weight: 650; font-size: 15px; }
.prog-head .p-elapsed { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.stepper { display: flex; align-items: center; gap: 0; margin: 4px 0 18px; }
.stepper .step { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.stepper .step .s-dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  background: var(--surface-3); color: var(--muted); border: 2px solid transparent;
}
.stepper .step .s-name { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper .step .s-line { flex: 1; height: 2px; background: var(--border); margin: 0 6px; min-width: 12px; }
.stepper .step.done .s-dot { background: var(--ok-bg); color: var(--ok); }
.stepper .step.done .s-line { background: var(--ok); }
.stepper .step.active .s-dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-weak); }
.stepper .step.active .s-name { color: var(--ink); font-weight: 600; }

.pbar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 6px 0; }
.pbar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .5s ease; }
.prog-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 14px; }
.prog-stats .ps { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.prog-stats .ps .ps-val { font-family: var(--font-mono); font-size: 23px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.prog-stats .ps .ps-lbl { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ───────────────────────────── Launch: source picker ───────────────────────────── */
.field-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; }
/* Stacked field: label sits ABOVE its input (not cramped inline to the left). Applies wherever
   `.fld` is used — inline create-forms on Users/Roles included, not only `.field-row` grids. */
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* "?" explainer: a small circular toggle next to a card title, opening an inline help panel. */
.help-q { margin-left: 8px; width: 19px; height: 19px; padding: 0; vertical-align: middle;
  border-radius: 50%; border: 1px solid var(--accent); background: var(--surface-2);
  color: var(--accent); font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all .14s ease; }
.help-q:hover { background: var(--accent); color: var(--accent-ink, #fff); }
.help-panel { margin: 8px 0 12px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); font-size: 12.5px; line-height: 1.55;
  color: var(--ink-2); animation: calibFade .2s ease; }
.help-panel h4 { margin: 12px 0 4px; font-size: 12.5px; color: var(--ink); }
.help-panel h4:first-child { margin-top: 0; }
.help-panel p { margin: 0 0 6px; }
.help-panel ul { margin: 0 0 6px; padding-left: 18px; }
.help-panel li { margin: 2px 0; }
.help-panel b { color: var(--ink); }

/* Calibration source tabs switch client-side; the shown body fades in (removing [hidden]
   replays the animation) so the swap reads smooth, not abrupt. */
@keyframes calibFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.calib-body { animation: calibFade .2s ease; }
@media (prefers-reduced-motion: reduce) { .calib-body { animation: none; } }
/* Calibration control: a branded range slider paired with a compact number field. */
.calib-ctl { display: flex; align-items: center; gap: 10px; }
.calib-ctl input[type="range"] { flex: 1; min-width: 0; }
.calib-ctl input[type="number"] { width: 66px; flex: 0 0 auto; text-align: center; padding-left: 6px; padding-right: 6px; }
/* Read-only summary of the calibration in effect (recommended / from-leader modes). */
.calib-readonly { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
.calib-readonly .cr-head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.calib-readonly .cr-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 3px 0; border-bottom: 1px solid var(--hairline, rgba(127,127,127,.08)); }
.calib-readonly .cr-row b { color: var(--accent); }
@media (max-width: 560px) { .calib-readonly { grid-template-columns: 1fr; } }
.calib-note { color: var(--ink-2); line-height: 1.5; border: 1px solid var(--hairline, rgba(127,127,127,.12)); border-left: 3px solid var(--accent); border-radius: 3px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.calib-note b { color: var(--ink); }

.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg label { cursor: pointer; }
.seg label span { display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 7px; font-size: 13.5px; font-weight: 550; color: var(--muted); transition: all .14s ease; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.src-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.src-toolbar .counter { font-size: 13px; color: var(--muted); font-weight: 600; }
.src-toolbar input[type=search] { flex: 1; min-width: 180px; }
.src-groups { display: grid; gap: 18px; }
.src-group > .grp-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.src-group > .grp-head .grp-count { color: var(--accent); }
.src-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.src-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: all .14s ease;
}
.src-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.src-item input { margin: 0; }
.src-item.checked { border-color: var(--accent); background: var(--accent-weak); }
.src-item .s-label { font-size: 13.5px; font-weight: 500; line-height: 1.25; }
.src-item .s-detail { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.preset-list { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px 7px 13px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); font-size: 13px; }
.preset-chip .p-name { font-weight: 600; cursor: pointer; }
.preset-chip .p-meta { color: var(--muted); font-size: 12px; }
.preset-chip .p-del { background: transparent; border: none; color: var(--muted); padding: 2px; width: 22px; height: 22px; border-radius: 50%; justify-content: center; }
.preset-chip .p-del:hover { background: var(--err-bg); color: var(--err); filter: none; }
.preset-chip .p-del svg { width: 14px; height: 14px; }

/* ───────────────────────────── Sources management ───────────────────────────── */
.src-discover { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 12px; color: var(--muted); background: var(--surface); }
.src-discover input[type=search] { flex: 1; border: none; background: transparent; padding: 11px 0; }
.src-discover input[type=search]:focus { outline: none; box-shadow: none; }
.search-results { display: flex; flex-direction: column; gap: 6px; }
.search-results:not(:empty) { margin-top: 10px; }
/* Live skeleton placeholders while the API search is in flight (shown via HTMX's htmx-request). */
.search-loading { display: none; flex-direction: column; gap: 6px; margin-top: 10px; }
.src-search.htmx-request .search-loading { display: flex; }
.sk-row { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sk-row:nth-child(2) { animation: skFade .6s ease both .08s; } .sk-row:nth-child(3) { animation: skFade .6s ease both .16s; }
.sk-lines { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.sk-bar, .sk-btn { border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: skShimmer 1.3s linear infinite; }
.sk-bar { height: 11px; } .sk-bar.w60 { width: 58%; } .sk-bar.w40 { width: 36%; height: 9px; }
.sk-btn { width: 84px; height: 30px; border-radius: var(--radius-sm); flex-shrink: 0; }
@keyframes skShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes skFade { from { opacity: 0; } to { opacity: 1; } }
.search-hit { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.s-info { display: flex; flex-direction: column; min-width: 0; }
.s-info .s-label { font-weight: 500; font-size: 13.5px; }
.s-info .s-detail { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.src-manual { margin-top: 14px; }
.src-manual summary { cursor: pointer; font-size: 13px; color: var(--accent); width: max-content; }
.src-divider { height: 1px; background: var(--border); margin: 16px 0 14px; }
.src-manage { display: flex; flex-direction: column; gap: 6px; }
.src-manage .grp-head { margin: 8px 0 4px; }
.src-row { border: 1px solid var(--border); border-radius: var(--radius-sm); transition: opacity .15s ease, border-color .15s ease; }
.src-row.off { opacity: .5; }
.src-row.open { border-color: var(--border-strong); }
.src-manage-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.src-manage-item .s-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-right: 12px; }
.s-info-btn { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; background: transparent; border: none; padding: 9px 12px; cursor: pointer; text-align: left; color: var(--ink); }
.s-info-btn:hover { background: var(--surface-2); filter: none; }
.s-info-btn .caret { color: var(--muted); font-size: 11px; transition: transform .15s ease; flex-shrink: 0; }
.src-row.open .s-info-btn .caret { transform: rotate(90deg); color: var(--accent); }
.src-info-panel { display: none; padding: 2px 14px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.src-row.open .src-info-panel { display: block; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 20px; padding-top: 10px; }
.info-grid .d-full { grid-column: 1 / -1; }
.subj-chip { display: inline-block; background: var(--surface-3); color: var(--ink-2); font-size: 12px; padding: 2px 8px; border-radius: 3px; margin: 2px 4px 2px 0; }
.year-bars { display: flex; align-items: flex-end; gap: 14px; margin-top: 8px; }
.ybar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; }
.ybar .ybar-fill { width: 22px; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.ybar .ybar-n { font-size: 11px; color: var(--ink-2); font-weight: 600; }
.ybar .ybar-y { font-size: 11px; color: var(--muted); }
.icon-btn.sm { width: 30px; height: 30px; }

.switch-form { margin: 0; display: inline-flex; }
.switch { display: inline-block; position: relative; width: 38px; height: 22px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 99px; transition: background .15s ease, border-color .15s ease; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s ease, background .15s ease; }
.switch input:checked + .track { background: var(--accent-weak); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent); }

/* ───────────────────────────── API docs ───────────────────────────── */
.api-ep { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.api-ep .ep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.api-ep .method { font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 3px; text-transform: uppercase; letter-spacing: .03em; }
.api-ep .method.get { color: var(--ok); background: var(--ok-bg); }
.api-ep .method.post { color: var(--info); background: var(--info-bg); }
.api-ep .method.put { color: var(--warn); background: var(--warn-bg); }
.api-ep .ep-path { font-family: var(--font-mono); font-size: 13.5px; font-weight: 500; }
.api-ep .ep-desc { color: var(--muted); font-size: 13px; margin: 7px 0 0; }
.api-ep pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; font-family: var(--font-mono); font-size: 12.5px; margin: 9px 0 0; color: var(--ink-2); }
.api-grp { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .03em; font-size: 14px; font-weight: 600; margin: 22px 0 12px; color: var(--ink); }

/* ───────────────────────────── 2FA QR ───────────────────────────── */
.qr-box { display: inline-block; background: #fff; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 8px 0; line-height: 0; }
.qr-box img { display: block; width: 180px; height: 180px; image-rendering: pixelated; }

/* ───────────────────────────── Auth page ───────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; position: relative; z-index: 1; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 30px; box-shadow: var(--shadow-lg); }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.auth-card input { width: 100%; }
.field-error { background: var(--err-bg); color: var(--err); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px; text-align: center; margin-bottom: 16px; }

/* Split login: a branded navy panel (mission + Nova) beside a clean form; the starfield shows
   around the form card. Distinctly the product's, not a generic centered box. */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; position: relative; z-index: 1; }
.auth-brand { background: var(--navy); color: #e7ecf6; padding: 46px 52px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; right: -120px; top: -120px; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(133,221,255,.16), transparent 70%); pointer-events: none; }
.auth-brand .brand-name { color: #fff; font-size: 17px; }
.auth-brand .brand-sub { color: #97d7ff; }
.ab-top { display: flex; align-items: center; gap: 11px; }
.ab-top .logo { width: 36px; height: 36px; }
.ab-hero { margin: auto 0; max-width: 470px; position: relative; }
.ab-title { font-family: var(--font-head); text-transform: uppercase; font-size: 38px; line-height: 1.06; letter-spacing: .01em; color: #fff; margin: 0 0 18px; }
.ab-title span { color: #85ddff; }
.ab-lead { font-size: 15px; line-height: 1.6; color: #b8c4dc; margin: 0 0 24px; }
.ab-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 13px; }
.ab-points li { display: flex; gap: 12px; align-items: center; font-size: 14px; color: #d4dcec; }
.ab-points svg { width: 19px; height: 19px; color: #5ad0ea; flex-shrink: 0; }
.ab-foot { display: flex; align-items: center; gap: 13px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.13); font-size: 13px; line-height: 1.45; color: #aab6ce; }
.ab-foot b { color: #e7ecf6; }
.ab-foot .ab-mascot .mascot { width: 54px; height: 54px; flex-shrink: 0; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-form-side .auth-card { margin: 0; box-shadow: 0 16px 48px rgba(8,15,30,.16); }
.auth-form-side .auth-card .brand { display: none; }   /* brand lives in the left panel now */
.ac-title { font-family: var(--font-head); text-transform: uppercase; font-size: 23px; margin: 0 0 6px; letter-spacing: .02em; }
.ac-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
@media (max-width: 880px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { padding: 30px 28px; }
  .ab-hero { margin: 22px 0; max-width: none; }
  .ab-title { font-size: 27px; }
  .ab-points { display: none; }
  .auth-form-side { padding: 28px 20px 40px; }
}
@media (max-width: 880px) and (max-height: 740px) { .ab-hero { margin: 16px 0; } .ab-lead, .ab-foot { display: none; } }

/* Off-canvas nav toggle — hidden on desktop, shown by the mobile media query below. */
#burger { display: none; }
/* Tables in cards scroll horizontally instead of overflowing on narrow screens. */
.table-wrap { overflow-x: auto; }
/* Dim/blur backdrop behind the open off-canvas nav (mobile). Tap to close. */
.nav-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(6,10,20,.55);
  opacity: 0; pointer-events: none; transition: opacity .25s ease; backdrop-filter: blur(2px); }
.nav-backdrop.show { opacity: 1; pointer-events: auto; }

@media (max-width: 760px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w) - 12px); z-index: 50; transition: left .25s ease; }
  .sidebar.open { left: 0; box-shadow: 0 0 60px rgba(0,0,0,.55); }
  #burger { display: inline-flex; }
  .content { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 10px; gap: 6px; }
  .topbar > div:first-child { gap: 6px !important; min-width: 0; }
  .topbar .crumb { display: none; }
  .topbar .tb-actions { gap: 6px; flex-shrink: 0; }
  .ws-switch { min-width: 0; }
  .ws-switch select { max-width: 100px; }
  .content { padding-top: 20px; }
  .card { padding-left: 15px; padding-right: 15px; }
}

/* Cramped width (tablet + small laptops): run tables become a stack of labeled cards, and
   the dense results table drops secondary columns (still reachable by expanding a row). */
@media (max-width: 1000px) {
  .runs-table, .runs-table tbody { display: block; }
  .runs-table thead { display: none; }
  .runs-table tr { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 8px 14px; margin-bottom: 10px; }
  .runs-table tr:hover td { background: transparent; }
  .runs-table td { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: none; padding: 6px 0; text-align: right; }
  .runs-table td + td { border-top: 1px solid var(--border); }
  .runs-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
  .runs-table td:empty { display: none; }
  .runs-table td.row-action { justify-content: center; padding-top: 10px; }
  .runs-table td.row-action::before { display: none; }
  .runs-table td.row-action a { display: inline-block; padding: 7px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13px; }

  /* results table: keep the title; secondary columns remain available in the detail panel. */
  .results-table th:nth-child(n+6), .results-table .res-row td:nth-child(n+6) { display: none; }
}

@media (max-width: 768px) {
  .results-scroll { overflow: visible; }
  .results-table, .results-table tbody { display: block; width: 100%; }
  .results-table thead { display: none; }
  .results-table .res-row {
    position: relative; display: grid; width: 100%;
    grid-template-columns: 22px auto auto minmax(0, 1fr);
    gap: 7px 9px; margin-bottom: 10px; padding: 13px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .results-table .res-row td { display: block; border: 0; padding: 0; min-width: 0; }
  .results-table .res-row td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; padding-top: 3px; }
  .results-table .res-row td:nth-child(5) {
    grid-column: 2 / -1; grid-row: 1; max-width: none !important;
    font-weight: 600; line-height: 1.42; overflow-wrap: anywhere;
  }
  .results-table .res-row td:nth-child(2) { grid-column: 2; grid-row: 2; }
  .results-table .res-row td:nth-child(3) { grid-column: 3; grid-row: 2; }
  .results-table .res-row td:nth-child(4) { grid-column: 4; grid-row: 2; text-align: right; }
  .results-table .res-row td:nth-child(2)::before { content: "Вердикт"; }
  .results-table .res-row td:nth-child(3)::before { content: "Кат."; }
  .results-table .res-row td:nth-child(4)::before { content: "Знач."; }
  .results-table .res-row td:nth-child(2)::before,
  .results-table .res-row td:nth-child(3)::before,
  .results-table .res-row td:nth-child(4)::before {
    display: block; margin-bottom: 3px; color: var(--muted);
    font-size: 9px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  }
  .results-table .res-row td:nth-child(n+6) { display: none; }
  .results-table .res-row:hover { background: var(--surface-2); }
  .results-table .res-row:hover td { background: transparent; }
  .results-table .res-row.open td { background: transparent; }
  .results-table .detail-row { display: block; margin: -10px 0 10px; }
  .results-table .detail-row[hidden] { display: none; }
  .results-table .detail-row > td:first-child { display: none; }
  .results-table .detail-row > td:last-child {
    display: block; padding: 14px; border: 1px solid var(--border);
    border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--surface-2);
  }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid > div { min-width: 0; overflow-wrap: anywhere; }
  .filter-field, .filter-search { flex: 1 1 100%; min-width: 0; }
  .conf-slider { width: 100%; justify-content: space-between; flex-wrap: wrap; }
}

/* ───────────────────────────── Нова — assistant ─────────────────────────── */
.nova-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.nova-launch { position: relative; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 50%; width: 48px; height: 48px; padding: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 3px 12px rgba(8,15,30,.16); opacity: .9; transition: transform .16s ease, border-color .16s ease, opacity .16s ease; }
.nova-launch:hover { transform: translateY(-2px); border-color: var(--accent); opacity: 1; }
.nova-launch .mascot { width: 36px; height: 36px; }
.nova-thought { position: absolute; right: 70px; bottom: 12px; max-width: 200px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 7px 11px; font-size: 12.5px; color: var(--ink-2); white-space: normal; box-shadow: var(--shadow); opacity: 0; transform: translateX(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.nova-thought.show { opacity: 1; transform: translateX(0); }
.nova-thought::after { content: ""; position: absolute; right: -5px; bottom: 14px; width: 9px; height: 9px; background: var(--surface); border-right: 1px solid var(--border-strong); border-top: 1px solid var(--border-strong); transform: rotate(45deg); }

.nova-panel { width: 364px; max-width: calc(100vw - 28px); height: 468px; max-height: calc(100vh - 130px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 10px 36px rgba(8,15,30,.26); }
.nova-panel[hidden] { display: none; }  /* the class's display:flex would otherwise override the hidden attribute */
/* Dashboard: the chat lives in the content flow, in the greeting's place — not floating. Wide
   single column (uses the horizontal space), readable bubbles, Max-style quick-reply chips. */
.nova-inline-chat { position: static; width: 100%; max-width: none; height: 460px; max-height: none; box-shadow: var(--shadow); }
.nova-inline-chat .ai-bubble { max-width: 680px; }

/* Quick-reply chips (Max-style «быстрые ответы») — a horizontal bar pinned above the input so
   they stay reachable as the conversation grows (no scrolling back up). */
.nova-suggest { display: flex; gap: 8px; padding: 10px 12px 0; overflow-x: auto; scrollbar-width: thin; }
.nova-suggest::-webkit-scrollbar { height: 5px; }
.nova-suggest::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
.nq-chip { flex-shrink: 0; white-space: nowrap; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; transition: border-color .14s ease, background .14s ease; }
.nq-chip:hover { border-color: var(--accent); background: var(--accent-weak); }
.nova-head { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.nova-head .nova-mini .mascot { width: 34px; height: 34px; }
.nova-head .nova-id { display: flex; flex-direction: column; line-height: 1.15; flex: 1; }
.nova-head .nova-id b { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .04em; font-size: 14px; }
.nova-head .nova-id span { font-size: 11.5px; color: var(--muted); }
.nova-x { background: transparent; border: none; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; }
.nova-x:hover { background: var(--surface-3); color: var(--ink); }
.nova-x svg { width: 16px; height: 16px; flex-shrink: 0; }

.nova-thread { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble { max-width: 84%; padding: 9px 12px; border-radius: var(--radius-lg); font-size: 13.5px; line-height: 1.46; }
.ai-msg.nova .ai-bubble { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); border-top-left-radius: var(--radius-sm); }
.ai-msg.user .ai-bubble { background: var(--accent-weak); color: var(--accent); border: 1px solid var(--accent); border-top-right-radius: var(--radius-sm); }
.ai-suggest { display: inline-block; margin-top: 7px; color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: none; }
.ai-suggest:hover { text-decoration: underline; }
/* Nova "thinking" indicator */
.nova-dots { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.nova-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); opacity: .35; animation: novaDot 1s infinite ease-in-out; }
.nova-dots i:nth-child(2) { animation-delay: .15s; }
.nova-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes novaDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: .9; transform: translateY(-3px); } }
/* Typewriter caret while Nova "types" the answer */
.ai-msg.nova.typing .ai-text::after { content: "\258F"; margin-left: 1px; color: var(--accent); animation: novaCaret .8s steps(1) infinite; }
@keyframes novaCaret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .nova-dots i, .ai-msg.nova.typing .ai-text::after { animation: none; } }
/* Nova session divider (dated separator between chat sessions) */
.nova-divider { display: flex; align-items: center; gap: 10px; margin: 8px 2px 2px; color: var(--muted); font-size: 11px; }
.nova-divider::before, .nova-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.nova-divider span { white-space: nowrap; letter-spacing: .03em; text-transform: uppercase; }
/* Nova in-chat per-user mode toggle — the shared .seg segmented control, compact for the header
   (native radios + CSS :checked → smooth fade on persistent DOM; the POST doesn't swap it) */
.nova-head .nova-id { min-width: 0; }
.seg.seg-sm { flex-wrap: nowrap; border-radius: 999px; padding: 2px; flex-shrink: 0; }
.seg.seg-sm:empty { display: none; }  /* lazy placeholder: no empty pill before history loads */
.seg.seg-sm label span { padding: 4px 10px; font-size: 11.5px; font-weight: 550; border-radius: 999px; }
.nova-clear { background: transparent; border: none; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nova-clear:hover { background: var(--surface-3); color: var(--ink); }
.nova-clear svg { width: 15px; height: 15px; flex-shrink: 0; }
.nova-try-smart { display: inline-block; margin-top: 8px; }

.nova-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.nova-form input { flex: 1; min-width: 0; }
.nova-form .btn { padding: 0 12px; }
.nova-form .btn svg { width: 18px; height: 18px; }

/* Emotion expressions — subtle tweaks on the lens eye / body / antenna spark. */
.mascot.happy .m-eye { transform: translateY(-1px) scale(1.08); }
.mascot.curious .m-body { transform: rotate(-5deg); transition: transform .25s ease; }
.mascot.thinking .m-spark { animation: mBlink 1s infinite; }
.mascot.thinking .m-eye { transform: translateX(2px); }
.mascot.sad .m-eye { transform: translateY(3px) scale(.86); }
.mascot.sad .m-spark { opacity: .5; }

@media (max-width: 540px) {
  .nova-wrap { right: 12px; bottom: 12px; }
  .nova-panel { width: calc(100vw - 24px); height: min(70vh, 460px); }
}
@media (prefers-reduced-motion: reduce) {
  .nova-launch, .nova-thought, .mascot.curious .m-body { transition: none; }
}

/* ─────────────────────── Glass & depth — "panels in open space" ───────────────────────
   Frosted, translucent matte panels floating over a cosmic backdrop (CSS nebulae + the bg.js
   starfield). Surfaces are semi-transparent with a backdrop blur so the space drifts behind them;
   layered shadows + a top highlight give each panel real depth. Form controls stay opaque (set
   earlier in the file) for legibility. This section is intentionally last so it overrides the
   flat "scientific-terminal" surfaces above without touching them. */
:root {
  --glass: rgba(255, 255, 255, 0.60);
  --glass-chrome: rgba(247, 250, 253, 0.68);
  --glass-bd: rgba(255, 255, 255, 0.72);
  --glass-hi: rgba(255, 255, 255, 0.85);
  --glass-blur: saturate(135%) blur(16px);
  --glass-shadow: 0 14px 36px -12px rgba(28, 48, 92, 0.20), 0 3px 10px rgba(28, 48, 92, 0.07);
  --glass-r: 16px;
  /* Bevel — top/left catch light, bottom/right recede, so a panel reads as carved into a slab
     rather than a flat outlined rectangle. The outer border is a near-invisible hairline that
     dissolves into the backdrop instead of drawing a crisp generic-card frame. */
  --bevel-hi: rgba(255, 255, 255, 0.9);
  --bevel-lo: rgba(40, 60, 100, 0.12);
  --hairline: rgba(40, 60, 100, 0.06);
}
[data-theme="dark"] {
  --glass: rgba(19, 27, 48, 0.52);
  --glass-chrome: rgba(12, 18, 34, 0.62);
  --glass-bd: rgba(135, 185, 230, 0.16);
  --glass-hi: rgba(180, 222, 255, 0.10);
  --glass-blur: saturate(140%) blur(18px);
  --glass-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.62), 0 3px 12px rgba(0, 0, 0, 0.32);
  --bevel-hi: rgba(185, 225, 255, 0.13);
  --bevel-lo: rgba(0, 0, 0, 0.34);
  --hairline: rgba(150, 195, 240, 0.05);
}

/* Cosmic backdrop: soft nebula glows layered under the (fixed) starfield canvas. */
body {
  background:
    radial-gradient(1150px 780px at 8% -12%, rgba(150, 200, 236, 0.50), transparent 60%),
    radial-gradient(960px 700px at 102% 2%, rgba(13, 125, 163, 0.12), transparent 56%),
    radial-gradient(900px 820px at 50% 120%, rgba(120, 160, 220, 0.16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
[data-theme="dark"] body {
  background:
    radial-gradient(1200px 820px at 10% -12%, rgba(34, 66, 132, 0.42), transparent 60%),
    radial-gradient(1040px 720px at 102% 0%, rgba(13, 125, 163, 0.22), transparent 55%),
    radial-gradient(980px 900px at 52% 122%, rgba(58, 34, 120, 0.30), transparent 60%),
    #070b16;
  background-attachment: fixed;
}

/* Carved glass panels — no crisp rectangle outline. Edges are defined by a light/shadow bevel
   (carved-into-stone) plus a dissolving hairline, so they don't read as generic AI cards. */
.card,
.auth-card,
.nova-panel,
.nova-inline-chat,
.greet .bubble {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--hairline);
  border-radius: var(--glass-r);
  box-shadow:
    var(--glass-shadow),
    inset 1px 1px 0 var(--bevel-hi),
    inset -1px -1px 0 var(--bevel-lo);
}
.greet .bubble::before { background: var(--glass); border-color: var(--hairline); }

/* Glass chrome — sidebar + topbar let the starfield drift behind them (cockpit feel). */
.sidebar {
  background: var(--glass-chrome);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-bd);
}
.topbar {
  background: var(--glass-chrome);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-bd);
}

/* Login: navy brand panel gains depth; the form side floats as glass over the haze. */
.auth-brand { box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06), 24px 0 60px -30px rgba(0, 0, 0, 0.5); }
.auth-form-side { background: transparent; }

/* A touch more lift on hover — the panel rises out of the depth. */
.card.hover { transition: border-color var(--speed) ease, box-shadow var(--speed) ease, transform var(--speed) ease; }
.card.hover:hover { box-shadow: var(--glass-shadow), inset 1px 1px 0 var(--bevel-hi), inset -1px -1px 0 var(--bevel-lo), 0 24px 54px -16px rgba(13, 125, 163, 0.30); transform: translateY(-2px); }

/* The expanded stat detail must read as its own floating slab, never abutting the stat row above
   it (two beveled panels sharing a hard seam looks muddy). Clear gap when open; clipped away while
   the panel is collapsed so it adds no space at rest. */
#stat-detail .stat-detail { margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  .card.hover:hover { transform: none; }
}

/* ───────────────────────────── Animated nav icons ─────────────────────────────
   Each sidebar icon has an idle state (a complete, still icon) and a hover "story" that plays while
   the pointer is on the item. One unified pattern — to add an animated icon:
     1. give the moving parts a class + an idle state in the IDLE block,
     2. add a `.nav a:hover .ic-NAME .part` trigger in the single HOVER block (uses --nav-anim),
     3. define its @keyframes in the KEYFRAMES block.
   The animation is applied ONLY on hover, so the idle state (also what reduced-motion users get) is
   always the full icon — never a frozen keyframe. All share one duration and one reduced-motion
   guard, so cadence and accessibility stay consistent across icons. */
:root { --nav-anim: 4.5s; --icon-fill: #f2f6fb; }     /* --icon-fill ≈ sidebar backdrop, for occluding stacked icon parts */
[data-theme="dark"] { --icon-fill: #0c1322; }

/* — idle states (full icon at rest) — */
.ic-journal .jr-ink   { stroke-dasharray: 9; stroke-dashoffset: 0; }   /* line drawn */
.ic-journal .jr-pen   { opacity: 0; }                                  /* pen away */
.ic-users   .us-second { opacity: 1; transform: translateX(0); }        /* both figures present */
.ic-users   .us-smile  { opacity: 0; }                                  /* no smile */
.ic-sources .db-layer  { transform-box: fill-box; transform-origin: center; }  /* all layers stacked */

/* — hover stories (one guard, one cadence for every icon) — */
@media (prefers-reduced-motion: no-preference) {
  .nav a:hover .ic-journal .jr-ink   { animation: jrWrite var(--nav-anim) ease-in-out infinite; }
  .nav a:hover .ic-journal .jr-pen   { animation: jrPen   var(--nav-anim) ease-in-out infinite; }
  .nav a:hover .ic-users   .us-second { animation: usJoin  var(--nav-anim) ease-in-out infinite; }
  .nav a:hover .ic-users   .us-smile  { animation: usSmile var(--nav-anim) ease-in-out infinite; }
  .nav a:hover .ic-sources .db-l1    { animation: dbL1    var(--nav-anim) ease-in-out infinite; }
  .nav a:hover .ic-sources .db-l2    { animation: dbL2    var(--nav-anim) ease-in-out infinite; }
  .nav a:hover .ic-sources .db-l3    { animation: dbL3    var(--nav-anim) ease-in-out infinite; }
}

/* — keyframes — */
/* Журнал: a pen appears at the line, glides across it (writing), and lifts off; the line stays. */
@keyframes jrPen {
  0%, 6%   { opacity: 0; transform: translateX(-1.5px); }
  11%      { opacity: 1; transform: translateX(-1px); }   /* appear at the start of the line */
  14%      { opacity: 1; transform: translateX(0); }
  44%      { opacity: 1; transform: translateX(8px); }    /* glide right, writing as it goes */
  52%      { opacity: 0; transform: translateX(8px); }    /* lift off */
  100%     { opacity: 0; transform: translateX(8px); }
}
@keyframes jrWrite {
  0%, 11%   { stroke-dashoffset: 9; }    /* erased, ready for the pen */
  44%       { stroke-dashoffset: 0; }    /* drawn left→right under the moving pen */
  100%      { stroke-dashoffset: 0; }    /* stays written for the rest of the loop */
}
/* Пользователи: a second figure drifts in, then both smile (glad to meet) and stand together. */
@keyframes usJoin {
  0%, 14%   { opacity: 0; transform: translateX(7px); }     /* off to the right, alone */
  30%       { opacity: 1; transform: translateX(-0.6px); }   /* glides in, slight overshoot */
  36%       { transform: translateX(0); }
  85%       { opacity: 1; transform: translateX(0); }        /* stand together */
  96%, 100% { opacity: 0; transform: translateX(7px); }      /* drift back out, reset to one */
}
@keyframes usSmile {
  0%, 38%   { opacity: 0; }      /* no smile until the second has arrived */
  47%       { opacity: 1; }      /* both grin — glad to meet */
  85%       { opacity: 1; }
  93%, 100% { opacity: 0; }
}
/* Источники: a database builds layer by layer; after the third lands, the stack scatters + rebuilds. */
@keyframes dbL1 {  /* top layer — lands first */
  0%, 6%   { opacity: 0; transform: translateY(-5px); }
  16%      { opacity: 1; transform: translateY(0); }
  62%      { opacity: 1; transform: translate(0, 0) rotate(0); }
  77%      { opacity: 0; transform: translate(-7px, -8px) rotate(-24deg); }   /* scatter */
  100%     { opacity: 0; transform: translate(-7px, -8px) rotate(-24deg); }
}
@keyframes dbL2 {  /* middle layer — lands second */
  0%, 22%  { opacity: 0; transform: translateY(-5px); }
  32%      { opacity: 1; transform: translateY(0); }
  62%      { opacity: 1; transform: translate(0, 0) rotate(0); }
  78%      { opacity: 0; transform: translate(9px, -3px) rotate(22deg); }
  100%     { opacity: 0; transform: translate(9px, -3px) rotate(22deg); }
}
@keyframes dbL3 {  /* bottom layer — lands third, then the stack falls apart */
  0%, 38%  { opacity: 0; transform: translateY(-5px); }
  48%      { opacity: 1; transform: translateY(0); }
  62%      { opacity: 1; transform: translate(0, 0) rotate(0); }
  79%      { opacity: 0; transform: translate(-2px, 11px) rotate(16deg); }
  100%     { opacity: 0; transform: translate(-2px, 11px) rotate(16deg); }
}
