/* ============================================================================
   BlockGenie Codex — "Night Desk" · Panel checker + queue
   Art direction: docs/18-ui-redesign.md

   Same room as the console: cool surfaces, warm ink, one desaturated accent,
   serif asks / mono reports / grotesque works. This screen is the instrument
   rather than the conversation, so the signature rail carries the *queue*:
   because the worker is serialized, the vertical order of nodes is the order
   the box will do the work.
   ========================================================================== */

:root {
  --ink: #0b0d11;
  --room: #10131a;
  --panel: #171b23;
  --panel-2: #1d222b;
  --edge: #262c37;
  --bone: #edeae4;

  --edge-soft: #1a1f28;
  --edge-strong: #333a46;
  --bone-dim: #a7aeb9;
  --faint: #848d9a;
  --glacier: #8fb9cf;
  --glacier-dim: #6d93a8;
  --glacier-sunk: #1b2b34;
  --ember: #d9705e;
  --ember-sunk: #2c1a18;
  /* semantic tokens (docs/52) — night values; shell.css owns the day values */
  --on-bone: #14171d; --bone-hi: #ffffff; --wash: rgba(143, 185, 207, .052); --tap: rgba(143, 185, 207, .12);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --t-display: clamp(2.5rem, 5.2vw, 3.75rem); /* docs/53: the one serif line reads as display */
  --t-title: 1.0625rem;
  --t-body: 1rem;
  --t-ui: 0.9375rem;
  --t-sm: 0.8125rem;
  --t-micro: 0.6875rem;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px; --s10: 72px;

  --r-sm: 3px; --r-md: 6px; --r-lg: 10px; --r-xl: 14px; --r-pill: 6px; /* docs/53: pills are gone; the alias means "a control" */

  --sh-1: 0 1px 2px rgba(0, 0, 0, .34);
  --sh-2: 0 2px 8px rgba(0, 0, 0, .3), 0 14px 34px -10px rgba(0, 0, 0, .5);

  --measure: 46rem;
  --page: 1064px;
  --gutter: 30px;

  --e-out: cubic-bezier(.22, .68, .28, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; }
html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--room);
  color: var(--bone);
  font-family: var(--sans);
  font-size: var(--t-ui);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* the room light — one ambient wash, fixed, never on a component */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(115% 58% at 50% -14%, var(--wash), transparent 62%);
}

h1, h2, h3, p, ol, ul, dl, dd, dt { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: var(--tap); }

a {
  color: var(--glacier);
  text-decoration-color: color-mix(in srgb, var(--glacier) 40%, transparent);
  text-underline-offset: 2px;
}
a:hover { text-decoration-color: var(--glacier); }

:focus-visible {
  outline: 2px solid var(--glacier);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: var(--s4); top: -60px; z-index: 90;
  padding: var(--s2) var(--s4); border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--edge); color: var(--bone);
  text-decoration: none; transition: top 140ms var(--e-out);
}
.skip-link:focus { top: var(--s4); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 16px; height: 16px; flex: none; display: block; }

/* the machine reporting */
.tape {
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 400;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
}

.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--t-display);
  line-height: 1.02;
  letter-spacing: -.016em;
  text-wrap: balance;
  color: var(--bone);
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- topbar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 56px;
  padding: var(--s3) var(--s5);
  background: var(--room);
  isolation: isolate;
}

.top-title { min-width: 0; flex: 1; }
.top-title h1 {
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -.005em;
}

.product-nav { display: flex; align-items: center; gap: 2px; }
.product-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 var(--s3);
  border-radius: var(--r-sm);
  color: var(--bone-dim);
  text-decoration: none;
  font-size: var(--t-sm);
  transition: background-color 140ms var(--e-out), color 140ms var(--e-out);
}
.product-nav a:hover { background: var(--panel); color: var(--bone); }
.product-nav a[aria-current="page"] { background: var(--panel-2); color: var(--bone); }

/* ------------------------------------------------------------------ page -- */

.page {
  position: relative;
  z-index: 1;
  width: min(100% - var(--s8), var(--page));
  margin: 0 auto;
  padding: var(--s7) 0 var(--s10);
  display: grid;
  gap: var(--s9);
}

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  padding-bottom: var(--s3);
  margin-bottom: var(--s5);
  border-bottom: 1px solid var(--edge-soft);
}
.sec-head h2 {
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -.005em;
}
.sec-note { font-size: var(--t-sm); color: var(--bone-dim); max-width: var(--measure); }

/* ---------------------------------------------------------------- verdict -- */

.verdict {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--s7);
}

