/* =========================================================================
   bpm-calculator.com — "Studio Console"

   Design rationale: producers work in dark DAWs, so the site is dark-first.
   The visual language borrows from studio hardware — amber LED readouts,
   tabular numerics, panel edges, and a beat indicator that actually pulses
   at the user's tempo. No framework, no web fonts, one stylesheet.
   ========================================================================= */

:root {
  /* surfaces — near-black with a cool cast, like a rack unit */
  --bg:           #0A0C0F;
  --surface:      #12151A;
  --surface-2:    #191D24;
  --surface-3:    #212731;
  --border:       #272D37;
  --border-lit:   #39424F;

  /* type */
  --text:         #EDF0F4;
  --text-dim:     #98A2B3;
  --text-faint:   #6B7684;

  /* amber: the LED accent. Used for live values and primary actions only. */
  --accent:       #FF9E2C;
  --accent-lit:   #FFB65C;
  --accent-ink:   #1A1000;
  --accent-soft:  rgba(255, 158, 44, 0.14);
  --accent-glow:  rgba(255, 158, 44, 0.32);

  /* teal: secondary data, never competes with amber */
  --teal:         #35D0BA;
  --teal-soft:    rgba(53, 208, 186, 0.13);

  --danger:       #FF6B6B;
  --danger-soft:  rgba(255, 107, 107, 0.12);

  --wrap:         72rem;
  --wrap-narrow:  46rem;
  --r-sm:         6px;
  --r:            12px;
  --r-lg:         18px;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;

  /* Set live by JS to the current beat length. Drives the pulse animation. */
  --beat: 500ms;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #FBFBF9;
    --surface:     #FFFFFF;
    --surface-2:   #F4F5F7;
    --surface-3:   #EAECF0;
    --border:      #E2E5EA;
    --border-lit:  #C9CFD8;
    --text:        #101319;
    --text-dim:    #5B6472;
    --text-faint:  #858E9C;
    --accent:      #C25E00;
    --accent-lit:  #A04D00;
    --accent-ink:  #FFFFFF;
    --accent-soft: rgba(194, 94, 0, 0.09);
    --accent-glow: rgba(194, 94, 0, 0.22);
    --teal:        #0E8F7E;
    --teal-soft:   rgba(14, 143, 126, 0.10);
    --danger:      #C42B2B;
    --danger-soft: rgba(196, 43, 43, 0.08);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  /* A faint grid, echoing a DAW arrangement view. Decorative only. */
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.016) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.016) 1px, transparent 1px);
  background-size: 64px 64px;
}
@media (prefers-color-scheme: light) {
  body {
    background-image:
      linear-gradient(to right, rgba(0,0,0,0.022) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(0,0,0,0.022) 1px, transparent 1px);
  }
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 680; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 5.5vw, 3.25rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.25rem); letter-spacing: -0.01em; }
p  { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-lit); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 1.25rem; }
.wrap-narrow { max-width: var(--wrap-narrow); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.7rem 1.1rem; border-radius: 0 0 var(--r) 0; font-weight: 650;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Section rhythm */
.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section-head { max-width: 58ch; margin-bottom: 1.75rem; }
.section-head p { color: var(--text-dim); margin-bottom: 0; }
.eyebrow {
  display: inline-block; font-family: var(--mono); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--accent); margin-bottom: 0.6rem;
}

/* =============================================================== header === */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .site-header { background: var(--bg); } }

.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 4rem; }

.brand {
  display: inline-flex; align-items: center; gap: 0.6rem; margin-right: auto;
  min-height: 2.75rem; /* a real tap target, not just the height of its text */
  font-weight: 750; font-size: 1.0625rem; letter-spacing: -0.03em;
  color: var(--text); text-decoration: none;
}
/* Four bars, the middle two lit — a tiny level meter as a logo. */
.brand-mark { display: flex; align-items: flex-end; gap: 2px; height: 20px; }
.brand-mark i {
  display: block; width: 3px; border-radius: 2px; background: var(--border-lit);
}
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; background: var(--accent); }
.brand-mark i:nth-child(3) { height: 20px; background: var(--accent); }
.brand-mark i:nth-child(4) { height: 11px; }
.brand:hover .brand-mark i { background: var(--accent); }

.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.nav-toggle-bar, .nav-toggle-bar::before, .nav-toggle-bar::after {
  display: block; width: 17px; height: 2px; border-radius: 2px;
  background: currentColor; content: '';
}
.nav-toggle-bar { position: relative; }
.nav-toggle-bar::before { position: absolute; top: -6px; }
.nav-toggle-bar::after  { position: absolute; top: 6px; }

