:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-card: #1a2029;
  --line: #2b333d;
  --fg: #e6edf3;
  --fg-dim: #9aa7b4;
  --fg-faint: #6b7684;
  --mic: #6ea8fe;
  --ref: #d2a8ff;
  --out: #56d364;
  --jaec: #e3b341;
  --accent: #56d364;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Layout scales with the viewport so the page does not become a thin
     ribbon on a 27" display, nor overflow on a phone. Every breakpoint
     below only moves these two numbers. */
  --content-max: 880px;
  --pad-x: 24px;
  --wave-h: clamp(72px, 6.5vw, 104px);

  /* Running text is deliberately NOT capped to a narrower measure: notes,
     figure captions, the step list and the cards and tables all end on the
     same column edge, so the page has one width instead of a ribbon of prose
     floating inside a wider column. Blocks disagreeing about that edge is
     what made section 02 read as if the layout had come apart -- a 68ch note
     stopped at 567 px while the hint right under it ran the full 952. ch was
     the wrong unit for the job anyway: it is the width of "0" in whatever
     font the element itself uses, so one number rendered 567 px in a 15 px
     note and 529 px in the 14 px caption below it. */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

/* ---------------------------------------------------- repo link (top right) */
.repo {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(22, 27, 34, .84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--fg-dim);
  font-size: 13.5px;
  line-height: 1;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.repo:hover { color: var(--fg); border-color: var(--fg-faint); background: var(--bg-soft); }
.repo svg { flex: none; display: block; }

/* ---------------------------------------------------------------- hero */
.hero {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 12% -20%, #14311f 0%, transparent 55%),
    radial-gradient(90% 120% at 88% -10%, #1b2a45 0%, transparent 50%);
  padding: 76px 0 52px;
}

.eyebrow {
  margin: 0 0 14px;
  font: 12px/1 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(40px, 6.4vw, 72px);
  line-height: 1.02;
  letter-spacing: -.03em;
  font-weight: 700;
}

.lede {
  margin: 0;
  font-size: 17px;
  color: var(--fg-dim);
}

.lede strong { color: var(--fg); font-weight: 600; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.facts li { display: flex; align-items: baseline; gap: 9px; }
.facts span { font-size: 12px; color: var(--fg-faint); }
.facts b { font: 15px/1 var(--mono); color: var(--fg); }

/* ------------------------------------------------------------ sections */
main { padding: 8px 0 40px; }

section { padding: 56px 0 8px; }

h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.01em;
}

h2 .num {
  font: 13px/1 var(--mono);
  color: var(--accent);
  opacity: .85;
}

.note {
  margin: 0 0 26px;
  color: var(--fg-dim);
  font-size: 15px;
}

.note.tight { margin-top: 18px; margin-bottom: 0; }
.note b { color: var(--fg); }
.note code {
  font: 13px/1 var(--mono);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
}

.hint {
  margin: 20px 0 0;
  font-size: 14px;
  color: var(--fg-faint);
}
.hint b { color: var(--fg-dim); }

/* ------------------------------------------------------------- players */
.players { display: grid; gap: 16px; }

.player {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 14px;
}

.player figcaption { margin-bottom: 12px; }

.tag {
  display: inline-block;
  font: 12px/1 var(--mono);
  letter-spacing: .04em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.tag-mic { color: var(--mic); }
.tag-ref { color: var(--ref); }
.tag-out { color: var(--out); }
.tag-jaec { color: var(--jaec); }

.sub {
  display: block;
  margin-top: 7px;
  font-size: 13px;
  color: var(--fg-faint);
}

.player canvas {
  display: block;
  width: 100%;
  height: var(--wave-h);
  margin-bottom: 10px;
  border-radius: 6px;
  background: #0b0f14;
}

audio { width: 100%; height: 34px; display: block; }

.player.changed { border-color: var(--out); }

/* ------------------------------------------------------- spectrogram tiles
   Four time-frequency tiles on one time axis, drawn in the page from the same
   WAVs the players use. They stay fluid at any width: the canvases are
   resolution-independent and both the names and the frequency ticks are drawn
   at a fixed CSS size, so unlike the architecture SVG there is nothing here
   that turns to mush on a phone. */
.tiles { margin: 18px 0 0; }

.tile-grid { display: grid; grid-template-columns: 1fr; }

/* The stack exists so the playhead can span exactly the four tiles without
   measuring them: top:0/bottom:0 is the canvas area by construction. */
.tile-stack { position: relative; display: grid; gap: 4px; }

.tile { position: relative; }

.tile canvas {
  display: block;
  width: 100%;
  height: clamp(64px, 4.6vw, 84px);
  background: #0b0f14;
  border-radius: 6px;
}

.tile-name {
  position: absolute;
  top: 4px;
  left: 5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(6, 10, 15, .74);
  color: var(--fg-dim);
  font: 11px/1.45 var(--mono);
  pointer-events: none;
}

.tile-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font: 11px/1 var(--mono);
  color: var(--fg-faint);
}

/* The bar is a DOM gradient filled in from the same anchor colours the canvas
   LUT is built from, so the legend cannot drift away from the picture. */
.tile-scale {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font: 11px/1 var(--mono);
  color: var(--fg-faint);
}
.scale-bar {
  flex: 0 0 108px;
  height: 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.scale-note { margin-left: auto; }

/* One playhead for all four rows: the players are time-aligned, so a single
   line reads correctly against every tile. It is a DOM element moved with a
   transform, so no canvas is redrawn while audio plays. */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, .6);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}

.tiles figcaption {
  margin-top: 16px;
  color: var(--fg-faint);
  font-size: 14px;
}
.tiles figcaption b { color: var(--fg-dim); font-weight: 600; }

/* -------------------------------------------------------------- runner */
.runner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

button, .ghost {
  font: 14px/1 inherit;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  text-decoration: none;
  display: inline-block;
}

.primary {
  background: var(--accent);
  color: #07240f;
  font-weight: 600;
}
.primary:hover:not(:disabled) { background: #6ee87a; }
.primary:disabled { opacity: .4; cursor: not-allowed; }

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--fg);
}
.ghost:hover { border-color: var(--fg-faint); background: var(--bg-soft); }

