/* wmetrymarket: an operations strip board.
   Dense tabular strips, a cool grey-blue field, condensed headings, and one
   hue per pipeline stage. Magenta is reserved for "a human is needed". */

:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --sunk: #e4e8ec;
  --hover: #f3f5f7;
  --ink: #17212b;
  --muted: #5f6c7b;
  --line: #d4dae1;
  --line-strong: #b9c2cc;

  --queue: #6e7c8c;
  --working: #b7791f;
  --review: #6d4fd8;
  --needs: #d4326a;
  --published: #0b8a7a;
  --done: #46525f;
  --win: #2f8f46;
  --dead: #8c6a5a;
  --alert: #c2552d;
  --fact: #3f6fb5;

  --display: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  --shadow: -12px 0 32px rgba(23, 33, 43, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131a22;
    --surface: #1c2530;
    --sunk: #0f151c;
    --hover: #232e3b;
    --ink: #e7ecf1;
    --muted: #93a0ae;
    --line: #2c3846;
    --line-strong: #3b4959;

    --queue: #8e9baa;
    --working: #d9a040;
    --review: #9a84f0;
    --needs: #f06292;
    --published: #2db5a3;
    --done: #7b8896;
    --win: #5cbf73;
    --dead: #b39484;
    --alert: #e5805a;
    --fact: #6f9be0;
    --shadow: -12px 0 32px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--body); font-variant-numeric: tabular-nums; }
a { color: inherit; }
h1, h2, h3, h4, .brand, .fcount, .verdict, .sid, dl.stats dd { font-family: var(--display); font-stretch: 87%; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 600; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }
h4 { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
h5 { font-size: 12px; font-weight: 600; margin: 10px 0 4px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--review); outline-offset: 2px; }

.quiet { color: var(--muted); }
p.quiet { margin: 6px 0; font-size: 13px; }
.pad { padding: 18px; }
.mono { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
p.err, span.err, dd.err { color: var(--alert); }
.lead { max-width: 76ch; color: var(--muted); margin: 0 0 12px; }
.boot { padding: 40px; color: var(--muted); }

.s-queue { --hue: var(--queue); }
.s-working { --hue: var(--working); }
.s-review { --hue: var(--review); }
.s-approval { --hue: var(--needs); }
.s-published { --hue: var(--published); }
.s-done { --hue: var(--done); }

/* ---------------------------------------------------------------- controls */

.btn { font: inherit; font-size: 13px; font-weight: 600; line-height: 1.4; padding: 5px 12px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.danger { color: var(--alert); }
.btn.quietbtn { border-color: transparent; background: none; color: var(--muted); font-weight: 400; }
.btn.quietbtn:hover { border-color: var(--line-strong); color: var(--ink); }

input, select, textarea { font: inherit; font-size: 13.5px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); min-width: 0; }
textarea { resize: vertical; width: 100%; }
input[type="checkbox"] { accent-color: var(--ink); width: 15px; height: 15px; padding: 0; }
input.num { width: 104px; }
.switch, .check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; }
.seg button { border: 0; border-left: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: var(--surface); }
.seg button:disabled { color: var(--line-strong); cursor: not-allowed; }

.count { margin-left: 6px; font-family: var(--body); font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 9px; background: var(--sunk); color: var(--muted); }
.badge { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--win); border-color: currentColor; }
.badge.bad { color: var(--alert); border-color: currentColor; white-space: normal; }
.badge.warn { color: var(--working); border-color: currentColor; }