.primary-nav { display: none; }
.primary-nav ul { list-style: none; margin: 0; padding: 0; }
.primary-nav a {
  display: block; padding: 0.55rem 0.7rem; border-radius: var(--r-sm);
  color: var(--text-dim); text-decoration: none;
  font-size: 0.9375rem; font-weight: 550;
}
.primary-nav a:hover { color: var(--text); background: var(--surface-2); }
.primary-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* Mobile: full-width panel below the bar */
.primary-nav.is-open {
  display: block; position: absolute; inset-inline: 0; top: 100%;
  padding: 0.75rem 1.25rem 1.25rem;
  background: var(--bg); border-bottom: 1px solid var(--border);
  max-height: calc(100vh - 4rem); overflow-y: auto;
}
.nav-group + .nav-group { margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px solid var(--border); }
.nav-group-label {
  display: block; font-family: var(--mono); font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-faint); margin-bottom: 0.3rem; padding-inline: 0.7rem;
}

@media (min-width: 60rem) {
  .nav-toggle { display: none; }
  .primary-nav { display: flex; align-items: center; gap: 0.25rem; position: static; }
  .primary-nav.is-open { position: static; padding: 0; background: none; border: none; max-height: none; }
  .nav-group { position: relative; }
  .nav-group + .nav-group { margin: 0; padding: 0; border: none; }
  .nav-group-label {
    display: flex; align-items: center; gap: 0.3rem; cursor: default;
    margin: 0; padding: 0.55rem 0.7rem; border-radius: var(--r-sm);
    font-family: var(--font); font-size: 0.9375rem; font-weight: 550;
    letter-spacing: normal; text-transform: none; color: var(--text-dim);
  }
  .nav-group-label::after {
    content: ''; width: 5px; height: 5px; margin-top: -3px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
  }
  .nav-group:hover .nav-group-label, .nav-group:focus-within .nav-group-label { color: var(--text); }
  .nav-group ul {
    display: none; position: absolute; top: calc(100% + 0.35rem); left: 0;
    min-width: 15rem; padding: 0.4rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  }
  .nav-group:hover ul, .nav-group:focus-within ul { display: block; }
  /* A single-item group needs no dropdown. */
  .nav-group.is-single .nav-group-label { display: none; }
  .nav-group.is-single ul { display: block; position: static; min-width: 0; padding: 0; background: none; border: none; box-shadow: none; }
}

/* ========================================================== breadcrumbs === */
.breadcrumbs { padding-top: 1.1rem; }
.breadcrumbs ol {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin: 0; padding: 0; font-size: 0.8125rem; color: var(--text-faint);
}
.breadcrumbs li + li::before { content: '/'; margin-right: 0.4rem; color: var(--border-lit); }
.breadcrumbs a { color: var(--text-faint); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }

/* ================================================================= hero === */
.hero { padding-block: clamp(1.75rem, 4vw, 3rem) 0; }
.hero-head { max-width: 40ch; }
.hero h1 { margin-bottom: 0.4rem; }
.hero h1 .accent { color: var(--accent); }
.lede { font-size: clamp(1.0625rem, 2vw, 1.1875rem); color: var(--text-dim); max-width: 52ch; }

/* Trust badges — plain facts, no marketing */
.badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; padding: 0; list-style: none; }
.badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.7rem; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.8125rem; color: var(--text-dim); font-weight: 500;
}
.badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal); flex: none;
}

/* ============================================================== console === */
/* The main tool panel. Styled as a hardware faceplate. */
.console {
  margin-top: 1.75rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-lit);
  border-radius: var(--r-lg);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 50px rgba(0,0,0,0.35);
  overflow: hidden;
}
@media (prefers-color-scheme: light) {
  .console { box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 18px 40px rgba(0,0,0,0.07); }
}

.console-top { display: grid; gap: 1.25rem; padding: clamp(1.1rem, 3vw, 1.75rem); }
@media (min-width: 54rem) {
  .console-top { grid-template-columns: minmax(0, 21rem) minmax(0, 1fr); gap: 2rem; }
}

/* --- the LED readout --- */
.display {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 100%;
}
.display-label {
  font-family: var(--mono); font-size: 0.6875rem; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--text-faint); margin-bottom: 0.15rem;
}
.display-value {
  display: flex; align-items: baseline; gap: 0.5rem;
  font-family: var(--mono); font-weight: 700; letter-spacing: -0.04em;
  font-size: clamp(3.25rem, 12vw, 5.5rem); line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 28px var(--accent-glow);
}
.display-value .unit {
  font-size: 0.22em; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-faint); text-shadow: none; font-weight: 600;
}