.verdict-line { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }

.verdict h1 { max-width: 20ch; }

.verdict-lede {
  margin-top: var(--s4);
  max-width: var(--measure);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--bone-dim);
}
.verdict-lede strong { color: var(--bone); font-weight: 500; }

.pulse-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  margin-top: var(--s5);
}

.dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 50%;
  background: var(--faint);
}
.dot.is-ok { background: var(--glacier); }
.dot.is-warn { background: var(--glacier-dim); }
.dot.is-bad { background: var(--ember); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  background: var(--panel);
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--bone-dim);
}
.pill.is-ok { border-color: color-mix(in srgb, var(--glacier) 34%, var(--edge)); background: var(--glacier-sunk); color: var(--bone); }
.pill.is-warn { border-color: var(--edge-strong); background: var(--panel-2); color: var(--bone-dim); }
.pill.is-bad { border-color: color-mix(in srgb, var(--ember) 40%, var(--edge)); background: var(--ember-sunk); color: var(--bone); }

/* the poll control — the one raised object up here */
.pulse {
  display: grid;
  gap: var(--s3);
  min-width: 232px;
  padding: var(--s4);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.pulse .tape { color: var(--bone-dim); }
.pulse-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 34px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--edge-strong);
  background: transparent;
  color: var(--bone);
  font-size: var(--t-sm);
  cursor: pointer;
  transition: background-color 140ms var(--e-out), border-color 140ms var(--e-out), transform 140ms var(--e-out);
}
.btn:hover { background: var(--panel-2); border-color: var(--glacier-dim); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.is-solid { background: var(--bone); border-color: var(--bone); color: var(--on-bone); font-weight: 500; }
.btn.is-solid:hover { background: var(--bone-hi); border-color: var(--bone-hi); }

.meter {
  height: 2px;
  border-radius: 0;
  background: var(--edge);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--glacier);
  transition: width 260ms linear;
}

/* ---------------------------------------------------------------- readout -- */

/* hairline rows, not a card grid — this is an instrument panel */
.readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s8); }

.fact {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--edge-soft);
}
.fact > .dot { align-self: center; margin-inline: 5px; }
.fact-k { color: var(--bone-dim); font-size: var(--t-sm); }
.fact-v {
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
  color: var(--bone);
  text-align: right;
  overflow-wrap: anywhere;
}
.fact-v.is-dim { color: var(--faint); }
.fact-v.is-bad { color: var(--ember); }
.fact-sub {
  grid-column: 2 / -1;
  font-size: var(--t-sm);
  color: var(--faint);
  line-height: 1.5;
}

/* honesty slab: concurrency is a promise this screen has to keep visible */
.honesty {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s7);
  margin-top: var(--s6);
  padding: var(--s5) var(--s6);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-left: 2px solid var(--glacier-dim);
  border-radius: var(--r-md);
}
/* the numeral is the point of this block, so it gets room and a label —
   a bare serif "1" next to the accent rule just reads as a second hairline */
.honesty-slot { display: grid; justify-items: center; gap: var(--s1); padding-left: var(--s2); }
/* mono, not serif: this is the machine stating a number about itself, the same
   voice the device code speaks in. Instrument Serif's "1" is a bare stroke and
   reads as another hairline next to the accent rule. */
.honesty-num {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 2.5rem;
  line-height: 1;
  min-width: 1.5ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}
.honesty p { font-size: var(--t-sm); color: var(--bone-dim); max-width: var(--measure); }
.honesty strong { color: var(--bone); font-weight: 500; }

/* ------------------------------------------------------------------ queue -- */

.queue-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin-bottom: var(--s6);
}

/* the rail: the signature element, carrying real FIFO order */
.rail { display: grid; gap: 0; }

.qrow {
  position: relative;
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr) auto;
  gap: var(--s4);
  padding: var(--s4) 0;
}
.qrow + .qrow { border-top: 1px solid var(--edge-soft); }

/* hairline through the gutter, drawn per row so it stops at the last node */
.qrow::before {
  content: "";
  position: absolute;
  left: calc(var(--gutter) / 2);
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--edge-strong);
}
.qrow:first-child::before { top: var(--s5); }
.qrow:last-child::before { bottom: calc(100% - var(--s5) - 10px); }

.node {
  position: relative;
  grid-row: 1 / span 2;
  justify-self: center;
  align-self: start;
  margin-top: var(--s4);
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--room);
  border: 1.5px solid var(--edge-strong);
}
.node::after {
  content: "";
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: var(--bone-dim);
}
.qrow.is-live .node { border-color: var(--glacier); }
.qrow.is-live .node::after { background: var(--glacier); animation: nodePulse 1.5s linear infinite; }
.qrow.is-bad .node { border-color: var(--ember); }
.qrow.is-bad .node::after { background: var(--ember); }

