:root {
  color-scheme: dark;
  --ink: #eef6ec;
  --muted: #a5b5ad;
  --paper: #101613;
  --panel: #17211c;
  --panel-2: #1d2923;
  --line: #33453b;
  --mint: #7fffb2;
  --yellow: #ffd866;
  --pink: #ff6b9d;
  --blue: #73d7ff;
  --shadow: #07100b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(127, 255, 178, .09), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.65;
}

a { color: var(--blue); text-underline-offset: .18em; }
a:hover { color: var(--mint); }

.page {
  width: min(100% - 2rem, 980px);
  margin: 0 auto;
  padding: 4rem 0 6rem;
}

.eyebrow {
  color: var(--mint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1, h2, h3 { line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 8vw, 5.7rem); letter-spacing: -.055em; margin: .4rem 0 1rem; }
h2 { font-size: clamp(1.55rem, 4vw, 2.25rem); margin: 3.5rem 0 1rem; letter-spacing: -.025em; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { max-width: 68ch; }
.lede { color: #d3dfd7; font-size: clamp(1.08rem, 2.5vw, 1.35rem); max-width: 58ch; }
.meta { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }

.win {
  border-left: 4px solid var(--yellow);
  margin: 2rem 0;
  padding: .25rem 0 .25rem 1.25rem;
}
.win strong { color: var(--yellow); }

.concepts {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
  margin: 1.5rem 0;
}
.card, .source-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.15rem;
}
.card .number {
  color: var(--pink);
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  margin-bottom: .5rem;
}
.card p, .source-card p { color: var(--muted); font-size: .94rem; margin: 0; }

.sequencer-shell {
  background: #0a0f0c;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .28);
  margin: 1.5rem 0;
  overflow: hidden;
}
.transport {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  justify-content: space-between;
  padding: 1rem;
}
.transport-group { display: flex; flex-wrap: wrap; gap: .55rem; }
button {
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font: 700 .85rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  min-height: 42px;
  padding: .7rem .9rem;
}
button:hover { border-color: var(--mint); }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button.primary { background: var(--mint); border-color: var(--mint); color: #092113; }
button.danger:hover { border-color: var(--pink); }

.tempo { color: var(--muted); font: .8rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.grid-wrap { overflow-x: auto; padding: 1rem; }
.beat-labels, .note-row {
  display: grid;
  gap: 5px;
  grid-template-columns: 54px repeat(16, minmax(29px, 1fr));
  min-width: 760px;
}
.beat-labels { color: var(--muted); font: .7rem ui-monospace, SFMono-Regular, Menlo, monospace; margin-bottom: 6px; text-align: center; }
.beat-labels span:nth-child(4n + 2) { color: var(--yellow); font-weight: 800; }
.note-row { margin-top: 5px; }
.note-name { align-items: center; color: var(--muted); display: flex; font: .75rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.cell {
  aspect-ratio: 1;
  background: #151e19;
  border: 1px solid #26352d;
  border-radius: 4px;
  min-height: 29px;
  padding: 0;
}
.cell.beat { border-left-color: #657a6c; }
.cell.active { background: var(--mint); border-color: var(--mint); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22); }
.cell.playing { outline: 2px solid var(--yellow); outline-offset: 1px; }
.cell.active.playing { background: var(--yellow); }
.sequencer-note { color: var(--muted); font-size: .8rem; margin: 0; padding: 0 1rem 1rem; }

.challenge {
  background: linear-gradient(135deg, rgba(255, 216, 102, .1), rgba(127, 255, 178, .06));
  border: 1px solid #5d5637;
  border-radius: 14px;
  padding: 1.25rem;
}
.challenge ol { margin-bottom: 1.25rem; }
.feedback { color: var(--muted); margin: 1rem 0 0; min-height: 1.7em; }
.feedback.success { color: var(--mint); }
.feedback.try-again { color: var(--yellow); }

.rhythm-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(16, minmax(34px, 1fr));
  min-width: 680px;
}
.rhythm-cell {
  aspect-ratio: 1;
  background: #151e19;
  border: 1px solid #26352d;
  border-radius: 5px;
  min-height: 34px;
  padding: 0;
  position: relative;
}
.rhythm-cell::after {
  color: #718279;
  content: attr(data-count);
  font: 700 .68rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  inset: auto 0 .42rem;
  position: absolute;
  text-align: center;
}
.rhythm-cell.beat-start { border-left: 3px solid #657a6c; }
.rhythm-cell.beat-start::after { color: var(--yellow); }
.rhythm-cell.active {
  background: var(--mint);
  border-color: var(--mint);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .22);
}
.rhythm-cell.active::after { color: #092113; }
.rhythm-cell.playing { outline: 2px solid var(--yellow); outline-offset: 2px; }
.rhythm-cell.active.playing { background: var(--yellow); }

.legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font: .78rem ui-monospace, SFMono-Regular, Menlo, monospace;
  gap: .55rem 1.15rem;
  padding: 0 1rem 1rem;
}
.legend span::before {
  border: 1px solid var(--line);
  border-radius: 2px;
  content: "";
  display: inline-block;
  height: .72rem;
  margin-right: .4rem;
  vertical-align: -.08rem;
  width: .72rem;
}
.legend .anchor::before { border-left: 3px solid #657a6c; }
.legend .sound::before { background: var(--mint); border-color: var(--mint); }

.recall {
  border: 1px dashed var(--line);
  border-radius: 12px;
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
}
.recall summary { cursor: pointer; font-weight: 800; }
.recall p { color: var(--muted); margin-bottom: 0; }

.count-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  margin: 1.3rem 0;
  min-width: 620px;
}
.count-grid span { border-left: 1px solid var(--line); padding: .45rem .25rem; text-align: center; }
.count-grid span:nth-child(4n + 1) { color: var(--yellow); font-weight: 800; }
.overflow { overflow-x: auto; }

.callout {
  background: rgba(115, 215, 255, .06);
  border: 1px solid rgba(115, 215, 255, .28);
  border-radius: 12px;
  padding: 1rem 1.2rem;
}
.callout p { margin: 0; }

.next {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding-top: 2rem;
}

footer { color: var(--muted); font-size: .85rem; margin-top: 4rem; }

@media (max-width: 720px) {
  .page { padding-top: 2.5rem; }
  .concepts { grid-template-columns: 1fr; }
}

@media print {
  :root { color-scheme: light; --ink: #111; --muted: #444; --paper: #fff; --panel: #f5f5f2; --panel-2: #eee; --line: #bbb; }
  body { background: white; font-size: 11pt; }
  .page { max-width: none; padding: 0; width: 100%; }
  button { display: none; }
  a { color: #111; }
  .sequencer-shell { box-shadow: none; }
}