/* --- beat indicator: four segments, lit in turn at the real tempo --- */
.beat-bar {
  display: flex; gap: 5px; margin-top: 1.1rem;
  padding: 0; list-style: none;
}
.beat-bar li {
  flex: 1; height: 7px; border-radius: 3px;
  background: var(--surface-3); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.beat-bar li::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: var(--accent); opacity: 0;
}
.beat-bar.is-running li::after {
  animation: beat-flash calc(var(--beat) * 4) steps(1, end) infinite;
}
.beat-bar.is-running li:nth-child(1)::after { animation-delay: calc(var(--beat) * 0); }
.beat-bar.is-running li:nth-child(2)::after { animation-delay: calc(var(--beat) * 1); }
.beat-bar.is-running li:nth-child(3)::after { animation-delay: calc(var(--beat) * 2); }
.beat-bar.is-running li:nth-child(4)::after { animation-delay: calc(var(--beat) * 3); }
/* First beat of the bar reads brighter, so the downbeat is visible. */
.beat-bar.is-running li:first-child::after { box-shadow: 0 0 12px var(--accent-glow); }
@keyframes beat-flash {
  0%   { opacity: 1; }
  24%  { opacity: 1; }
  25%  { opacity: 0.12; }
  100% { opacity: 0.12; }
}
@media (prefers-reduced-motion: reduce) {
  .beat-bar.is-running li::after { animation: none; opacity: 0.2; }
}
.beat-caption { font-size: 0.75rem; color: var(--text-faint); margin: 0.5rem 0 0; }

/* --- controls --- */
.controls { display: grid; gap: 1rem; align-content: start; }

.tap-button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.25rem; width: 100%; min-height: 8.5rem; cursor: pointer;
  background: linear-gradient(180deg, var(--accent-lit), var(--accent));
  color: var(--accent-ink); border: none; border-radius: var(--r);
  font-family: inherit; font-size: 1.1875rem; font-weight: 750;
  letter-spacing: -0.01em;
  box-shadow: 0 6px 18px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.3) inset;
  transition: transform 80ms ease, box-shadow 80ms ease, filter 80ms ease;
  touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent;
}
.tap-button:hover { filter: brightness(1.06); }
.tap-button.is-tapped {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.3) inset;
  filter: brightness(1.18);
}
@media (prefers-reduced-motion: reduce) { .tap-button { transition: none; } }
.tap-hint { font-size: 0.8125rem; font-weight: 600; opacity: 0.72; }

.tap-readout {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem;
  margin-top: 0.7rem; font-size: 0.8125rem; color: var(--text-dim);
}
.tap-readout p { margin: 0; }
.tap-readout .tap-note { flex-basis: 100%; color: var(--teal); }

.field label, .field-label {
  display: block; font-family: var(--mono); font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-faint); margin-bottom: 0.4rem;
}
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%; min-height: 3rem; padding: 0.65rem 0.85rem;
  font-family: var(--mono); font-size: 1.375rem; font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border-lit); border-radius: var(--r-sm);
}
.field select { font-family: var(--font); font-size: 1rem; font-weight: 550; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.field-help { font-size: 0.75rem; color: var(--text-faint); margin: 0.35rem 0 0; }
.field-error {
  font-size: 0.8125rem; color: var(--danger); margin: 0.4rem 0 0; font-weight: 550;
}

/* tempo chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  min-height: 2.25rem; padding: 0.35rem 0.75rem; cursor: pointer;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 100px;
  font-family: var(--mono); font-size: 0.8125rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color 100ms ease, color 100ms ease;
}
.chip em { font-family: var(--font); font-style: normal; font-weight: 500; color: var(--text-faint); font-size: 0.75rem; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip:hover em { color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (pointer: coarse) { .chip { min-height: 2.75rem; padding-inline: 0.9rem; } }

.btn-ghost {
  justify-self: start; min-height: 2.5rem; padding: 0.5rem 0.9rem; cursor: pointer;
  font-family: inherit; font-size: 0.875rem; font-weight: 600;
  color: var(--text-dim); background: none;
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-lit); }
@media (pointer: coarse) { .btn-ghost { min-height: 2.75rem; } }

/* --- metric strip along the bottom of the console --- */
.metrics {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0; border-top: 1px solid var(--border);
  background: var(--surface);
}
@media (min-width: 40rem) { .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.metric {
  padding: 0.9rem 1rem; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.metric:last-child { border-right: none; }
@media (min-width: 40rem) { .metric { border-bottom: none; } }
.metric dt {
  font-family: var(--mono); font-size: 0.6875rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-faint); margin-bottom: 0.2rem;
}
.metric dd {
  margin: 0; font-family: var(--mono); font-size: 1.25rem; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.metric .unit { font-size: 0.6875rem; color: var(--text-faint); font-weight: 600; margin-left: 0.15rem; }

/* copy affordance */
.copyable {
  font: inherit; font-variant-numeric: tabular-nums; color: inherit;
  background: none; border: none; padding: 0; cursor: pointer;
  border-bottom: 1px dashed var(--border-lit);
}
.copyable:hover { color: var(--accent); border-bottom-color: var(--accent); }
.copyable.is-copied { color: var(--teal); border-bottom-color: transparent; }
.copyable.is-copied::after {
  content: 'copied'; font-family: var(--font); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal);
  margin-left: 0.4rem; vertical-align: middle;
}
.copy-hint { font-size: 0.75rem; color: var(--text-faint); margin: 0.75rem 0 0; }

/* ======================================================= answer / prose === */
.answer {
  position: relative; margin-top: 1.75rem; padding: 1.1rem 1.25rem 1.1rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
}
.answer::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--teal));
}
.answer p { margin: 0; font-size: 1.0625rem; }

