:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #1d1c1a;
  --muted: #6b675f;
  --line: #e2ded4;
  --accent: #23466e;
  --accent-ink: #ffffff;
  --quote-bg: #f2efe7;
  --present: #1f6b45;  --present-bg: #e3f1e8;
  --absent: #8a2f24;   --absent-bg: #f6e3df;
  --unclear: #7a5a10;  --unclear-bg: #f6eccf;
  --na: #55524b;       --na-bg: #ebe8e1;
  --error: #a3271a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614; --surface: #1f1f1c; --ink: #ecebe6; --muted: #a29e94; --line: #34332e;
    --accent: #8fb3dd; --accent-ink: #10141a; --quote-bg: #26251f;
    --present: #8fd3ad; --present-bg: #1d3328; --absent: #f0a196; --absent-bg: #3a2320;
    --unclear: #e8c76f; --unclear-bg: #382f17; --na: #bdb9af; --na-bg: #2b2a26; --error: #f0a196;
  }
}
:root[data-theme="dark"] {
  --bg: #161614; --surface: #1f1f1c; --ink: #ecebe6; --muted: #a29e94; --line: #34332e;
  --accent: #8fb3dd; --accent-ink: #10141a; --quote-bg: #26251f;
  --present: #8fd3ad; --present-bg: #1d3328; --absent: #f0a196; --absent-bg: #3a2320;
  --unclear: #e8c76f; --unclear-bg: #382f17; --na: #bdb9af; --na-bg: #2b2a26; --error: #f0a196;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 0 0 .6rem; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 .6rem; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 .8rem; }
em { font-style: normal; color: var(--muted); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; }
.brand { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.tag { font: 600 .7rem/1 var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: .25rem .5rem; margin-left: .4rem; vertical-align: middle; }
.who { font-size: .9rem; color: var(--muted); display: flex; gap: .6rem; align-items: center; }
.who button { padding: .3rem .6rem; font-size: .85rem; }

.intro { padding: 2rem 0 1rem; }
.intro p { color: var(--muted); max-width: 62ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin: 0 0 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 1rem; }
.grow { flex: 1 1 200px; }

input[type="text"], input:not([type]), textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: .55rem .7rem;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button {
  font: 600 .95rem var(--sans); color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 6px; padding: .6rem 1.1rem; cursor: pointer;
}
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: progress; }

label.file, label.text { display: block; margin: 0 0 .9rem; }
label.file > span, label.text > span { display: block; font-weight: 600; margin-bottom: .35rem; }
input[type="file"] { width: 100%; font: inherit; font-size: .9rem; color: var(--muted); }
details.optional { border: 1px dashed var(--line); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .5rem; }
details.optional summary { cursor: pointer; font-weight: 600; }
details.optional[open] summary { margin-bottom: .5rem; }

fieldset.yn { border: 0; padding: 0; margin: 0 0 .9rem; }
fieldset.yn legend { font-weight: 600; padding: 0; margin-bottom: .3rem; }
fieldset.yn label { margin-right: 1.1rem; white-space: nowrap; }

.notice { background: var(--quote-bg); border-radius: 8px; padding: .8rem 1rem; font-size: .92rem; margin-top: .5rem; }
.error { color: var(--error); margin: .6rem 0 0; min-height: 1em; }

.working { display: flex; gap: 16px; align-items: center; }
.working p { margin: 0; }
.spinner { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Readout */
.about { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .95rem; margin: 0; }
.about dt { color: var(--muted); }
.about dd { margin: 0; }
.tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 1rem 0 0; padding: 0; list-style: none; }

.pill { display: inline-block; font: 600 .78rem/1 var(--sans); padding: .35rem .6rem; border-radius: 99px; white-space: nowrap; }
.pill.present { color: var(--present); background: var(--present-bg); }
.pill.absent { color: var(--absent); background: var(--absent-bg); }
.pill.unclear { color: var(--unclear); background: var(--unclear-bg); }
.pill.not_testable, .pill.not_judged { color: var(--na); background: var(--na-bg); }

.feature { border-top: 1px solid var(--line); padding: 1.1rem 0; }
.feature:first-of-type { border-top: 0; padding-top: 0; }
.feature-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.feature h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.feature h3 .num { color: var(--muted); margin-right: .35rem; }
.reason { margin: .2rem 0 .7rem; }

blockquote { margin: 0 0 .6rem; padding: .6rem .9rem; background: var(--quote-bg); border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; font-family: var(--serif); }
blockquote p { margin: 0 0 .3rem; }
blockquote footer { font: .8rem var(--sans); color: var(--muted); }

.check { border-top: 1px solid var(--line); padding: .9rem 0; }
.check:first-of-type { border-top: 0; padding-top: 0; }
.check .claim { font-weight: 600; margin-bottom: .4rem; }

ul.plain { padding-left: 1.1rem; margin: 0; }
ul.plain li { margin-bottom: .4rem; }
.principle { margin-bottom: .9rem; }
.principle strong { display: block; font-family: var(--serif); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 20px; }

.foot { color: var(--muted); font-size: .85rem; padding-bottom: 2.5rem; }

@media (max-width: 520px) {
  .card { padding: 16px; }
  .feature-head { flex-direction: column; gap: 4px; }
  .about { grid-template-columns: 1fr; }
  .about dt { margin-top: .4rem; }
  .who span { display: none; }
  .tag { display: none; }
}
@media print {
  .top, #upload, .actions, .foot { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}

/* Free page */
.free-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.free-form label.file { margin: 0; width: 100%; }
.verdict h2 { font-size: 1.4rem; margin: 0 0 .5rem; }
.verdict { border-left: 4px solid var(--line); }
.verdict.strong { border-left-color: var(--present); }
.verdict.partial { border-left-color: var(--unclear); }
.verdict.weak { border-left-color: var(--absent); }
.verdict a { color: var(--accent); }

/* Terms */
ol.terms { padding-left: 1.2rem; margin: 0 0 1rem; }
ol.terms li { margin-bottom: .45rem; }
label.agree { display: flex; gap: .5rem; align-items: center; font-weight: 600; margin-bottom: .9rem; }

/* Notice above upload buttons */
.notice-wrap { width: 100%; }
.purpose { margin: .2rem 0 .5rem; }
div.notice-box { background: var(--quote-bg); border-radius: 8px; padding: .7rem 1rem; font-size: .92rem; margin-bottom: .4rem; }
div.notice-box p { margin: .3rem 0 0; }
.ref { font-size: .8rem; word-break: break-all; }

/* ABL-beta */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.grid th, table.grid td { border-top: 1px solid var(--line); padding: .55rem .5rem; text-align: left; vertical-align: top; }
table.grid thead th { border-top: 0; font-weight: 600; white-space: nowrap; }
table.grid thead th .small { display: block; font-weight: 400; font-size: .8rem; }
table.grid tbody th { font-weight: 500; min-width: 14rem; }
.change { margin: 0 0 .9rem; }
.change-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: .4rem; }
.pill.na-pill { color: var(--na); background: var(--na-bg); }
.pair { font-weight: 600; margin: .4rem 0; }
details.version { border-top: 1px solid var(--line); padding: .6rem 0; }
details.version summary { cursor: pointer; }
details.version p { margin: .5rem 0; }
.beta-link { font: 600 .8rem var(--sans); color: var(--accent); margin-left: .5rem; }
.keep { margin: .9rem 0 .3rem; } .record { font-size: .85rem; margin: .2rem 0 .6rem; }

/* Protected results: watermark, no selection, nothing printed */
.protected { position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.protected::after { content: ""; position: absolute; inset: 0; background-image: var(--mark); background-repeat: repeat; pointer-events: none; z-index: 2; }
@media print {
  body * { display: none !important; }
  body::before { content: "Printing is turned off for this confidential reading."; display: block; padding: 2rem; font: 16px sans-serif; }
}
