:root {
  --ink: #1c1a18;
  --muted: #8b867f;
  --paper: #f3f0e9;
  --card: rgba(255, 255, 255, .62);
  --orange: #ff5b2e;
  --orange-dark: #dc3f17;
  --line: rgba(28, 26, 24, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,.98) 0, rgba(255,255,255,0) 38%),
    repeating-linear-gradient(90deg, rgba(30,25,20,.018) 0, rgba(30,25,20,.018) 1px, transparent 1px, transparent 4px),
    var(--paper);
}

button, input, select { font: inherit; }
button { color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(24px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; font-size: .82rem; font-weight: 800; letter-spacing: .22em; }
.brand-mark { width: 18px; height: 18px; border: 3px solid var(--orange); border-radius: 50%; position: relative; }
.brand-mark::after { content: ""; position: absolute; width: 3px; height: 8px; background: var(--orange); left: 5px; top: -7px; transform: rotate(25deg); }

.sound-button { border: 0; background: transparent; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .85rem; font-weight: 700; }
.sound-icon { color: var(--orange); font-size: 1.35rem; }
.sound-menu { position: absolute; z-index: 10; right: clamp(24px, 5vw, 72px); top: 64px; width: 224px; max-height: min(520px, calc(100vh - 90px)); overflow-y: auto; padding: 7px; border: 1px solid var(--line); border-radius: 14px; background: rgba(250,248,243,.96); box-shadow: 0 18px 50px rgba(30,24,18,.13); backdrop-filter: blur(14px); transform: translateY(-6px); opacity: 0; pointer-events: none; transition: .18s ease; }
.sound-menu.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.sound-menu button { display: block; width: 100%; border: 0; border-radius: 9px; padding: 10px 12px; text-align: left; background: transparent; cursor: pointer; }
.sound-menu button:hover, .sound-menu button[aria-selected="true"] { background: #eae5da; }
.sound-group + .sound-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.sound-group p { margin: 7px 12px 3px; color: var(--orange-dark); font-size: .58rem; font-weight: 850; letter-spacing: .16em; }

.stage { display: flex; min-height: 600px; flex-direction: column; align-items: center; justify-content: center; padding: 44px 24px 36px; }
.eyebrow, .settings label > span { margin: 0 0 14px; color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .18em; }
.tempo-row { display: flex; align-items: center; gap: clamp(24px, 7vw, 92px); }
.step-button { width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.4); cursor: pointer; font-size: 1.7rem; font-weight: 300; transition: .15s ease; }
.step-button:hover { border-color: var(--orange); color: var(--orange); transform: scale(1.05); }
.tempo-readout { display: flex; flex-direction: column; align-items: center; }
.tempo-readout input { width: 230px; border: 0; outline: none; background: transparent; color: var(--ink); text-align: center; font-size: clamp(5rem, 11vw, 8.5rem); font-weight: 250; line-height: .9; letter-spacing: -.08em; appearance: textfield; }
.tempo-readout input::-webkit-inner-spin-button { appearance: none; }
.tempo-readout span { margin-top: 12px; color: var(--orange); font-size: .72rem; font-weight: 800; letter-spacing: .22em; }

.visualizer { position: relative; width: 174px; height: 174px; display: grid; place-items: center; margin: 28px 0 24px; }
.orbit, .pulse-ring, .core { position: absolute; border-radius: 50%; }
.orbit { inset: 0; border: 1px solid rgba(28,26,24,.1); }
.orbit-one::before, .orbit-two::before { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--orange); left: calc(50% - 2px); top: -3px; }
.orbit-one { animation: rotate 8s linear infinite; }
.orbit-two { inset: 17px; animation: rotate 5s linear infinite reverse; opacity: .55; }
.pulse-ring { inset: 31px; border: 1px solid rgba(255,91,46,.35); transition: transform .1s, opacity .25s; }
.core { width: 68px; height: 68px; display: grid; place-items: center; color: white; background: var(--orange); box-shadow: 0 12px 40px rgba(255,91,46,.32); font-size: 1rem; font-weight: 800; transition: transform .1s, background .15s; }
.visualizer.beat .core { transform: scale(1.13); background: var(--orange-dark); }
.visualizer.beat .pulse-ring { transform: scale(1.45); opacity: 0; }
@keyframes rotate { to { transform: rotate(360deg); } }

.tempo-slider { width: min(460px, 80vw); height: 3px; appearance: none; border-radius: 2px; outline: none; background: linear-gradient(to right, var(--orange) var(--progress, 33.3%), #d5d0c7 var(--progress, 33.3%)); }
.tempo-slider::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border: 4px solid var(--paper); border-radius: 50%; background: var(--orange); box-shadow: 0 1px 7px rgba(0,0,0,.25); cursor: pointer; }
.range-labels { width: min(460px, 80vw); display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: .65rem; }
.transport { display: grid; grid-template-columns: 72px 82px 72px; align-items: center; gap: 28px; margin-top: 28px; }
.tap-button { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .15em; }
.tap-button:hover { color: var(--orange); }
.play-button { width: 82px; height: 82px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 12px 32px rgba(28,26,24,.18); cursor: pointer; display: grid; place-items: center; transition: transform .18s, background .18s; }
.play-button:hover { transform: scale(1.04); }
.play-button.loading { opacity: .65; cursor: wait; }
.play-icon { width: 0; height: 0; margin-left: 5px; border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 14px solid white; }
.play-button.playing { background: var(--orange); }
.play-button.playing .play-icon { width: 14px; height: 17px; margin: 0; border: 0; border-left: 5px solid white; border-right: 5px solid white; }
.hint { margin: 16px 0 0; color: var(--muted); font-size: .65rem; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: rgba(255,255,255,.45); font: inherit; }
.timer-display { display: flex; align-items: baseline; gap: 9px; margin: 12px 0 0; color: var(--muted); }
.timer-display[hidden] { display: none; }
.timer-display span { font-size: .58rem; font-weight: 800; letter-spacing: .14em; }
.timer-display strong { color: var(--orange-dark); font-size: .84rem; font-variant-numeric: tabular-nums; letter-spacing: .06em; }

.settings { display: flex; justify-content: center; gap: clamp(26px, 5vw, 76px); padding: 27px 24px 30px; border-top: 1px solid var(--line); background: rgba(255,255,255,.22); }
.settings label { min-width: 142px; display: flex; flex-direction: column; }
.settings select { appearance: none; min-width: 150px; border: 0; border-bottom: 1px solid var(--line); padding: 0 28px 8px 0; outline: none; background: transparent; font-weight: 650; cursor: pointer; }
.accent-control { position: relative; cursor: pointer; }
.accent-control input { position: absolute; opacity: 0; }
.accent-control i { width: 42px; height: 23px; border-radius: 20px; background: #cbc6bd; position: relative; transition: .2s; }
.accent-control i::after { content: ""; position: absolute; width: 17px; height: 17px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.accent-control input:checked + i { background: var(--orange); }
.accent-control input:checked + i::after { transform: translateX(19px); }

@media (max-width: 620px) {
  .stage { min-height: 0; padding-top: 38px; }
  .tempo-row { gap: 18px; }
  .tempo-readout input { width: 180px; }
  .visualizer { width: 145px; height: 145px; margin: 22px 0; }
  .settings { flex-wrap: wrap; gap: 24px; justify-content: flex-start; }
  .settings label { width: calc(50% - 12px); min-width: 120px; }
  .transport { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; } }
