:root {
  --paper: #ffffff;
  --ink: #111827;
  --blue: #2563EB;
  --blue-soft: #EFF4FF;
  --muted: #4B5563;
  --line: #C9CED6;
  --card: #F8FAFC;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: Bahnschrift, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
main, .top, .foot { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.top { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding-top: 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; color: var(--ink); display: flex; align-items: baseline; gap: 8px; }
.mark { font-weight: 800; letter-spacing: 0.12em; font-size: 22px; }
.sub { color: var(--blue); font-weight: 700; font-size: 16px; }
.tag { margin: 0; color: var(--muted); font-size: 14px; }

.pick { margin-top: 18px; }
.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.pickrow { display: flex; gap: 8px; }
select { flex: 1; min-width: 0; padding: 12px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); font-size: 16px; }
.ghost { padding: 0 18px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); font-weight: 700; transition: background 300ms var(--ease); }
.ghost:hover { background: var(--card); }

.player { margin-top: 18px; }
/* Signature: the title sits on a five-line staff. */
.staff-title { position: relative; padding: 14px 0 12px; background:
  repeating-linear-gradient(to bottom, transparent 0, transparent 11px, var(--line) 11px, var(--line) 12px) 0 6px / 100% 60px no-repeat; }
.group { display: table; margin-bottom: 4px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: 0.04em; }
h1 { margin: 8px 0 0; font-size: clamp(24px, 5.5vw, 36px); line-height: 1.15; background: var(--paper); display: inline; box-decoration-break: clone; -webkit-box-decoration-break: clone; padding-right: 6px; }
.concept { color: var(--muted); margin: 10px 0 0; font-size: 16px; }

/* Stage: the full kit (always visible) and the notation. Side by side on wide screens, stacked on phones. */
.stage { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; margin-top: 14px; }
.kitbox { border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 0; background: var(--paper); }
.kitwrap { width: 100%; }
.stage .score { max-height: min(72vh, 640px); overflow-y: auto; overscroll-behavior: contain; }
.count { margin: 0 0 4px; padding: 0 4px; display: flex; align-items: center; gap: 14px; min-height: 56px; }
.count-now { font-size: 48px; font-weight: 800; min-width: 3ch; color: var(--blue); line-height: 1; }
.count-row { display: flex; flex-wrap: wrap; gap: 6px; font-size: 18px; color: #9CA3AF; font-weight: 600; }
.count-row span.on { color: var(--blue); font-weight: 800; }
.count-row span.beat { color: var(--ink); }
.count-row span.beat.on { color: var(--blue); }

.score { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); overflow: hidden; }
canvas { display: block; width: 100%; }

