/* cft-cmi interactive site — one stylesheet for every page.
   Light and dark, a 16px gutter, no horizontal scroll at phone width. */

:root {
  color-scheme: light dark;  /* form controls and scrollbars follow the theme */
  --bg: #fbfbfa;          --panel: #ffffff;      --fg: #17181a;
  --muted: #5c6066;       --line: #8d939c;       --line-soft: #ecedef;
  --accent: #1f5fa9;      --accent-soft: #e6eefa;
  --proved: #0b6a42;      --proved-bg: #e2f3ea;
  --numerical: #8a5a00;   --numerical-bg: #fbf0d8;
  --certified: #274b8c;   --certified-bg: #e4ebf7;
  --conditional: #7a3d8f; --conditional-bg: #f2e6f6;
  --open: #8a2c2c;        --open-bg: #f9e5e5;
  --series-1: #1f5fa9;    --series-2: #b4530a;   --series-3: #0b6a42;
  --series-4: #7a3d8f;    --series-5: #8a2c2c;
  --focus: #1f5fa9;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;        --panel: #1c1f25;      --fg: #e8eaed;
    --muted: #a0a6b0;     --line: #6a7280;       --line-soft: #262a31;
    --accent: #7fb2ee;    --accent-soft: #1d2b3e;
    --proved: #74d6a6;    --proved-bg: #12301f;
    --numerical: #e8bd63; --numerical-bg: #33280d;
    --certified: #9db9ec; --certified-bg: #1a2439;
    --conditional: #d3a5e4;--conditional-bg: #2b1b32;
    --open: #ef9a9a;      --open-bg: #331818;
    --series-1: #7fb2ee;  --series-2: #f0a35e;   --series-3: #74d6a6;
    --series-4: #d3a5e4;  --series-5: #ef9a9a;
    --focus: #7fb2ee;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a;          --panel: #1c1f25;      --fg: #e8eaed;
  --muted: #a0a6b0;       --line: #6a7280;       --line-soft: #262a31;
  --accent: #7fb2ee;      --accent-soft: #1d2b3e;
  --proved: #74d6a6;      --proved-bg: #12301f;
  --numerical: #e8bd63;   --numerical-bg: #33280d;
  --certified: #9db9ec;   --certified-bg: #1a2439;
  --conditional: #d3a5e4; --conditional-bg: #2b1b32;
  --open: #ef9a9a;        --open-bg: #331818;
  --series-1: #7fb2ee;    --series-2: #f0a35e;   --series-3: #74d6a6;
  --series-4: #d3a5e4;    --series-5: #ef9a9a;
  --focus: #7fb2ee;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.6 var(--sans);
  overflow-x: hidden;
}
.wrap { max-width: 61rem; margin: 0 auto; padding: 0 16px 4rem; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

header.site {
  border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
header.site .wrap {
  display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center;
  padding-top: .55rem; padding-bottom: .55rem;
}
header.site .brand { font-weight: 650; letter-spacing: -.01em; margin-right: auto; }
header.site .brand a { color: inherit; text-decoration: none; }
header.site nav { display: flex; flex-wrap: wrap; gap: .1rem .9rem; font-size: .88rem; }
button.theme {
  font: inherit; font-size: .82rem; padding: .25rem .6rem; cursor: pointer;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px;
}

h1 { font-size: 1.6rem; line-height: 1.25; margin: 1.6rem 0 .4rem; letter-spacing: -.015em; }
h2 { font-size: 1.16rem; margin: 2rem 0 .5rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 1.3rem 0 .35rem; }
p, li { max-width: 62ch; }
.lede { color: var(--muted); max-width: 62ch; }
code, .mono { font-family: var(--mono); font-size: .88em; }

.badge {
  display: inline-block; font: 600 .7rem/1.5 var(--sans); letter-spacing: .04em;
  text-transform: uppercase; padding: .05rem .42rem; border-radius: 3px;
  border: 1px solid currentColor; white-space: nowrap; vertical-align: .08em;
}
.badge.proved, .badge.refereed { color: var(--proved); background: var(--proved-bg); }
.badge.numerical { color: var(--numerical); background: var(--numerical-bg); }
.badge.certified { color: var(--certified); background: var(--certified-bg); }
.badge.conditional { color: var(--conditional); background: var(--conditional-bg); }
.badge.conjectural, .badge.open { color: var(--open); background: var(--open-bg); }

.claim {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  padding: .8rem 1rem; margin: 1rem 0;
}
.claim > .claim-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.claim > .claim-head > .claim-title { font-weight: 600; }
.claim p { margin: .45rem 0; }
.provenance { font-size: .82rem; color: var(--muted); margin-top: .45rem; }
.provenance a { color: var(--accent); }
.hypo {
  font-size: .85rem; border-left: 3px solid var(--conditional);
  padding: .1rem 0 .1rem .7rem; margin: .5rem 0; color: var(--fg);
}
.value { font-family: var(--mono); font-weight: 600; }
.value .err { font-weight: 400; color: var(--muted); }

.panel {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  padding: .9rem; margin: 1rem 0;
}
figure { margin: 1.2rem 0; }
figure img, figure svg { max-width: 100%; height: auto; display: block; }
figcaption { font-size: .85rem; color: var(--muted); margin-top: .4rem; max-width: 62ch; }

.controls { display: grid; gap: .75rem 1.2rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.control { display: grid; gap: .2rem; }
.control label { font-size: .85rem; font-weight: 600; }
.control .hint { font-size: .78rem; color: var(--muted); }
.control input[type="range"] { width: 100%; accent-color: var(--accent); }
.control input[type="number"], .control select {
  font: inherit; padding: .25rem .4rem; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 4px; width: 100%;
}
.readout { display: grid; gap: .3rem .9rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); margin-top: .8rem; }
.readout .cell { border-top: 1px solid var(--line-soft); padding-top: .25rem; }
.readout .k { font-size: .78rem; color: var(--muted); display: block; }
.readout .v { font-family: var(--mono); font-size: .95rem; }

table { border-collapse: collapse; width: 100%; font-size: .88rem; }
/* display:block on a table strips its role from assistive technology, so the
   scrolling lives on a wrapper and every table stays a table (REF-MOD710). */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
th, td { text-align: left; padding: .32rem .55rem; border-bottom: 1px solid var(--line-soft); }
th { font-weight: 600; color: var(--muted); font-size: .8rem; letter-spacing: .02em; }
td.num, th.num { text-align: right; font-family: var(--mono); }

svg.plot { width: 100%; height: auto; display: block; touch-action: none; }
svg .axis line, svg .axis path { stroke: var(--line); fill: none; }
svg .axis text { fill: var(--muted); font: 11px var(--sans); }
svg .grid line { stroke: var(--line-soft); }
svg .curve { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg .handle { cursor: grab; }
svg .handle:active { cursor: grabbing; }
svg text.label { fill: var(--fg); font: 12px var(--sans); }
svg text.small { fill: var(--muted); font: 11px var(--sans); }

.js-only { display: none; }
.has-js .js-only { display: revert; }
.has-js .no-js { display: none; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--panel);
  padding: .4rem .7rem; border: 1px solid var(--line); z-index: 10;
}
.skip:focus { left: 8px; top: 8px; }
footer.site { border-top: 1px solid var(--line); margin-top: 3rem; padding-top: 1rem; font-size: .85rem; color: var(--muted); }
@media (max-width: 30rem) {
  h1 { font-size: 1.35rem; }
  .wrap { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* KaTeX display math is wider than a phone: scroll it locally rather than clip it,
   and never let it push the page sideways. */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0 6px; }
.katex { font-size: 1em; }
[data-tex] { overflow-wrap: anywhere; }