.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--working); display: inline-block; flex: none; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--surface); padding: 8px 16px; border-radius: 6px; font-weight: 600; max-width: 80vw; }
.toast.error { background: var(--alert); color: #fff; }

/* ---------------------------------------------------------------- header */

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px; height: 48px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-size: 20px; font-weight: 700; font-stretch: 80%; text-decoration: none; white-space: nowrap; }
.brand .demo { margin-left: 8px; font-family: var(--body); font-size: 11px; font-weight: 600; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 3px; color: var(--muted); vertical-align: middle; }
nav.main { display: flex; gap: 2px; align-self: stretch; }
nav.main a { display: flex; align-items: center; gap: 6px; padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; border-top: 2px solid transparent; }
nav.main a.on { color: var(--ink); border-bottom-color: var(--ink); }
.navcount { font-weight: 400; font-size: 12px; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; min-width: 0; }
.runstate { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; min-width: 0; white-space: nowrap; }
.runstate i { width: 8px; height: 8px; border-radius: 2px; background: var(--win); flex: none; }
.runstate.st-paused i { background: var(--queue); }
.runstate.st-setup i { background: var(--alert); }
.runstate.st-idle i { background: var(--line-strong); }
.runstate .why { font-weight: 400; color: var(--muted); max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.top .agents { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; color: var(--muted); }
.needsbtn { background: var(--needs); color: #fff; font-weight: 600; padding: 4px 10px; border-radius: 5px; text-decoration: none; white-space: nowrap; }
.offline { color: var(--alert); font-weight: 600; }

.overview, .dive, .settings { padding: 16px 20px 48px; }

/* ---------------------------------------------------------------- the flow band (signature) */

.flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 16px; }
.fseg { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: baseline; padding: 9px 14px 11px; border-left: 1px solid var(--line); border-top: 4px solid var(--hue); min-width: 0; }
.fseg:first-child { border-left: 0; }
.fcount { grid-row: span 2; font-size: 36px; line-height: 1; font-weight: 600; align-self: center; }
.flabel { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsub { color: var(--muted); font-size: 12px; min-height: 1.4em; display: flex; gap: 5px; align-items: center; white-space: nowrap; overflow: hidden; }
.fseg.zero { border-top-color: color-mix(in srgb, var(--hue) 30%, var(--line)); }
.fseg.zero .fcount { color: var(--line-strong); }

/* ---------------------------------------------------------------- layer 1: matrix */

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 16px; align-items: start; }
.matrixwrap { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; }
table.matrix { border-collapse: collapse; width: 100%; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.matrix th:first-child { border-left: 0; }
.matrix thead th { text-align: left; padding: 8px 9px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.matrix thead th a { text-decoration: none; }
.matrix thead th a:hover { color: var(--ink); text-decoration: underline; }
.matrix .siterow th { background: var(--sunk); text-align: left; padding: 4px 10px; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted); }
.matrix .siterow th.sub { padding-left: 22px; }
.branch { margin-right: 6px; color: var(--line-strong); }
.sitelabel { margin-left: 8px; font-family: var(--body); font-weight: 400; color: var(--muted); font-size: 12px; }
.matrix .prow th { text-align: left; padding: 8px 10px; min-width: 168px; vertical-align: top; }
.matrix .prow th.sub { padding-left: 22px; }
.matrix .prow th a { font-weight: 600; text-decoration: none; display: block; }
.matrix .prow th a:hover { text-decoration: underline; }
.pmeta { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
td.cell { padding: 0; min-width: 116px; vertical-align: top; }
td.cell a { display: block; padding: 6px 8px 7px; text-decoration: none; min-height: 64px; }
td.cell a:hover { background: var(--hover); }
td.cell.off a { display: grid; place-items: center; color: var(--line-strong); font-size: 12px; }
td.cell.attn { box-shadow: inset 0 0 0 2px var(--needs); }
.cmode { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.g-approval_required .cmode { color: var(--ink); }
.g-autonomous .cmode { color: var(--published); font-weight: 600; }
.cbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin: 4px 0; }
.cbar i { height: 18px; font-style: normal; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; color: #fff; background: var(--hue); border-radius: 2px; }
.cbar i.zero { background: var(--sunk); }
.cout { display: flex; gap: 8px; font-size: 11.5px; min-height: 16px; white-space: nowrap; }
.cout .needs { color: var(--needs); }
.win { color: var(--win); }
.deadc { color: var(--dead); }
.legend { margin: 0; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 32px; }

.rail { display: grid; gap: 16px; min-width: 0; }
.rail > section { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; min-width: 0; }
.rail .needs h2 .count { background: var(--needs); color: #fff; }
.need { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.needmain { display: grid; grid-template-columns: auto auto 1fr; gap: 2px 6px; align-items: center; text-decoration: none; min-width: 0; }
.needmain .stitle { grid-column: 1 / -1; font-weight: 600; line-height: 1.3; }
.needmain .needsub { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.needmain:hover .stitle { text-decoration: underline; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; font-size: 12.5px; }
.feed li { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); }
.feed time { color: var(--muted); }
.feed a { text-decoration: none; }
.feed a:hover { text-decoration: underline; }
.feed .lv-warn > :last-child { color: var(--working); }
.feed .lv-attention > :last-child { color: var(--needs); font-weight: 600; }
.feed .lv-dead > :last-child { color: var(--dead); }
.feed .lv-published > :last-child { color: var(--published); }
.feed .lv-win > :last-child { color: var(--win); font-weight: 600; }
.feed .lv-fact > :last-child { color: var(--fact); }
.feed .lv-demo > :last-child { font-style: italic; }

/* ---------------------------------------------------------------- strips */

.sid { font-size: 13px; font-weight: 600; color: var(--muted); }
.chtag { font-size: 10.5px; font-weight: 600; line-height: 16px; padding: 0 5px; border-radius: 3px; background: var(--ink); color: var(--surface); white-space: nowrap; }
.strip { display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "id ch . age" "title title title title" "meta meta meta meta"; gap: 3px 6px; align-items: center; padding: 7px 9px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; text-decoration: none; font-size: 12.5px; min-width: 0; }
.strip .sid { grid-area: id; }
.strip .chtag { grid-area: ch; }
.strip .sage { grid-area: age; color: var(--muted); }
.strip .stitle { grid-area: title; font-weight: 600; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.strip .smeta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; color: var(--muted); min-width: 0; }
a.strip:hover { border-color: var(--ink); }
.strip.sel { outline: 2px solid var(--ink); outline-offset: -1px; }
.strip.attn { border-left: 4px solid var(--needs); }
.strip.dead .stitle { color: var(--muted); font-weight: 400; }
.strip.s-queue { border-style: dashed; }
.strip.s-queue.active { border-style: solid; border-color: var(--queue); }
.strip.s-queue .stitle { font-weight: 400; }
.mark { font-weight: 600; }
.mark.dead { color: var(--dead); }
.sprod { font-weight: 600; color: var(--ink); }
.sstatus { overflow-wrap: anywhere; }
.rev { white-space: nowrap; }

/* ---------------------------------------------------------------- layer 2: drill-down */

.crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs .here { color: var(--ink); font-weight: 600; }
.context { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; margin-bottom: 14px; }
.ctxmain, .ctxside, .gates { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; min-width: 0; }
.ctxmain h1 .on { color: var(--muted); font-weight: 400; }
dl.stats { display: flex; flex-wrap: wrap; gap: 10px 0; margin: 0; }
dl.stats > div { padding-right: 18px; margin-right: 18px; border-right: 1px solid var(--line); }
dl.stats > div:last-child { border-right: 0; }
dl.stats dt { font-size: 12px; color: var(--muted); }
dl.stats dd { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.2; }
.ctxlinks { display: flex; gap: 18px; margin: 12px 0 0; font-size: 13px; flex-wrap: wrap; }
ul.notes { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 7px; font-size: 13px; }
.note b { text-transform: capitalize; }
.note.k-forbidden b { color: var(--alert); }
.note.k-promo b { color: var(--working); }
.terms { color: var(--muted); }
.exp { margin-left: 6px; font-size: 11.5px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 3px; white-space: nowrap; color: var(--muted); }
.more { font-size: 13px; }
.gates { margin-bottom: 14px; padding-top: 12px; padding-bottom: 8px; }
.gatectl { display: grid; grid-template-columns: 250px auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.gatectl .gatehint { font-size: 12.5px; color: var(--muted); }
.gatectl:not(.on) .seg, .gatectl:not(.on) .gatehint { opacity: 0.45; }
.gatehint .warn { color: var(--alert); }
nav.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
nav.tabs a { padding: 6px 10px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
nav.tabs a:hover { color: var(--ink); }

.bays { display: grid; grid-template-columns: repeat(6, minmax(196px, 1fr)); gap: 10px; overflow-x: auto; align-items: start; padding-bottom: 4px; }
.bay { background: var(--sunk); border-radius: 6px; border-top: 4px solid var(--hue); min-width: 0; }
.bay header { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px 2px; }
.bay h3 { font-size: 14px; }
.strips { display: grid; gap: 6px; padding: 6px; max-height: calc(100vh - 150px); overflow-y: auto; }
.strips .quiet { margin: 4px; }

/* ---------------------------------------------------------------- layer 3: drawer */

.drawer { position: fixed; top: 48px; right: 0; bottom: 0; width: min(660px, 100vw); z-index: 15; background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow); overflow-y: auto; }
.drawer .close { position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 4px; background: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.drawer .close:hover { background: var(--sunk); color: var(--ink); }
.dhead { padding: 14px 54px 12px 18px; border-bottom: 1px solid var(--line); }
.dmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.dhead h2 { font-size: 22px; line-height: 1.2; margin: 7px 0 5px; }
.dstatus { margin: 0; font-size: 13px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.pill { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 9px; background: var(--hue); color: #fff; }
.pill.dead { background: var(--dead); }
.pill.win { background: var(--win); }
.actions { padding: 12px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 9px; }
.actions.attn { background: color-mix(in srgb, var(--needs) 7%, var(--surface)); border-left: 4px solid var(--needs); padding-left: 14px; }
.actions p { margin: 0; max-width: 62ch; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: grid; gap: 8px; }
form.inline label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
form.inline.oneline { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.outcome { padding: 10px 18px 12px; border-bottom: 1px solid var(--line); color: var(--ink); }
.outcome h3 { margin-bottom: 4px; }
.outcome.win h3 { color: var(--win); }
.outcome.dead h3 { color: var(--dead); }
.outcome p { margin: 2px 0; max-width: 66ch; overflow-wrap: anywhere; }
.dtabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dtabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 9px 9px 7px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.dtabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.dtabs .count { font-weight: 400; }
.dbody { padding: 14px 18px 48px; }
.dbody > div > :first-child { margin-top: 0; }

.versions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.artnote { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.artifact { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--sunk); border: 1px solid var(--line); border-radius: 5px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
ins { background: color-mix(in srgb, var(--win) 24%, transparent); text-decoration: none; }
del { background: color-mix(in srgb, var(--alert) 18%, transparent); color: var(--muted); }
.claims ul { padding-left: 18px; margin: 0; }
.claims li { margin: 4px 0; }
a.fact { font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 3px; text-decoration: none; color: var(--fact); margin-right: 3px; white-space: nowrap; }
a.fact:hover { border-color: var(--fact); }
dl.kv { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 0 0 8px; }
dl.kv dt { font-size: 12px; color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
dl.kv.wide { display: grid; gap: 8px; }
dl.kv.wide dd { font-weight: 400; }
details.raw { margin-top: 18px; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
pre { font: 12px/1.5 var(--mono); background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 380px; overflow: auto; margin: 4px 0; }

.review { border: 1px solid var(--line); border-top: 3px solid var(--review); border-radius: 5px; padding: 10px 12px; margin: 10px 0; }
.review header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.review p { margin: 6px 0; }
.verdict { font-size: 16px; font-weight: 600; }
.v-approve .verdict { color: var(--win); }
.v-revise .verdict { color: var(--working); }
.v-reject .verdict { color: var(--alert); }
.override { background: color-mix(in srgb, var(--working) 14%, transparent); padding: 6px 10px; border-radius: 4px; font-size: 13px; }
.reasons { padding-left: 18px; margin: 6px 0; }
.reasons li { margin: 3px 0; }
.reasons b { text-transform: capitalize; }
.reasons .sev-block b { color: var(--alert); }
.fix { color: var(--muted); }
table.checks, table.plain { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; }
table.checks th, table.plain th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-strong); padding: 4px 6px; }
table.checks td, table.plain td { border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: top; }
th.n, td.n { text-align: right; }
.compliance, .lint, .human { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 5px; font-size: 13px; }
.knodes { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; font-size: 13.5px; }
.knode a { text-decoration: none; }
.knode a:hover { text-decoration: underline; }
.knode.stale { opacity: 0.7; }
blockquote { margin: 4px 0 2px; padding-left: 10px; border-left: 2px solid var(--line-strong); color: var(--muted); font-size: 13px; }
.src { display: block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ktype { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 3px; color: #fff; background: var(--queue); white-space: nowrap; }
.ktype.t-fact { background: var(--fact); }
.ktype.t-hook { background: var(--win); }
.ktype.t-angle { background: var(--published); }
.ktype.t-objection { background: var(--working); }
.ktype.t-insight { background: var(--review); }
.ktype.t-rejection { background: var(--alert); }
.ktype.t-dead_end { background: var(--dead); }

ul.agents { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 3px; font-size: 13px; }
ul.agents li { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
ol.trace { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.trow { border-bottom: 1px solid var(--line); }
.trow > button { display: grid; grid-template-columns: 60px 50px minmax(110px, 190px) minmax(0, 1fr); gap: 8px; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); font: inherit; font-size: 12.5px; padding: 5px 2px; cursor: pointer; }
.trow > button:hover { background: var(--hover); }
.trow time, .trow .who { color: var(--muted); }
.trow .tname { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.trow .tsum { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow.k-llm .tname { color: var(--review); }
.trow.k-state .tname { color: var(--published); }
.trow.err .tname { color: var(--alert); }
.tdetail { padding: 0 2px 10px 68px; }

/* ---------------------------------------------------------------- knowledge */

.knowledge { display: grid; grid-template-columns: 450px minmax(0, 1fr); gap: 16px; height: calc(100vh - 48px); padding: 16px 20px; }
.kside { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 14px 0; }
.kside .lead { font-size: 13px; }
.ksearch input { width: 100%; }
.kfilters { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: 12.5px; }
.ktypes { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.ktypes button { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 4px; padding: 2px 7px; font: inherit; font-size: 12px; cursor: pointer; }
.ktypes button i { width: 8px; height: 8px; border-radius: 50%; }
.ktypes button.on { border-color: var(--ink); background: var(--sunk); font-weight: 600; }
.ktypes .count { margin-left: 0; padding: 0; background: none; font-weight: 400; }
.klist { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid var(--line); margin: 0 -14px; padding: 0 14px; }
.krow { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 2px 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 13px; }
.krow .ktype { justify-self: start; }
.krow .kmeta { grid-column: 2; color: var(--muted); font-size: 12px; }
.krow:hover .ktitle { text-decoration: underline; }
.krow.sel { background: var(--sunk); box-shadow: -14px 0 0 var(--sunk), 14px 0 0 var(--sunk); }
.krow.off { opacity: 0.6; }
.kgraph { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.graphslot { flex: 1; min-height: 0; position: relative; }
.graphslot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.kgraph .legend { border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- settings */

.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 26px; align-items: start; }
.snav { display: grid; gap: 2px; position: sticky; top: 64px; }
.snav a { padding: 6px 10px; border-radius: 4px; color: var(--muted); text-decoration: none; font-weight: 600; }
.snav a:hover { color: var(--ink); }
.snav a.on { background: var(--surface); color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.sbody { max-width: 1120px; min-width: 0; }
.sbody h2 { font-size: 18px; margin: 0; }
.banner { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--queue); padding: 8px 12px; border-radius: 4px; max-width: 86ch; margin: 0 0 12px; }
.banner.warn { border-left-color: var(--alert); }
.site, .channel, .block, .sbody > .form { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; margin: 0 0 14px; }
.site.sub { margin: 14px 0 0; border: 0; border-left: 3px solid var(--line-strong); border-radius: 0; padding: 4px 0 4px 16px; }
.site > header, .channel > header, .product > header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.site > header .quietbtn, .product > header .quietbtn { margin-left: auto; }
.site > header h2 { font-family: var(--mono); font-stretch: normal; font-size: 15px; }
.product { border-top: 1px solid var(--line); padding: 12px 0 4px; margin-top: 12px; }
.product h3 { font-size: 17px; }
.product h3 a { text-decoration: none; }
.product h3 a:hover { text-decoration: underline; }
.product h4 { margin-top: 12px; }
.pfields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin: 8px 0; }
.field { display: grid; gap: 3px; font-size: 13px; align-content: start; min-width: 0; }
.field .fname { font-weight: 600; font-size: 12.5px; }
.field .hint { color: var(--muted); font-size: 12px; max-width: 40ch; }
.field > input:not(.num), .field > select, .field > textarea { width: 100%; }
.formrow { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.formrow .field { flex: 1 1 160px; }
.formrow > .btn { flex: none; }
.block .formrow { align-items: start; margin-top: 10px; }
.form { margin-top: 12px; }
.form h3 { margin-bottom: 8px; }
.form > .field { margin: 10px 0; max-width: 760px; }
ul.sources { list-style: none; padding: 0; margin: 0; }
.source { display: grid; grid-template-columns: 92px minmax(0, 1.2fr) minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px; }
.source .skind { font-weight: 600; text-transform: capitalize; }
.source .sloc { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .sstate { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source.bad .sstate { color: var(--alert); }
.source.off .skind, .source.off .sloc { opacity: 0.55; }
ul.noterows { list-style: none; padding: 0; margin: 0 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.noterow { display: grid; grid-template-columns: 116px 150px minmax(0, 1fr) 150px auto; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); align-items: baseline; font-size: 13.5px; }
.noterow:first-child { border-top: 0; }
.noterow .nkind { font-weight: 600; }
.noterow.k-forbidden .nkind { color: var(--alert); }
.noterow.k-promo .nkind { color: var(--working); }
.noterow .nscope, .noterow .nexp { color: var(--muted); font-size: 12.5px; }
.noterow.expired { opacity: 0.55; }
.sbody > h3 { margin: 16px 0 8px; }
.norms { color: var(--muted); max-width: 86ch; font-size: 13px; margin: 6px 0 4px; }
.secrets { margin-top: 6px; }
form.secret { display: flex; gap: 8px; align-items: end; margin: 8px 0; }
form.secret .field { flex: 0 1 400px; }
table.gatetable { border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.gatetable th, .gatetable td { text-align: left; padding: 5px 16px 5px 0; border-top: 1px solid var(--line); font-weight: 400; }
.gatetable thead th { color: var(--muted); font-size: 12px; border-top: 0; font-weight: 600; }
.gatetable tbody th a { font-weight: 600; text-decoration: none; }
.gatetable tr.off td:nth-child(n + 3) { opacity: 0.45; }
.gatetable input.num { width: 72px; }
.provider { border-top: 1px solid var(--line); padding: 10px 0; margin-top: 10px; }
.provider h3 .quiet { font-family: var(--body); font-weight: 400; font-size: 13px; }
table.models input[type="text"] { width: 200px; }
table.models input.num { width: 84px; }
table.models td { vertical-align: middle; }

/* ---------------------------------------------------------------- sign in */

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px; width: min(400px, 100%); display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.login p { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 1180px) {
  .cols, .context, .settings { grid-template-columns: minmax(0, 1fr); }
  .snav { position: static; display: flex; flex-wrap: wrap; }
  .knowledge { grid-template-columns: minmax(0, 1fr); height: auto; }
  .kside { max-height: 70vh; }
  .kgraph { height: 70vh; }
  .runstate .why { display: none; }
}
@media (max-width: 760px) {
  .top { height: auto; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; position: static; }
  .top .right { margin-left: 0; flex-wrap: wrap; }
  .drawer { top: 0; }
  .overview, .dive, .settings, .knowledge { padding: 12px; }
  .flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fseg:nth-child(4) { border-left: 0; }
  .fcount { font-size: 28px; }
  .gatectl, .pfields, .source, .noterow { grid-template-columns: minmax(0, 1fr); }
  .trow > button { grid-template-columns: 56px 44px minmax(0, 1fr); }
  .trow .tsum { grid-column: 1 / -1; }
  .tdetail { padding-left: 2px; }
}
