:root {
  color-scheme: light;
  --paper: #f3f0e8;
  --ink: #1d1e1b;
  --muted: #77786f;
  --line: #d8d4ca;
  --acid: #d5ff3f;
  --acid-dark: #bce72a;
  --card: #fbfaf5;
  --shadow: 0 18px 45px rgba(45, 43, 33, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; min-width: 320px; min-height: 100dvh; color: var(--ink); background: var(--paper); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(29, 30, 27, .35); outline-offset: 3px; }
.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; }

.app-shell { width: min(100%, 520px); min-height: 100dvh; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-size: .82rem; font-weight: 850; letter-spacing: .18em; }
.brand-mark { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 50%; position: relative; }
.brand-mark::after { content: ""; position: absolute; width: 2px; height: 7px; left: 7px; top: 2px; background: var(--ink); transform: rotate(28deg); transform-origin: bottom; }
.header-actions { display: flex; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; }
.icon-button svg { width: 20px; height: 20px; fill: currentColor; }
.sound-off { display: none; }
.icon-button.muted .sound-on { display: none; }
.icon-button.muted .sound-off { display: block; }

.hero { min-height: 355px; display: grid; place-items: center; position: relative; }
.pulse-orbit { position: absolute; width: min(82vw, 330px); aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; transition: transform 90ms ease, border-color 90ms ease; }
.pulse-orbit::before, .pulse-orbit::after { content: ""; position: absolute; inset: 10%; border: 1px solid rgba(29,30,27,.06); border-radius: 50%; }
.pulse-orbit::after { inset: 26%; }
.pulse-orbit span { position: absolute; width: 12px; height: 12px; top: 7%; left: calc(50% - 6px); background: var(--acid); border: 2px solid var(--ink); border-radius: 50%; box-shadow: 0 0 0 5px var(--paper); }
.pulse-orbit.pulse { transform: scale(.965); border-color: var(--ink); }
.tempo-display { z-index: 1; text-align: center; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }
.tempo-value-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.tempo-input-wrap { width: min(72vw, 270px); }
.tempo-input { width: 100%; padding: 0; border: 0; background: transparent; text-align: center; font-size: clamp(4.25rem, 19vw, 6.25rem); line-height: 1; font-weight: 800; letter-spacing: -.08em; font-variant-numeric: tabular-nums; appearance: textfield; }
.tempo-input.ms-value { font-size: clamp(3.65rem, 16vw, 5.3rem); letter-spacing: -.07em; }
.tempo-input::-webkit-inner-spin-button { appearance: none; }
.unit-switch { display: inline-flex; margin-top: 12px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.35); }
.unit-option { padding: 7px 15px; border-radius: 999px; background: transparent; color: var(--muted); font-size: .68rem; font-weight: 850; letter-spacing: .12em; }
.unit-option.active { background: var(--ink); color: white; }