.status { font: 13px/1.5 var(--mono); color: var(--fg-dim); }
.status.busy { color: var(--mic); }
.status.ok { color: var(--out); }
.status.err { color: #ff7b72; }

.result {
  margin-top: 22px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 18px 16px;
}

.metrics { width: 100%; border-collapse: collapse; }

.metrics th, .metrics td {
  text-align: left;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 400;
}

.metrics tr:last-child th, .metrics tr:last-child td { border-bottom: none; }
.metrics th { color: var(--fg-dim); }
.metrics td { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

/* -------------------------------------------------------------- upload */
.uploads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  align-items: end;
}

.drop {
  display: block;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 18px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color .15s;
}
.drop:hover { border-color: var(--fg-faint); }
.drop > span { display: block; font-size: 14px; margin-bottom: 10px; }
.drop small {
  display: block;
  margin-top: 10px;
  font: 12px/1.5 var(--mono);
  color: var(--fg-faint);
  word-break: break-all;
}
.drop input { display: block; width: 100%; font-size: 12px; color: var(--fg-dim); }

/* -------------------------------------------------------------- tables */
.scores {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 14px;
}

.scores th, .scores td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.scores th:first-child, .scores td:first-child { text-align: left; }

.scores thead th {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-faint);
  letter-spacing: .02em;
  border-bottom-color: var(--fg-faint);
}

.scores td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.scores td:first-child { font-family: inherit; color: var(--fg-dim); }
.scores .best { color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------------- how */
/* The SVG draws its own panel, border and rounded corners, so the wrapper
   stays bare -- a second box here would just double the frame. */
.arch { margin: 0 0 24px; }
.arch img { display: block; width: 100%; height: auto; }

.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--fg-dim);
  font-size: 15px;
}
.steps li { margin-bottom: 11px; }
.steps b { color: var(--fg); font-weight: 600; }
.steps i { color: var(--accent); font-style: normal; }
.steps code {
  font: 13px/1 var(--mono);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
}

/* -------------------------------------------------------------- footer */
footer {
  padding-block: 40px 72px;
  border-top: 1px solid var(--line);
  color: var(--fg-faint);
  font-size: 14px;
}
footer p { margin: 0 0 8px; }
footer a { color: var(--mic); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.fine { font-size: 12.5px; color: var(--fg-faint); }

/* --------------------------------------------------- display-size adaptation
   The column widens in steps as the viewport grows, and the type along with
   it, so the page keeps a readable measure on a phone and stops looking like
   a ribbon on a large desktop display. */
@media (min-width: 1200px) {
  :root { --content-max: 1000px; }
}

@media (min-width: 1500px) {
  :root { --content-max: 1120px; --pad-x: 32px; }
  body { font-size: 16.5px; }
  section { padding-top: 64px; }
  .player { padding: 18px 20px 16px; }
}

@media (min-width: 1900px) {
  :root { --content-max: 1280px; }
  body { font-size: 17px; }
  h2 { font-size: 25px; }
  .lede { font-size: 18px; }
  h2 .num { font-size: 14px; }
}

@media (max-width: 560px) {
  .repo { top: 12px; right: 12px; padding: 8px 12px; font-size: 12.5px; }
  .repo svg { width: 15px; height: 15px; }
  .hero { padding: 64px 0 36px; }
  section { padding: 40px 0 4px; }
  .player { padding: 14px 14px 12px; }
  .scores th, .scores td { padding: 10px 6px; font-size: 12.5px; }
  .tile-name { font-size: 10px; padding: 1px 6px; }
  .tile-axis, .tile-scale { font-size: 10px; }
  .scale-bar { flex-basis: 72px; }
  .tiles figcaption { font-size: 13px; }
  /* At 360 px the figure's 10.5 px labels shrink to ~3.6 px and turn to
     mush. Scroll it instead of shrinking it. */
  .arch {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .arch img { width: 640px; max-width: none; }
}
