:root {
  --paper: #F3F1F8;
  --paper-2: #E9E5F2;
  --ink: #1E1935;
  --ink-2: #3E3858;
  --muted: #5B5575;
  --rule: #D9D4E7;
  --accent: #6A3FD6;
  --accent-soft: #E3DAFA;
  --r1: #00889E;
  --r2: #6A3FD6;
  --strip-bg: #000004;
  --playhead: #FFFFFF;
  --playhead-shadow: rgba(0, 0, 4, 0.55);
  --strip-wash: rgba(255, 255, 255, 0.08);
  --strip-marker: rgba(255, 255, 255, 0.55);
  --sheet-bg: #FFFFFF;
  --focus: #6A3FD6;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --measure: 40rem;
  --wide: 72rem;
  --duration: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17132A;
    --paper-2: #211C38;
    --ink: #ECE8F7;
    --ink-2: #CFC9E3;
    --muted: #A9A2C4;
    --rule: #2F2848;
    --accent: #9A76F5;
    --accent-soft: #2E2550;
    --r1: #1B9AAB;
    --r2: #9A76F5;
    --focus: #B89CFF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #17132A;
  --paper-2: #211C38;
  --ink: #ECE8F7;
  --ink-2: #CFC9E3;
  --muted: #A9A2C4;
  --rule: #2F2848;
  --accent: #9A76F5;
  --accent-soft: #2E2550;
  --r1: #1B9AAB;
  --r2: #9A76F5;
  --focus: #B89CFF;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-optical-sizing: auto;
}
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; font-family: var(--sans); }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; }

h1, h2, h3, h4 { font-family: var(--sans); color: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 0.75rem; }
h3 { font-size: 1.3rem; line-height: 1.25; margin: 0; }
h4 { font-size: 0.95rem; margin: 1.25rem 0 0.25rem; color: var(--muted); font-weight: 500; }
p { margin: 0 0 1rem; }

.prose { max-width: var(--wide); margin-left: auto; margin-right: auto; padding: 0 16px; }
.prose > * { max-width: var(--measure); }
main > section { margin-top: 5.5rem; }

/* hero */
.hero { max-width: var(--wide); margin: 0 auto; padding: 4.5rem 16px 1rem; }
.byline { font-family: var(--sans); color: var(--muted); font-size: 1rem; margin: 0 0 1.25rem; }
.hero-title {
  font-size: clamp(2.6rem, 7.4vw, 6rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  font-weight: 700;
  margin: 0 0 1.75rem;
  max-width: 13ch;
}
.hero-copy { max-width: var(--measure); color: var(--ink-2); }
.hero-player { margin-top: 2rem; }

/* spectrogram player: the one bold element */
.player { max-width: var(--wide); margin: 0 auto; }
.strip {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 2.4;
  min-height: 84px;
  background: var(--strip-bg) center / 100% 100% no-repeat;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
}
.hero-player .strip { aspect-ratio: 16 / 3.6; border-radius: 8px; }
.strip .played {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--strip-wash);
  pointer-events: none;
}
.strip .head {
  position: absolute; top: 0; bottom: 0; left: 0; width: 2px;
  background: var(--playhead);
  box-shadow: 0 0 0 1px var(--playhead-shadow);
  transform: translateX(-2px);
  pointer-events: none;
}
.strip .marker {
  position: absolute; top: 6px; width: 1px; bottom: 6px;
  background: var(--strip-marker);
  pointer-events: none;
}
.transport {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  font-family: var(--sans); font-size: 0.95rem; color: var(--muted);
  margin-top: 0.6rem;
}
.button, .play {
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  color: var(--paper); background: var(--ink);
  border: 0; border-radius: 999px; padding: 0.45rem 1rem 0.45rem 0.8rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.5rem;
  transition: background-color var(--duration) var(--ease);
}
.button { padding: 0.55rem 1.1rem; }
.play:hover, .button:hover { background: var(--accent); }
.play svg { width: 0.9rem; height: 0.9rem; fill: currentColor; }
.time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-player .caption { color: var(--muted); font-family: var(--sans); font-size: 0.95rem; }

/* method */
.steps { padding-left: 1.4rem; margin: 0 0 1.5rem; }
.steps li { margin-bottom: 0.75rem; padding-left: 0.25rem; }
.note { border-left: 3px solid var(--accent); padding: 0.25rem 0 0.25rem 1.1rem; margin: 2rem 0 0; }
.note h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.note p { color: var(--ink-2); margin: 0; }

/* download */
.download { margin-top: 1rem; }
.helper { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); margin-top: 0.5rem; }

