/* Driftbell console.
 *
 * The page is a log sheet. Driftbell records: the mark is a bell over a wave,
 * and the artifact its world produces is a chart recorder's paper — a pen
 * drawing continuously, events marking the sheet.
 *
 * Two layers of ink, and the distinction is the whole design:
 *   the pale pre-printed form  — the graph, every node, printed before the run
 *   the pen's own record       — ink, drawn only where the run actually reached
 *
 * So the freeze needs no glow and no animation. The pen stops, and the paper
 * below it is blank, because nothing has happened there yet.
 */

@font-face {
  font-family: "Plex Mono";
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --desk:   #d8dad1;   /* the surface the sheet lies on */
  --paper:  #eceee6;   /* the sheet */
  --rule:   #c5c9bd;   /* printed ruling, and the pre-printed form */
  --ink:    #17221f;   /* the pen */
  --pencil: #69726b;   /* annotation, secondary reading */
  --brass:  #a86a12;   /* the bell. Spent only where the run stops */
  --stop:   #93321e;   /* rejected, escalated */

  /* Mono leads. The page is a machine's own record, so the machine's face
     carries the headings; the humanist face appears only where a sentence was
     written to be read by a person. */
  --mono: "Plex Mono", ui-monospace, Consolas, monospace;
  --sans: "Plex Sans", system-ui, sans-serif;

  --gap: 8px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); }

a { color: var(--brass); text-underline-offset: 2px; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ head -- */

/* One column, and everything hangs off it: the header block, the notice, the
   sheet and the notes all begin on the same vertical. */
.bar-inner,
.banner-inner,
.explainer-inner,
main {
  max-width: 1500px;
  margin-inline: auto;
  padding-inline: calc(var(--gap) * 3);
}

/* Printed like the header block of a paper form: name on the left, state of
   the instrument on the right, one rule under both. */
.topbar {
  padding: calc(var(--gap) * 2) 0;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.bar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--gap) * 2);
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: calc(var(--gap) * 1.5); }

.mark { width: 20px; height: 27px; color: var(--ink); }
.mark .clapper { fill: var(--brass); }
.mark .wave { stroke: var(--brass); fill: none; }

h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
}

.tagline { margin: 0; font-size: 11.5px; color: var(--pencil); }

/* Wraps, because the two inputs cannot fold onto a phone otherwise and the
   header runs off the right edge. */
.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px calc(var(--gap) * 1.5);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pencil); }
.dot[data-state="ok"]   { background: var(--ink); }
.dot[data-state="down"] { background: var(--stop); }
.dot[data-state="demo"] { background: var(--brass); }

#health-text { color: var(--pencil); font-size: 11.5px; }

.token { display: flex; align-items: center; gap: 6px; }
.token span { font-size: 11px; color: var(--pencil); }
.token input { width: 122px; }

/* ---------------------------------------------------------------- notice -- */

/* Not a coloured alert box. A stamp across the top of the sheet, which is what
   a notice on a paper record actually looks like. */
.banner {
  padding: calc(var(--gap) * 1.5) 0;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--pencil);
}
/* No coloured box and no rule down the side. The brass opening clause is
   already the loudest thing on a page made of grey ink. */
.banner p { margin: 0; max-width: 108ch; }
.banner strong { color: var(--brass); font-weight: 600; }
.banner em { color: var(--ink); font-style: normal; font-weight: 600; }

/* ---------------------------------------------------------------- layout -- */

main {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: calc(var(--gap) * 4);
  padding-block: calc(var(--gap) * 4);
  align-items: start;
}

/* The controls sit in the margin, unboxed. They are what you reach for after
   the sheet has shown you something, so they do not compete with it. */
.side { display: grid; gap: calc(var(--gap) * 4); }

.card { display: grid; gap: calc(var(--gap) * 1.5); }

.card h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.hint { margin: 0; font-size: 11.5px; color: var(--pencil); line-height: 1.55; }

/* ------------------------------------------------------------------ form -- */

