/* Great Ticks — metronome UI.
   Base tokens/reset from great-apps/framework.css via CDN. */

/* Kill the mobile double-tap-zoom delay/gesture on every control so rapid taps
   (tap tempo, steppers) register instantly and never "lock out". */
button, .beat-dot, input[type="range"], input[type="checkbox"], select {
  touch-action: manipulation;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.app-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
}

/* Center the primary controls (tempo → subdivision) in the space above the
   pinned transport, so the tempo sits mid-screen instead of hugging the top. */
.main-controls {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ── Tempo ──────────────────────────────── */
.tempo-display {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-top: 4px;
}
.bpm-wrap { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.bpm-value {
  width: 3.2ch; text-align: center; padding: 0; border: none; outline: none;
  background: transparent; color: var(--text);
  font-size: 4.2rem; font-weight: 800; letter-spacing: -0.02em;
  -moz-appearance: textfield;
}
.bpm-value:focus { color: var(--accent); }
.bpm-value::-webkit-outer-spin-button,
.bpm-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-unit { font-size: 0.75rem; letter-spacing: 0.15em; color: var(--text-muted); font-weight: 600; margin-top: -6px; }

.tempo-term {
  text-align: center; color: var(--accent); font-size: 0.95rem;
  font-style: italic; margin: 2px 0 14px;
}

.tempo-slider { width: 80%; align-self: center; accent-color: var(--accent); margin-bottom: 20px; }

.step-btn {
  width: 44px; height: 44px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 1.5rem; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.step-btn:hover { border-color: var(--accent); }
.step-btn:active { background: var(--bg-active); }
.step-btn:disabled { opacity: 0.4; cursor: default; }
.step-btn:disabled:hover { border-color: var(--border); }

/* ── Beat dots ──────────────────────────── */
.beat-dots {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin-bottom: 22px; min-height: 46px;
}
.beat-dot {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700; cursor: pointer;
  border: 2px solid var(--border); background: var(--bg-surface); color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease-out, box-shadow 0.12s, background 0.12s, border-color 0.12s, color 0.12s;
}
.beat-dot.accent { border-color: var(--accent); color: #fff; background: var(--accent-dim); }
.beat-dot.normal { border-color: var(--border); color: var(--text); background: var(--bg-active); }
.beat-dot.mute   { border-style: dashed; color: var(--text-muted); background: transparent; opacity: 0.55; }
.beat-dot.active { box-shadow: 0 0 0 3px rgba(124, 111, 255, 0.35); }
.beat-dot.pulse  { animation: dotPulse 0.16s ease-out; }
.beat-dot.locked { cursor: default; }
.beat-dot:disabled { cursor: default; }
@keyframes dotPulse {
  0%   { transform: scale(1.35); box-shadow: 0 0 20px rgba(124, 111, 255, 0.7); }
  100% { transform: scale(1); }
}

/* ── Beat / measure tracker ─────────────── */
.tracker {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 40px; margin: -6px 0 18px; text-align: center;
}
.tracker[hidden] { display: none; }
.tracker-main { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.tracker-main .tk-dim { color: var(--text-muted); font-weight: 600; }

/* ── Program-mode banner + locked controls ─ */
.program-banner {
  display: block; width: 100%; text-align: center; font-size: 0.75rem; font-weight: 600;
  color: var(--accent); background: var(--accent-dim); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 8px 10px; margin: 0 auto 16px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.program-banner:hover { background: var(--accent); color: #fff; }
.program-banner[hidden] { display: none; }
body.program-mode .tempo-display,
body.program-mode .tempo-slider,
body.program-mode .meter-row { opacity: 0.9; }
.bpm-value:disabled { color: var(--text); }
.tempo-slider:disabled { opacity: 0.55; }

/* ── Meter row ──────────────────────────── */
.meter-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.beats-control, .subdiv-block { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }
.beats-control { flex-direction: row; align-items: center; }
.meter-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600;
}
.beats-control .meter-label { margin-right: 4px; }
.beats-readout { font-size: 1.3rem; min-width: 1.6ch; text-align: center; }
.beats-readout b { color: var(--accent); font-weight: 800; }

/* Time-signature widget: numerator over a tap-to-cycle denominator. */
.timesig { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; min-width: 2ch; }
.timesig .ts-num { font-size: 1.35rem; color: var(--accent); font-weight: 800; }
.timesig .ts-den {
  font-size: 1.05rem; font-weight: 800; color: var(--text);
  background: transparent; border: none; border-top: 2px solid var(--text-muted);
  padding: 1px 7px 0; margin-top: 2px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color 0.12s, border-color 0.12s;
}
.timesig .ts-den:hover { color: var(--accent); border-color: var(--accent); }
.timesig .ts-den:disabled { opacity: 0.7; cursor: default; }
.timesig .ts-den:disabled:hover { color: var(--text); border-color: var(--text-muted); }

.seg-control { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
/* Forces extended tuplets (5·6·9) onto a second row under the basic subdivisions. */
.seg-break { flex-basis: 100%; height: 0; margin: 0; }
.seg-btn {
  min-width: 46px; height: 44px; padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.seg-btn.active { color: #fff; background: var(--accent-dim); border-color: var(--accent); }
.seg-btn:disabled { opacity: 0.4; cursor: default; }
.seg-btn:disabled:hover { border-color: var(--border); }
.note-glyph { height: 22px; width: auto; display: block; }

/* ── Rest pattern (mute sub-positions within a beat) ─ */
.subpattern-block {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin: -8px 0 22px;
}
.subpattern-block[hidden] { display: none; }
.subpattern { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.subpos {
  min-width: 40px; height: 34px; padding: 0 8px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-size: 0.8rem; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color 0.12s, border-color 0.12s, background 0.12s, opacity 0.12s;
}
.subpos.downbeat { color: var(--accent); border-color: var(--accent); }
.subpos.rest {
  color: var(--text-muted); border-style: dashed; background: transparent; opacity: 0.55;
}
.subpos:hover:not(.rest) { border-color: var(--accent); }

/* ── Transport ──────────────────────────── */
.transport { display: flex; align-items: stretch; gap: 12px; }
.tap-btn {
  flex: 0 0 96px; border-radius: var(--radius);
  background: var(--bg-surface); border: 1px solid var(--border); color: var(--text);
  font-size: 1rem; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent;
  line-height: 1.15; padding: 12px 0;
}
.tap-btn .tap-sub { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }
.tap-btn:hover { border-color: var(--accent); }
.tap-btn.tapped { animation: tapFlash 0.18s ease-out; }
@keyframes tapFlash { 0% { background: var(--accent-dim); border-color: var(--accent); } 100% {} }

.play-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 72px; border-radius: var(--radius); cursor: pointer;
  background: linear-gradient(var(--accent), var(--accent-dim));
  border: none; color: #fff; font-size: 1.35rem; font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 20px rgba(124, 111, 255, 0.35);
  transition: filter 0.12s, box-shadow 0.12s;
}
.play-btn:active { filter: brightness(0.94); }
.play-btn.running { background: linear-gradient(#e05a6a, #c23b4d); box-shadow: 0 6px 20px rgba(224, 90, 106, 0.35); }
/* Play (triangle) → Pause (two bars) */
.play-icon {
  width: 0; height: 0; border-style: solid;
  border-width: 12px 0 12px 20px; border-color: transparent transparent transparent #fff;
}
.play-btn.running .play-icon {
  width: 18px; height: 22px; box-sizing: border-box; border-radius: 2px;
  border: none; border-left: 6px solid #fff; border-right: 6px solid #fff; background: transparent;
}

/* Stop / reset — square button beside the play-pause control */
.stop-btn {
  flex: 0 0 64px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: var(--bg-surface); border: 1px solid var(--border); color: var(--text);
  transition: border-color 0.12s, color 0.12s, opacity 0.12s;
}
.stop-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.stop-btn:disabled { opacity: 0.4; cursor: default; }
.stop-icon { width: 16px; height: 16px; background: currentColor; border-radius: 3px; }

.hint { text-align: center; color: var(--text-muted); font-size: 0.8rem; line-height: 1.45; margin-top: 14px; }

/* ── Settings drawer (shared pattern) ───── */
.settings-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 50; display: flex; justify-content: flex-end; }
.settings-panel { width: min(400px, 88vw); background: var(--bg-surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; height: 100%; }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
}
.settings-head h2 { font-size: 1.1rem; font-weight: 600; }
.settings-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 24px; }
.setting-block h3 {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-bottom: 10px; font-weight: 600;
}

.inst-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.inst-btn {
  padding: 11px 4px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted); font-size: 0.82rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.inst-btn:hover { border-color: var(--accent); }
.inst-btn.active { color: #fff; background: var(--accent-dim); border-color: var(--accent); }

.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 0.9rem; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }

.setting-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 10px; line-height: 1.45; }

/* ── Cloud sync control (settings drawer) ────────── */
.sync-signin {
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sync-state { font-size: 0.85rem; }

.sync-off {
  flex: none;
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sync-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.sync-alt {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sync-off:disabled,
.sync-alt:disabled { opacity: 0.6; cursor: default; }

.sync-message {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.sync-error { color: #ff8da9; }

/* ── Count-in + Program settings ────────── */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 0.9rem; padding: 4px 0;
}
.switch-row input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; flex: 0 0 auto;
}
.switch-row.disabled { opacity: 0.4; pointer-events: none; }

.countin-config {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px;
}
.countin-config.disabled { opacity: 0.4; pointer-events: none; }
.countin-config .beats-control { gap: 8px; }

.program-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.program-list.disabled { opacity: 0.4; pointer-events: none; }

.link-btn {
  background: none; border: none; color: var(--accent); font: inherit; font-weight: 600;
  cursor: pointer; padding: 0; text-decoration: underline; -webkit-tap-highlight-color: transparent;
}

/* ── Program page (dedicated full-screen editor) ── */
.program-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 60; display: flex; justify-content: center; }
.program-overlay[hidden] { display: none; }
.program-page {
  width: min(560px, 100vw); background: var(--bg-surface);
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100%;
}
.program-page .settings-head { gap: 10px; }
.program-page .settings-head h2 { flex: 1; }
.prog-enable-switch { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); }
.prog-enable-switch input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.program-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.program-toolbar { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.program-summary { font-size: 0.78rem; color: var(--text-muted); }

.program-cards { display: flex; flex-direction: column; gap: 12px; }
.program-cards.disabled { opacity: 0.4; pointer-events: none; }
.prog-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; transition: border-color 0.15s, box-shadow 0.15s;
}
.prog-card.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.prog-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.prog-letter {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent-dim); color: #fff; font-size: 0.82rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.prog-label {
  flex: 1 1 auto; min-width: 0; background: transparent; border: 1px solid transparent;
  border-radius: 6px; color: var(--text); font-size: 0.9rem; font-weight: 600; padding: 5px 6px;
}
.prog-label::placeholder { color: var(--text-muted); font-weight: 400; }
.prog-label:hover { border-color: var(--border); }
.prog-label:focus { outline: none; border-color: var(--accent); background: var(--bg-surface); }
.prog-tools { display: flex; gap: 4px; flex: 0 0 auto; }
.prog-tool {
  width: 28px; height: 28px; border-radius: 6px; background: transparent;
  border: 1px solid var(--border); color: var(--text-muted); font-size: 0.9rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center;
}
.prog-tool:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.prog-tool:disabled { opacity: 0.3; cursor: default; }
.prog-tool.prog-del:hover:not(:disabled) { border-color: #e05a6a; color: #e05a6a; }

.prog-card-body { display: grid; gap: 8px 10px; grid-template-columns: 1fr 1fr; }
.prog-field {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
/* Inline "beats / denominator" time signature inside a program card. */
.ts-inline { display: flex; align-items: center; gap: 3px; }
.ts-inline .ts-beats { flex: 1 1 auto; min-width: 0; }
.ts-inline .ts-slash { color: var(--text-muted); font-weight: 700; }
.ts-inline .ts-den { flex: 1 1 auto; min-width: 0; }
.prog-in {
  width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 0.9rem; padding: 5px 4px;
  text-align: center; -moz-appearance: textfield;
}
.prog-in:focus { outline: none; border-color: var(--accent); }
.prog-in::-webkit-outer-spin-button, .prog-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select.prog-in { text-align: left; padding: 5px 4px; }
.add-section-btn {
  margin-top: 10px; width: 100%; padding: 9px; background: var(--bg);
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.85rem; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.add-section-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.add-section-btn:disabled { opacity: 0.4; cursor: default; }

.settings-foot {
  padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}
.foot-note { font-size: 0.78rem; color: var(--text-muted); }

/* ── Mobile ─────────────────────────────── */
@media (max-width: 480px) {
  .meter-row { flex-direction: column; align-items: center; gap: 16px; }
  .subdiv-block { width: 100%; }
  .subdiv-block .seg-control { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 420px) {
  .bpm-value { font-size: 3.6rem; }
  .beat-dot { width: 38px; height: 38px; }
  .meter-row { gap: 10px; }
}

/* ── Visual metronome overlay ───────────── */
.visual-overlay {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  overflow: hidden; touch-action: manipulation;
}
.visual-overlay[hidden] { display: none; }
.viz-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.viz-bar {
  position: absolute; left: 0; right: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; transition: opacity 0.35s ease, transform 0.35s ease;
}
.viz-top {
  top: 0;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  background: linear-gradient(to bottom, rgba(15, 15, 19, 0.88), rgba(15, 15, 19, 0));
}
.viz-bottom {
  bottom: 0;
  flex-direction: column; align-items: stretch; justify-content: flex-end; gap: 10px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  background: linear-gradient(to top, rgba(15, 15, 19, 0.88), rgba(15, 15, 19, 0));
}
.viz-top-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* Auto-hide the chrome for an unobstructed view while running. */
.visual-overlay.viz-idle .viz-top { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.visual-overlay.viz-idle .viz-bottom { opacity: 0; transform: translateY(8px); pointer-events: none; }

.viz-style { flex: 0 1 auto; }
.viz-style .seg-btn {
  min-width: 0; height: 40px; padding: 0 13px; font-size: 0.82rem; font-weight: 600;
  background: rgba(26, 26, 36, 0.72);
}
.viz-style .seg-btn.active { color: #fff; background: var(--accent-dim); border-color: var(--accent); }
.visual-overlay .icon-btn { background: rgba(26, 26, 36, 0.72); }

.viz-readout { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.viz-tempo-num { display: inline-flex; align-items: baseline; gap: 6px; min-width: 62px; justify-content: center; }
.viz-tempo-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 26, 36, 0.72); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 1.4rem; line-height: 1;
  cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none;
}
.viz-tempo-btn:hover { border-color: var(--accent); }
.viz-tempo-btn:active { background: var(--bg-active); }
.viz-tempo-btn[hidden] { display: none; }
.viz-bpm-input {
  width: 3.1ch; text-align: center; padding: 0; border: none; outline: none;
  background: transparent; color: var(--text); line-height: 1;
  font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; cursor: text;
}
.viz-bpm-input:focus { color: var(--accent); }
.viz-bpm-input:read-only { cursor: default; }
.viz-bpm-input::-webkit-outer-spin-button,
.viz-bpm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.viz-readout .viz-unit { font-size: 0.7rem; letter-spacing: 0.12em; font-weight: 600; }
.viz-readout .viz-meter { font-size: 0.85rem; }
.viz-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.viz-tempo-slider { width: 100%; height: 26px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.viz-tempo-slider[hidden] { display: none; }

.viz-play {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 128px; min-height: 52px; padding: 0 22px; flex: 0 0 auto;
  border: none; border-radius: var(--radius); cursor: pointer; color: #fff;
  font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(var(--accent), var(--accent-dim));
  box-shadow: 0 6px 20px rgba(124, 111, 255, 0.35);
  -webkit-tap-highlight-color: transparent; transition: filter 0.12s, box-shadow 0.12s;
}
.viz-play:active { filter: brightness(0.94); }
.viz-play.running { background: linear-gradient(#e05a6a, #c23b4d); box-shadow: 0 6px 20px rgba(224, 90, 106, 0.35); }
.viz-play .play-icon {
  width: 0; height: 0; border-style: solid;
  border-width: 9px 0 9px 15px; border-color: transparent transparent transparent #fff;
}
.viz-play.running .play-icon { width: 14px; height: 17px; box-sizing: border-box; border: none; border-left: 5px solid #fff; border-right: 5px solid #fff; background: transparent; }

.viz-rotate-hint {
  position: absolute; top: 22%; left: 50%; transform: translate(-50%, -50%); z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  color: var(--text-muted); background: rgba(26, 26, 36, 0.92);
  border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; font-size: 0.85rem;
}
.viz-rotate-hint[hidden] { display: none; }

.viz-tap-hint {
  position: absolute; left: 0; right: 0; z-index: 1;
  bottom: calc(98px + env(safe-area-inset-bottom, 0px));
  text-align: center; color: var(--text-muted); font-size: 0.85rem; pointer-events: none;
  transition: opacity 0.3s;
}
.viz-tap-hint.hide { opacity: 0; }

/* Visualization settings panel (opened by the gear in the top bar). */
.viz-settings {
  position: absolute; z-index: 4;
  top: calc(60px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: min(300px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 15px;
  padding: 16px 18px; border-radius: 16px;
  background: rgba(18, 18, 26, 0.97); border: 1px solid var(--border);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
}
.viz-settings[hidden] { display: none; }
.viz-set-title { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.viz-set-row { display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; color: var(--text); }
.viz-set-row span { display: flex; justify-content: space-between; align-items: baseline; }
.viz-set-row span b { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; }
.viz-set-row input[type="range"] { width: 100%; margin: 0; }
.viz-set-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.9rem; color: var(--text); }
.viz-set-note { margin: 0; font-size: 0.72rem; color: var(--text-muted); line-height: 1.45; }

@media (orientation: landscape) {
  .viz-tap-hint { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 430px) {
  .viz-bar { padding-top: 8px; padding-bottom: 8px; }
  .viz-play { min-height: 46px; min-width: 112px; }
  .viz-bpm-input { font-size: 1.3rem; }
  .viz-readout { gap: 6px; }
  .viz-tempo-btn { width: 38px; height: 38px; }
  .viz-tempo-num { min-width: 54px; }
}
