/* Jarvis dashboard, «Сетка» (v4). Rules: jarvis/web/DESIGN.md. White field, black type, one blue signal, 2px ink rules, radius 2px, no shadows, no motion. */
/* tokens:start (mirrors the design system's tokens.json; keep names in sync) */
:root {
  --ground: #fafaf8; --surface: #ffffff; --surface-2: #f0f0ec;
  --ink: #0a0a0a; --ink-2: #3a3a37; --muted: #66665f;
  --line: #d9d9d3; --line-control: #85857e;
  --signal: #002fa7; --on-signal: #ffffff; --signal-soft: #e8ecf9;
  --ok: #176b33; --err: #b3201a; --warn: #7d5900; --off: #85857e;
  --font-sans: "Onest", -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;
  --radius: 2px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c0c0c; --surface: #141414; --surface-2: #1d1d1c;
    --ink: #f4f4f1; --ink-2: #c8c8c3; --muted: #96968f;
    --line: #2f2f2d; --line-control: #767670;
    --signal: #8aa2ff; --on-signal: #0a0a0a; --signal-soft: #171e3d;
    --ok: #6fcf8a; --err: #ff8073; --warn: #e3b64f; --off: #767670;
  }
}
/* tokens:end */

* { box-sizing: border-box; }
html { background: var(--ground); }
body { margin: 0; color: var(--ink); font: 15px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased; }
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-weight: 600; font-size: 44px; line-height: 1.05; letter-spacing: -0.025em; margin: 0; }
h2 { font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); margin: 0; }
p { margin: 0 0 var(--space-3); }
code, .mono { font-family: var(--font-mono); font-size: 13px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: var(--radius); }
pre { background: var(--surface-2); border: 1px solid var(--line); padding: var(--space-3); overflow-x: auto; margin: var(--space-2) 0; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err { color: var(--err); } .off { color: var(--off); } .busy { color: var(--signal); }
i.ph { font-size: 1.15em; vertical-align: -0.15em; }
.note { border: 1px solid var(--line); background: var(--surface); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-6); border-radius: var(--radius); }
.tag { display: inline-block; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); border: 1px solid var(--line-control); padding: 0 6px; border-radius: var(--radius); vertical-align: middle; }
[hidden] { display: none !important; }

/* shell: sidebar + main */
.shell { --side: 248px; display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: var(--space-8) var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-6); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.wordmark { font-weight: 700; font-size: 28px; letter-spacing: -0.03em; color: var(--ink); line-height: 1; padding: 0 var(--space-3); }
.wordmark:hover { text-decoration: none; }
.wordmark.big { font-size: 64px; line-height: 60px; padding: 0; margin-bottom: var(--space-4); }
.side-state { display: flex; gap: var(--space-2); align-items: center; color: var(--ink-2); font-family: var(--font-mono); font-size: 12px; padding: 0 var(--space-3); }
.nav { display: flex; flex-direction: column; gap: var(--space-6); }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0 var(--space-3) var(--space-1); }
.nav a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--ink-2); font-weight: 500; }
.nav a i { color: var(--muted); font-size: 18px; }
.nav a:hover { text-decoration: none; color: var(--ink); background: var(--surface-2); }
.nav a.current, .nav a.current:hover { background: var(--ink); color: var(--ground); }
.nav a.current i { color: var(--ground); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); font-size: 13px; padding: var(--space-4) var(--space-3) 0; border-top: 1px solid var(--line); }
.kv-mini { display: flex; justify-content: space-between; gap: var(--space-2); color: var(--muted); }
.kv-mini b { color: var(--ink-2); font-weight: 500; text-align: right; }
.side-foot button.link { color: var(--muted); padding: 6px 0; text-align: left; }
.side-foot button.link:hover { color: var(--ink); text-decoration: none; }
.main { padding: var(--space-12) 56px 80px; max-width: 1240px; width: 100%; min-width: 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); padding: var(--space-4); gap: var(--space-3); }
  .wordmark, .side-state { padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: var(--space-1); }
  .nav-group { display: contents; }
  .nav-label { display: none; }
  .nav a { padding: 6px var(--space-2); }
  .nav a span { font-size: 13px; }
  .side-foot { display: none; }
  .main { padding: var(--space-6) var(--space-4) var(--space-12); }
  h1 { font-size: 32px; }
}

/* page head */
.page-head { margin-bottom: var(--space-12); }
.page-head.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.lede { color: var(--ink-2); margin: var(--space-4) 0 0; font-size: 17px; line-height: 26px; max-width: 60ch; }

