:root {
  --paper: #f7f5f0; --card: #ffffff; --ink: #1c1b19; --muted: #5f5b53; --line: #dcd7cc;
  --accent: #1f5d4c; --accent-ink: #ffffff; --flag: #9f2d1c; --flag-bg: #fbeeea;
  --g0: #8a857a; --g1: #6f7d4e; --g2: #a07a1a; --g3: #b85c12; --g4: #a8381d; --g5: #7d1f1f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --w: 46rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1.0625rem/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem .75rem; z-index: 10; }
.skip:focus { left: .5rem; top: .5rem; }

.site-header, main, .site-footer { max-width: var(--w); margin: 0 auto; padding: 0 1.25rem; }
.site-header { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: baseline; justify-content: space-between; padding-top: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.brand { font: 600 1.05rem var(--serif); color: var(--ink); text-decoration: none; letter-spacing: .01em; }
.site-header nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; font-size: .95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; padding: .35rem 0; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--ink); text-decoration: underline; }

.hero { padding: 2.5rem 0 1.25rem; }
h1 { font: 600 clamp(2rem, 6.5vw, 3.1rem)/1.08 var(--serif); letter-spacing: -.015em; margin: 0 0 .75rem; text-wrap: balance; }
.lede { font-size: 1.15rem; color: var(--muted); margin: 0; max-width: 38rem; }
h2 { font: 600 1.45rem/1.25 var(--serif); margin: 2.5rem 0 .6rem; }
h3 { font: 600 1.05rem/1.3 var(--sans); margin: 1.75rem 0 .35rem; }

.tool { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; margin-top: 1rem; }
label[for], legend { font-weight: 600; font-size: .95rem; }
textarea, input[type=search] { display: block; width: 100%; margin-top: .4rem; padding: .75rem .85rem; font: 1rem/1.5 var(--sans); color: var(--ink); background: #fff; border: 1.5px solid #b9b3a6; border-radius: 8px; }
textarea { resize: vertical; min-height: 9rem; }
textarea[aria-invalid=true] { border-color: var(--flag); }
.help { font-size: .9rem; color: var(--muted); margin: .45rem 0 0; }
.error { font-size: .95rem; color: var(--flag); font-weight: 600; margin: .45rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .9rem; }
button { font: 600 1rem var(--sans); padding: .7rem 1.05rem; min-height: 44px; border-radius: 8px; border: 1.5px solid #b9b3a6; background: #fff; color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: #17493c; border-color: #17493c; }

.results { margin-top: 1.75rem; outline: none; }
.results h2 { margin-top: 0; }
.headline { font: 600 1.3rem/1.3 var(--serif); margin: .2rem 0 .6rem; padding-left: .8rem; border-left: 5px solid var(--accent); }
.headline.has-flags { border-left-color: var(--flag); }
.counts { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1.4rem; padding: 0; margin: 0 0 1rem; color: var(--muted); font-size: .95rem; }
.counts b { color: var(--ink); font-variant-numeric: tabular-nums; }
.notice, .caveat { background: #efece4; border-radius: 8px; padding: .7rem .85rem; font-size: .95rem; }
.caveat { margin-top: 1.25rem; }

.threshold { border: 0; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.threshold legend { float: left; padding: 0; margin-right: .2rem; }
.segs { display: inline-flex; border: 1.5px solid #b9b3a6; border-radius: 8px; overflow: hidden; background: #fff; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; min-width: 3.1rem; min-height: 44px; line-height: 44px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; border-left: 1px solid var(--line); }
.seg:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; vertical-align: top; padding: .65rem .8rem; border-top: 1px solid var(--line); }
thead th { border-top: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
tbody th { font-weight: 600; }
tr.flagged { background: var(--flag-bg); }
tr.flagged th { box-shadow: inset 4px 0 0 var(--flag); }
.sub { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.sub.flag { color: var(--flag); font-weight: 600; }
.pos { display: inline-block; min-width: 1.7rem; padding: 0 .35rem; text-align: center; font: 600 .85rem/1.6 var(--mono); border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pos.top5 { background: var(--ink); color: #fff; border-color: var(--ink); }
.grade { display: inline-block; min-width: 2rem; padding: .05rem .45rem; text-align: center; font: 700 1rem/1.5 var(--mono); color: #fff; border-radius: 6px; background: var(--g0); }
.grade.g1 { background: var(--g1); } .grade.g2 { background: var(--g2); } .grade.g3 { background: var(--g3); } .grade.g4 { background: var(--g4); } .grade.g5 { background: var(--g5); }
.meter { display: inline-flex; gap: 2px; margin-left: .45rem; vertical-align: middle; }
.meter i { width: 9px; height: 14px; border-radius: 2px; background: #e4dfd4; }
.meter i.on { background: var(--ink); } .meter i.half { background: repeating-linear-gradient(135deg, var(--ink) 0 2px, #e4dfd4 2px 4px); }

.chips { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.chips li { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .6rem; font-size: .93rem; }
.chips small { color: var(--muted); margin-left: .25rem; }
details { border-top: 1px solid var(--line); padding: .7rem 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
.untested { margin-top: 1.25rem; }
summary { cursor: pointer; font-weight: 600; min-height: 32px; }
details p { margin: .5rem 0 0; }

.prose { max-width: 40rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: .35rem 0; }
.table-tools { margin: 1.5rem 0 .8rem; max-width: 24rem; }
.ratings abbr { text-decoration: none; cursor: help; }

.site-footer { margin-top: 3.5rem; padding-top: 1.25rem; padding-bottom: 2.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.site-footer p { margin: .35rem 0; }

@media (max-width: 640px) {
  .result-table thead, .ratings thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .result-table, .result-table tbody, .result-table tr, .result-table th, .result-table td,
  .ratings, .ratings tbody, .ratings tr, .ratings th, .ratings td { display: block; width: 100%; }
  .result-table tr, .ratings tr { padding: .6rem .8rem; border-top: 1px solid var(--line); }
  .result-table tr:first-child, .ratings tr:first-child { border-top: 0; }
  .ratings tr[hidden] { display: none; }
  .result-table th, .result-table td, .ratings th, .ratings td { border: 0; padding: .2rem 0; }
  .result-table td::before, .ratings td::before { content: attr(data-label) ": "; display: inline-block; min-width: 8.2rem; color: var(--muted); font-size: .82rem; }
  .result-table td[data-label=Position]::before { content: "Position: "; }
  .result-table td[data-label=Position] .sub { display: inline; margin-left: .4rem; }
  .result-table td:not([data-label=Position]) .sub { display: block; margin: .1rem 0 0 8.45rem; }
  tr.flagged th { box-shadow: none; }
  tr.flagged { box-shadow: inset 4px 0 0 var(--flag); }
}
@media (prefers-reduced-motion: no-preference) { button, .seg span { transition: background-color .15s, border-color .15s; } }
@media print { .tool, .site-header nav, .actions, .threshold { display: none; } body { background: #fff; } }
.crumbs { margin: 0 0 .6rem; font-size: .92rem; }
.facts dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .6rem; margin: 1rem 0 0; }
.facts dl div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem; }
.facts dt { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: .25rem 0 0; font-weight: 600; }
a.button { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; padding: .7rem 1.05rem; border-radius: 8px; min-height: 44px; }
.peers, .ing-index { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .35rem .9rem; }
.ing-index li[hidden] { display: none; }