/* entries */
.entries { margin-top: 2.5rem; }
.entry { max-width: var(--wide); margin: 0 auto 4.5rem; padding: 0 16px; }
.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, var(--measure)) minmax(0, 17rem);
  justify-content: space-between;
  gap: 2rem 3rem;
  margin-top: 1.5rem;
}
.entry-title { font-size: 1.45rem; }
.entry-credit { font-family: var(--sans); color: var(--muted); font-size: 0.95rem; margin: 0.3rem 0 1rem; }
.entry-headline { font-size: 1.45rem; line-height: 1.3; font-style: italic; color: var(--ink); margin-bottom: 0.25rem; }
.entry-noticed, .entry-felt { color: var(--ink-2); }
.entry-why { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 0.75rem; }
.entry-why:empty { display: none; }
.entry-side { font-family: var(--sans); }
.glyph svg { display: block; width: 100%; max-width: 17rem; height: auto; overflow: visible; }
.glyph .petal { fill: var(--accent); fill-opacity: 0.82; stroke: var(--paper); stroke-width: 2; }
.glyph .petal:hover, .glyph .petal:focus { fill-opacity: 1; outline: none; }
.glyph .ring { fill: none; stroke: var(--rule); stroke-width: 1; }
.glyph .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.glyph .axis-val { fill: var(--ink); font-size: 11px; font-weight: 600; font-family: var(--sans); }
.pull { display: flex; align-items: baseline; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.pull-num { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.pull-label { color: var(--muted); font-size: 0.95rem; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.9rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.sheet { margin-top: 1.25rem; font-family: var(--sans); font-size: 0.95rem; }
.sheet summary { cursor: pointer; color: var(--accent); }
.sheet img { display: block; width: 100%; max-width: 1100px; height: auto; margin-top: 1rem; border-radius: 6px; background: var(--sheet-bg); }

/* charts */
.chart-fig { max-width: var(--wide); margin: 2rem auto 0; padding: 0 16px; font-family: var(--sans); }
.chart-fig > div[id$="-chart"] { max-width: 56rem; }
.chart-fig figcaption { color: var(--muted); font-size: 0.95rem; margin-top: 0.75rem; max-width: var(--measure); }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.95rem; color: var(--ink-2); margin-bottom: 0.5rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.r1 { background: var(--r1); }
.legend i.r2 { background: var(--r2); }
.legend i.felt { background: var(--accent); }
.legend i.ring { background: transparent; border: 2px solid var(--accent); }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid line { stroke: var(--rule); }
.chart-svg .grid .domain { display: none; }
.chart-svg text { fill: var(--muted); font-family: var(--sans); font-size: 12px; }
.chart-svg .label { fill: var(--ink-2); font-size: 13px; }
.chart-svg .dot { stroke: var(--paper); stroke-width: 2; }
.chart-svg .hit { fill: transparent; cursor: pointer; }
.chart-svg .hit:focus { outline: none; }
.chart-svg .hit:focus + .dot, .chart-svg .row:hover .dot { stroke: var(--ink); }
.chart-svg .stem { stroke: var(--rule); stroke-width: 2; }
.chart-svg .pred { fill: var(--paper); stroke: var(--accent); stroke-width: 2; }
.chart-svg .felt { fill: var(--accent); stroke: var(--paper); stroke-width: 2; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 20;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 0.9rem; line-height: 1.35;
  padding: 0.5rem 0.7rem; border-radius: 6px; max-width: 18rem;
  opacity: 0; transition: opacity var(--duration) var(--ease);
}
.tooltip.show { opacity: 1; }
.table-view { margin-top: 1rem; font-size: 0.95rem; }
.table-view summary { cursor: pointer; color: var(--accent); }
.table-view table { border-collapse: collapse; width: 100%; margin-top: 0.75rem; }
.table-view th, .table-view td { text-align: left; padding: 0.3rem 0.6rem 0.3rem 0; border-bottom: 1px solid var(--rule); }
.table-view td.num { font-variant-numeric: tabular-nums; }

footer { margin: 6rem auto 4rem; font-size: 1rem; color: var(--ink-2); }
footer h2 { font-size: 1.2rem; }
.fine { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); }

@media (max-width: 820px) {
  body { font-size: 1.0625rem; }
  .entry-grid { grid-template-columns: minmax(0, 1fr); }
  .entry-side { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: 0 1.25rem; align-items: start; }
  .entry-side .glyph { grid-row: span 2; }
  .hero { padding-top: 2.5rem; }
  .hero-player .strip { aspect-ratio: 16 / 5; }
}
@media (max-width: 420px) {
  .entry-side { grid-template-columns: minmax(0, 1fr); }
  .glyph svg { max-width: 14rem; }
}
@media (prefers-reduced-motion: reduce) {
  .button, .play, .tooltip { transition: none; }
}