.prose { max-width: 68ch; }
.prose > h2 { margin-top: 2.25rem; }
.prose > h3 { margin-top: 1.75rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin-bottom: 1.25rem; }
.prose li { margin-bottom: 0.45rem; }
.prose li::marker { color: var(--accent); }
.prose code {
  font-family: var(--mono); font-size: 0.9em;
  background: var(--surface-2); padding: 0.12em 0.4em; border-radius: 4px;
  border: 1px solid var(--border);
}

.formula {
  font-family: var(--mono); font-size: 1rem; font-weight: 600;
  background: var(--surface); color: var(--accent);
  padding: 1rem 1.15rem; border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 0 var(--r) var(--r) 0;
  overflow-x: auto; margin-block: 1.25rem;
}

.note {
  background: var(--teal-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--r) var(--r) 0; padding: 1rem 1.15rem; margin-block: 1.5rem;
}
.note p:last-child { margin-bottom: 0; }

/* ================================================================ steps === */
.steps { display: grid; gap: 1rem; padding: 0; list-style: none; counter-reset: step; }
@media (min-width: 46rem) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 68rem) { .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.step {
  position: relative; padding: 1.25rem 1.15rem 1.15rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.step::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  display: block; font-family: var(--mono); font-size: 1.75rem; font-weight: 700;
  color: var(--accent); opacity: 0.4; line-height: 1; margin-bottom: 0.6rem;
}
.step h3 { font-size: 1rem; margin-bottom: 0.3rem; }
.step p { margin: 0; font-size: 0.9375rem; color: var(--text-dim); }

/* ============================================================== tables === */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.data-table th, .data-table td {
  padding: 0.65rem 0.9rem; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  font-family: var(--mono); font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-faint); background: var(--surface-2);
}
.data-table tbody th { font-weight: 600; white-space: normal; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.data-table .col-note { white-space: normal; font-family: var(--font); color: var(--text-dim); font-size: 0.875rem; min-width: 16rem; }
.division { color: var(--text-faint); font-weight: 400; font-size: 0.875em; }
.table-note { font-size: 0.8125rem; color: var(--text-faint); margin-top: 0.65rem; }

/* =============================================================== cards === */
.card-grid { display: grid; gap: 0.9rem; padding: 0; list-style: none; }
@media (min-width: 40rem) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64rem) { .card-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  display: flex; flex-direction: column; height: 100%;
  padding: 1.15rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color 120ms ease, transform 120ms ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--text); }
@media (prefers-reduced-motion: reduce) { .card:hover { transform: none; } }
.card-title {
  font-weight: 680; font-size: 1.0625rem; letter-spacing: -0.015em;
  margin-bottom: 0.3rem; color: var(--text);
}
.card:hover .card-title { color: var(--accent); }
.card-desc { font-size: 0.9rem; color: var(--text-dim); line-height: 1.55; margin: 0; }
.card-tag {
  align-self: flex-start; margin-top: 0.75rem;
  font-family: var(--mono); font-size: 0.625rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text-faint);
  padding: 0.2rem 0.5rem; border: 1px solid var(--border); border-radius: 100px;
}

