:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-2: #f1ece3;
  --ink: #1f1c18;
  --ink-2: #3d3832;
  --muted: #6f685f;
  --line: #e2dccf;
  --line-strong: #c9c1b0;
  --accent: #7a2e1f;
  --accent-ink: #ffffff;
  --research: #3d6a4d;
  --research-bg: #e3ece4;
  --mixed: #a9823a;
  --mixed-bg: #f2e8d2;
  --commentary: #9e4330;
  --commentary-bg: #f3dfd8;
  --good: var(--research);
  --bad: var(--commentary);
  --band-top: var(--research-bg);
  --band-mid: var(--mixed-bg);
  --band-low: var(--commentary-bg);
  --shadow: 0 1px 2px rgba(31, 28, 24, .04), 0 8px 24px rgba(31, 28, 24, .05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Archivo", "Inter", system-ui, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161411; --surface: #1e1b17; --surface-2: #262219; --ink: #ede7db; --ink-2: #d2cbbd; --muted: #a39b8d;
    --line: #332e26; --line-strong: #4a4337; --accent: #d9735c; --accent-ink: #161411;
    --research: #8dc39b; --research-bg: #1f2b22; --mixed: #d6b062; --mixed-bg: #2f291a; --commentary: #e08d78; --commentary-bg: #35211c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #161411; --surface: #1e1b17; --surface-2: #262219; --ink: #ede7db; --ink-2: #d2cbbd; --muted: #a39b8d;
  --line: #332e26; --line-strong: #4a4337; --accent: #d9735c; --accent-ink: #161411;
  --research: #8dc39b; --research-bg: #1f2b22; --mixed: #d6b062; --mixed-bg: #2f291a; --commentary: #e08d78; --commentary-bg: #35211c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
b, strong { font-weight: 600; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- masthead ---------- */
header.site { border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; }
header.site .brand { display: flex; align-items: baseline; gap: 12px; color: var(--ink); text-decoration: none; }
header.site .brand .mark { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: .08em; text-transform: uppercase; }
header.site .brand small { color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 15px; }
header.site nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.site nav a { padding: 6px 10px; font-size: 14px; color: var(--muted); text-decoration: none; border-radius: 6px; }
header.site nav a:hover { color: var(--ink); background: var(--surface-2); }
header.site nav a.current { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 6px 6px 0 0; }

/* ---------- layout and type ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 36px 20px 72px; }
h1 { font-family: var(--display); font-weight: 600; font-size: clamp(32px, 4.5vw, 46px); line-height: 1.1; margin: 8px 0 14px; letter-spacing: -0.015em; }
h2 { font-family: var(--display); font-weight: 600; font-size: 27px; line-height: 1.2; margin: 44px 0 12px; letter-spacing: -0.01em; }
h3 { font-family: var(--display); font-weight: 600; font-size: 20px; margin: 28px 0 8px; }
p, li { max-width: none; }
.lede { font-family: var(--serif); font-size: 20px; line-height: 1.5; color: var(--ink-2); margin: 0 0 24px; }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
.prose p { font-family: var(--serif); font-size: 18px; line-height: 1.6; color: var(--ink-2); }
.prose p b { color: var(--ink); }
.prose .note, .prose .note p { font-family: var(--sans); font-size: 14px; }
.formula { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; border-radius: 8px; display: inline-block; margin: 8px 0 12px; }
.note { font-size: 14px; color: var(--muted); }
.pos { color: var(--good); } .neg { color: var(--bad); }
footer { color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); margin-top: 64px; padding-top: 18px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
footer .by { font-family: var(--serif); font-style: italic; }

/* ---------- cards, forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; margin: 18px 0; box-shadow: var(--shadow); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1 1 220px; }
.row > div.fixed { flex: 0 0 auto; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 5px; }
input[type=text] { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); color: var(--ink); }
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button { font: inherit; font-weight: 500; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); font-weight: 400; }
button.secondary:hover { background: var(--surface-2); filter: none; }
button:disabled { opacity: .55; cursor: default; }
.status { font-size: 14px; color: var(--muted); min-height: 20px; margin-top: 12px; }
.status.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; margin-right: 8px; vertical-align: -1px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; font-size: 13px; color: var(--muted); }
.chip { font: inherit; font-size: 13px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); filter: none; }
details.card { padding: 14px 24px; }
details.card[open] { padding-bottom: 22px; }
summary { cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 15px; }
summary::marker { color: var(--muted); }
.weights { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 22px; margin-top: 12px; }
.weights label { display: flex; justify-content: space-between; color: var(--ink); font-size: 13px; }
.weights label b { font-variant-numeric: tabular-nums; color: var(--accent); }
.weights input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- result ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 28px; align-items: center; }
.hero .big { font-family: var(--serif); font-weight: 600; font-size: 84px; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero .k { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.hero .band { display: inline-block; margin-top: 10px; font-size: 14px; font-weight: 500; padding: 4px 10px; border-radius: 6px; }
.hero .verdict { font-family: var(--serif); font-size: 18px; line-height: 1.5; color: var(--ink-2); margin: 0; }
.hero .verdict b { color: var(--ink); }
.hero .scale { margin-top: 16px; max-width: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 18px 0 6px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); line-height: 1.3; }
.stat .v { font-size: 26px; font-family: var(--serif); font-weight: 600; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.band.top, .hero .band.top { background: var(--band-top); color: var(--research); }
.band.mid, .hero .band.mid { background: var(--band-mid); color: var(--mixed); }
.band.low, .hero .band.low { background: var(--band-low); color: var(--commentary); }
.band { padding: 2px 7px; border-radius: 4px; font-size: 12px; font-weight: 500; }

/* ---------- scale ---------- */
.scale { margin: 12px 0 6px; position: relative; }
.scale-bar { position: relative; display: flex; height: 12px; border-radius: 6px; overflow: visible; }
.scale-bar .seg { height: 100%; }
.scale-bar .seg:first-child { border-radius: 6px 0 0 6px; } .scale-bar .seg:last-child { border-radius: 0 6px 6px 0; }
.scale-bar .seg.top { background: var(--research); } .scale-bar .seg.mid { background: var(--mixed); } .scale-bar .seg.low { background: var(--commentary); }
.scale-bar .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .6; transform: translateX(-50%); }
.scale-bar .marker { position: absolute; top: -9px; width: 0; height: 0; transform: translateX(-50%); border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 12px solid var(--ink); }
.scale-bar .marker::after { content: ""; position: absolute; left: -9px; top: -12px; width: 18px; height: 12px; }
.scale-labels { position: relative; height: 20px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 6px; }
.scale-labels span { position: absolute; top: 0; transform: translateX(-50%); }
.scale-labels span:first-child { transform: none; left: 0; } .scale-labels span:last-child { transform: none; right: 0; }
.scale-words { display: flex; justify-content: space-between; font-size: 12px; margin-top: 2px; }
.scale-words span:nth-child(1) { color: var(--research); } .scale-words span:nth-child(2) { color: var(--mixed); } .scale-words span:nth-child(3) { color: var(--commentary); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; background: var(--surface); z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.band-top td:first-child { box-shadow: inset 4px 0 0 var(--research); }
tr.band-mid td:first-child { box-shadow: inset 4px 0 0 var(--mixed); }
tr.band-low td:first-child { box-shadow: inset 4px 0 0 var(--commentary); }
tr.excluded td { opacity: .45; }
#papers td:last-child { min-width: 320px; }
#papers td:last-child a { color: var(--ink); }
#papers .note { margin-top: 2px; font-size: 12px; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); margin-right: 6px; vertical-align: 1px; }
.pill.A { border-color: var(--research); color: var(--research); background: var(--research-bg); }
.pill.B { border-color: var(--mixed); color: var(--mixed); background: var(--mixed-bg); }
.pill.C { border-color: var(--commentary); color: var(--commentary); background: var(--commentary-bg); }
input[type=checkbox] { accent-color: var(--accent); }

/* ---------- interpretation legend ---------- */
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 18px 0; }
.legend .box { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); }
.legend .box.top { background: var(--research-bg); } .legend .box.mid { background: var(--mixed-bg); } .legend .box.low { background: var(--commentary-bg); }
.legend .box .t { font-family: var(--display); font-weight: 600; font-size: 18px; }
.legend .box.top .t { color: var(--research); } .legend .box.mid .t { color: var(--mixed); } .legend .box.low .t { color: var(--commentary); }
.legend .box .r { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.legend .box p { font-size: 14px; margin: 6px 0 0; font-family: var(--sans); color: var(--ink-2); }

@media (max-width: 720px) {
  main { padding: 24px 16px 56px; }
  header.site .wrap { padding: 14px 16px; }
  .hero { grid-template-columns: 1fr; gap: 16px; }
  .hero .big { font-size: 64px; }
  .card { padding: 18px 16px; border-radius: 12px; }
  .lede { font-size: 18px; }
  .prose p { font-size: 17px; }
}
#cmp td:nth-child(3), #cmp td:nth-child(8) { white-space: nowrap; }
#cmp td:first-child { min-width: 220px; }
.intro { margin: 0 0 36px; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.intro h1 { margin-top: 0; }
.intro p { font-family: var(--serif); font-size: 19px; line-height: 1.55; color: var(--ink-2); margin: 0 0 14px; }
h1.second { font-size: clamp(26px, 3.5vw, 34px); margin-top: 0; }
