:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #5c5a55;
  --line: #dedbd3;
  --accent: #b45309;
  --accent-text: #ffffff;
  --accent-soft: #fdf3e6;
  --focus: #1d4ed8;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --check: #8a5a00;
  --check-soft: #fff6e0;
  --missing: #4a5568;
  --missing-soft: #eef0f3;
  --good: #1e6b3a;
  --good-soft: #e8f4ec;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

main, .top, .foot {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

main { padding-bottom: 32px; }
main:focus { outline: none; }

.top { padding-top: 14px; padding-bottom: 6px; }
.brand { color: var(--accent); font-weight: 700; font-size: 1.15rem; text-decoration: none; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 18px 0 10px; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 18px 0 8px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }
h2:focus, h3:focus { outline: none; }
.lead { font-size: 1.05rem; color: var(--muted); }
p { margin: 8px 0; }
a { color: var(--focus); }

.choices { display: grid; gap: 14px; margin-top: 18px; }
.choice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
}
.choice h2 { margin-top: 2px; font-size: 1.15rem; }
.sample-list { display: grid; gap: 8px; margin-top: 10px; }
.sample-list .button { text-align: left; display: flex; flex-direction: column; align-items: flex-start; }
.sample-list .button span { font-weight: 400; font-size: 0.9rem; color: var(--muted); }

.button {
  display: inline-block;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary { background: var(--surface); color: var(--accent); }
.button.link { background: none; border-color: transparent; color: var(--focus); padding-left: 4px; padding-right: 4px; }
.button:disabled { opacity: 0.55; cursor: progress; }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }

.file-pick { display: inline-block; position: relative; margin: 8px 0; }
.file-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.file-pick:focus-within .button { outline: 3px solid var(--focus); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 0.92rem; }
.status { color: var(--muted); min-height: 1.5em; }
.status.error { color: var(--bad); }
.notes { padding-left: 20px; color: var(--muted); }

.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.previews figure { margin: 0; text-align: center; font-size: 0.8rem; color: var(--muted); }
.previews img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }

.spinner {
  width: 36px; height: 36px; margin: 16px 0;
  border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.mode {
  display: inline-block;
  margin: 14px 0 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 14px 0 0;
  padding: 10px 14px 14px;
  min-width: 0;
}
.group legend { font-weight: 700; padding: 0 4px; }

.field { display: block; margin-top: 12px; font-weight: 600; }
.field input, .field select, .row input, .row select {
  display: block;
  width: 100%;
  margin-top: 4px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #a8a49a;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.row { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; padding-top: 0; }
.row label { font-weight: 600; display: block; }
.evidence { font-size: 0.92rem; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; align-items: flex-start; }
.evidence q { quotes: "\"" "\""; color: var(--text); }
.evidence .warn { color: var(--bad); }
.thumb { flex: none; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: zoom-in; }
.thumb img { display: block; width: 52px; height: auto; border-radius: 3px; }
.text-thumb { flex: none; font-size: 0.8rem; min-height: 32px; padding: 4px 8px; }

.charge { border: 1px dashed var(--line); border-radius: 8px; padding: 4px 10px 10px; margin-top: 12px; }

.radio-set { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.radio-set legend { font-weight: 600; padding: 0; }
.radio-set .opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.radio-set label {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 6px 12px;
  border: 1px solid #a8a49a; border-radius: 999px; background: #fff; cursor: pointer;
}
.radio-set label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.finding-group { margin-top: 20px; }
.finding-group h3 { display: flex; align-items: center; gap: 8px; }
.finding {
  border: 1px solid var(--line);
  border-left: 5px solid var(--missing);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
  margin-top: 10px;
}
.finding h4 { margin: 0 0 4px; font-size: 1rem; }
.finding ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.93rem; }
.finding li { margin: 4px 0; }
/* A page thumbnail sits to the right of its line, so the quoted text never splits around it. */
.finding li .thumb { float: right; margin: 0 0 4px 10px; }
.finding li .thumb img { width: 40px; }
.finding li::after { content: ""; display: block; clear: both; }
.finding .rule, .finding .note { font-size: 0.9rem; color: var(--muted); }
.badge { font-size: 0.8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.status-inconsistent { border-left-color: var(--bad); }
.status-needs_confirmation { border-left-color: var(--check); }
.status-consistent { border-left-color: var(--good); }
.badge.status-inconsistent { background: var(--bad-soft); color: var(--bad); }
.badge.status-needs_confirmation { background: var(--check-soft); color: var(--check); }
.badge.status-missing, .badge.status-out_of_scope { background: var(--missing-soft); color: var(--missing); }
.badge.status-consistent { background: var(--good-soft); color: var(--good); }

.vendor { margin-top: 26px; }
.vendor ol { padding-left: 20px; }
.message {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.93rem;
}

.foot { border-top: 1px solid var(--line); padding-top: 12px; padding-bottom: 28px; color: var(--muted); font-size: 0.88rem; }

dialog {
  width: min(96vw, 900px);
  max-height: 92vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.viewer-head h3 { margin: 0; }
#page-viewer-body { padding: 12px; }
#page-viewer-body img { width: 100%; height: auto; }
.page-text { font-family: ui-monospace, Consolas, monospace; font-size: 0.88rem; white-space: pre-wrap; background: #fff; border: 1px solid var(--line); padding: 12px; }
.page-text mark { background: #ffe8a3; }

@media (min-width: 640px) {
  h1 { font-size: 2rem; }
  .choices { grid-template-columns: 1fr 1fr; }
  .choices .choice:first-child { grid-column: 1 / -1; }
  .sample-list { grid-template-columns: repeat(3, 1fr); }
  .charge-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
}
.check-this { margin-top: 0.35rem; }
.check-this .warn { color: var(--bad); display: block; }
.check-this .verify { display: flex; gap: 0.5rem; align-items: flex-start; margin-top: 0.25rem; font-size: 0.92rem; }
.page-frame { position: relative; display: block; width: 100%; }
.page-frame img { display: block; width: 100%; height: auto; }
.page-frame .hl { position: absolute; border: 2px solid #c2410c; background: rgba(250, 204, 21, 0.28); border-radius: 2px; pointer-events: none; box-sizing: border-box; }
.quote-link { all: unset; cursor: pointer; text-decoration: underline dotted; overflow-wrap: anywhere; }
.quote-link:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.candidates { margin: 6px 0 0; padding-left: 18px; }
.read-from { margin: 4px 0 0; overflow-wrap: anywhere; }
.operands ul { padding-left: 18px; overflow-wrap: anywhere; }

/* Language switch on the results screen */
.lang-switch { display: flex; gap: 0.25rem; align-items: center; justify-content: flex-end; }
.lang-switch [aria-pressed="true"] { font-weight: 700; text-decoration: none; }

/* "Fix a number" highlights the fields it came from */
.fix-target { outline: 3px solid var(--accent); outline-offset: 2px; background: var(--accent-soft); }
