:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e2230; --text: #e8ebf1; --muted: #8b93a7;
  --accent: #4cc9f0; --accent2: #f4a261; --green: #7bd88f; --red: #ef476f; --line: #2a3040; --radius: 14px;
}
* { box-sizing: border-box; }
/* Locked page zoom: no double-tap zoom on fast taps, no rubber-band bounce, no text inflation. */
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { padding-bottom: 24px; overflow-x: hidden; }
button, input, select, textarea { touch-action: manipulation; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; position: sticky; top: 0; background: rgba(15,17,21,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { font-weight: 700; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modes { display: flex; background: var(--panel); border-radius: 999px; padding: 3px; flex-shrink: 0; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; font-weight: 600; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--panel2); color: var(--text); }
.tab:disabled { opacity: .4; cursor: default; }
.load { position: relative; flex-shrink: 0; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 170px; z-index: 6; }
.menu-item { text-align: left; background: transparent; border-color: transparent; }
.menu-item:hover { background: var(--panel2); }

.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; min-height: 42px; font-size: 14px; user-select: none; -webkit-user-select: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); color: #06222b; border-color: transparent; }
.btn.big { font-size: 22px; min-width: 76px; min-height: 56px; }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: 13px; }
.btn.active, .btn.toggle.on { background: var(--accent2); color: #2b1600; border-color: transparent; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.cue { background: #3a2a14; border-color: #7a5424; color: var(--accent2); min-height: 56px; font-weight: 800; letter-spacing: .02em; }
.btn.cue.at { outline: 2px solid var(--accent2); outline-offset: 1px; }
.btn.flash { background: var(--accent2); color: #2b1600; }

main { max-width: 960px; margin: 0 auto; padding: 10px 12px; display: grid; gap: 10px; }

.count-panel { text-align: center; padding: 4px 0 0; overflow: hidden; }
.count-label { font-size: min(28vw, 140px); line-height: 1; font-weight: 800; color: var(--accent); will-change: transform; min-height: 1em; font-variant-numeric: tabular-nums; }
.count-label.one { color: var(--accent2); }
.count-label.virtual { color: var(--muted); }
.count-meta { color: var(--muted); font-size: 14px; min-height: 20px; }
.beat-dots { display: flex; justify-content: center; gap: 8px; margin-top: 6px; min-height: 12px; }
.beat-dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.beat-dots span.on { background: var(--accent); }
.beat-dots span.first { outline: 2px solid var(--accent2); outline-offset: 1px; }
.beat-dots span.mute { opacity: .35; }
/* With a video on screen the big count sits on the video instead of above it. */
body.has-video .count-label { display: none; }
.count-overlay { position: absolute; top: 4px; right: 10px; font-size: 64px; line-height: 1; font-weight: 800; color: var(--accent); text-shadow: 0 0 10px rgba(0,0,0,.9), 0 0 2px #000; pointer-events: none; font-variant-numeric: tabular-nums; }
.count-overlay.one { color: var(--accent2); }
.count-overlay.virtual { color: var(--muted); }

.stage { display: grid; gap: 6px; }
.video-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; margin: 0 auto; max-width: 100%; }
video { width: 100%; height: 100%; object-fit: contain; display: block; }
video.mirror { transform: scaleX(-1); }
.wave { position: relative; }
.timeline { width: 100%; height: 100px; background: var(--panel); border-radius: var(--radius); touch-action: none; display: block; cursor: crosshair; }
.zoom-chips { position: absolute; top: 6px; right: 8px; display: flex; gap: 3px; }
.chip { border: 1px solid var(--line); background: rgba(15,17,21,.75); color: var(--muted); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; cursor: pointer; min-height: 22px; }
.chip { display: none; }
.chip.active { display: inline-block; background: var(--accent2); color: #2b1600; border-color: transparent; }
.overview { width: 100%; height: 28px; background: var(--panel); border-radius: 8px; touch-action: none; display: block; cursor: pointer; }
.video-strip { width: 100%; height: 64px; background: var(--panel); border-radius: var(--radius) var(--radius) 4px 4px; touch-action: none; display: block; cursor: ew-resize; }
.time-row { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.time-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.transport { display: flex; gap: 8px; justify-content: center; align-items: center; }
.transport .btn { flex: 1; max-width: 120px; }
.transport .btn.big { flex: 1.3; }

.panel-tabs { display: flex; background: var(--panel); border-radius: 999px; padding: 3px; gap: 2px; }
.ptab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 6px; border-radius: 999px; font-weight: 600; cursor: pointer; font-size: 14px; min-height: 38px; }
.ptab.active { background: var(--panel2); color: var(--text); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; align-content: start; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.head { justify-content: space-between; }
.hint { color: var(--muted); font-size: 13px; }
label { color: var(--muted); font-size: 13px; }
output { color: var(--text); font-weight: 600; min-width: 44px; font-variant-numeric: tabular-nums; }
input[type=range] { flex: 1; min-width: 110px; accent-color: var(--accent); }
/* 16 px keeps iOS Safari from zooming in when a field gets focus. */
input[type=number] { width: 92px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px; font-size: 16px; }
select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 16px; }
.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { gap: 4px; }
.seg .btn { flex: 1; }
.practice-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border: 1px solid #c77dff; border-radius: 10px; background: rgba(199,125,255,0.10); font-size: 14px; }
.practice-bar span { flex: 1; min-width: 200px; }
.pair-list { display: grid; gap: 6px; }
.pair { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); font-size: 13px; }
.pair.editing { border-color: #c77dff; }
.pair .pair-times { font-variant-numeric: tabular-nums; color: var(--text); }
.pair .pair-label { color: var(--muted); min-width: 64px; }
.pair .btn.small { min-height: 30px; padding: 4px 8px; }
.seg-list { display: flex; gap: 4px; flex-wrap: wrap; }
.seg-list .btn { font-variant-numeric: tabular-nums; }
.seg-list .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.debug { color: var(--muted); font-size: 11px; font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.drop { position: fixed; inset: 0; background: rgba(76,201,240,.15); border: 3px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 24px; z-index: 10; pointer-events: none; }

@media (max-width: 480px) {
  .brand { font-size: 14px; }
  .tab { padding: 6px 9px; font-size: 13px; }
  .btn { padding: 9px 10px; }
  .transport { gap: 6px; }
  .transport .btn { padding: 9px 6px; font-size: 13px; }
}