/* instruments */
.instruments { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); margin-bottom: var(--space-12); }
.instruments > div { padding: var(--space-4) var(--space-4) var(--space-4) 0; margin-right: var(--space-4); border-right: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: var(--space-3); row-gap: var(--space-2); align-items: start; }
.instruments > div:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.instruments i { grid-column: 2; grid-row: 1 / span 2; font-size: 20px; color: var(--muted); }
.instruments .k { grid-column: 1; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.instruments .v { grid-column: 1; font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.instruments .v.mono { font-size: 16px; font-weight: 500; letter-spacing: 0; }
.instruments.tight { margin-bottom: var(--space-3); }
.under { margin-bottom: var(--space-12); }
@media (max-width: 900px) { .instruments { grid-template-columns: 1fr 1fr; } .instruments > div:nth-child(2) { border-right: none; margin-right: 0; } .instruments > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }

/* panels: a 2px ink rule and whitespace, no boxes */
.panel { border-top: 2px solid var(--ink); padding-top: var(--space-4); margin-bottom: var(--space-12); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-4); }
.panel-head a { font-size: 13px; }
.panel > h2:first-child { margin-bottom: var(--space-4); }
.panel-actions { margin: var(--space-4) 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-12); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 var(--space-8); }
.head-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-4); }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 22px; }
table.wide { margin-bottom: var(--space-12); }
.panel table.wide { margin-bottom: 0; }
th, td { text-align: left; padding: 10px var(--space-4) 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child > td, tbody tr:last-child > th { border-bottom: none; }
thead th { font-size: 11px; line-height: 16px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--ink); padding-top: 0; vertical-align: bottom; }
table.wide > thead th { border-top: 2px solid var(--ink); padding-top: 10px; }
.panel table.wide > thead th { border-top: none; padding-top: 0; }
tbody th { font-weight: 600; }
table.kv th { width: 160px; color: var(--muted); font-weight: 500; }
tr.dim td, tr.dim th { color: var(--muted); }
td.st { width: 36px; font-size: 18px; }
@media (max-width: 900px) { table.wide { display: block; overflow-x: auto; } }
td.actions form { margin: 0 6px 6px 0; }
td.actions button { padding: 5px 10px; font-size: 13px; }
button.compact { padding: 5px 10px; font-size: 13px; }
button.link, td.actions button.link { border: none; background: none; padding: 0; color: var(--signal); font-weight: 400; font-size: 13px; }
button.link:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
button.link.danger { color: var(--err); }
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.state.off { color: var(--muted); } .state.off i { color: var(--off); }

/* controls */
button, .button, input, select, textarea { font: inherit; font-size: 14px; line-height: 20px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-control); border-radius: var(--radius); padding: 9px var(--space-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }
button, .button { cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; border-color: var(--ink); }
button:hover, .button:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .button.primary, button.primary:hover, .button.primary:hover { background: var(--signal); color: var(--on-signal); border-color: var(--signal); }
button.danger { color: var(--err); border-color: var(--err); }
button:disabled { color: var(--muted); border-color: var(--line); background: var(--surface-2); cursor: default; }
input, select, textarea { width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
::placeholder { color: var(--muted); opacity: 1; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: var(--space-1); display: block; font-weight: 400; color: var(--ink); }
form.inline, .inline { display: inline-block; margin: 0 var(--space-3) var(--space-2) 0; vertical-align: middle; }
form.inline label { display: inline-flex; gap: var(--space-2); align-items: center; }
form.inline select, form.inline input { width: auto; margin-top: 0; }
.stack > * { margin-bottom: var(--space-3); } .stack > *:last-child { margin-bottom: 0; }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 220px; }
.form label { margin-bottom: var(--space-3); }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); } ul.plain li:last-child { border-bottom: none; }
details > summary { cursor: pointer; color: var(--signal); font-weight: 600; font-size: 14px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: var(--space-2); }

/* tabs (memory) */
.tabs { display: flex; gap: var(--space-6); margin-bottom: var(--space-6); border-bottom: 1px solid var(--line); }
.tabs a { padding: var(--space-2) 0 10px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; font-family: var(--font-mono); font-size: 13px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.current { color: var(--ink); border-bottom-color: var(--ink); }
.grid-journal { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-8); }
.days a { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); } .days a.current { font-weight: 500; color: var(--signal); }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4) var(--space-6); overflow-wrap: anywhere; line-height: 1.65; max-width: 80ch; }
.panel .prose { background: none; border: none; padding: 0; }
.prose p { margin: 0 0 var(--space-3); } .prose p:last-child { margin-bottom: 0; }
.prose blockquote { margin: var(--space-2) 0; padding-left: var(--space-4); color: var(--ink-2); border-left: 1px solid var(--ink); }
.prose b { font-weight: 600; }
@media (max-width: 900px) { .grid-journal { grid-template-columns: 1fr; gap: var(--space-4); } }

