/*
 * The engine console (live.html).
 * Two faces of the same data: the presenter view (default: the inbox beside what Continuity knows)
 * and the details console (body.details) with rail, thread, pipeline, streams, board, terminal.
 */

html, body { height: 100%; }
body { overflow: hidden; }

/* which face is showing */
body:not(.details) .app { display: none; }
body.details .pres { display: none; }

/* ============================================================ presenter view: inbox | Continuity */
.pres {
  --px: clamp(16px, 2.4vw, 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr); /* a long header must never widen the page */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- top bar: logo, beat counter, the beat itself, controls */
.p-top {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.6vw, 24px);
  min-height: 76px;
  padding: 10px var(--px);
  border-bottom: 1px solid var(--line-2);
}
.p-count {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font: 500 12px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.p-count:empty { display: none; }
.p-beat { display: flex; align-items: baseline; gap: 14px; min-width: 0; flex: 1; }
.p-beat h1 {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  font-size: clamp(22px, 2.3vw, 38px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
  white-space: nowrap;
  animation: pin 0.6s var(--ease);
}
.p-beat p {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: clamp(14px, 1.2vw, 19px);
  letter-spacing: -0.01em;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  animation: pin 0.7s var(--ease) 0.06s backwards;
}
@keyframes pin { from { opacity: 0; transform: translateY(8px); } }

.p-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font: 500 12px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}
.p-hint .spin { width: 7px; height: 7px; background: var(--signal); animation: blink 0.7s steps(2) infinite; }
.p-details {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: transparent;
  font: 500 11.5px var(--mono);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.p-details:hover { border-color: var(--ink-2); color: var(--ink); }

/* ---------- the split */
.split {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  min-height: 0;
  padding: 0 var(--px);
}
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; padding: 18px 0 16px; }

.side-h { display: flex; align-items: baseline; gap: 12px; min-height: 24px; }
.side-k {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 12px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.side-k b {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 11px;
  letter-spacing: 0;
}
.engine-side .side-k b { background: var(--signal); }
.side-k { flex: none; white-space: nowrap; }
.side-q { min-width: 0; overflow: hidden; font-size: 14px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

/* the seam between the halves: Primitive carries the mail across */
.seam { position: relative; display: grid; place-items: center; }
.seam::before {
  content: "";
  position: absolute;
  inset: 18px 50% 16px auto;
  width: 0;
  border-left: 1px dashed var(--line-2);
}
.seam span {
  position: relative;
  padding: 8px 0;
  background: var(--bg);
  font: 500 10.5px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.pkt-x {
  position: absolute;
  z-index: 5;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  background: var(--signal);
  pointer-events: none;
}
.pkt-x.out { background: var(--ink); }

/* ---------- A: the inbox, drawn the way Gmail draws it (its own light palette, whatever the page theme) */
.gm {
  --gm-ink: #1f1f1f;
  --gm-muted: #5e5e5e;
  --gm-line: #eceff1;
  --gm-row: #f2f6fc;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.15), 0 1px 3px 1px rgba(60, 64, 67, 0.08);
  font-family: Roboto, Arial, sans-serif;
  color: var(--gm-ink);
}
.gm-top { display: flex; align-items: center; gap: 14px; padding: 10px 14px 6px; }
.gm-search { display: flex; flex: 1; align-items: center; gap: 12px; height: 42px; padding: 0 16px; border-radius: 24px; background: #eaf1fb; font-size: 15px; color: #444746; }
.gm-search svg, .gm-ic { flex: none; width: 18px; height: 18px; fill: none; stroke: #444746; stroke-width: 2; stroke-linecap: round; }
.gm-addr { font-size: 12px; color: var(--gm-muted); white-space: nowrap; }
.gm-bar { display: flex; align-items: center; gap: 20px; height: 38px; padding: 0 16px 0 20px; }
.gm-box { flex: none; width: 13px; height: 13px; border: 2px solid #747775; border-radius: 2px; }
.gm-count { margin-left: auto; font-size: 12px; color: var(--gm-muted); }
.gm-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--gm-line); }
.gm .mrow {
  display: grid;
  grid-template-columns: 13px 18px minmax(110px, 190px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--gm-line);
  background: var(--gm-row);
  font-size: 14px;
  cursor: pointer;
}
.gm .mrow:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15); position: relative; z-index: 1; }
.gm .mrow.unread { background: #fff; }
.gm .mrow.open { background: #d3e3fd; }
.gm .gm-star { font-size: 17px; line-height: 1; color: #747775; }
.gm .mrow .who { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gm .mrow .who b, .gm .mrow.unread .subj, .gm .mrow.unread .meta { font-weight: 700; }
.gm .mrow .who small { font-size: 12px; color: var(--gm-muted); }
.gm .mrow .line { display: flex; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; }
.gm .mrow .subj { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.gm .mrow .snip { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--gm-muted); }
.gm .mrow .meta { font-size: 12px; color: var(--gm-muted); white-space: nowrap; }
.gm .mrow.fresh { animation: gm-in 0.7s var(--ease); }
@keyframes gm-in { from { opacity: 0; transform: translateY(-8px); background: #fef7e0; } }
.gm-draft { font-style: normal; color: #d93025; }
.gm-chip, .gm-file { display: inline-flex; flex: none; align-items: center; gap: 6px; border: 1px solid #c4c7c5; font-size: 12px; color: #444746; }
.gm-chip { max-width: 180px; margin-left: 10px; padding: 2px 10px 2px 6px; border-radius: 16px; overflow: hidden; text-overflow: ellipsis; }
.gm-chip i, .gm-file i { flex: none; padding: 1px 3px; border-radius: 2px; background: #ea4335; font: 700 8.5px Roboto, Arial, sans-serif; font-style: normal; color: #fff; }
.mail-empty { padding: 28px 20px; font-size: 14px; color: var(--gm-muted); list-style: none; }

.gm-read { min-height: 0; overflow: auto; padding: 18px 24px 24px; border-top: 1px solid var(--gm-line); }
.gm-read:empty { display: none; }
.gm-subj { margin: 0 0 12px 52px; font: 400 22px/1.3 Roboto, Arial, sans-serif; color: var(--gm-ink); }
.gm-label { margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: #ddd; font-size: 12px; vertical-align: 3px; color: #444746; }
.gm-msg { padding: 10px 0; }
.gm-msg + .gm-msg { border-top: 1px solid var(--gm-line); }
.gm-msg.min { display: flex; align-items: center; gap: 12px; padding-left: 8px; font-size: 14px; }
.gm-msg.min .gm-sn { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--gm-muted); }
.gm-head { display: flex; align-items: flex-start; gap: 12px; }
.gm-from { flex: 1; min-width: 0; font-size: 14px; }
.gm-from b { font-weight: 700; }
.gm-from small { margin-left: 4px; font-size: 12px; color: var(--gm-muted); }
.gm-from .gm-draft { margin-left: 6px; }
.gm-to { display: block; font-size: 12px; color: var(--gm-muted); }
.gm-when { flex: none; font-size: 12px; color: var(--gm-muted); white-space: nowrap; }
.gm-av { display: inline-grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--c); font: 500 17px Roboto, Arial, sans-serif; color: #fff; }
.gm-av.sm { width: 24px; height: 24px; font-size: 11px; }
.gm-by { margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: var(--ink); font: 500 10.5px var(--mono); color: var(--on-ink); vertical-align: 1px; }
.gm-body { margin: 10px 0 0 52px; font: 14px/1.6 Roboto, Arial, sans-serif; color: #222; white-space: pre-wrap; }
.gm-files { display: flex; gap: 8px; margin: 14px 0 0 52px; }
.gm-file { padding: 9px 14px 9px 10px; border-color: #dadce0; border-radius: 8px; font-size: 13px; }

/* ---------- B: Continuity's memory, as a graph */
.graph-wrap { display: flex; flex: 1; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
.graph { flex: 1; width: 100%; min-height: 0; }
.graph .e { stroke: var(--line-2); stroke-width: 1.2; transition: stroke 0.4s; }
.graph .e.mail-fact { stroke: var(--faint); stroke-width: 1; }
.graph .e.fact-hub { stroke: var(--ink-2); stroke-width: 1.5; }
.graph .e.fact-hub.bad { stroke: var(--signal); }
.graph .e.ghost { stroke: var(--faint); stroke-dasharray: 3 4; }
.graph .e.blocked { stroke: var(--signal); stroke-dasharray: 2 5; }
.graph .e.wrote { stroke: var(--ink-2); stroke-dasharray: 4 4; }
.graph .e.enter { animation: g-in 1s var(--ease); }
.graph .flow { stroke: var(--signal); stroke-width: 2.6; stroke-linecap: round; }
@keyframes g-in { from { opacity: 0; } }
.n.enter { animation: g-in 0.8s var(--ease); }
.n .name { font: 500 15px var(--mono); letter-spacing: 0.02em; fill: var(--muted); }
.n .value { font: 500 24px var(--sans); letter-spacing: -0.015em; fill: var(--ink); }
.n .dot, .n .core, .n .body { transform-box: fill-box; transform-origin: center; }
.n .halo { fill: none; stroke: none; }
.n.mail .dot { fill: var(--bg); stroke: var(--ink-2); stroke-width: 1.6; }
.n.mail.out .dot { fill: var(--ink-2); stroke: none; }
.n.mail .pdf { fill: var(--signal); }
.n.fact .dot { fill: var(--ink); }
.n.fact.bad .dot { fill: var(--signal); }
.n.fact.bad .name { fill: var(--signal-ink); }
.n.fact.bad .halo { stroke: var(--signal); stroke-width: 2; animation: ring 1.8s var(--ease) infinite; }
.n.fact.open .dot { fill: var(--bg); stroke: var(--ink); stroke-width: 3; }
.n.fact.kept .dot, .n.fact.ok .dot { fill: var(--ok); }
.n.ghost .dot { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.n.ghost .value { font-size: 18px; fill: var(--muted); text-decoration: line-through; text-decoration-color: var(--signal); }
.n.hub .core { fill: var(--ink); }
.n.hub .hub-t { font: 600 12px var(--mono); fill: var(--on-ink); }
.n.hub .req { fill: none; stroke: var(--line-2); stroke-width: 5; stroke-linecap: round; transition: stroke 0.5s; }
.n.hub .req.pass { stroke: var(--ok); }
.n.hub .req.fail { stroke: var(--signal); }
.n.blocked .dot { fill: var(--signal); }
.n.blocked .name { fill: var(--signal-ink); }
.n.blocked .value { font-size: 18px; fill: var(--muted); }
.n.agent .body { fill: var(--bg); stroke: var(--ink); stroke-width: 2; }
.n.agent.running .body { fill: var(--ink); }
.n.agent.killed .body { stroke: var(--signal); }
.n.agent .x { display: none; stroke: var(--signal); stroke-width: 3; stroke-linecap: round; }
.n.agent.killed .x { display: inline; }
.n.agent.killed text { fill: var(--muted); }
.n.agent .value { font-size: 16px; fill: var(--muted); }
@keyframes ring { from { r: 10px; stroke-opacity: 0.7; } to { r: 30px; stroke-opacity: 0; } }
.graph.focusing .n:not(.focus) { opacity: 0.3; }
.graph.focusing .e { opacity: 0.35; }
.graph .n, .graph .e { transition: opacity 0.6s var(--ease), stroke 0.4s; }
.graph .spark { fill: var(--signal); }
.n .ripple { fill: none; stroke: var(--signal); stroke-width: 2; }
.n text { transform-box: fill-box; paint-order: stroke; stroke: var(--bg); stroke-width: 6px; stroke-linejoin: round; }
.n.hub .hub-t { stroke: none; }

/* the only card on the right: a person being asked */
.en-now { flex: none; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.en-now .ln { margin-top: 4px; font-size: 16px; }
.en-now .ln.quiet { color: var(--muted); }
.nk { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font: 500 11px/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nk b { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-2); }

/* ---------- a person in the loop: the agent pauses and asks */
.en-now.human {
  border-color: var(--signal);
  background: linear-gradient(var(--signal-bg), var(--signal-bg)), var(--surface);
  box-shadow: inset 3px 0 0 var(--signal), 0 0 0 3px var(--signal-bg);
  animation: ask-in 0.5s var(--ease);
}
.en-now.human .nk span { color: var(--signal-ink); }
.en-now.human.done { border-color: var(--line-2); background: var(--surface); box-shadow: inset 3px 0 0 var(--ink); animation: none; }
@keyframes ask-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.hq { font-size: clamp(17px, 1.45vw, 23px); font-weight: 500; line-height: 1.25; letter-spacing: -0.02em; text-wrap: pretty; }
.hwhy { margin-top: 6px; font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.hfacts { display: flex; flex-wrap: wrap; gap: clamp(12px, 1.6vw, 24px); margin-top: 10px; }
.hfacts span { display: grid; gap: 1px; }
.hfacts b { font-size: clamp(18px, 1.5vw, 24px); font-weight: 500; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hfacts small { font: 11px var(--mono); color: var(--muted); }
.hdraft { margin-top: 8px; font: 13px/1.5 var(--mono); color: var(--ink-2); }
.hopts { display: grid; gap: 6px; margin-top: 12px; }
.hopts.approval, .hopts.verify { grid-template-columns: 1fr auto; }
.hopt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.hopt:hover { border-color: var(--ink); }
.hopt:active { transform: scale(0.99); }
.hopt:disabled { opacity: 0.5; cursor: progress; }
.hopt b { font-size: 14.5px; font-weight: 600; }
.hopt small { display: block; margin-top: 1px; font-size: 12.5px; line-height: 1.3; color: var(--muted); }
.hopt.primary { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.hopt.primary small { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.hopt.primary .kbd { border-color: color-mix(in srgb, var(--on-ink) 40%, transparent); color: var(--on-ink); }
.hopt .kbd { flex: none; }

.p-hint .you { padding: 2px 7px; border-radius: 4px; background: var(--signal); color: #fff; animation: breathe 1.6s ease-in-out infinite; }
.ag.wait { border-color: var(--signal); color: var(--signal-ink); }
.ag.wait i { background: var(--signal); animation: blink 0.9s steps(2) infinite; }


/* ---------- the thread, full width along the bottom */
.p-thread {
  padding: 8px var(--px) 10px;
  border-top: 1px solid var(--line-2);
  background-image: radial-gradient(var(--line-2) 0.8px, transparent 0.8px);
  background-size: 16px 16px;
}
.p-thread .thread-svg { height: clamp(96px, 13vh, 132px); }
.p-thread .thr-t { font-size: 12.5px; }
.p-thread .thr-t.small { font-size: 11.5px; }
.p-thread .empty { font-size: 13px; }

@media (max-width: 1000px) {
  body { overflow: auto; }
  .pres { height: auto; min-height: 100dvh; }
  .p-top { flex-wrap: wrap; }
  .p-beat { order: 5; flex-basis: 100%; flex-wrap: wrap; }
  .p-beat h1, .p-beat p { white-space: normal; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .seam { height: 28px; }
  .seam::before { inset: 0 auto 0 50%; }
  .seam span { writing-mode: horizontal-tb; transform: none; padding: 0 8px; }
  .gm { min-height: 560px; }
  .gm .mrow { grid-template-columns: 13px minmax(0, 1fr) auto; }
  .gm .gm-star, .gm .mrow .line { display: none; }
  .graph-wrap { min-height: 480px; }
  .cap { bottom: 16px; border-radius: 14px; }
}

/* ============================================================ details console: grid */
.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) minmax(340px, 420px);
  grid-template-rows: auto minmax(0, 1fr) 168px;
  grid-template-areas:
    "top  top    top"
    "rail center right"
    "rail term   right";
  gap: 8px;
  height: 100vh;
  height: 100dvh;
  padding: 0 8px 8px;
  background: var(--bg-2);
}

/* top bar */
.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  height: 52px;
  margin: 0 -8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.goal {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-2);
}
.goal #goal { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.badges .pill { height: 22px; padding: 0 8px; font-size: 10.5px; }
.badges .pill.ok   { color: var(--ok); }
.badges .pill.warn { color: var(--signal-ink); }
.badges .pill.v    { color: var(--ink); font-variant-numeric: tabular-nums; }

/* panel chrome */
.panel, .rail, .right, .term {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.sec-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sec-h .mono {
  overflow: hidden;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================ rail: beats, controls, processes */
.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 16px 12px;
}

.beats {
  display: grid;
  gap: 1px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.beat {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: background 0.3s, color 0.3s;
}
.beat .n { font: 500 11px/18px var(--mono); color: var(--faint); }
.beat .tt { font-size: 13px; font-weight: 500; line-height: 1.35; }
.beat .cp { display: none; margin-top: 3px; font-size: 12px; line-height: 1.4; color: var(--muted); }

.beat.done { color: var(--ink-2); }
.beat.done .n { color: var(--ok); }

.beat.next { background: var(--bg); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.beat.next .n { color: var(--ink); }
.beat.next .cp,
.beat.running .cp { display: block; }

.beat.running { background: var(--signal-bg); color: var(--ink); }
.beat.running .n { color: var(--signal); }
.beat.running::after {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  background: var(--signal);
  animation: blink 0.9s steps(2) infinite;
}
.beat.error { background: var(--signal-bg); color: var(--signal-ink); }

.ctl { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 20px; }
.ctl .run { --h: 42px; justify-content: space-between; }
.ctl .reset { --h: 42px; padding: 0 12px; font-size: 13px; }
.ctl .run.busy { background: transparent; border-color: var(--line-2); color: var(--ink-2); }

.procs { display: grid; gap: 4px; }
.proc {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 3px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  transition: border-color 0.3s, opacity 0.5s;
}
.proc .nm { font: 500 12.5px var(--mono); }
.proc .pid { font: 11px var(--mono); color: var(--muted); }
.proc .sub { grid-column: 1 / -1; font: 11px var(--mono); color: var(--muted); }
.proc.running { border-color: var(--line-2); }
.proc.killed { border-color: var(--signal); background: var(--signal-bg); }
.proc.killed .nm { color: var(--signal-ink); text-decoration: line-through; }
.proc.exited { opacity: 0.55; }

/* heartbeat trace */
.hb { width: 44px; height: 14px; color: var(--ink); }
.hb path { fill: none; stroke: currentColor; stroke-width: 1.25; }
.proc.engine .hb { color: var(--ok); }
.proc.running .hb path,
.proc.engine .hb path { stroke-dasharray: 60; animation: hb 1.4s linear infinite; }
@keyframes hb { from { stroke-dashoffset: 120; } to { stroke-dashoffset: 0; } }

/* ============================================================ center column */
.center {
  grid-area: center;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
}

.thread-panel { padding: 14px 16px 4px; }
.thread-panel .thread-svg { height: 140px; }

/* the pipeline */
.pipe-panel { padding: 10px; }
.pipe {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.pn {
  position: relative;
  z-index: 1;
  min-width: 0;
  margin: 0 3px;
  padding: 8px 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color 0.3s, background 0.3s;
}
.pn b {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pn span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font: 10.5px var(--mono);
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pn.busy::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 9px;
  width: 5px;
  height: 5px;
  background: var(--signal);
  animation: blink 0.7s steps(2) infinite;
}
.pn.lit { border-color: var(--ink); background: var(--bg); }
.pipe-line {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 50%;
  z-index: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line-2) 0 2px, transparent 2px 5px);
}
.pkt {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  background: var(--ink);
  pointer-events: none;
}
.pkt.out { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--ink); }

/* tabbed streams */
.stream-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px 12px 0;
}
.tabs { display: flex; gap: 2px; padding: 2px; border-radius: var(--r-sm); background: var(--bg-2); }
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
#handoff-dot:not(:empty) { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); font-size: 0; }

.stream {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

/* evidence cards */
.ev {
  margin-bottom: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
  animation: evin 0.5s var(--ease);
}
@keyframes evin { from { opacity: 0; transform: translateY(-6px); } }
.ev.out { box-shadow: inset 2px 0 0 var(--ink); }
.ev.unlinked { opacity: 0.55; border-style: dashed; }
.ev-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-size: 13px; }
.ev-h .who { font-weight: 500; }
.ev-h .who i { margin: 0 4px; font-style: normal; color: var(--muted); }
.ev-h .id { font: 11px var(--mono); color: var(--ink-2); }
.ev-h .meta { margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.ev-s {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin-top: 6px;
  font: 12px/1.6 var(--mono);
  color: var(--ink-2);
  white-space: pre-wrap;
  cursor: pointer;
}
.ev-s.open { display: block; -webkit-line-clamp: unset; }
.ev-a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* transition chips */
.trs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.tr {
  max-width: 100%;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--bg-2);
  font: 11px/1.4 var(--mono);
  color: var(--ink-2);
}
.tr.new { animation: trin 0.4s var(--ease) backwards; animation-delay: calc(var(--i) * 60ms + 0.2s); }
@keyframes trin { from { opacity: 0; transform: translateY(4px); } }
.tr.claim_superseded,
.tr.conflict_detected,
.tr.obligation_opened,
.tr.claim_tentative,
.tr.claim_contested,
.tr.injection_quarantined { background: var(--signal-bg); color: var(--signal-ink); }
.tr.obligation_resolved,
.tr.conflict_resolved,
.tr.check_passed { background: var(--ok-bg); color: var(--ok); }

/* agent handoff */
.handoff {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  animation: evin 0.5s var(--ease);
}
.ho-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
}
.ho-card.mail { border-color: var(--line-2); background: var(--surface); box-shadow: var(--shadow); }
.ho-k {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font: 500 10.5px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ho-k.blocked { margin-top: 10px; color: var(--signal-ink); }
.ho-big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.ho-big div b {
  display: block;
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.ho-big div span { font: 10.5px var(--mono); color: var(--muted); }
.ho-big .zero b { color: var(--signal); }
.ho-card pre {
  max-height: 300px;
  overflow: auto;
  margin: 0;
  font: 12px/1.6 var(--mono);
  color: var(--ink);
  white-space: pre-wrap;
}
.ho-acts { display: grid; gap: 4px; }
.ho-acts div { font-size: 12px; line-height: 1.4; color: var(--ink-2); }
.ho-acts div b { margin-right: 6px; font: 500 10.5px var(--mono); color: var(--muted); }

/* compiled briefing */
.briefing { margin: 0; font: 12px/1.6 var(--mono); color: var(--ink-2); white-space: pre-wrap; }
.briefing .h { color: var(--ink); font-weight: 500; }

/* ============================================================ right column: the state board */
.right {
  grid-area: right;
  overflow: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.right .b-card { background: var(--bg); }
.right .b-grid { grid-template-columns: 1fr; }

/* ============================================================ process output */
.term {
  grid-area: term;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 0;
}
.term pre {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding-bottom: 10px;
  font: 11.5px/1.6 var(--mono);
  color: var(--muted);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.term .ln { display: block; white-space: pre-wrap; animation: lnin 0.3s var(--ease); }
@keyframes lnin { from { opacity: 0; } }
.term .p { display: inline-block; min-width: 76px; color: var(--ink-2); }
.term .p.engine { color: var(--ok); }
.term .p.stage  { color: var(--ink); }
.term .l-mail { color: var(--ink); }
.term .l-kill { color: var(--signal-ink); }

/* ============================================================ full-screen moments (kill / born / end) */
.flashover {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.flashover.on { opacity: 1; }
.fo-in { position: relative; padding: 0 24px; text-align: center; }
.fo-k {
  font: 500 12px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.fo-t {
  margin: 18px 0 16px;
  font-size: clamp(56px, 10vw, 148px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.055em;
  transform: translateY(6px);
  transition: transform 0.6s var(--ease);
}
.flashover.on .fo-t { transform: none; }
.fo-s { font: 13px var(--mono); color: var(--ink-2); }
.fo-t em { font-style: normal; color: var(--faint); }

/* a hairline that is cut on a kill, and drawn on a birth */
.fo-in::before {
  content: "";
  display: block;
  width: min(420px, 60vw);
  height: 1.5px;
  margin: 0 auto 28px;
  background: var(--ink);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.8s var(--ease) 0.1s;
}
.flashover.on .fo-in::before { transform: scaleX(1); }
.flashover.kill .fo-t { color: var(--signal); }
.flashover.kill .fo-in::before {
  background: linear-gradient(90deg, var(--ink) 0 46%, transparent 46% 54%, var(--signal) 54%);
}
.flashover.end { pointer-events: auto; cursor: pointer; }
.flashover.end .fo-t { font-size: clamp(48px, 8vw, 116px); }

/* ============================================================ narrow screens: stack the console */
@media (max-width: 1180px) {
  body.details { overflow: auto; }
  .app {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas: "top" "rail" "center" "right" "term";
  }
  .top { flex-wrap: wrap; height: auto; padding: 12px 16px; }
  .goal { flex-basis: 100%; order: 3; }
  .center { grid-template-rows: auto auto 70vh; }
  .term { height: 260px; }
  .pipe { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 8px; }
  .pipe-line { display: none; }
  .handoff { grid-template-columns: 1fr; }
}

/* ---------- captions + spotlight (presenting and filming; C toggles) */
.cap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  max-width: min(880px, calc(100vw - 32px));
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: clamp(17px, 1.5vw, 24px);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.cap.on { opacity: 1; transform: translate(-50%, 0); }
.spot {
  position: fixed;
  z-index: 39;
  border: 2px solid var(--signal);
  border-radius: 12px;
  box-shadow: 0 0 0 6px var(--signal-bg);
  opacity: 0;
  pointer-events: none;
  transition: left 0.5s var(--ease), top 0.5s var(--ease), width 0.5s var(--ease), height 0.5s var(--ease), opacity 0.3s;
}
.spot.on { opacity: 1; }
body.no-cap .cap, body.details .cap { display: none; }
@media (prefers-reduced-motion: reduce) { .spot, .cap { transition: none; } }

/* ============================================================ presenter: show only what is in use
   No permanent chrome: the beat counter, version, controls and timeline stay out of the way, pipeline
   steps light up only while they work, and cards appear only once they have something to say. */
.pres { grid-template-rows: auto minmax(0, 1fr); }
.pres .p-count, .pres .p-details, .p-top .theme-btn, .pres #en-ver, .pres #p-thread { display: none; }
.pres .side { padding-bottom: 84px; } /* room for the caption */
.en-now.empty { display: none; }
.ib-agents:empty { display: none; }

/* ---------- an agent writing: Gmail's compose window */
.gm { position: relative; }
.gm-compose {
  position: absolute;
  right: 18px;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(560px, calc(100% - 36px));
  height: min(420px, 72%);
  border-radius: 10px 10px 0 0;
  background: #fff;
  box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2);
  font-family: Roboto, Arial, sans-serif;
  color: #1f1f1f;
  opacity: 0;
  transform: translateY(40px);
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.45s var(--ease);
}
.gm-compose.open { opacity: 1; transform: none; }
.gm-compose.sent { opacity: 0; transform: translate(-30%, -60%) scale(0.4); transition: opacity 0.42s ease-in, transform 0.42s cubic-bezier(0.55, 0, 0.75, 0.2); }
.gc-head { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px; border-radius: 10px 10px 0 0; background: #f2f6fc; font-size: 14px; }
.gc-who { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px; background: var(--ink); font: 500 11px var(--mono); color: var(--on-ink); white-space: nowrap; }
.gc-who::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: blink 0.9s steps(2) infinite; }
.gc-title { flex: 1; min-width: 0; overflow: hidden; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.gc-ctl { font-size: 13px; color: #444746; }
.gc-field { display: flex; gap: 10px; margin: 0 14px; padding: 9px 0; border-bottom: 1px solid #eceff1; font-size: 14px; color: #1f1f1f; }
.gc-field span { color: #5e5e5e; }
.gc-field b { padding: 0 8px; border-radius: 12px; background: #e8eaed; font-weight: 400; }
.gc-body { margin: 0; padding: 12px 14px; overflow: hidden; font: 14px/1.55 Roboto, Arial, sans-serif; white-space: pre-wrap; }
.gc-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px 14px; }
.gc-send { padding: 9px 24px; border-radius: 18px; background: #0b57d0; font-size: 14px; font-weight: 500; color: #fff; transition: transform 0.15s, background 0.15s; }
.gm-compose.sending .gc-send { background: #0842a0; transform: scale(0.92); }
.gm-compose.held .gc-send { background: #c4c7c5; }
.gc-note { font-size: 13px; font-weight: 500; color: var(--signal-ink); }
.gm-compose.held .gc-note::before { content: "● "; animation: blink 0.9s steps(2) infinite; }
.caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 1px; background: #0b57d0; vertical-align: -0.15em; animation: blink 0.8s steps(2) infinite; }

/* captions rise in a word at a time */
.cap.on #cap-t span { display: inline-block; animation: word-in 0.45s var(--ease) backwards; animation-delay: calc(var(--i) * 45ms); }
@keyframes word-in { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }
@media (prefers-reduced-motion: reduce) { .gm-compose, .cap.on #cap-t span { transition: none; animation: none; } }

/* ---------- the next press is due: a small arrow that breathes, only once a beat has fully landed */
.next-cue {
  position: fixed;
  right: 32px;
  bottom: 30px;
  z-index: 41;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  transform: translateX(-6px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}
.next-cue svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.next-cue.on { opacity: 1; transform: none; pointer-events: auto; }
.next-cue.on svg { animation: nudge 1.6s var(--ease-in-out) 0.6s infinite; }
.next-cue.on::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid var(--signal);
  border-radius: 50%;
  animation: halo 1.6s var(--ease) 0.6s infinite;
}
.next-cue:hover { background: var(--ink); color: var(--on-ink); }
@keyframes nudge { 0%, 60%, 100% { transform: none; } 30% { transform: translateX(3px); } }
@keyframes halo { from { opacity: 0.8; transform: scale(1); } to { opacity: 0; transform: scale(1.55); } }
body.details .next-cue, body.no-hint .next-cue, body.no-hint .p-hint { display: none; }
@media (prefers-reduced-motion: reduce) { .next-cue.on svg, .next-cue.on::after { animation: none; } }