.field { display: grid; gap: 4px; }
.field > span { font-size: 11px; color: var(--pencil); }

input {
  width: 100%;
  padding: 5px 7px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
}
input:hover { border-color: var(--pencil); }
input[readonly] { color: var(--pencil); background: transparent; border-style: dashed; }

.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.presets { display: flex; flex-wrap: wrap; gap: 5px; }

button {
  padding: 6px 11px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
button:disabled { opacity: .4; cursor: not-allowed; }

.preset {
  padding: 5px 8px;
  font-size: 10.5px;
  border-color: var(--rule);
  color: var(--pencil);
}

.primary { background: var(--ink); color: var(--paper); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--brass); border-color: var(--brass); }

/* ----------------------------------------------------------------- sheet -- */

/* Paper on a desk: a hairline and one hard offset, not a soft floating blur. */
.run {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 1px 1px 0 rgba(23, 34, 31, .10);
  padding: calc(var(--gap) * 3);
  gap: calc(var(--gap) * 2);
  min-height: 560px;
}

.rail { position: sticky; top: calc(var(--gap) * 2); align-self: start; }
.rail svg { width: 100%; height: auto; overflow: visible; }

/* --- the pre-printed form: every node, printed before the run ------------ */

.spine { stroke: var(--rule); stroke-width: 1; }

.arc {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.node text {
  font-family: var(--mono);
  font-size: 9.5px;
  fill: var(--rule);
  text-anchor: end;
}
.node circle { fill: var(--paper); stroke: var(--rule); stroke-width: 1; }

/* --- the pen's record: ink, only where the run actually reached ---------- */

.spine-progress {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  transition: y2 .4s cubic-bezier(.4, 0, .2, 1);
}

.arc.hot { stroke: var(--ink); stroke-dasharray: none; }

.node.done text,
.node.active text { fill: var(--ink); }
.node.done circle,
.node.active circle { fill: var(--ink); stroke: var(--ink); }

/* The stop. Ink pools where a pen is lifted mid-stroke, so the mark is heavier
   than the line that led to it. No pulse: a stopped pen does not blink. */
.node.frozen text { fill: var(--brass); font-weight: 600; }
.node.frozen circle {
  fill: var(--brass);
  stroke: var(--brass);
  stroke-width: 4;
  paint-order: stroke;
}

.node.skipped text { fill: var(--rule); font-style: italic; }

.freeze { opacity: 0; transition: opacity .25s ease; }
.freeze.on { opacity: 1; }
.freeze line { stroke: var(--brass); stroke-width: 1; }
.freeze text { font-family: var(--mono); font-size: 8.5px; fill: var(--brass); }

/* ---------------------------------------------------------------- record -- */

.trace-wrap { min-width: 0; display: flex; flex-direction: column; }

.trace-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink);
}

.eyebrow { font-size: 11px; font-weight: 600; }
#thread-label { color: var(--pencil); font-size: 11px; }

.trace { list-style: none; margin: 0; padding: 0; }

/* Each entry rules its own line. The paper is ruled exactly as far as the run
   got, and blank below — which is the freeze, drawn by the structure itself. */
.entry {
  padding: calc(var(--gap) * 1.25) 0;
  border-bottom: 1px solid var(--rule);
}

.entry-node { font-size: 12px; font-weight: 600; color: var(--ink); }
.entry-node .pass { color: var(--pencil); font-weight: 400; }

.line {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: var(--gap);
  margin-top: 5px;
  font-size: 12px;
}

.line .tag { color: var(--pencil); font-size: 11px; }
.line .body { color: var(--ink); word-break: break-word; white-space: pre-wrap; }

.line.tool-call .tag,
.line.tool-call .body { color: var(--brass); }
.line.tool-result .body { color: var(--pencil); }