/* ============================================================ callouts === */
.callout {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem;
  justify-content: space-between; margin-block: 2rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.callout-text { flex: 1 1 22rem; }
.callout h2 { font-size: 1.0625rem; margin-bottom: 0.25rem; }
.callout p { margin: 0; font-size: 0.9375rem; color: var(--text-dim); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; padding: 0.65rem 1.15rem; cursor: pointer;
  font-family: inherit; font-size: 0.9375rem; font-weight: 650;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--r-sm); text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-lit); border-color: var(--accent-lit); color: var(--accent-ink); }
.btn-outline {
  background: none; color: var(--accent); border-color: var(--border-lit);
}
.btn-outline:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ================================================================== faq === */
.faq-list { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.15rem; cursor: pointer; font-weight: 620; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: ''; flex: none; width: 8px; height: 8px; margin-right: 2px;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg) translateY(-2px); transition: transform 150ms ease;
}
.faq-item[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.faq-item[open] summary { color: var(--accent); }
.faq-item summary:hover { background: var(--surface-2); }
.faq-answer { padding: 0 1.15rem 1.15rem; color: var(--text-dim); margin: 0; }

/* ============================================================== author === */
.author-box {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.25rem; margin-block: 2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.author-avatar {
  flex: none; width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent); font-weight: 750; font-size: 1.125rem;
}
.author-name { font-weight: 680; margin-bottom: 0.15rem; }
.author-role { font-size: 0.8125rem; color: var(--text-faint); margin-bottom: 0.5rem; }
.author-bio { font-size: 0.9rem; color: var(--text-dim); margin: 0; }

.reviewed {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem;
  font-size: 0.8125rem; color: var(--text-faint);
  padding-top: 1.25rem; margin-top: 2rem; border-top: 1px solid var(--border);
}

/* =============================================================== forms === */
.form-field { margin-bottom: 1.1rem; }
.form-field label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.35rem; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; min-height: 2.75rem; padding: 0.65rem 0.8rem;
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-lit); border-radius: var(--r-sm);
}
.form-field textarea { min-height: 9rem; resize: vertical; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus { border-color: var(--accent); }

/* ============================================================== footer === */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 4rem; }
.footer-top { display: grid; gap: 2rem; padding-block: 2.75rem 2rem; }
@media (min-width: 46rem)  { .footer-top { grid-template-columns: 1.4fr 1fr 1fr; } }
@media (min-width: 68rem)  { .footer-top { grid-template-columns: 1.6fr 1fr 1fr 1fr; } }

.footer-about .brand { margin-bottom: 0.75rem; }
.footer-about p { font-size: 0.9rem; color: var(--text-dim); max-width: 34ch; }
.footer-heading {
  font-family: var(--mono); font-size: 0.6875rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text-faint); margin-bottom: 0.7rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.site-footer li a {
  color: var(--text-dim); text-decoration: none; font-size: 0.9rem;
}
.site-footer li a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between;
  border-top: 1px solid var(--border); padding-block: 1.25rem;
  font-size: 0.8125rem; color: var(--text-faint);
}
.footer-bottom p { margin: 0; }
.footer-legal-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.footer-legal-links a { color: var(--text-faint); text-decoration: none; }
.footer-legal-links a:hover { color: var(--accent); }

/* ============================================================= consent === */
.consent {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 90;
  background: var(--surface); border-top: 1px solid var(--border-lit);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.4);
}
.consent[hidden] { display: none; }
.consent-inner {
  display: grid; gap: 0.9rem; align-items: center;
  width: 100%; max-width: var(--wrap); margin-inline: auto; padding: 1.1rem 1.25rem;
}
@media (min-width: 48rem) { .consent-inner { grid-template-columns: 1fr auto; gap: 1.75rem; } }
.consent-title { font-size: 0.9375rem; margin-bottom: 0.2rem; }
.consent-body { font-size: 0.875rem; color: var(--text-dim); margin: 0; }
.consent-actions { display: flex; gap: 0.5rem; }

/* ========================================================== utilities ==== */
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--text-dim); }
.center { text-align: center; }
.max-narrow { max-width: var(--wrap-narrow); margin-inline: auto; }

/* ---------------------------------------------------- metronome additions */
/* The metronome lights segments from JS rather than a CSS animation, because
   the lit segment has to follow the audio clock, not a timer. */
.beat-bar li.is-lit::after { opacity: 1; }
.beat-bar li.is-lit:first-child::after { box-shadow: 0 0 14px var(--accent-glow); }

.field input[type="range"] {
  width: 100%; min-height: 2.75rem; padding: 0; margin: 0;
  background: none; border: none; accent-color: var(--accent); cursor: pointer;
}

/* A stopped metronome should not look like a live control. */
.tap-button[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  color: var(--accent); border: 1px solid var(--accent);
}