/* chat */
.chat-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.chat-head h1 { font-size: 32px; }
.chat-head p { margin: var(--space-2) 0 0; }
.chat-controls { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.chat-controls form { margin: 0; }
.chat-controls label { display: flex; flex-direction: column; gap: var(--space-1); }
.chat-controls select { width: auto; margin-top: 0; }
.log { background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--ink); padding: var(--space-4) var(--space-6); min-height: 46vh; max-height: 60vh; overflow-y: auto; }
.msg { padding: var(--space-3) var(--space-4); margin: var(--space-3) 0; max-width: 78%; overflow-wrap: anywhere; border-radius: var(--radius); line-height: 1.6; }
.msg.user { margin-left: auto; background: var(--signal-soft); }
.msg.assistant { margin-right: auto; background: var(--surface-2); }
.msg.assistant code, .msg.assistant pre { background: var(--surface); }
.msg.error { border: 1px solid var(--err); }
.msg .label { display: block; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--space-1); }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin-bottom: 0; }
.msg .foot { display: block; margin-top: var(--space-2); color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; }
.status { color: var(--signal); font-family: var(--font-mono); font-size: 13px; padding: var(--space-2) var(--space-3); margin: var(--space-3) 0 0; border: 1px solid var(--line); border-radius: var(--radius); white-space: pre-wrap; }
.composer { margin-top: var(--space-4); }
.composer textarea { width: 100%; margin-bottom: var(--space-2); font-size: 15px; }
.composer-row { align-items: flex-start; }
.composer-row .push { margin-left: auto; }
.composer-row details form { margin-top: var(--space-2); min-width: 320px; }

/* login */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: var(--space-4); }
.login { width: 100%; max-width: 480px; border-top: 2px solid var(--ink); padding: var(--space-8) 0; }
.tagline { font-size: 17px; line-height: 26px; color: var(--ink-2); margin: 0 0 var(--space-6); }
.flash { border: 1px solid currentColor; padding: var(--space-3); border-radius: var(--radius); display: flex; gap: var(--space-2); align-items: center; }
.login form { margin: var(--space-2) 0 var(--space-3); }

/* live layer */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: var(--space-2); z-index: 50; max-width: 380px; }
.toast { background: var(--surface); color: var(--ink); border: 1px solid var(--ink); border-top-width: 2px; border-radius: var(--radius); padding: var(--space-3) var(--space-4); font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.toast.err { border-top-color: var(--err); } .toast.warn { border-top-color: var(--warn); }
@media (max-width: 900px) { .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; } }
pre { position: relative; padding-top: 30px; }
pre .copy { position: absolute; top: 6px; right: 6px; font-size: 11.5px; line-height: 16px; font-weight: 500; padding: 2px 8px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-control); }
pre code.hljs { background: transparent; padding: 0; font-family: var(--font-mono); font-size: 13px; }

/* intel media library */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.filters select { width: auto; min-width: 150px; }
.filters button, .filters .button { width: auto; }
.filters .check { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--ink-2); }
.filters .check input { width: auto; margin: 0; accent-color: var(--signal); }
.filters .push { margin-left: auto; }
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; }
.card:hover { border-color: var(--ink); text-decoration: none; }
.card .shot { display: block; width: 100%; height: 150px; object-fit: cover; background: var(--surface-2); }
.card .shot.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.card .shot.note { padding: var(--space-3); font-size: 12.5px; line-height: 1.45; color: var(--ink-2); background: var(--surface-2); overflow: hidden; }
.card .shot.note .quote { float: left; font-weight: 700; font-size: 34px; line-height: 0.8; margin: 4px 6px 0 0; color: var(--ink); }
.card-body { padding: var(--space-2) var(--space-3) var(--space-3); }
.card-title { margin-bottom: var(--space-1); font-size: 13.5px; font-weight: 600; }
.card .excerpt { margin: 5px 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-2); overflow-wrap: anywhere; }
.statline span, .media-count { display: inline-flex; align-items: center; gap: var(--space-1); }
.statline { display: flex; flex-wrap: wrap; gap: var(--space-2); font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
@media (max-width: 1200px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tag.hit { color: var(--signal); border-color: var(--signal); }
.pager { display: flex; gap: var(--space-4); align-items: center; margin-bottom: var(--space-8); }
.media { margin: 0 0 var(--space-4); }
.media video, .media img { display: block; width: 100%; max-width: 520px; background: #000; border: 1px solid var(--line); border-radius: var(--radius); }
.media figcaption { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.chips a { font-size: 13px; }
.tg-login { margin: var(--space-3) 0 var(--space-2); display: flex; justify-content: center; }
.login details { margin-top: var(--space-4); }