.line details summary { cursor: pointer; color: var(--pencil); list-style: none; }
.line details summary::-webkit-details-marker { display: none; }
.line details summary::before { content: "+ "; color: var(--rule); }
.line details[open] summary::before { content: "− "; }
.line details pre {
  margin: 5px 0 0;
  padding: var(--gap);
  max-height: 240px;
  overflow: auto;
  background: var(--desk);
  border-left: 2px solid var(--rule);
  font: inherit;
  color: var(--pencil);
}

.empty { color: var(--pencil); font-size: 12px; padding-top: calc(var(--gap) * 2); }

/* -------------------------------------------------------------- annotate -- */

/* The human's part of the record: written onto the sheet, in the margin ink
   that marks every other decision point. */
.proposal {
  margin-top: calc(var(--gap) * 2);
  border-left: 3px solid var(--brass);
  padding: 0 0 0 calc(var(--gap) * 2);
  display: grid;
  gap: calc(var(--gap) * 1.5);
}

.verdict-row { display: flex; align-items: baseline; gap: var(--gap); flex-wrap: wrap; }

.verdict {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--brass);
}
.verdict[data-v="IGNORE"]   { color: var(--pencil); }
.verdict[data-v="ESCALATE"] { color: var(--stop); }

/* The number, written out. A filled progress bar would be decoration standing
   in for a figure that is already right there. */
.confidence { font-size: 11.5px; color: var(--pencil); }

.rationale {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 62ch;
}

.decide { display: flex; gap: var(--gap); }
.approve { background: var(--ink); color: var(--paper); font-weight: 600; }
.approve:hover:not(:disabled) { background: var(--brass); border-color: var(--brass); }
.reject { border-color: var(--stop); color: var(--stop); }
.reject:hover:not(:disabled) { background: var(--stop); color: var(--paper); }

.settled { font-size: 11.5px; color: var(--pencil); }

.error {
  border-left: 3px solid var(--stop);
  color: var(--stop);
  padding: 4px 0 4px var(--gap);
  margin-top: var(--gap);
  font-size: 12px;
}

/* ----------------------------------------------------------------- notes -- */

/* Marginalia, not a card grid. A label in the margin, prose in one column, the
   way an annotated document actually reads. */
.explainer {
  background: var(--paper);
  border-top: 1px solid var(--ink);
  padding-block: calc(var(--gap) * 6) calc(var(--gap) * 8);
}

.lede {
  margin: 0 0 calc(var(--gap) * 5);
  max-width: 44ch;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.5;
}

.note {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: calc(var(--gap) * 4);
  padding: calc(var(--gap) * 3) 0;
  border-top: 1px solid var(--rule);
}

.note h3 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--pencil);
}

.note p {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.65;
  max-width: 64ch;
}
.note p + p { margin-top: calc(var(--gap) * 1.5); }

.note b { font-weight: 600; }
.note code { font-family: var(--mono); font-size: 13px; color: var(--brass); }

.flow {
  margin: calc(var(--gap) * 2) 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--pencil);
  white-space: pre-wrap;
  overflow-x: auto;
}

.explainer-foot {
  margin-top: calc(var(--gap) * 4);
  padding-top: calc(var(--gap) * 2);
  border-top: 1px solid var(--ink);
  font-size: 11.5px;
  color: var(--pencil);
}

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

@media (max-width: 960px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .run { min-height: 0; }
  .note { grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
}

@media (max-width: 560px) {
  .bar-inner, .banner-inner, .explainer-inner, main {
    padding-inline: calc(var(--gap) * 1.5);
  }
  .run { grid-template-columns: 84px minmax(0, 1fr); padding: calc(var(--gap) * 2); }
  .node text { display: none; }
  /* Unreadable in an 84px rail, and the brass rule plus the pooled mark
     already say the pen stopped. */
  .freeze text { display: none; }
  .token { flex: 1 1 128px; }
  .token input { width: 100%; min-width: 0; }
  .line { grid-template-columns: minmax(0, 1fr); gap: 1px; }
  .explainer { padding-block: calc(var(--gap) * 4); }
  .lede { font-size: 17px; }
}

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