:root {
  --bg: #fdfdfc;
  --text: #1a1a1a;
  --text-dim: #55534d;
  --rule: #e0ddd6;
  --denoising: #2c6ba8;
  --discriminative: #e08b2c;
  --neutral: #a8a49a;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 66ch;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--denoising); color: #fff; }

a { color: var(--denoising); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.mono, code, .layer, .model-code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.wrap--wide { max-width: 980px; }

section { padding: 3.5rem 0; }
section + section { border-top: 1px solid var(--rule); }

/* ---- page shell: left sidebar + content ---- */
.page { display: flex; align-items: flex-start; }

.sidebar {
  flex: 0 0 210px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 1.25rem;
  border-right: 1px solid var(--rule);
}
.sidebar .brand { display: block; margin-bottom: 2rem; }
.sidebar .brand-logo { display: block; height: 68px; }
.sidebar .index { display: flex; flex-direction: column; gap: 1.05rem; }
.sidebar .index a {
  color: var(--text-dim);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  margin-left: -0.5rem;
  transition: color 0.15s ease, background 0.15s ease;
}
.sidebar .index a:hover { color: var(--text); background: #f2f0ea; }
.sidebar .index a.active {
  color: var(--text);
  background: #f2f0ea;
}

.content { flex: 1 1 auto; min-width: 0; }

@media (max-width: 900px) {
  .page { display: block; }
  .sidebar {
    position: static;
    height: auto;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    overflow-x: auto;
    white-space: nowrap;
  }
  .sidebar .brand { margin-bottom: 0; flex: 0 0 auto; }
  .sidebar .brand-logo { height: 30px; }
  .sidebar .index { flex-direction: row; gap: 1.1rem; }
  /* keep the horizontal strip compact: desktop sizing must not leak in */
  .sidebar .index a {
    font-size: 0.86rem;
    font-weight: 400;
    letter-spacing: 0;
    border-left: none;
    padding: 0;
    margin-left: 0;
    background: none;
  }
  .sidebar .index a:hover, .sidebar .index a.active {
    background: none;
    border-left: none;
    color: var(--text);
  }
}

h1, h2, h3 { font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.5rem; margin: 0 0 1.25rem; }
h2 .num { color: var(--text-dim); font-weight: 400; margin-right: 0.4em; }
h3 { font-size: 1.1rem; margin: 1.75rem 0 0.75rem; }

p { max-width: var(--measure); margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

.byline { max-width: var(--measure); }

/* ---- hero ---- */
.hero { padding-top: 3rem; }
.hero h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.05rem);
  margin: 0 0 1.25rem;
  max-width: 50ch;
}
.hero .byline { color: var(--text-dim); margin-bottom: 0.35rem; }
.hero .meta { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 1.75rem; }

.buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 2.5rem; }
.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #eef4fa;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.btn:hover { background: var(--denoising); border-color: var(--denoising); color: #fff; }

/* ---- SBC demo ---- */
.demo {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 620px;
}
.demo-canvas-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }
#sbc-canvas, .demo-fallback svg { display: block; max-width: 100%; height: auto; }
.demo-controls {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 0.75rem;
}
.demo-readout {
  font-family: var(--mono); font-size: 0.85rem; color: var(--text-dim);
  text-align: center;
}
button.toggle {
  font-family: var(--serif);
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--text);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
button.toggle:hover { background: var(--text); color: var(--bg); }
button.toggle[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* ---- stat strip ---- */
.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 2.25rem;
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}
.stat-item { display: flex; flex-direction: column; gap: 0.15rem; }
.stat-value { font-family: var(--mono); font-weight: 700; font-size: 1.15rem; }
.stat-label { font-size: 0.78rem; color: var(--text-dim); }

/* ---- video ---- */
.video-wrap { max-width: 720px; margin-bottom: 2rem; }
.video-wrap video {
  width: 100%;
  display: block;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #111;
}
.video-wrap .chart-caption { margin-top: 0.85rem; }