@keyframes nodePulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

.qbody { min-width: 0; }
.qtitle {
  font-size: var(--t-body);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.qmeta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); margin-top: var(--s2); }
.qright { display: flex; align-items: center; gap: var(--s3); justify-self: end; align-self: start; }

.clock {
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
  color: var(--bone-dim);
}

/* ----------------------------------------------------------------- errors -- */

.errs { display: grid; gap: var(--s3); }

.err {
  display: grid;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-left: 2px solid var(--ember);
  border-radius: var(--r-md);
}
.err-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); }
.err-msg {
  font-family: var(--mono);
  font-size: var(--t-sm);
  line-height: 1.55;
  color: var(--bone);
  overflow-wrap: anywhere;
}
.err-ctx { font-size: var(--t-sm); color: var(--faint); overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- probes -- */

.probes { display: grid; gap: 0; }
.probe-note-copy { margin-top: var(--s5); }

.probe {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--edge-soft);
}
.probe-path { font-family: var(--mono); font-size: var(--t-sm); color: var(--bone); overflow-wrap: anywhere; }
.probe-note { font-size: var(--t-sm); color: var(--faint); text-align: right; }
.probe-code {
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: .09em;
  color: var(--bone-dim);
  font-variant-numeric: tabular-nums;
  min-width: 7ch;
  text-align: right;
}

/* ------------------------------------------------------------ empty/state -- */

.empty {
  display: grid;
  gap: var(--s3);
  padding: var(--s8) 0;
  text-align: left;
}
/* empties are rows with zero rows, not a second display line (docs/43 §7) */
.empty .display { font-family: var(--sans); font-weight: 600; font-size: var(--t-title); letter-spacing: -.005em; line-height: 1.3; }
.empty p { max-width: var(--measure); color: var(--bone-dim); font-size: var(--t-sm); }

.slab {
  display: grid;
  gap: var(--s4);
  padding: var(--s6);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.slab h3 { font-size: var(--t-title); font-weight: 600; }
.slab p { font-size: var(--t-sm); color: var(--bone-dim); max-width: var(--measure); }

.field-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.field-row input {
  flex: 1 1 220px;
  min-height: 42px;
  padding: 0 var(--s4);
  background: var(--room);
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-md);
  color: var(--bone);
}
.field-row input::placeholder { color: var(--faint); }

.error-text { color: var(--ember); font-size: var(--t-sm); }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3) var(--s5);
  padding-top: var(--s6);
  border-top: 1px solid var(--edge-soft);
}

/* -------------------------------------------------------------- responsive -- */

@media (max-width: 900px) {
  .verdict { grid-template-columns: minmax(0, 1fr); }
  .pulse { min-width: 0; }
  .readout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .honesty { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .honesty-slot { justify-items: start; padding-left: 0; }
}

@media (max-width: 720px) {
  .page { width: min(100% - var(--s5), var(--page)); padding: var(--s6) 0 var(--s9); gap: var(--s8); }
  .topbar {
    padding: max(var(--s2), env(safe-area-inset-top)) var(--s4) var(--s2);
    flex-wrap: wrap; min-height: 0;
  }
  .top-title .tape { display: none; }
  .product-nav { order: 3; width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
  .product-nav a { min-height: 40px; flex: 1 0 auto; justify-content: center; }
  .btn { min-height: 44px; }
  .qrow { grid-template-columns: 22px minmax(0, 1fr); }
  .qrow::before { left: 11px; }
  .qright { grid-column: 2; justify-self: start; margin-top: var(--s2); }
  .probe { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .probe-note { display: none; }
  .fact-v { text-align: left; }
  .fact { grid-template-columns: 18px minmax(0, 1fr); }
  .fact-v { grid-column: 2; }
}

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

@media (forced-colors: active) {
  .dot, .node, .node::after { forced-color-adjust: none; }
  .pill, .slab, .err, .pulse, .honesty { border: 1px solid CanvasText; }
  .dot.is-ok, .node::after { background: Highlight; }
  .dot.is-bad { background: LinkText; }
  .meter > i { background: Highlight; }
}

/* ── shared shell: the product bar owns the top 48px (docs/44 §2) ───────── */
.product-nav { display: none; }
.topbar { top: 0; }
.boot, .gate { top: var(--bar-h); }
