:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e2230; --text: #e8ebf1; --muted: #8b93a7;
  --accent: #4cc9f0; --accent2: #f4a261; --green: #7bd88f; --red: #ef476f; --line: #2a3040; --radius: 14px;
  /* one colour per function, taken from the logo's gradient */
  --c-play: #4cc9f0; --c-loop: #ffd23f; --c-grid: #ff8c42; --c-count: #ff5c8a; --c-video: #c77dff; --ink: #0b0c10;
}
* { 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 { display: flex; align-items: center; gap: 8px; margin-right: auto; text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.brand-word { height: 22px; width: auto; }
.welcome { text-align: center; padding: 18px 12px 6px; display: grid; gap: 6px; justify-items: center; }
.welcome img { height: 72px; width: auto; max-width: 92vw; }
.welcome p { margin: 0; max-width: 420px; color: var(--text); }
.welcome .slogan { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.welcome .hint { color: var(--muted); }
.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; }

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); }
.fs-btn { position: absolute; left: 8px; top: 8px; width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.45); color: #fff; font-size: 18px; cursor: pointer; }
/* Full screen: the video and the count together. Real fullscreen where the browser allows
   it, otherwise the same box pinned over the whole viewport (iPhone). */
.video-wrap:fullscreen, .video-wrap.stage-full { position: fixed; inset: 0; width: 100vw !important; height: 100vh !important; max-width: none; border-radius: 0; z-index: 50; background: #000; }
.video-wrap:fullscreen video, .video-wrap.stage-full video { width: 100%; height: 100%; object-fit: contain; }
.video-wrap:fullscreen .count-overlay, .video-wrap.stage-full .count-overlay { font-size: 22vmin; top: 2vmin; right: 4vmin; }
.video-wrap:fullscreen .fs-btn, .video-wrap.stage-full .fs-btn { left: 12px; top: 12px; width: 44px; height: 44px; }

.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: 6px; justify-content: center; }
/* Five equal buttons, colour-coded by family: green = the cue, cyan = play, yellow = loop.
   The main action of a family is solid, the secondary one tinted. */
.transport .btn { flex: 1 1 0; min-width: 0; max-width: 150px; min-height: 56px; font-size: 15px; font-weight: 800; padding: 6px 4px; border-radius: 12px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.1; }
.transport .ic { font-size: 18px; line-height: 1; }
.t-start { background: color-mix(in srgb, var(--c-play) 20%, var(--panel)); color: var(--c-play); border-color: color-mix(in srgb, var(--c-play) 55%, transparent); }
.t-play { background: var(--c-play); color: var(--ink); border-color: transparent; }
.t-setcue { background: color-mix(in srgb, var(--green) 20%, var(--panel)); color: var(--green); border-color: color-mix(in srgb, var(--green) 55%, transparent); }
.t-cue { background: var(--green); color: var(--ink); border-color: transparent; }
.t-cue.at { outline: 2px solid #fff; outline-offset: 1px; }
.t-setcue.flash { background: var(--green); color: var(--ink); }
.t-loop { background: color-mix(in srgb, var(--c-loop) 20%, var(--panel)); color: var(--c-loop); border-color: color-mix(in srgb, var(--c-loop) 55%, transparent); }
.t-loop.on { background: var(--c-loop); color: var(--ink); border-color: transparent; }

.panel-tabs { display: flex; gap: 6px; }
/* Every tab wears its own colour all the time: tinted when closed, solid when open. */
.ptab { flex: 1; border: 1px solid color-mix(in srgb, var(--pc) 55%, transparent); background: color-mix(in srgb, var(--pc) 20%, var(--panel)); color: var(--pc); padding: 8px 6px; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 14px; min-height: 40px; }
.ptab.active { background: var(--pc); color: var(--ink); border-color: transparent; }
.ptab[data-panel=play], #panel-play { --pc: var(--c-play); }
.ptab[data-panel=loop], #panel-loop { --pc: var(--c-loop); }
.ptab[data-panel=grid], #panel-grid { --pc: var(--c-grid); }
.ptab[data-panel=count], #panel-count { --pc: var(--c-count); }
.ptab[data-panel=video], #panel-video { --pc: var(--c-video); }

.panel { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--pc); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; align-content: start; }
.panel .head strong { color: var(--pc); }
.panel .btn.active, .panel .btn.toggle.on { background: var(--pc); color: var(--ink); border-color: transparent; }
.panel input[type=range], .panel .chk input { accent-color: var(--pc); }
.panel .seg-list .btn.active { background: var(--pc); color: var(--ink); }
.pair.editing { border-color: var(--c-video); }
.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-word { height: 18px; }
  .brand-mark { width: 26px; height: 26px; }
  .tab { padding: 6px 9px; font-size: 13px; }
  .btn { padding: 9px 10px; }
  .transport { gap: 4px; }
  .transport .btn { font-size: 12px; min-height: 54px; }
  .transport .ic { font-size: 16px; }
}

.sheet { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; max-width: 460px; width: calc(100vw - 32px); }
.sheet::backdrop { background: rgba(0,0,0,.6); }
.sheet h2 { margin: 0 0 8px; font-size: 18px; }
.sheet p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.sheet dl { margin: 0 0 14px; display: grid; gap: 8px; }
.sheet dt { font-weight: 700; font-size: 14px; }
.sheet dd { margin: 0; color: var(--muted); font-size: 14px; }
.sheet em { color: var(--text); font-style: normal; font-weight: 600; }
.sheet form { text-align: right; }

/* The About section under the app, and the privacy page. */
.about { margin-top: 28px; padding: 18px 4px 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; max-width: 640px; }
.about h2 { font-size: 15px; color: var(--text); margin: 14px 0 6px; }
.about p, .about ol { margin: 0 0 8px; line-height: 1.5; }
.about ol { padding-left: 20px; }
.about a { color: var(--accent); }
.page { max-width: 680px; margin: 0 auto; padding: 18px 16px 40px; line-height: 1.55; }
.page h1 { font-size: 28px; margin: 6px 0 6px; }
.page h2 { font-size: 17px; margin: 22px 0 6px; }
.page p, .page li { color: var(--text); }
.page .lede { font-size: 17px; color: var(--muted); }
.page a { color: var(--accent); }
.page ul { padding-left: 20px; }
body.doc .top { justify-content: space-between; }
body.doc .top .btn { text-decoration: none; display: inline-flex; align-items: center; }

.recent-list { display: grid; gap: 6px; margin: 0 0 14px; }
.recent-item { display: flex; align-items: center; gap: 8px; }
.recent-item .btn { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .kind { font-size: 11px; color: var(--muted); text-transform: uppercase; width: 44px; flex-shrink: 0; }

.plans { gap: 8px; margin: 4px 0 8px; }
.btn.plan { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; min-height: 64px; background: var(--c-play); color: var(--ink); border-color: transparent; }
.btn.plan strong { font-size: 20px; }
.btn.plan span { font-size: 12px; font-weight: 600; opacity: .85; }
#proKey { flex: 1; min-width: 160px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px 10px; font-size: 16px; font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }
#proError { color: var(--red); }
.sheet .row { margin-bottom: 8px; }

.auth { display: grid; gap: 8px; margin: 0 0 6px; }
.auth input, #resetPass { width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 16px; }
.auth .row { margin: 2px 0; }
.hint.error { color: var(--red); }
.hint a { color: var(--accent); }
#btnWelcomeSignup { margin-top: 4px; }

.consent { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; max-width: 560px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.consent p { margin: 0; font-size: 13px; line-height: 1.4; }
.consent a { color: var(--accent); }
.consent .row { display: flex; gap: 8px; }