/* ---- details disclosure ---- */
details.more {
  margin-top: 1.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}
details.more summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-dim);
  list-style: none;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before {
  content: "\25B8  ";
  display: inline-block;
}
details.more[open] summary::before { content: "\25BE  "; }
details.more summary:hover { color: var(--text); }
details.more[open] summary { color: var(--text); margin-bottom: 1rem; }
details.more h3:first-of-type { margin-top: 0; }

/* ---- signal-flow diagram ---- */
.signal-flow-peak {
  animation: signal-pulse 2.2s ease-in-out infinite;
}
@keyframes signal-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}
@media (prefers-reduced-motion: reduce) {
  .signal-flow-peak { animation: none; }
}

/* ---- abstract ---- */
.abstract p { max-width: 68ch; }

/* ---- claims ---- */
#claims p { margin-bottom: 1.25rem; }

/* ---- methods ---- */
table.models {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 1rem 0 0.5rem;
}
table.models th, table.models td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}
table.models th { font-weight: 700; color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
table.models .family-group td { color: var(--text-dim); font-style: italic; border-bottom: none; padding-top: 1rem; padding-bottom: 0.2rem; }
.footnote { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.5rem; }

.equation {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  text-align: center;
  margin: 1.5rem 0;
  padding: 1rem;
  background: #f7f6f2;
  border-radius: var(--radius);
}
.equation sub { font-style: normal; }

ul.compact { padding-left: 1.2rem; margin: 0.5rem 0 1rem; }
ul.compact li { margin-bottom: 0.35rem; max-width: var(--measure); }

/* ---- figures ---- */
figure { margin: 1.5rem 0; }
figure img { max-width: 100%; height: auto; display: block; border: 1px solid var(--rule); border-radius: 10px; }
figcaption { font-size: 0.85rem; color: var(--text-dim); margin-top: 0.6rem; max-width: var(--measure); }
figure.wide img { border: none; }

.note {
  font-size: 0.88rem; color: var(--text-dim);
  border-left: 2px solid var(--rule);
  padding-left: 0.85rem;
  margin: 1rem 0;
  max-width: var(--measure);
}

.source-link { font-size: 0.85rem; margin-top: 0.5rem; }

/* ---- charts ---- */
.chart-container {
  display: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0 0.5rem;
  overflow-x: auto;
}
.chart-container.ready { display: block; }
.chart-container svg { display: block; max-width: 100%; }
.chart-container .tick text { font-family: var(--mono); font-size: 10px; fill: var(--text-dim); }
.chart-container .axis-line { stroke: var(--text-dim); stroke-width: 1; }
.chart-caption { font-size: 0.9rem; color: var(--text-dim); margin-top: 0.75rem; max-width: var(--measure); }

.tooltip {
  position: absolute;
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 20;
  transform: translate(-50%, -110%);
}
.tooltip[hidden] { display: none; }

.legend { display: flex; gap: 1.25rem; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.75rem; }
.legend .swatch { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 1px; margin-right: 0.35em; vertical-align: middle; }

/* ---- limitations ---- */
ol.limitations { padding-left: 1.3rem; }
ol.limitations li { margin-bottom: 1rem; max-width: var(--measure); }

/* ---- cite / footer ---- */
.bibtex {
  background: #f7f6f2;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  position: relative;
}
.bibtex-text {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.copy-btn {
  position: absolute; top: 0.6rem; right: 0.6rem;
  font-family: var(--serif);
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--text); }

footer.site-footer {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
footer.site-footer .logo { height: 28px; }
footer.site-footer a { text-decoration: none; }
footer.site-footer a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
footer.site-footer .contact { color: var(--text); }
footer.site-footer .contact a { color: var(--denoising); }

@media (max-width: 640px) {
  section { padding: 2.25rem 0; }
  .stat-strip { gap: 1.25rem 1.75rem; }
}
