:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2330; --muted: #5d6677; --line: #dde1e8; --accent: #1f5fbf;
  --ok: #1b7a43; --ok-bg: #e5f4ea; --bad: #b42318; --bad-bg: #fdecea; --warn: #8a5a00; --warn-bg: #fff4dc;
  --chip: #eef1f6; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12.5px; }
h2 { font-size: 18px; margin: 0 0 8px; } h3 { font-size: 15px; margin: 0 0 10px; } h4 { font-size: 13.5px; margin: 16px 0 6px; }
p { margin: 6px 0; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 20px; background: #16202e; color: #fff; }
.top .brand { color: #fff; font-weight: 600; font-size: 15px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #c9d3e3; padding: 5px 10px; border-radius: 6px; }
.top nav a.on, .top nav a:hover { background: #2a3a52; color: #fff; text-decoration: none; }
.top .signout { color: #c9d3e3; font-size: 13px; }
.demo-flag { background: #ffd56b; color: #3d2d00; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 10px; }
main { max-width: 1280px; margin: 0 auto; padding: 16px 20px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; overflow-x: auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
.grid2 > .card { margin-bottom: 0; } .grid2 { margin-bottom: 16px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .empty { color: var(--muted); font-style: italic; }
.k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; margin-right: 4px; }
.hidden { display: none; }

/* forms */
input[type=text], textarea, select { font: inherit; border: 1px solid #c8ced8; border-radius: 6px; padding: 6px 8px; background: #fff; }
textarea { width: 100%; resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow, .grow { flex: 1; min-width: 200px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 0; }
legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
label.check { display: flex; flex-direction: row; gap: 6px; align-items: center; font-size: 13px; }
.tasks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.stack label.task-opt { display: flex; flex-direction: row; gap: 8px; align-items: flex-start; padding: 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.task-opt:hover { background: var(--chip); }
.task-opt input { margin-top: 3px; }
.task-opt .muted { font-size: 12px; }
button, .button { font: inherit; font-size: 13px; border: 1px solid #c3cad6; background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 6px; cursor: pointer; display: inline-block; }
button:hover, .button:hover { background: var(--chip); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover, .button.primary:hover { background: #184d9c; }
button.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
button.danger { color: var(--bad); border-color: #e3b2ad; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.small { padding: 2px 6px; font-size: 12px; }
.button.disabled { color: var(--muted); cursor: not-allowed; background: var(--chip); }
form.inline { display: inline; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 8px; background: #fafbfc; }
.tbl td { border-bottom: 1px solid #edf0f4; padding: 7px 8px; vertical-align: top; }
.tbl.compact td { padding: 5px 8px; font-size: 13px; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .actions { text-align: right; white-space: nowrap; }
.row-bad td { background: #fff8f7; }
.events td:first-child { white-space: nowrap; color: var(--muted); font-size: 12px; }
.ev-error td { color: var(--bad); } .ev-questions td, .ev-answers td { background: var(--warn-bg); } .ev-done td { background: var(--ok-bg); }

/* badges */
.badge { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 10px; background: var(--chip); color: #3b4456; white-space: nowrap; vertical-align: 1px; }
.st-ok, .st-done, .st-approved, .st-checked_ok, .st-answered, .st-resolved, .st-applied { background: var(--ok-bg); color: var(--ok); }
.st-bad, .st-failed, .st-issue, .st-rejected, .st-checks_failed, .st-error { background: var(--bad-bg); color: var(--bad); }
.st-warn, .st-waiting_for_answers, .st-changed, .st-defaulted, .st-noted, .st-pending-expert-review { background: var(--warn-bg); color: var(--warn); }
.st-running { background: #e6eefb; color: var(--accent); }
.conf-low { background: var(--warn-bg); color: var(--warn); } .conf-high { background: var(--ok-bg); color: var(--ok); }
.sev-high { background: var(--bad-bg); color: var(--bad); } .sev-medium { background: var(--warn-bg); color: var(--warn); }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 10px; background: #e6eefb; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* review page */
.review-head h2 { margin-bottom: 2px; }
.signoff { padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.signoff.blocked { background: var(--bad-bg); color: var(--bad); }
.signoff.clear { background: var(--ok-bg); color: var(--ok); }
.facts { display: flex; gap: 28px; flex-wrap: wrap; margin: 10px 0; }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.summary { font-size: 14.5px; max-width: 90ch; }
.decision, .open-item, .question, .proposal { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.decision.st-approved { border-left: 4px solid var(--ok); background: #fbfefc; }
.decision.st-changed { border-left: 4px solid var(--warn); }
.open-item.blocking, .question.blocking { border-left: 4px solid var(--bad); }
.closed { opacity: .75; }
.q-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.q-id { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.q-meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 6px 0 8px; font-size: 13px; }
.q-meta dt { color: var(--muted); } .q-meta dd { margin: 0; }
.meta-line { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: baseline; font-size: 13px; margin: 4px 0; }
.decide { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
details.change > summary { list-style: none; }
details.change > summary::-webkit-details-marker { display: none; }
details.change[open] { flex: 1; }
details.change[open] > summary { margin-bottom: 8px; }
.changed { background: var(--warn-bg); padding: 6px 8px; border-radius: 6px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 12px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
ul.trace, ul.trace ul { list-style: none; padding-left: 18px; margin: 4px 0; }
ul.trace { padding-left: 0; }
ul.trace li { margin: 3px 0; }
ul.trace ul { border-left: 1px dashed #c8ced8; }
.tn-label { font-weight: 600; } .tn-value { font-family: var(--mono); margin: 0 6px; }
.tn-op { font-size: 11.5px; background: #eef1f6; padding: 0 6px; border-radius: 4px; color: #4b5568; }
.tn-src { font-size: 12.5px; color: var(--muted); margin-left: 6px; }
pre.err, pre.body { white-space: pre-wrap; background: #f7f8fa; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12.5px; }
.callout { background: #eef4fd; border: 1px solid #c9daf5; padding: 10px 12px; border-radius: 8px; margin: 10px 0; }

/* cell links and panel */
.cells { display: inline-flex; flex-wrap: wrap; gap: 4px; }
a.cell-link, a.doc-link { display: inline-flex; gap: 4px; align-items: baseline; background: #eef3fc; border: 1px solid #d3e0f6; border-radius: 5px; padding: 0 6px; color: #1b4d99; font-size: 12.5px; white-space: nowrap; }
a.cell-link:hover { background: #dce8fb; text-decoration: none; }
a.doc-link:hover { background: #dce8fb; text-decoration: none; }
a.cell-link.labeled { display: inline; white-space: normal; font-size: 13px; }
a.cell-link.labeled .tab { font-weight: 600; }
a.cell-link.labeled .addr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; white-space: nowrap; }
a.guide-link { color: #1b4d99; text-decoration: underline dotted; text-underline-offset: 3px; }
a.guide-link:hover { text-decoration-style: solid; }
.cell-label { color: #4b5b78; font-size: 12px; }
.src { font-size: 12.5px; background: var(--chip); border-radius: 5px; padding: 0 6px; }
.cell-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(20, 30, 50, .12); padding: 14px 16px; overflow: auto; z-index: 10; }
.cell-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cell-panel-head button { font-size: 20px; }
.cell-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; margin-bottom: 12px; }
.cell-facts dt { color: var(--muted); } .cell-facts dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.grid-wrap { overflow: auto; }
table.cellgrid { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.cellgrid th { background: #f1f3f6; color: var(--muted); font-weight: 500; padding: 2px 6px; border: 1px solid #e1e4ea; }
table.cellgrid td { border: 1px solid #e1e4ea; padding: 2px 6px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
table.cellgrid td.f { color: #1b4d99; }
table.cellgrid td.target { background: #fff3c4; outline: 2px solid #e0b100; outline-offset: -2px; }
table.cellgrid td.num { text-align: right; }
.ask-answer { border-top: 1px solid var(--line); padding-top: 10px; }
.ask-answer .answer-text { white-space: pre-wrap; }
@media (max-width: 720px) { .tasks { grid-template-columns: 1fr; } main { padding: 12px; } .top { padding: 8px 12px; } }

/* details page: what matters first, the process folded away at the end; the chat's calm palette */
:root { --bg: #faf9f6; --ink: #2b2a27; --muted: #7a766e; --line: #e5e2d9; --accent: #2f5f9e; --chip: #efece4; }
.top { background: #f2f0ea; color: var(--ink); border-bottom: 1px solid var(--line); }
.top .brand { color: var(--ink); }
.top nav a { color: var(--muted); }
.top nav a.on, .top nav a:hover { background: #e5e2d9; color: var(--ink); }
.top .signout { color: var(--muted); }
.review-head .back { margin: 0 0 4px; font-size: 13.5px; }
.review-head h2 { margin-top: 0; font: 400 24px/1.3 ui-serif, "Iowan Old Style", Georgia, serif; }
.jump { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; }
details.process > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
details.process > summary::-webkit-details-marker { display: none; }
details.process > summary h3 { margin: 0; display: inline; }
details.process > summary h3::before { content: '\25B8\00a0'; color: var(--muted); }
details.process[open] > summary h3::before { content: '\25BE\00a0'; }
details.process[open] > summary { margin-bottom: 12px; }
@media (max-width: 700px) {
  main { padding: 12px 12px 48px; }
  .card { padding: 14px; }
  .head-row { flex-direction: column; }
}

/* details page: the step-by-step account (one plain line per step, raw bodies folded and loaded on demand) */
#steps .turn { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
#steps .turn:first-of-type { border-top: 0; margin-top: 4px; }
.turn-msg { color: var(--ink); font-style: italic; margin-left: 4px; overflow-wrap: anywhere; }
.measure { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 10px 0 8px; padding: 10px 12px; background: var(--chip); border-radius: 8px; }
.measure .figs { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; flex: 1 1 320px; align-content: flex-start; }
.measure .figs div { min-width: 0; }
.measure dt { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.measure dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.measure .where { flex: 1 1 360px; min-width: 0; }
.bar-row { display: grid; grid-template-columns: minmax(0, 15em) 1fr 4.5em; gap: 8px; align-items: center; font-size: 12.5px; margin: 2px 0; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row.sub .lbl { padding-left: 1.2em; color: var(--muted); }
.bar-row .bar { height: 8px; background: #fff; border-radius: 4px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--accent); opacity: .75; border-radius: 4px; }
.bar-row.sub .bar i { opacity: .4; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
ol.steps { list-style: none; margin: 6px 0; padding: 0; }
ol.steps.nested { margin-left: 14px; padding-left: 10px; border-left: 2px solid var(--line); }
li.step { margin: 0; }
details.raw > summary { cursor: pointer; list-style: none; display: flex; gap: 4px 12px; align-items: baseline; padding: 4px 6px; border-radius: 6px; }
details.raw > summary::-webkit-details-marker { display: none; }
details.raw > summary:hover { background: var(--chip); }
details.raw > summary .line { flex: 1; min-width: 0; overflow-wrap: anywhere; }
details.raw > summary .line::before { content: '\25B8\00a0'; color: var(--muted); font-size: 11px; }
details.raw[open] > summary .line::before { content: '\25BE\00a0'; }
details.raw .why { color: var(--muted); font-style: italic; }
details.raw .why::after { content: ' \2014'; }
details.raw .got { color: var(--muted); }
li.step.err .got { color: var(--bad); }
li.step.k-brief .did, li.step.k-reply .did { font-weight: 600; }
details.raw .meta { flex: none; color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.raw-body { margin: 2px 0 8px 18px; }
.raw-part { margin: 6px 0; }
pre.raw-pre { margin: 2px 0 0; padding: 8px 10px; max-height: 360px; overflow: auto; background: #f4f2ec; border: 1px solid var(--line); border-radius: 6px; font: 11.5px/1.4 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
details.worker { margin: 2px 0 6px 18px; }
details.worker > summary { cursor: pointer; padding: 3px 6px; border-radius: 6px; }
details.worker > summary:hover { background: var(--chip); }
details.worker.err > summary strong { color: var(--bad); }
#steps .totals { margin-top: 6px; }
@media (max-width: 700px) {
  details.raw > summary { flex-wrap: wrap; }
  details.raw > summary .line { flex-basis: 100%; }
  details.raw .meta { white-space: normal; padding-left: 1.2em; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 30% 4em; }
  ol.steps.nested { margin-left: 4px; padding-left: 6px; }
  details.worker, .raw-body { margin-left: 6px; }
}
