/* Same light palette as the other tools, plus one colour per kind of block. */
:root {
  color-scheme: light;
  --ink: #15202a;
  --muted: #61707d;
  --line: #d8e0e6;
  --line-strong: #a8b5bf;
  --paper: #f4f7f9;
  --surface: #ffffff;
  --sidebar: #edf2f5;
  --accent-dark: #c94f10;
  --shadow: 0 12px 34px rgba(20, 32, 42, 0.1);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Block colours. Harness blocks are cool, yours is the site orange, the
     model's are warm gold, green and blue. */
  --k-system: #4a5f86;
  --k-tools: #1f8a8a;
  --k-memory: #8a63d2;
  --k-conversation: #7d8d9b;
  --k-you: #ff7a2f;
  --k-thinking: #e0a526;
  --k-toolcall: #2f7d53;
  --k-results: #6dbb8a;
  --k-answer: #2d79ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
}

[hidden] { display: none !important; }
button { font: inherit; }
h2, p { margin: 0; }

.eyebrow { color: var(--muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }

[data-kind="system"] { --c: var(--k-system); --on: #fff; }
[data-kind="tools"] { --c: var(--k-tools); --on: #fff; }
[data-kind="memory"] { --c: var(--k-memory); --on: #fff; }
[data-kind="conversation"] { --c: var(--k-conversation); --on: #fff; }
[data-kind="you"] { --c: var(--k-you); --on: #1b120c; }
[data-kind="thinking"] { --c: var(--k-thinking); --on: #1b120c; }
[data-kind="toolcall"] { --c: var(--k-toolcall); --on: #fff; }
[data-kind="results"] { --c: var(--k-results); --on: #10251a; }
[data-kind="answer"] { --c: var(--k-answer); --on: #fff; }

/* ---- Layout: step bar on top, stack on the left, panel on the right ---- */
.anatomy {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 0.9rem;
  font-weight: 750;
  cursor: pointer;
}
.button.primary { color: #1b120c; background: var(--k-you); }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button:hover { filter: brightness(1.06); }
.button.secondary:hover { filter: none; background: var(--sidebar); }
.button:disabled { opacity: 0.4; cursor: default; filter: none; }
.button.secondary:disabled:hover { background: var(--surface); }

.view-switch {
  margin-left: auto;
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  overflow: hidden;
}
.view-switch button {
  min-height: 38px;
  padding: 6px 14px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.view-switch button + button { border-left: 1px solid var(--line-strong); }
.view-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 36px);
  padding: 20px clamp(16px, 3vw, 36px);
}

/* ---- The stack ---- */
.stack-col { min-height: 0; display: flex; flex-direction: column; gap: 12px; }

.meter-total { font-size: clamp(28px, 3.4vw, 40px); font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.meter-unit { font-size: 0.5em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.meter-note { font-size: 0.9rem; color: var(--muted); }

.stack-wrap { position: relative; flex: 1; min-height: 0; padding-right: 34px; }

/* Every block keeps its final slot, sized by its token count (small ones get
   a minimum height), so blocks appear where they will end up and the stack
   fills up as the turn goes on. */
.stack {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.seg {
  flex: var(--t) 1 0px;
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  background: var(--c);
  color: var(--on);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: opacity 300ms ease, filter 300ms ease, box-shadow 200ms ease;
}
.seg-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-tokens { font-variant-numeric: tabular-nums; opacity: 0.85; font-weight: 600; }
.seg.is-hidden { visibility: hidden; opacity: 0; }
.seg.is-current { box-shadow: 0 0 0 3px var(--ink); animation: pop-in 350ms ease-out; }
.seg.is-dim { opacity: 0.18; filter: grayscale(1); }
.seg:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
@keyframes pop-in { from { opacity: 0; transform: scaleX(0.94); } }
@media (prefers-reduced-motion: reduce) { .seg.is-current { animation: none; } }

.read-bracket {
  position: absolute;
  right: 0;
  width: 24px;
  border: 3px solid var(--ink);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  transition: top 300ms ease, height 300ms ease;
}
.read-bracket span {
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translate(-50%, -50%) rotate(180deg);
  writing-mode: vertical-rl;
  padding: 6px 2px;
  background: var(--paper);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.legend .harness { background: linear-gradient(90deg, var(--k-system) 50%, var(--k-results) 50%); }
.legend .you { background: var(--k-you); }
.legend .model { background: linear-gradient(90deg, var(--k-thinking) 50%, var(--k-answer) 50%); }

/* ---- The panel ---- */
.panel {
  min-height: 0;
  overflow-y: auto;
  padding: clamp(18px, 2.4vw, 32px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.view { display: flex; flex-direction: column; gap: 16px; }

.step-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--sidebar);
  color: var(--muted);
}
.tag[data-source="you"] { background: #ffe7d9; color: var(--accent-dark); }
.tag[data-source="model"] { background: #e3edff; color: #1d5bd0; }

.view h2 { font-size: clamp(24px, 2.6vw, 34px); line-height: 1.15; letter-spacing: -0.02em; }
.adds { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.body { max-width: 62ch; font-size: clamp(17px, 1.35vw, 20px); line-height: 1.55; }
.body q { font-weight: 650; }

.raw {
  margin: 0;
  padding: 16px 18px;
  border-radius: 4px;
  background: #121a22;
  color: #d9e2ea;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.raw.excerpt { border-left: 6px solid var(--c); }
.raw .marker { color: #8fa3b5; }
.raw .more { display: inline-block; margin: 4px 0; color: #ffb27d; font-style: italic; }

.view-intro { font-size: clamp(17px, 1.35vw, 20px); font-weight: 650; }

.raw-block {
  display: block;
  padding-left: 12px;
  border-left: 5px solid var(--c);
  opacity: 0.72;
}
.raw-block.is-current { opacity: 1; background: rgba(255, 255, 255, 0.06); }

.authors { display: flex; flex-direction: column; gap: 12px; max-width: 720px; margin-top: 8px; }
.authors ul { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.authors li { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 14px; font-weight: 700; }
.author-bar { height: 22px; border-radius: 3px; background: var(--sidebar); overflow: hidden; }
.author-bar span { display: block; height: 100%; border-radius: 3px; }
[data-source="harness"] .author-bar span { background: linear-gradient(90deg, var(--k-system), var(--k-tools), var(--k-results)); }
[data-source="model"] .author-bar span { background: linear-gradient(90deg, var(--k-thinking), var(--k-answer)); }
[data-source="you"] .author-bar span { background: var(--k-you); }
.author-n { font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---- Chat view ---- */
.chat { display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.bubble { max-width: 85%; padding: 12px 16px; border-radius: 14px; line-height: 1.5; }
.bubble p + p { margin-top: 10px; }
.bubble.user { align-self: flex-end; background: var(--sidebar); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-status { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.chat-status span { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.chat-note { font-weight: 650; color: var(--muted); }

.footnote { margin-top: auto; padding-top: 8px; font-size: 0.8rem; line-height: 1.5; color: var(--muted); }
.footnote code { font-family: var(--mono); font-size: 0.95em; }

/* ---- Narrow screens: everything in one scrolling column ---- */
@media (max-width: 760px) {
  .anatomy { overflow-y: auto; }
  .stage { flex: none; grid-template-columns: 1fr; }
  .stack-wrap { flex: none; height: 440px; }
  .panel { overflow: visible; }
  .view-switch { margin-left: 0; }
}