.controls { display: grid; grid-template-columns: auto 1fr; gap: 16px 20px; align-items: center; margin-top: 16px; padding: 16px; background: var(--card); border-radius: 14px; }
.play { width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; font-size: 20px; font-weight: 800; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35); transition: transform 300ms var(--ease), background 300ms var(--ease); }
.play:hover { transform: scale(1.04); }
.play[aria-pressed="true"] { background: var(--ink); box-shadow: none; }
.play:disabled { opacity: 0.5; cursor: default; }
.tempo { min-width: 0; }
.tempo-head { display: flex; align-items: center; gap: 14px; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); font-size: 22px; font-weight: 700; line-height: 1; }
.bpm { display: flex; align-items: baseline; gap: 6px; }
.bpm span { font-size: 36px; font-weight: 800; min-width: 3ch; text-align: right; }
.bpm small { color: var(--muted); font-weight: 700; }
input[type=range] { width: 100%; margin: 12px 0 8px; accent-color: var(--blue); height: 28px; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; transition: border-color 300ms var(--ease); }
.chip:hover, .chip.on { border-color: var(--blue); color: var(--blue); }
.toggles { grid-column: 1 / -1; display: flex; gap: 18px; flex-wrap: wrap; font-size: 15px; font-weight: 600; }
.toggles label { display: flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.toggles input { width: 20px; height: 20px; accent-color: var(--blue); }

.steps { margin-top: 26px; }
h2 { font-size: 20px; margin: 0 0 10px; }
ol { margin: 0; padding-left: 22px; line-height: 1.55; }
ol li { margin-bottom: 6px; }
.task { margin-top: 14px; border-left: 4px solid var(--blue); background: var(--blue-soft); padding: 12px 14px; border-radius: 0 10px 10px 0; }
.task p { margin: 4px 0 0; }

.foot { margin-top: 36px; padding-top: 16px; padding-bottom: 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.social { display: flex; gap: 16px; flex-wrap: wrap; }
.social a { color: var(--blue); font-weight: 700; text-decoration: none; }
.social a:hover { text-decoration: underline; }
.small { font-size: 13px; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; gap: 10px; }
  .stage .score { max-height: 38vh; }
}
/* Phones: compact header, kit first, and the Play + tempo bar stuck to the bottom of the screen. */
@media (max-width: 560px) {
  .top { padding-top: 12px; padding-bottom: 8px; }
  .tag { display: none; }
  .pick { margin-top: 12px; }
  .lbl { display: none; }
  select { padding: 10px; }
  .player { margin-top: 12px; }
  .staff-title { padding: 6px 0 6px; background-size: 100% 48px; }
  h1 { font-size: 22px; }
  .concept { font-size: 14px; margin-top: 6px; }
  .count { min-height: 44px; gap: 10px; }
  .count-now { font-size: 34px; min-width: 2.4ch; }
  .count-row { font-size: 15px; gap: 4px; }
  .controls {
    position: sticky; bottom: 0; z-index: 5; margin: 12px -16px 0; border-radius: 16px 16px 0 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); grid-template-columns: auto 1fr; gap: 8px 12px;
    box-shadow: 0 -6px 20px rgba(17, 24, 39, 0.12); background: #fff; border-top: 1px solid var(--line);
  }
  .play { width: 64px; height: 64px; font-size: 16px; }
  .tempo-head { gap: 8px; }
  .round { width: 36px; height: 36px; font-size: 20px; }
  .bpm span { font-size: 26px; }
  input[type=range] { margin: 2px 0; height: 24px; }
  .presets { gap: 6px; }
  .chip { padding: 5px 10px; font-size: 13px; }
  .toggles { gap: 12px; font-size: 13px; }
  .toggles label { min-height: 24px; gap: 4px; }
  .toggles input { width: 16px; height: 16px; }
  .kitbox { padding: 8px 8px 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Accounts and plans (Free / Basic / Premium) ---------- */
.top { position: relative; }
.acct { margin-left: auto; border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; }
.acct:hover { background: var(--card); }
.score { position: relative; }
.lock { padding: 28px 20px; text-align: center; }
.lock-title { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.lock-text { color: var(--muted); margin: 0 0 14px; }
.cta { border: 0; background: var(--blue); color: #fff; font-weight: 800; border-radius: 10px; padding: 12px 18px; transition: transform 300ms var(--ease); }
.cta:hover { transform: translateY(-1px); }
.cta:disabled { opacity: 0.5; cursor: default; transform: none; }
.pro-tools { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 15px; font-weight: 600; }
.pro-tools label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.pro-tools input { width: 20px; height: 20px; accent-color: var(--blue); }
.tag-premium { background: var(--ink); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.plans { margin-top: 30px; }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.plan { border: 1.5px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.plan.best { border-color: var(--blue); box-shadow: 0 6px 18px rgba(37, 99, 235, 0.15); }
.plan.current { background: var(--blue-soft); }
.plan h3 { margin: 0; font-size: 18px; }
.plan .price { font-size: 26px; font-weight: 800; }
.plan ul { margin: 0 0 8px; padding-left: 18px; line-height: 1.5; flex: 1; }
.plan button { width: 100%; padding: 12px; }
.manage a { color: var(--blue); font-weight: 700; }
.pay-note { color: var(--muted); font-size: 14px; }
dialog.auth { border: 0; border-radius: 16px; padding: 22px 22px 18px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(17, 24, 39, 0.3); color: var(--ink); }
dialog.auth::backdrop { background: rgba(17, 24, 39, 0.45); }
.auth h2 { margin: 0 0 12px; }
.auth form { display: grid; gap: 12px; }
.auth label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
.auth input[type=email], .auth input[type=password], .auth input[type=text] { width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; font-size: 16px; }
.auth input:focus { border-color: var(--blue); outline: none; }
.pw { position: relative; display: block; }
.pw input { padding-right: 70px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--card); border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 13px; }
.auth .links { font-size: 14px; margin: 12px 0 0; }
.auth .links a { color: var(--blue); font-weight: 700; }
.auth .x { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 26px; line-height: 1; }
.auth .note { color: var(--blue); font-weight: 700; margin: 0 0 8px; min-height: 0; }
.auth .note:empty, .auth .err:empty { display: none; }
.auth .err { color: #B91C1C; font-weight: 700; margin: 0 0 8px; }
.acc-email { color: var(--muted); }
.acc-actions { display: flex; gap: 10px; margin-top: 14px; }
.acc-actions button { padding: 10px 16px; }
[hidden] { display: none !important; }
@media (max-width: 900px) { .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .plan-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .acct { padding: 5px 10px; font-size: 13px; }
  .pro-tools { gap: 10px; font-size: 13px; }
  .pro-tools input { width: 16px; height: 16px; }
}
