:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #69777f;
  --line: #dfe4e7;
  --paper: #f7f8f9;
  --panel: #ffffff;
  --accent: #176b87;
  --claim: #7c4d20;
  --claim-bg: #fff3df;
  --entity-bg: #edf6f8;
  --class-bg: #f1effa;
  --literal-bg: #f5f5f4;
  --evidence-bg: #ecf7ef;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
header, main, .error { width: min(960px, calc(100% - 40px)); margin-inline: auto; }
body.review-mode header, #review { width: min(1400px, calc(100% - 40px)); }
header { padding: 40px 0 20px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tabs button { padding: 8px 13px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; }
.tabs button.active { border-color: var(--line); background: var(--panel); color: var(--ink); }
.controls { display: grid; grid-template-columns: minmax(240px, .75fr) minmax(360px, 1.25fr); gap: 14px; }
.controls[hidden] { display: none; }
label { display: grid; gap: 7px; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
select { width: 100%; padding: 12px 38px 12px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }
main { display: grid; gap: 14px; padding-bottom: 60px; }
section { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
h1 { margin: 0 0 16px; font-size: 1rem; }
h2 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.llm-explanation { border-left: 3px solid var(--accent); background: #f0f6f8; }
.explanation-block { padding: 16px 18px; }
.explanation-block + .explanation-block { border-top: 1px solid #d7e6ea; }
.explanation-block p { margin: 8px 0 0; line-height: 1.55; }
.graph-explanation { display: grid; gap: 8px; margin: 10px 0 0; padding-left: 22px; }
.graph-explanation li { padding-left: 3px; line-height: 1.5; }
.explanation-loading { display: flex; align-items: center; gap: 9px; margin: 0; padding: 18px; color: var(--muted); }
.explanation-loading span { width: 14px; height: 14px; border: 2px solid #b6cbd2; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.explanation-error { margin: 0; padding: 16px 18px; color: #9f1b1b; background: #fbe7e7; }
@keyframes spin { to { transform: rotate(360deg); } }
.raw-result { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.raw-result summary { display: flex; align-items: center; gap: 8px; padding: 11px 13px; color: var(--muted); font-size: .74rem; font-weight: 700; cursor: pointer; list-style: none; }
.raw-result summary::-webkit-details-marker { display: none; }
.raw-result summary::before { content: "›"; font-size: 1rem; line-height: 1; transition: transform 120ms ease; }
.raw-result[open] summary::before { transform: rotate(90deg); }
.raw-result-body { padding: 4px 13px 14px; }
.raw-result-body > h2 { margin: 14px 0 10px; }
.expected { margin-bottom: 20px; padding: 15px 16px; border-left: 3px solid var(--accent); background: #f0f6f8; }
.expected p { margin: 8px 0 0; line-height: 1.5; }
.match { padding: 4px 7px; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.match.pass { color: #17633a; background: #e5f5eb; }
.match.fail { color: #9f1b1b; background: #fbe7e7; }
.returned-row { padding: 14px 15px; border: 1px solid var(--line); border-radius: 8px; }
.returned-row + .returned-row { margin-top: 9px; }
.result-number { margin: 0 0 12px; color: var(--accent); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 18px; margin: 0; }
dl div { min-width: 0; }
dt { margin-bottom: 4px; color: var(--muted); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
dd { margin: 0; font-size: .86rem; line-height: 1.35; overflow-wrap: anywhere; }
.picker { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.picker:empty { display: none; }
.picker button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); cursor: pointer; }
.picker button.active { border-color: var(--accent); background: var(--accent); color: white; }
.traversal { min-width: 0; }
.graph-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.graph-header p, .graph-note { margin: 0; color: var(--muted); font-size: .7rem; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 10px; }
.graph-legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .68rem; }
.graph-legend i { display: inline-block; width: 10px; height: 10px; border: 1px solid #8da1a9; border-radius: 3px; background: var(--entity-bg); }
.graph-legend i.claim { border-color: #c78b43; background: var(--claim-bg); }
.graph-legend i.class { border-color: #9c91c7; background: var(--class-bg); }
.graph-legend i.literal { border-color: #aaa7a2; background: var(--literal-bg); }
.graph-legend i.evidence { border-color: #80ae8d; background: var(--evidence-bg); }
.graph-legend i.answer-node { border: 2px solid var(--accent); background: white; }
.graph-shell { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background-color: #fbfcfc; background-image: radial-gradient(#dce4e7 0.7px, transparent 0.7px); background-size: 16px 16px; }
.trace-graph { display: block; width: 100%; min-width: 720px; height: auto; }
.graph-edge, .graph-node { transition: opacity 120ms ease; }
.graph-edge path { fill: none; stroke: #78909a; stroke-width: 1.6; }
.graph-edge.optional path { stroke-dasharray: 5 4; }
#trace-arrow path { fill: #78909a; }
.edge-label-bg { fill: rgba(251, 252, 252, .94); stroke: #e6ebed; stroke-width: .8; }
.edge-label { fill: #4f6973; font-size: 10px; font-weight: 650; text-anchor: middle; }
.graph-node { cursor: default; outline: none; }
.graph-node rect { fill: var(--entity-bg); stroke: #86a9b5; stroke-width: 1.4; transition: stroke-width 120ms ease, filter 120ms ease; }
.graph-node text { fill: var(--ink); font-size: 11px; font-weight: 650; text-anchor: middle; pointer-events: none; }
.graph-node.claim rect { fill: var(--claim-bg); stroke: #c78b43; }
.graph-node.class rect { fill: var(--class-bg); stroke: #9c91c7; }
.graph-node.literal rect { fill: var(--literal-bg); stroke: #aaa7a2; }
.graph-node.evidence rect { fill: var(--evidence-bg); stroke: #80ae8d; }
.graph-node.answer-node rect { stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 2px 3px rgba(23, 107, 135, .15)); }
.trace-graph.has-focus .graph-edge, .trace-graph.has-focus .graph-node { opacity: .13; }
.trace-graph.has-focus .graph-edge.active, .trace-graph.has-focus .graph-node.active { opacity: 1; }
.graph-node:focus rect { stroke-width: 3; }
.graph-note { margin-top: 8px; text-align: right; }
.empty { margin: 0; color: var(--muted); }
.error { color: #9f1b1b; }
.review-panel { padding: 0; overflow: hidden; }
.review-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.review-heading h1 { margin-bottom: 5px; }
.review-heading p { margin: 0; color: var(--muted); font-size: .8rem; }
.review-actions { display: flex; gap: 8px; flex-shrink: 0; }
.primary-action, .secondary-action { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 12px; border-radius: 7px; font: inherit; font-size: .75rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.primary-action { border: 1px solid var(--accent); background: var(--accent); color: white; }
.primary-action:disabled { opacity: .55; cursor: wait; }
.secondary-action { border: 1px solid var(--line); background: white; color: var(--ink); }
.sheet-tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid #c9d0d3; background: #f2f4f5; }
.sheet-tabs button { padding: 8px 14px; border: 1px solid transparent; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
.sheet-tabs button.active { border-color: #c9d0d3; border-bottom-color: var(--accent); background: white; color: var(--ink); }
.review-table-shell { width: 100%; height: calc(100vh - 250px); min-height: 400px; overflow: auto; }
.review-table { width: 100%; min-width: 1220px; border-collapse: collapse; font-size: .76rem; line-height: 1.45; }
.review-table thead th { position: sticky; z-index: 2; text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }
.review-table .column-letters th { top: 0; height: 24px; padding: 4px 10px; border-right: 1px solid #c9d0d3; border-bottom: 1px solid #c9d0d3; color: #5f6a70; background: #eef1f2; text-align: center; }
.review-table .field-names th { top: 24px; padding: 10px 12px; color: white; background: #173f35; }
.review-table td { padding: 13px 12px; border-bottom: 1px solid rgba(23, 32, 38, .08); vertical-align: top; }
.cq-table th:nth-child(1) { width: 42px; }
.cq-table th:nth-child(2) { width: 150px; }
.cq-table th:nth-child(3) { width: 72px; }
.cq-table th:nth-child(4) { width: 250px; }
.cq-table th:nth-child(5) { width: 330px; }
.cq-table th:nth-child(6) { width: 220px; }
.cq-table th:nth-child(7) { width: 230px; }
.spec-table { min-width: 1360px; }
.spec-table th:nth-child(1) { width: 42px; }
.spec-table th:nth-child(2) { width: 90px; }
.spec-table th:nth-child(3) { width: 145px; }
.spec-table th:nth-child(4) { width: 170px; }
.spec-table th:nth-child(5) { width: 185px; }
.spec-table th:nth-child(6) { width: 245px; }
.spec-table th:nth-child(7) { width: 295px; }
.spec-table th:nth-child(8) { width: 190px; }
.review-table .row-number { padding: 13px 8px; border-right: 1px solid #c9d0d3; border-bottom: 1px solid #c9d0d3; color: #68757b; background: #f1f3f4; text-align: center; font-size: .68rem; font-weight: 600; }
.topic-cell, .cq-cell { font-weight: 700; }
.provenance-cell { color: #48585f; font-size: .7rem; }
.review-table textarea { width: 100%; min-height: 82px; resize: vertical; padding: 9px; border: 1px solid rgba(23, 32, 38, .18); border-radius: 6px; background: rgba(255,255,255,.78); color: var(--ink); font: inherit; line-height: 1.4; }
.topic-multiplication td { background: #e2f0d9; }
.topic-multiplication-to-factoring td { background: #c6e0b4; }
.topic-addition-circuits td { background: #ddebf7; }
.topic-addition-to-factoring td { background: #bdd7ee; }
.topic-shor-implementations td { background: #fff2cc; }
.topic-cross-paper-structure td { background: #e4dfec; }
.topic-evidence-status td { background: #fce4d6; }
.spec-vocabulary td { background: #eef7f1; }
.spec-axiom td { background: #fff5dc; }
.group-cell, .spec-id { font-weight: 700; }
.formal-cell { color: #405158; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; }
.cq-links { margin: 8px 0 0; color: var(--muted); font-size: .67rem; }
.review-status { min-height: 18px; margin: 0; padding: 10px 22px 14px; color: var(--muted); font-size: .75rem; }

@media (max-width: 700px) {
  .controls { grid-template-columns: 1fr; }
  .graph-header { align-items: flex-start; flex-direction: column; gap: 7px; }
  .graph-note { text-align: left; }
  .review-heading { align-items: flex-start; flex-direction: column; }
}