.controls-card { padding: 20px; border: 1px solid var(--line); border-radius: 26px; background: var(--card); box-shadow: var(--shadow); }
.slider-header { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
input[type="range"] { accent-color: var(--ink); }
.tempo-slider { width: 100%; height: 24px; margin: 0; }
.tempo-slider::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--ink) var(--range-progress, 25.7%), var(--line) var(--range-progress, 25.7%)); }
.tempo-slider::-webkit-slider-thumb { appearance: none; width: 22px; height: 22px; margin-top: -9px; border: 5px solid var(--card); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.play-row { display: grid; grid-template-columns: 1fr 108px 1fr; align-items: center; gap: 8px; margin-top: 18px; }
.tap-button, .haptic-button { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 7px; height: 54px; background: transparent; border-radius: 16px; color: var(--muted); font-size: .7rem; font-weight: 850; letter-spacing: .08em; }
.tap-button > span:last-child { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.tap-button strong { color: var(--ink); font-size: .65rem; letter-spacing: .06em; white-space: nowrap; }
.tap-button small { font-size: .55rem; font-weight: 650; letter-spacing: 0; white-space: nowrap; }
.tap-button:active, .haptic-button:active, .haptic-button.active { background: #ece9df; color: var(--ink); }
.tap-icon { font-size: 1.45rem; line-height: 0; }
.phone-icon { font-size: 1.5rem; line-height: 0; transform: rotate(90deg); }
.play-button { display: grid; place-items: center; width: 88px; height: 88px; justify-self: center; border-radius: 50%; background: var(--acid); box-shadow: inset 0 0 0 1px rgba(29,30,27,.12), 0 8px 24px rgba(164,196,35,.25); transition: transform 120ms ease, background 120ms ease; }
.play-button:active { transform: scale(.94); }
.play-button svg { width: 36px; height: 36px; fill: var(--ink); }
.pause-icon { display: none; }
.play-button.playing { background: var(--ink); }
.play-button.playing svg { fill: var(--acid); }
.play-button.playing .play-icon { display: none; }
.play-button.playing .pause-icon { display: block; }

.meter-section { padding: 32px 4px 22px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; }
.section-kicker { margin: 0 0 3px; color: var(--muted); font-size: .62rem; font-weight: 850; letter-spacing: .17em; }
h2 { margin: 0; font-size: 1.3rem; letter-spacing: -.03em; }
.meter-select-wrap select, .settings-panel select { min-height: 40px; padding: 0 32px 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: .78rem; font-weight: 750; }
.beat-grid { display: grid; grid-template-columns: repeat(var(--beats, 4), 1fr); gap: 10px; margin-top: 20px; }
.beat { position: relative; height: 56px; border: 1px solid var(--line); border-radius: 15px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 800; transition: transform 80ms ease, background 100ms ease; }
.beat::before { content: ""; position: absolute; left: 50%; top: 12px; width: 7px; height: 7px; transform: translateX(-50%); border-radius: 50%; background: currentColor; }
.beat strong { position: absolute; left: 0; right: 0; bottom: 9px; }
.beat.accent { background: var(--ink); color: var(--acid); border-color: var(--ink); }
.beat.current { transform: translateY(-4px); box-shadow: 0 6px 0 var(--acid); }
.beat-hint { margin: 12px 0 0; color: var(--muted); font-size: .7rem; text-align: center; }
footer { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 8px 0; color: #99998f; font-size: .55rem; font-weight: 800; letter-spacing: .12em; }
.footer-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--acid-dark); }

.scrim { position: fixed; inset: 0; z-index: 10; background: rgba(29,30,27,.35); backdrop-filter: blur(3px); }
.settings-panel { position: fixed; z-index: 11; left: 50%; bottom: 0; width: min(100%, 520px); padding: 10px 22px max(28px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--card); transform: translate(-50%, 105%); transition: transform 260ms cubic-bezier(.2,.8,.2,1); box-shadow: 0 -15px 45px rgba(29,30,27,.16); }
.settings-panel.open { transform: translate(-50%, 0); }
.panel-handle { width: 42px; height: 4px; margin: 0 auto 18px; border-radius: 4px; background: var(--line); }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-header .icon-button { font-size: 1.7rem; font-weight: 300; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 72px; border-bottom: 1px solid var(--line); }
.setting-row span { display: flex; flex-direction: column; gap: 3px; }
.setting-row strong { font-size: .85rem; }
.setting-row small { color: var(--muted); font-size: .68rem; }
.setting-row input[type="range"] { width: 125px; }
input[role="switch"] { appearance: none; width: 48px; height: 28px; padding: 3px; border-radius: 999px; background: var(--line); transition: background 150ms; }
input[role="switch"]::after { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: white; transition: transform 150ms; box-shadow: 0 2px 5px rgba(0,0,0,.2); }
input[role="switch"]:checked { background: var(--ink); }
input[role="switch"]:checked::after { transform: translateX(20px); background: var(--acid); }
.install-button { width: 100%; min-height: 52px; margin-top: 20px; border-radius: 15px; background: var(--acid); font-weight: 850; }
.screen-flash::after { content: ""; position: fixed; z-index: 20; inset: 0; pointer-events: none; background: rgba(213,255,63,.25); animation: flash 100ms ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

@media (min-width: 700px) {
  body { background: #dedbd2; }
  .app-shell { background: var(--paper); box-shadow: 0 0 80px rgba(29,30,27,.12); }
}
@media (max-height: 760px) {
  .hero { min-height: 290px; }
  .pulse-orbit { width: 270px; }
  .meter-section { padding-top: 24px; }
}
@media (max-width: 370px) {
  .controls-card { padding-inline: 16px; }
  .play-row { grid-template-columns: 70px 88px 70px; justify-content: space-between; }
  .play-button { width: 78px; height: 78px; }
  .tap-icon, .tap-button small { display: none; }
  .tap-button > span:last-child { align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
