:root {
  --ink: #18201d;
  --muted: #64706b;
  --paper: #f5f4ef;
  --surface: #ffffff;
  --line: #d9ddd8;
  --line-strong: #b6beb8;
  --red: #b42318;
  --red-bg: #fff1ef;
  --green: #18794e;
  --green-bg: #ecf8f1;
  --amber: #8a5d00;
  --amber-bg: #fff8e6;
  --blue: #315d86;
  --blue-bg: #eff6fb;
  --shadow: 0 18px 50px rgba(24, 32, 29, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button { color: inherit; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; background: var(--ink); color: white; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid #3b82f6; outline-offset: 3px; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(20px, 4vw, 64px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 760; letter-spacing: .08em; font-size: 14px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--ink); border-radius: 8px; letter-spacing: 0; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.sample-pill, .chip, .candidate-label { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; font-weight: 650; font-size: 12px; line-height: 1; }
.sample-pill { padding: 9px 12px; background: #eef1ee; color: #405049; }
.sample-pill span { color: var(--green); font-size: 9px; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 80px; }
.fixture-warning { display: flex; justify-content: space-between; gap: 20px; margin: -30px 0 34px; padding: 12px 15px; color: #684a08; background: #fff7e8; border: 1px solid #ead39b; border-radius: 9px; font-size: 12px; }
.fixture-warning span { color: #7a6842; }
.decision-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.2; font-weight: 800; letter-spacing: .13em; }
h1 { max-width: 820px; margin: 0; font-size: clamp(34px, 4.2vw, 60px); line-height: 1.03; letter-spacing: -.045em; font-weight: 730; }
.decision-scope { margin: 15px 0 0; color: var(--muted); font-size: 14px; }
.guide-button { display: flex; justify-content: space-between; gap: 30px; align-items: center; min-width: 240px; padding: 14px 0; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; font-size: 13px; font-weight: 700; cursor: pointer; }
.guide-panel { margin: -6px 0 26px auto; width: min(100%, 550px); padding: 20px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.guide-panel ol { margin: 0; padding-left: 20px; }
.guide-panel li + li { margin-top: 7px; }

.gate {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 24px 26px;
  border: 1px solid;
  border-radius: 14px;
  margin-bottom: 24px;
}
.gate-review { background: var(--amber-bg); border-color: #ead49d; }
.gate-blocked { background: var(--red-bg); border-color: #e5aaa4; }
.gate-safe { background: var(--green-bg); border-color: #a4d6ba; }
.gate-icon { display: grid; place-items: center; width: 46px; height: 46px; border: 2px solid currentColor; border-radius: 50%; font-size: 21px; font-weight: 800; }
.gate-review .gate-icon { color: var(--amber); }
.gate-blocked .gate-icon { color: var(--red); }
.gate-safe .gate-icon { color: var(--green); }
.gate-copy h2 { margin: 0 0 3px; font-size: 25px; letter-spacing: -.02em; }
.gate-copy p { margin: 0; color: #47524d; max-width: 770px; }
.gate-proof { text-align: right; }
.gate-proof strong { display: block; font-size: 13px; }
.gate-proof span { font-size: 12px; color: var(--muted); }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 38px 0 16px; }
.section-head h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.evidence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.origin-panel { margin-top: 14px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.origin-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.origin-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.origin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.origin-source { padding: 18px; background: #f7f7f4; border: 1px solid var(--line); border-radius: 10px; }
.origin-source h3 { margin: 0 0 4px; font-size: 18px; }
.origin-source > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; }
.origin-labels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.origin-label { display: inline-flex; padding: 6px 8px; color: #4b5550; background: #e9edea; border-radius: 999px; font-size: 11px; font-weight: 750; }
.origin-validation { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 12px; padding: 17px 18px; border: 1px solid; border-radius: 10px; }
.origin-validation.is-missing { background: var(--amber-bg); border-color: #ead49d; }
.origin-validation.is-present { background: var(--green-bg); border-color: #a4d6ba; }
.origin-validation p:not(.eyebrow) { margin: 3px 0 0; color: #47524d; font-size: 13px; }
.origin-validation .text-button { flex: 0 0 auto; margin-top: 0; }
.origin-explanation { margin-top: 12px; padding: 16px 18px; background: var(--blue-bg); border-left: 3px solid var(--blue); border-radius: 8px; }
.origin-explanation p { margin: 4px 0 0; color: #3d5263; font-size: 13px; }
.evidence-card, .claim-card, .panel, .brief-card, .validation-card, .before-after {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.evidence-card { position: relative; min-height: 235px; padding: 20px; display: flex; flex-direction: column; }
.evidence-type { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.type-icon { display: grid; place-items: center; width: 34px; height: 34px; background: #eef1ee; border-radius: 8px; font-size: 15px; }
.status-label { color: var(--muted); font-size: 11px; font-weight: 760; text-transform: uppercase; letter-spacing: .06em; }
.evidence-card h3 { margin: 18px 0 7px; font-size: 17px; }
.evidence-card p { margin: 0; color: var(--muted); font-size: 13px; }
.evidence-card .meta { margin-top: auto; padding-top: 22px; display: grid; gap: 6px; }
.meta-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.meta-row span:first-child { color: var(--muted); }
.text-button { align-self: flex-start; margin: 18px 0 0; padding: 0 0 3px; border: 0; border-bottom: 1px solid var(--ink); background: transparent; font-size: 12px; font-weight: 750; cursor: pointer; }

.primary-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 24px; padding: 20px 0; border-top: 1px solid var(--line); }
.primary-row p { margin: 0; color: var(--muted); font-size: 13px; max-width: 580px; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 12px 18px; font-size: 13px; font-weight: 750; cursor: pointer; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-primary { background: var(--ink); color: white; border-color: var(--ink); }
.button-primary:hover { background: #303a35; }
.button-danger { background: var(--red); color: white; }
.button-safe { background: var(--green); color: white; }
.button-quiet { background: transparent; border-color: var(--line-strong); }

.run-record { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 9px; background: var(--blue-bg); border: 1px solid #c8dce9; color: #294e6e; font-size: 12px; }
.run-record.fallback { background: #fff7e8; border-color: #ead39b; color: #684a08; }
.run-record strong { font-weight: 800; }
.run-record span:last-child { margin-left: auto; color: inherit; opacity: .75; }

.conflict-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.claim-card { padding: 22px; }
.claim-card.legacy { border-top: 4px solid #7b817e; }
.claim-card.current { border-top: 4px solid var(--red); }
.claim-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.chip { padding: 7px 9px; background: #eff1ef; color: #4b5550; }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-blue { background: var(--blue-bg); color: var(--blue); }
.claim-card h3 { margin: 20px 0 9px; font-size: 19px; }
.claim-value { min-height: 52px; font-size: 15px; font-weight: 650; }
.excerpt { margin: 18px 0 0; padding: 15px 16px; background: #f7f7f4; border-left: 3px solid var(--line-strong); color: #39423e; font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.locator { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.consequence { display: grid; grid-template-columns: 38px 1fr; gap: 14px; align-items: start; padding: 20px 22px; margin-top: 14px; background: #231f20; color: white; border-radius: 12px; }
.consequence .consequence-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #776f71; border-radius: 50%; }
.consequence strong { display: block; margin-bottom: 3px; }
.consequence p { margin: 0; color: #d7d3d4; }

.validation-card { margin-top: 14px; padding: 24px; display: grid; grid-template-columns: 1fr auto; gap: 26px; align-items: center; border-left: 4px solid var(--amber); }
.validation-card h3 { margin: 0 0 7px; font-size: 20px; }
.validation-card p { margin: 0; color: var(--muted); }
.task-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.before-after { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.before-after > div { padding: 23px; }
.before-after > div + div { border-left: 1px solid var(--line); background: #f4fbf7; }
.before-after h3 { margin: 0 0 8px; font-size: 15px; }
.before-after p { margin: 0; color: var(--muted); font-size: 13px; }
.brief-card { margin-top: 14px; padding: 28px; }
.brief-card h2 { margin: 0 0 12px; font-size: 24px; }
.instruction { max-width: 850px; margin: 0 0 22px; font-size: 18px; line-height: 1.6; }
.citations { display: flex; flex-wrap: wrap; gap: 8px; }
.citation-button { border: 1px solid var(--line-strong); background: #f8f9f7; border-radius: 999px; padding: 8px 11px; font-size: 11px; font-weight: 700; cursor: pointer; }
.legacy-row { margin-top: 14px; padding: 18px 20px; background: #eef0ee; border-radius: 10px; display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.legacy-row p { margin: 0; font-size: 13px; color: var(--muted); }

.dialog { width: min(650px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; color: var(--ink); background: var(--surface); border: 0; border-radius: 15px; box-shadow: var(--shadow); }
.dialog-wide { width: min(820px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(20, 28, 24, .62); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 24px; }
.icon-button { border: 1px solid var(--line); background: white; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; cursor: pointer; }
#source-content, #audit-content, #attestation-form > :not(.dialog-head) { margin-left: 26px; margin-right: 26px; }
#source-content { padding: 26px 0 30px; }
.source-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.source-meta div { padding: 12px; background: #f6f7f5; border-radius: 8px; font-size: 12px; }
.source-meta span { display: block; color: var(--muted); margin-bottom: 3px; }
.source-quote { padding: 20px; background: #f5f5f1; border-left: 3px solid var(--ink); font: 14px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; }
.source-quote-original { font-style: italic; }
.source-translation-label { margin-top: 22px; }
.fallback-callout { display: grid; grid-template-columns: 28px 1fr; gap: 12px; margin-top: 22px; padding: 14px 16px; background: var(--blue-bg); border: 1px solid #c8dce9; border-radius: 9px; }
.fallback-callout > span { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--blue); color: var(--blue); border-radius: 50%; font-weight: 800; }
.fallback-callout p { margin: 0; font-size: 12px; }
.measurement-card { margin-top: 16px; padding: 18px; display: grid; grid-template-columns: 160px 1fr; gap: 18px; align-items: center; border: 1px solid var(--line); border-radius: 10px; }
.meter-visual { padding: 18px 16px; background: #252b28; color: #e8f9c8; border-radius: 8px; font-family: ui-monospace, Consolas, monospace; }
.meter-visual span { font-size: 32px; }
.meter-visual small { margin-left: 8px; }
.candidate-label { padding: 6px 8px; background: var(--blue-bg); color: var(--blue); }
.measurement-card h3 { margin: 9px 0 0; font-size: 24px; }
.measurement-card p { margin: 2px 0 0; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.form-grid label { display: grid; gap: 6px; color: #4d5752; font-size: 12px; font-weight: 700; }
.form-grid input, .form-grid select { width: 100%; padding: 11px 12px; background: white; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); }
.span-2 { grid-column: span 2; }
.check-row { display: grid; grid-template-columns: 20px 1fr; gap: 10px; margin-top: 20px; font-size: 13px; }
.check-row input { margin-top: 3px; accent-color: var(--ink); }
.form-error { margin-top: 14px; padding: 10px 12px; color: var(--red); background: var(--red-bg); border-radius: 7px; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding: 18px 0 24px; border-top: 1px solid var(--line); }
.audit-list { padding: 18px 0 28px; }
.audit-item { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 13px; padding: 10px 0; }
.audit-dot { width: 10px; height: 10px; margin-top: 5px; background: var(--ink); border-radius: 50%; }
.audit-item:not(:last-child)::after { content: ""; position: absolute; left: 4px; top: 28px; bottom: -4px; width: 1px; background: var(--line); }
.audit-item h3 { margin: 0; font-size: 13px; text-transform: capitalize; }
.audit-item p { margin: 3px 0; color: var(--muted); font-size: 12px; }
.audit-item time { font-size: 11px; color: #89908d; }

.toast { position: fixed; z-index: 120; right: 22px; bottom: 22px; max-width: 370px; padding: 14px 16px; background: var(--ink); color: white; border-radius: 9px; box-shadow: var(--shadow); font-size: 13px; }
.footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px clamp(20px, 4vw, 64px); color: var(--muted); background: white; border-top: 1px solid var(--line); font-size: 12px; }
.footer p { margin: 0; }

.loading-shell { padding: 26px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.loading-line, .loading-grid > div { background: #e9ece9; animation: pulse 1.2s infinite alternate; }
.loading-line { width: 68%; height: 16px; margin-bottom: 12px; border-radius: 5px; }
.loading-title { width: 34%; height: 28px; }
.loading-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 30px; }
.loading-grid > div { height: 190px; border-radius: 10px; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 850px) {
  .decision-header, .primary-row, .footer { align-items: stretch; flex-direction: column; }
  .guide-button { min-width: 0; width: 100%; }
  .gate { grid-template-columns: auto 1fr; }
  .gate-proof { grid-column: 2; text-align: left; }
  .evidence-grid { grid-template-columns: 1fr; }
  .evidence-card { min-height: 0; }
  .conflict-layout { grid-template-columns: 1fr; }
  .origin-grid { grid-template-columns: 1fr; }
  .validation-card { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { align-items: flex-start; }
  .sample-pill { display: none; }
  .shell { width: min(100% - 28px, 1180px); padding-top: 36px; }
  .fixture-warning { flex-direction: column; margin-top: -14px; }
  .origin-heading, .origin-validation { align-items: stretch; flex-direction: column; }
  h1 { font-size: 38px; }
  .gate { grid-template-columns: 1fr; padding: 20px; }
  .gate-proof { grid-column: 1; }
  .gate-icon { width: 38px; height: 38px; }
  .before-after, .form-grid, .source-meta { grid-template-columns: 1fr; }
  .before-after > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .span-2 { grid-column: span 1; }
  .measurement-card { grid-template-columns: 1fr; }
  .dialog-head { padding: 20px; }
  #source-content, #audit-content, #attestation-form > :not(.dialog-head) { margin-left: 20px; margin-right: 20px; }
}
