:root {
  --paper: #f5f2e9;
  --paper-bright: #fffdf7;
  --ink: #11120f;
  --muted: #666b67;
  --rule: #c9c8bd;
  --blue: #1649ff;
  --blue-dark: #0a2fb8;
  --green: #087e56;
  --green-pale: #d9f2e8;
  --red: #d43c22;
  --red-pale: #fbe0d8;
  --amber: #9a5b00;
  --amber-pale: #f6e5bd;
  --steel: #e2e7e9;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Cabinet Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, textarea { font: inherit; letter-spacing: 0; }
button { touch-action: manipulation; }
button:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.masthead {
  min-height: 58px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 253, 247, 0.96);
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--ink);
  color: white;
  font-size: 11px;
}

.runtime-status {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  text-align: right;
}

main { width: 100%; max-width: 100%; overflow-x: hidden; }

.intro {
  padding: 48px 4vw 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.55fr);
  align-items: end;
  gap: clamp(28px, 6vw, 88px);
  border-bottom: 1px solid var(--ink);
  background:
    linear-gradient(90deg, transparent 0 74%, rgba(22, 73, 255, 0.08) 74% 100%),
    var(--paper-bright);
}

.intro h1 {
  max-width: 1100px;
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.9rem);
  line-height: 0.96;
  font-weight: 850;
  letter-spacing: 0;
  text-wrap: balance;
}

.lede {
  max-width: 760px;
  margin: 20px 0 0;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  line-height: 1.45;
  color: #343732;
}

blockquote {
  margin: 0;
  padding: 0 0 5px 22px;
  border-left: 5px solid var(--blue);
}

blockquote p {
  margin: 0;
  font: 700 clamp(1.05rem, 1.7vw, 1.45rem)/1.25 Georgia, serif;
}

