:root {
  --page-width: 1480px;   /* tables need the room on a desktop; paragraphs stay at 68ch */
  color-scheme: light dark;
  --bg: #f7fbfa;
  --fg: #18211f;
  --muted: #52615e;
  --accent: #0f766e;
  --accent-dark: #0b5a54;
  --accent-soft: #e0f0ee;
  --border: #dbe7e5;
  --panel: #fdfefe;
  --panel-soft: #f0f6f5;
  --code-bg: #e9f2f0;
  --header-bg: #15363a;
  --header-fg: #eff4f2;
  --header-muted: #a9c4c2;
  --ok: #1d7a36;
  --ok-soft: rgba(42, 157, 72, 0.12);
  --warn: #9a6c00;
  --warn-soft: rgba(184, 134, 11, 0.14);
  --bad: #a5281b;
  --bad-soft: rgba(192, 57, 43, 0.12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --math: "Cambria Math", Cambria, "STIX Two Math", "Times New Roman", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101c1b;
    --fg: #e6efed;
    --muted: #9fb6b2;
    --accent: #4fc1b5;
    --accent-dark: #7ad7cc;
    --accent-soft: #163634;
    --border: #274543;
    --panel: #152625;
    --panel-soft: #182c2b;
    --code-bg: #1c3331;
    --header-bg: #0b1f21;
    --header-fg: #eff4f2;
    --header-muted: #a9c4c2;
    --ok: #6ed08a;
    --ok-soft: rgba(110, 208, 138, 0.16);
    --warn: #e2b04a;
    --warn-soft: rgba(226, 176, 74, 0.16);
    --bad: #ef7f74;
    --bad-soft: rgba(239, 127, 116, 0.16);
  }
}
:root[data-theme="dark"] {
  --bg: #101c1b;
  --fg: #e6efed;
  --muted: #9fb6b2;
  --accent: #4fc1b5;
  --accent-dark: #7ad7cc;
  --accent-soft: #163634;
  --border: #274543;
  --panel: #152625;
  --panel-soft: #182c2b;
  --code-bg: #1c3331;
  --header-bg: #0b1f21;
  --header-fg: #eff4f2;
  --header-muted: #a9c4c2;
  --ok: #6ed08a;
  --ok-soft: rgba(110, 208, 138, 0.16);
  --warn: #e2b04a;
  --warn-soft: rgba(226, 176, 74, 0.16);
  --bad: #ef7f74;
  --bad-soft: rgba(239, 127, 116, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.55;
  font-size: 16px;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ------------------------------------------------------------------ header */
header.site {
  background: var(--header-bg);
  color: var(--header-fg);
}
header.site .inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
header.site h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
}
header.site h1 a { color: inherit; text-decoration: none; }
header.site h1 a:hover { color: #fff; }
header.site nav { display: flex; gap: 1.1rem; font-size: 0.92rem; flex-wrap: wrap; }
header.site nav a { color: var(--header-muted); text-decoration: none; white-space: nowrap; }
header.site nav a:hover, header.site nav a[aria-current="page"] { color: #fff; }

/* ------------------------------------------------------------------ main */
main {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}
main h2 {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
main h3 {
  margin: 1.75rem 0 0.5rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
}
main p { color: var(--muted); font-size: 1.02rem; max-width: 68ch; }
main p.wide { max-width: none; }
.muted { color: var(--muted); }
.m {
  font-family: var(--math);
  font-style: normal;
  color: var(--fg);
}
code, pre { font-family: var(--mono); }
p code, li code, td code, dd code {
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.45;
}
pre code { background: transparent; padding: 0; }

/* theorem-block hero: rules above and below, like the reference site */
.hero {
  margin: 0 0 1.5rem;
  padding: 1.15rem 1.75rem;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 0 0 6px 6px;
}
.hero .lede {
  margin: 0;
  color: var(--fg);
  font-family: var(--serif);
  font-size: 1.22rem;
  max-width: none;
}
.hero .lede em { font-style: normal; font-weight: 700; }
.hero .sub { margin: 0.5rem 0 0; font-size: 0.98rem; max-width: none; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin: 0.75rem 0 1.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.stats b { color: var(--fg); font-variant-numeric: tabular-nums; }

.page-nav { margin: 0 0 1rem; font-size: 0.95rem; }
.page-nav a { text-decoration: none; }
.page-nav a:hover { text-decoration: underline; }
.page-nav .sep { color: var(--muted); margin: 0 0.4rem; }

.degree-index { font-size: 1rem; }
.degree-index a { text-decoration: none; font-weight: 600; padding: 0 0.15rem; }
.degree-index a:hover { text-decoration: underline; }
.degree-index .sep { color: var(--muted); margin: 0 0.3rem; }
main h3[id^="d"] { scroll-margin-top: 1rem; }

/* ------------------------------------------------------------------ controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  margin: 0.75rem 0 0.5rem;
  font-size: 0.93rem;
  color: var(--muted);
}
.controls label { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.controls input[type="checkbox"] { accent-color: var(--accent); }

.btn {
  display: inline-block;
  padding: 0.5rem 1.3rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.98rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn.secondary:hover { background: var(--accent-soft); }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 0.5rem 0 1.5rem; }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.93rem;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.data th {
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--accent); }
table.data th.sorted::after { content: " ▾"; color: var(--accent); }
table.data th.sorted.asc::after { content: " ▴"; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.group th {
  background: var(--panel-soft);
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  padding-top: 0.7rem;
  border-bottom: 1px solid var(--border);
}
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link:hover td { background: var(--panel-soft); }
table.data tr.dim td { color: var(--muted); }
table.data td.poly { font-family: var(--math); font-size: 0.95rem; min-width: 13rem; max-width: 44rem; overflow-wrap: anywhere; }
table.data td.num { white-space: nowrap; }
table.data a.id { font-family: var(--mono); font-size: 0.9rem; text-decoration: none; }
table.data a.id:hover { text-decoration: underline; }
.degs { display: inline-flex; flex-wrap: wrap; gap: 0.15em; max-width: 14rem; }
.degs .d {
  display: inline-block;
  min-width: 1.45em;
  text-align: center;
  padding: 0 0.25em;
  border-radius: 3px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.35;
}
.degs .d.fin { background: var(--ok-soft); border-color: transparent; }
.degs .d.inf { background: var(--warn-soft); border-color: transparent; }
.empty { color: var(--muted); font-style: italic; }

/* yes / no / maybe answers */
.ans {
  display: inline-block;
  min-width: 3.4em;
  text-align: center;
  padding: 0.02rem 0.45rem;
  border-radius: 3px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ans.yes { background: var(--ok-soft); color: var(--ok); }
.ans.no { background: var(--panel-soft); color: var(--muted); border: 1px solid var(--border); }
.ans.maybe { background: var(--warn-soft); color: var(--warn); }

/* status chips */
.chip {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.chip.certified { background: var(--ok-soft); color: var(--ok); }
.chip.verified { background: var(--warn-soft); color: var(--warn); }
.chip.rejected { background: var(--bad-soft); color: var(--bad); }
.chip.neutral { background: var(--panel-soft); color: var(--muted); border: 1px solid var(--border); }

/* ------------------------------------------------------------------ panels & definition lists */
.panel {
  padding: 1rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  margin: 1rem 0;
}
.panel.accepted { border-left: 4px solid var(--ok); }
.panel.open { border-left: 4px solid var(--warn); }
.panel h3 { margin-top: 0; }
.panel h3:first-child { margin-top: 0.1rem; }
dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.2rem;
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
}
dl.facts dt { font-weight: 600; white-space: nowrap; }
dl.facts dd { margin: 0; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
dl.facts dd .m, dl.facts dd b { color: var(--fg); }
dl.facts dd.poly { font-family: var(--math); color: var(--fg); font-size: 1rem; }
@media (max-width: 560px) {
  dl.facts { grid-template-columns: 1fr; gap: 0.1rem 0; }
  dl.facts dd { margin-bottom: 0.5rem; }
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

.eq {
  font-family: var(--math);
  font-size: 1.15rem;
  text-align: center;
  margin: 0.75rem 0;
  overflow-x: auto;
}

.src { font-size: 0.85rem; color: var(--muted); }
.src a { text-decoration: none; }
ul.sources { padding-left: 1.2rem; font-size: 0.93rem; color: var(--muted); }
ul.sources li { margin: 0.3rem 0; }
ul.sources b { color: var(--fg); font-family: var(--mono); font-weight: 600; font-size: 0.85rem; }

ol.steps, ul.plain { color: var(--muted); font-size: 1rem; max-width: 70ch; }
ol.steps li, ul.plain li { margin: 0.35rem 0; }

.notice {
  padding: 0.7rem 1rem;
  border-radius: 4px;
  background: var(--warn-soft);
  color: var(--fg);
  font-size: 0.95rem;
  margin: 1rem 0;
}
.error { color: var(--bad); }

/* ------------------------------------------------------------------ footer */
footer.site {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}
footer.site a { text-decoration: none; }
footer.site a:hover { text-decoration: underline; }
footer.site .links { margin-bottom: 0.4rem; }
footer.site .links .sep { margin: 0 0.4rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
