/* Warden console. One family (Archivo, variable width) for everything; JetBrains Mono only for identifiers. */
:root {
  color-scheme: light;
  --paper: #eef1ef;
  --paper-2: #e3e8e5;
  --paper-3: #d8dfdb;
  --ink: #13201e;
  --ink-2: #3f4b49;
  --ink-3: #6c7876;
  --rule: #c7d0cc;
  --rule-strong: #9fada8;
  --chrome: #1b2b29;
  --chrome-ink: #cfdad7;
  --chrome-ink-2: #8aa09b;
  --chrome-active: #223835;
  --accent: #2b6f69;
  --accent-ink: #ffffff;
  --accent-soft: #d5e6e3;
  --focus: #2b6f69;
  --sev-critical: #d03b3b;
  --sev-high: #ec835a;
  --sev-medium: #fab219;
  --sev-low: #7d93a8;
  --sev-info: #8a9390;
  --ok: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail-w: 212px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121b1a; --paper-2: #182423; --paper-3: #1f2d2b;
    --ink: #e4eae8; --ink-2: #b1bcb9; --ink-3: #7f8b88;
    --rule: #2b3836; --rule-strong: #43534f;
    --chrome: #0c1413; --chrome-ink: #c4d0cc; --chrome-ink-2: #6f827e; --chrome-active: #16221f;
    --accent: #5fb3aa; --accent-ink: #0c1413; --accent-soft: #1d3a37; --focus: #5fb3aa;
    --sev-low: #8ea6bd; --sev-info: #8f9995;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121b1a; --paper-2: #182423; --paper-3: #1f2d2b;
  --ink: #e4eae8; --ink-2: #b1bcb9; --ink-3: #7f8b88;
  --rule: #2b3836; --rule-strong: #43534f;
  --chrome: #0c1413; --chrome-ink: #c4d0cc; --chrome-ink-2: #6f827e; --chrome-active: #16221f;
  --accent: #5fb3aa; --accent-ink: #0c1413; --accent-soft: #1d3a37; --focus: #5fb3aa;
  --sev-low: #8ea6bd; --sev-info: #8f9995;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.45; font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
button, input, select { font: inherit; color: inherit; }
code, .id { font-family: var(--mono); font-size: 0.86em; }
.id { overflow-wrap: anywhere; }
.tbl .id { white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--chrome); color: var(--chrome-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 0 16px; }
.mark { display: flex; align-items: center; gap: 10px; color: var(--chrome-ink); text-decoration: none; padding: 0 20px 18px; }
.mark svg { color: var(--accent); }
.mark-name { font-weight: 600; font-variation-settings: "wdth" 118; letter-spacing: 0.01em; font-size: 1.05rem; }
.nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav a { display: block; padding: 8px 20px; color: var(--chrome-ink-2); text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { color: var(--chrome-ink); }
.nav a[aria-current="page"] { color: var(--chrome-ink); background: var(--chrome-active); border-left-color: var(--accent); }
.nav a:focus-visible { outline-offset: -2px; }
.who { padding: 14px 20px 0; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.86rem; color: var(--chrome-ink-2); }
.who strong { color: var(--chrome-ink); font-weight: 500; display: block; word-break: break-all; }
.who button { margin-top: 8px; }
.main { padding: 28px 36px 60px; min-width: 0; }
.page-head { border-bottom: 1px solid var(--rule-strong); padding-bottom: 12px; margin-bottom: 22px; }
.page-title { margin: 0 0 6px; font-size: 1.9rem; line-height: 1.1; font-weight: 600; font-variation-settings: "wdth" 112; letter-spacing: -0.01em; }
.watch { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.92rem; min-height: 1.4em; }
.watch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; transition: background 300ms; }
.watch.live .watch-dot { background: var(--accent); }
.watch.stale .watch-dot { background: var(--warn); }
.watch.err .watch-dot { background: var(--bad); }
.watch .sep { color: var(--rule-strong); }

/* Buttons and controls */
.btn { background: transparent; border: 1px solid var(--rule-strong); border-radius: 2px; padding: 6px 12px; cursor: pointer; color: var(--ink); }
.btn:hover { border-color: var(--ink-3); background: var(--paper-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 3px 9px; font-size: 0.86rem; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { border-color: transparent; color: var(--accent); }
.rail .btn { border-color: rgba(255,255,255,0.18); color: var(--chrome-ink); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin-bottom: 18px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; color: var(--ink-2); }
.filters input, .filters select { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 2px; padding: 6px 8px; min-width: 150px; }
.filters input[type="search"] { min-width: 220px; }
.filters .check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 7px; }
.filters .check input { min-width: 0; }
.count { color: var(--ink-3); font-size: 0.9rem; margin: 0 0 10px; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl th { font-weight: 500; color: var(--ink-2); font-size: 0.86rem; border-bottom-color: var(--rule-strong); white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl time { white-space: nowrap; }
.tbl tr.row[tabindex]:hover, .tbl tr.row[tabindex]:focus-within { background: var(--paper-2); }
.tbl tr.row[tabindex] { cursor: pointer; }
.tbl .muted { color: var(--ink-3); }
.tbl .wrap { max-width: 44ch; }
.tbl-wrap { overflow-x: auto; }
.more { margin-top: 14px; display: flex; gap: 12px; align-items: center; }
.empty { padding: 28px 0; color: var(--ink-2); max-width: 60ch; }
.empty strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.error { border-left: 3px solid var(--bad); padding: 8px 12px; background: var(--paper-2); max-width: 70ch; }

/* Severity: glyph + word + colour, never colour alone */
.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; white-space: nowrap; }
.sev::before { content: ""; width: 10px; height: 10px; flex: none; background: currentColor; }
.sev.critical { color: var(--sev-critical); } .sev.critical::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sev.high { color: var(--sev-high); } .sev.high::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.sev.medium { color: var(--sev-medium); } .sev.medium::before { border-radius: 50%; }
.sev.low { color: var(--sev-low); } .sev.low::before { border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.sev.info { color: var(--sev-info); } .sev.info::before { height: 2px; }
.sev span { color: var(--ink); }
:root[data-theme="dark"] .sev.medium, :root:not([data-theme="light"]) .sev.medium { color: var(--sev-medium); }

/* Status words */
.tag { display: inline-block; font-size: 0.8rem; padding: 1px 7px; border: 1px solid var(--rule-strong); border-radius: 2px; color: var(--ink-2); white-space: nowrap; }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.bad { border-color: var(--bad); color: var(--bad); }
.tag.warn { border-color: #b07c00; color: #b07c00; }
:root[data-theme="dark"] .tag.warn, :root:not([data-theme="light"]) .tag.warn { border-color: var(--warn); color: var(--warn); }
.tag.accent { border-color: var(--accent); color: var(--accent); }

/* Overview */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 28px; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); }
.tile { padding: 16px 18px 14px 0; border-right: 1px solid var(--rule); margin-right: 18px; }
.tile:last-child { border-right: 0; }
.tile .label { color: var(--ink-2); font-size: 0.86rem; margin-bottom: 6px; }
.tile .value { font-size: 2rem; line-height: 1; font-weight: 600; font-variation-settings: "wdth" 108; }
.tile .sub { color: var(--ink-3); font-size: 0.84rem; margin-top: 6px; }
.tile .value.small { font-size: 1.15rem; font-weight: 500; line-height: 1.25; }
.two { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; margin-bottom: 28px; }
.fig { margin: 0; }
.fig figcaption { font-weight: 500; margin-bottom: 10px; }
.fig .note { color: var(--ink-3); font-size: 0.84rem; margin-top: 8px; }
.sevbar { width: 100%; height: 22px; display: block; }
.sevkey { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; }
.sevkey li { display: flex; gap: 6px; align-items: baseline; }
.sevkey .n { font-variant-numeric: tabular-nums; font-weight: 500; }
.spark { width: 100%; height: 72px; display: block; }
.spark rect { fill: var(--ink-3); }
.spark rect.now { fill: var(--accent); }
.spark rect:hover { fill: var(--accent); }
.spark .axis { stroke: var(--rule-strong); }
.accounts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 20px; }
.accounts li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--rule); gap: 8px; }
.accounts .n { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.accounts .id { color: var(--ink-3); font-size: 0.76rem; display: block; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 28px 0 10px; font-variation-settings: "wdth" 108; }
h2:first-child { margin-top: 0; }
h3 { font-size: 0.98rem; font-weight: 600; margin: 18px 0 6px; }
.prose { max-width: 68ch; }
.prose p, .prose li { color: var(--ink-2); }
.prose strong { color: var(--ink); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; font-size: 0.94rem; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre.json { background: var(--paper-2); border: 1px solid var(--rule); padding: 10px 12px; overflow: auto; font-family: var(--mono); font-size: 0.8rem; line-height: 1.45; margin: 0; max-height: 40vh; }

/* Estate tree */
.tree { list-style: none; padding: 0; margin: 0; }
.tree > li { border-bottom: 1px solid var(--rule); }
.tree summary { cursor: pointer; padding: 10px 0; display: flex; gap: 14px; align-items: baseline; list-style: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "+"; width: 14px; color: var(--ink-3); font-family: var(--mono); }
.tree details[open] > summary::before { content: "–"; }
.tree summary .name { font-weight: 500; }
.tree summary .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tree .types { list-style: none; padding: 0 0 8px 22px; margin: 0; }
.tree .types summary { padding: 6px 0; }
.tree .types .tbl { margin: 4px 0 10px; }
.gone { color: var(--ink-3); text-decoration: line-through; }

/* Drawer */
.drawer-host { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; }
.drawer-host[hidden] { display: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(10, 20, 18, 0.35); }
.drawer { position: relative; width: min(560px, 100%); height: 100%; background: var(--paper); border-left: 1px solid var(--rule-strong); overflow: auto; padding: 24px 28px 40px; box-shadow: -8px 0 30px rgba(0,0,0,0.12); }
.drawer h2 { margin-top: 0; font-size: 1.25rem; padding-right: 60px; }
.drawer .close { position: absolute; top: 18px; right: 20px; }
.drawer .events-list { list-style: none; padding: 0; margin: 0; }
.drawer .events-list li { padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 0.92rem; }
.drawer .events-list time { color: var(--ink-3); display: block; font-size: 0.82rem; }
.verdict { border-left: 3px solid var(--accent); padding: 2px 12px; margin: 8px 0 14px; }
.verdict .word { font-weight: 600; font-size: 1.05rem; }
.consult { border-bottom: 1px solid var(--rule); padding: 16px 0; }
.consult h3 { margin-top: 0; }
.consult .meta { color: var(--ink-3); font-size: 0.86rem; }
.consult .q { color: var(--ink-2); max-width: 70ch; }
.draft { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 16px; margin-top: 12px; font-size: 0.94rem; }
.draft dt { color: var(--ink-2); }
.draft dd { margin: 0; }
.draft ul { margin: 0; padding-left: 18px; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff pre { max-height: 30vh; }
.diff .h { font-size: 0.84rem; color: var(--ink-2); margin-bottom: 4px; }
.approval { border-bottom: 1px solid var(--rule); padding: 14px 0; }
.approval .head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.approval .desc { max-width: 70ch; margin: 4px 0 8px; }
.approval .meta { color: var(--ink-3); font-size: 0.86rem; }
.notice { background: var(--paper-2); border-left: 3px solid var(--accent); padding: 10px 14px; max-width: 70ch; margin-bottom: 18px; }
.notice.warn { border-left-color: var(--warn); }
.saving { font-variant-numeric: tabular-nums; }
.inline-form { display: grid; gap: 10px; max-width: 70ch; }
.inline-form textarea { font: inherit; font-size: 0.92rem; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 2px; padding: 8px; min-height: 160px; color: var(--ink); }
.inline-form .row { display: flex; gap: 10px; align-items: center; }

/* Ask */
.ask-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; min-height: 60vh; }
.ask-side .row.between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.thread-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.thread-list li { border-bottom: 1px solid var(--rule); display: flex; align-items: flex-start; gap: 6px; padding: 8px 0; }
.thread-list li.current { border-left: 3px solid var(--accent); padding-left: 8px; }
.thread-list a { flex: 1; text-decoration: none; color: var(--ink); font-size: 0.92rem; min-width: 0; }
.thread-list a:hover { text-decoration: underline; }
.thread-list .when { display: block; color: var(--ink-3); font-size: 0.8rem; }
.ask-main { display: flex; flex-direction: column; gap: 14px; }
.convo { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 76ch; }
.msg.user { border-left: 3px solid var(--rule-strong); padding-left: 12px; }
.msg.user p { margin: 2px 0 0; white-space: pre-wrap; }
.msg.assistant { background: var(--paper-2); padding: 12px 16px; border-radius: 2px; }
.msg .meta { color: var(--ink-3); font-size: 0.82rem; margin-bottom: 4px; }
.msg .meta .muted { color: var(--ink-3); }
.md p, .md li { margin: 0 0 8px; color: var(--ink); }
.md h3, .md h4, .md h5 { margin: 10px 0 6px; font-size: 1rem; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md code { background: var(--paper-3); padding: 0 4px; border-radius: 2px; }
.calls { font-size: 0.86rem; color: var(--ink-2); margin: 6px 0; }
.calls summary { cursor: pointer; }
.calls ul { margin: 4px 0 0; padding-left: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip { font-size: 0.8rem; border: 1px solid var(--accent); color: var(--accent); border-radius: 12px; padding: 1px 9px; text-decoration: none; }
.chip:hover { background: var(--accent-soft); }
.chip.static { border-color: var(--rule-strong); color: var(--ink-2); }
.progress { font-size: 0.9rem; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.progress ul { margin: 0; padding-left: 18px; flex-basis: 100%; }
.spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--rule-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.composer { display: grid; gap: 8px; border-top: 1px solid var(--rule-strong); padding-top: 12px; }
.composer .ctx { font-size: 0.84rem; color: var(--ink-2); }
.ask-input { font: inherit; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 2px; padding: 8px 10px; color: var(--ink); resize: vertical; min-height: 64px; }
.ask-input:disabled { opacity: 0.6; }
.composer .row { display: flex; gap: 12px; align-items: center; }
.ask-btn { white-space: nowrap; }
@media (max-width: 860px) { .ask-layout { grid-template-columns: minmax(0, 1fr); } .ask-side { order: 2; } }

.actions { display: flex; flex-wrap: wrap; gap: 4px; }
.tbl .tag { margin-right: 4px; }

/* Sign-in */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate .card { max-width: 420px; }
.gate h1 { font-size: 2rem; font-variation-settings: "wdth" 115; margin: 0 0 8px; }
.gate p { color: var(--ink-2); }

@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { width: 100%; max-width: 100vw; overflow: hidden; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 0; gap: 0 8px; }
  .mark { padding: 6px 16px; }
  .nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; padding: 0 8px; }
  .nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .nav a[aria-current="page"] { border-bottom-color: var(--accent); background: transparent; }
  .who { border-top: 0; padding: 0 12px; margin-left: auto; min-width: 0; flex: 0 1 auto; display: flex; align-items: center; gap: 10px; }
  .who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
  .who span { display: none; }
  .who button { margin: 0; white-space: nowrap; }
  .main { padding: 18px 16px 48px; }
  .two { grid-template-columns: 1fr; }
  .diff { grid-template-columns: 1fr; }
  .tile { padding-right: 12px; margin-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