blockquote cite {
  display: block;
  margin-top: 11px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.workspace { padding: 22px 4vw 30px; }

.action-rail {
  display: grid;
  grid-template-columns: repeat(4, max-content) 40px;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 16px;
}

.button, .icon-button {
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.button { padding: 9px 14px; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { transform: translateY(-2px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-primary { background: var(--blue); color: white; border-color: var(--blue); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-dark { background: var(--ink); color: white; }
.button-light { background: var(--paper-bright); color: var(--ink); }
.button-light:hover { background: var(--steel); }
.icon-button { width: 40px; padding: 0; background: transparent; color: var(--ink); font-size: 22px; }

.input-error {
  margin: 0 0 16px;
  border: 2px solid var(--red);
  background: var(--red-pale);
  padding: 12px 14px;
}
.input-error[hidden], .result-panel[hidden] { display: none; }
.input-error ol { margin: 6px 0 0; padding-left: 22px; font-size: 13px; }

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
}

.editor-sheet {
  min-width: 0;
  border: 1px solid var(--ink);
  background: var(--paper-bright);
}

.sheet-head {
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--ink);
}

.sheet-code, .proof-label {
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.sheet-head h2 { margin: 2px 0 0; font-size: 16px; line-height: 1.1; }
.schema { color: var(--muted); font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }

textarea {
  display: block;
  width: 100%;
  height: 138px;
  resize: vertical;
  border: 0;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  overflow: auto;
}

.editor-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
kbd { padding: 1px 5px; border: 1px solid var(--rule); background: white; font-family: ui-monospace, monospace; }

.result-panel {
  border-top: 1px solid var(--ink);
  background: var(--paper-bright);
}

.verdict-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.48fr);
  gap: 40px;
  padding: 26px 4vw;
  background: var(--ink);
  color: white;
}

.verdict-band h2 {
  margin: 6px 0 8px;
  max-width: 900px;
  font-size: clamp(1.9rem, 4vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.verdict-band p { margin: 0; max-width: 780px; color: #cfd2ce; line-height: 1.45; }
.scoreboard { display: flex; flex-direction: column; justify-content: center; gap: 7px; border-left: 1px solid #555a55; padding-left: 28px; }
.scoreboard strong { font-size: clamp(1.05rem, 2vw, 1.55rem); }
.scoreboard span { color: #b9bdb8; font-size: 13px; }

.matrix-head {
  padding: 22px 4vw 13px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}
.matrix-head h3 { margin: 3px 0 0; font-size: 21px; }
.matrix-head > p { margin: 0; color: var(--muted); font: 11px/1.3 ui-monospace, monospace; text-align: right; }

.evidence-matrix { margin: 0 4vw; border-top: 1px solid var(--ink); }
.evidence-row {
  --status-color: var(--muted);
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(160px, 0.8fr) minmax(200px, 1fr) minmax(180px, 1.35fr);
  min-width: 0;
  border-bottom: 1px solid var(--ink);
  box-shadow: inset 6px 0 0 var(--status-color);
  transform-origin: top;
}
.evidence-row[data-category="FIRSTHAND VERIFIED"] { --status-color: var(--green); background: linear-gradient(90deg, var(--green-pale), transparent 45%); }
.evidence-row[data-category="FIRSTHAND UNDOCUMENTED"] { --status-color: var(--amber); background: linear-gradient(90deg, var(--amber-pale), transparent 45%); }
.evidence-row[data-category="HEARSAY ONLY"] { --status-color: var(--red); background: linear-gradient(90deg, var(--red-pale), transparent 45%); }
.evidence-row[data-category="UNTESTED"] { --status-color: #656b71; background: linear-gradient(90deg, var(--steel), transparent 45%); }
.evidence-cell { min-width: 0; padding: 14px 14px 14px 18px; border-right: 1px solid var(--rule); }
.evidence-cell:last-child { border-right: 0; }
.cell-label { display: block; margin-bottom: 5px; color: var(--muted); font: 9px/1.2 ui-monospace, monospace; text-transform: uppercase; }
.question { font: 700 17px/1.18 Georgia, serif; }
.category { color: var(--status-color); font-size: 12px; font-weight: 900; }
.mono { overflow-wrap: anywhere; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.explanation { color: #353934; font-size: 12px; line-height: 1.4; }

.result-footer {
  padding: 24px 4vw 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.55fr);
  gap: 40px;
  align-items: center;
}
.boundary-copy { max-width: 780px; border-left: 5px solid var(--red); padding-left: 14px; }
.boundary-copy p { margin: 5px 0 0; color: var(--muted); line-height: 1.45; }
.export-actions { display: grid; gap: 7px; }
.export-actions p { margin: 0; color: var(--muted); font-size: 12px; }

footer {
  min-height: 84px;
  padding: 22px 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--blue);
  color: white;
}
footer p { margin: 0; }
footer a { color: white; font-weight: 800; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 840px) {
  .intro { grid-template-columns: 1fr; align-items: start; gap: 24px; padding-top: 34px; }
  .action-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .icon-button { width: 100%; }
  .editor-grid { grid-template-columns: 1fr; }
  .verdict-band, .result-footer { grid-template-columns: 1fr; }
  .scoreboard { border-left: 0; border-top: 1px solid #555a55; padding: 18px 0 0; }
  .evidence-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evidence-cell:nth-child(2) { border-right: 0; }
  .evidence-cell:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
}

@media (max-width: 520px) {
  .masthead { padding: 0 16px; gap: 8px; }
  .brand { font-size: 13px; }
  .brand-mark { width: 30px; height: 30px; }
  .runtime-status { max-width: 145px; font-size: 9px; }
  .intro, .workspace, .verdict-band, .matrix-head, .result-footer { padding-left: 16px; padding-right: 16px; }
  .intro h1 { font-size: 2.55rem; }
  .action-rail { gap: 6px; }
  .button { padding: 9px 7px; font-size: 11px; white-space: normal; line-height: 1.15; }
  .sheet-head { align-items: flex-start; }
  .schema { max-width: 115px; }
  textarea { height: 176px; font-size: 10px; }
  .matrix-head { align-items: flex-start; }
  .evidence-matrix { margin-left: 16px; margin-right: 16px; }
  .evidence-row { grid-template-columns: 1fr; }
  .evidence-cell { border-right: 0; border-bottom: 1px solid var(--rule); }
  .evidence-cell:last-child { border-bottom: 0; }
  footer { padding: 20px 16px; flex-direction: column; align-items: flex-start; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
