:root {
  --bg: #0d0d10; --panel: #16161b; --panel2: #1f1f26; --line: #2c2c36;
  --text: #e8e8ee; --dim: #8a8a98; --a: #2ec4ff; --b: #ff5ca8; --accent: #2ec4ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.3 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; }
#console { display: grid; grid-template-columns: 1fr 200px 1fr; gap: 12px; height: 100%;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.deck, .mixer { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
#deck-a { --accent: var(--a); }
#deck-b { --accent: var(--b); }
.deck-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.deck-label { font-size: 32px; font-weight: 800; color: var(--accent); }
.track-name { font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-height: 26px; }
.times { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums;
  font-size: 28px; font-weight: 300; }
.times .total { color: var(--dim); }
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 12px; font-size: 20px; font-weight: 700; letter-spacing: .05em;
  min-height: 56px; padding: 0 22px; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; touch-action: none; }
.btn.small { min-height: 44px; font-size: 15px; padding: 0 14px; }
.btn.load-btn { min-height: 48px; touch-action: manipulation; }
.btn:active, .btn.held { background: var(--accent); color: #000; }
.btn.play.active { background: var(--accent); color: #000; }
.transport { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.transport .btn { min-height: 84px; font-size: 26px; }
.row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; color: var(--dim); }
.row span:nth-child(2) { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; margin-right: auto; }
.pitch .row span:nth-child(2) { margin-right: auto; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px;
  background: transparent; margin: 0; touch-action: none; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 6px; }
input[type=range]::-moz-range-track { height: 10px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 6px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 40px; height: 40px;
  margin-top: -16px; border-radius: 10px; background: var(--accent); border: 2px solid #000; }
input[type=range]::-moz-range-thumb { width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); border: 2px solid #000; }
input[type=range]:disabled { opacity: .35; }
.mixer { align-items: stretch; justify-content: center; text-align: center; }
.mixer-title { font-size: 22px; font-weight: 800; letter-spacing: .15em; color: var(--dim); }
.xf { margin-top: auto; margin-bottom: auto; }
.xf-labels { display: flex; justify-content: space-between; font-weight: 800; font-size: 22px; }
.xf-labels span:first-child { color: var(--a); }
.xf-labels span:last-child { color: var(--b); }
.xf-slider { --accent: #ddd; }
.xf-hint { color: var(--dim); font-size: 14px; margin-top: 4px; }
#rotate-hint { display: none; }
@media (orientation: portrait) {
  #console { display: none; }
  #rotate-hint { display: flex; height: 100%; align-items: center; justify-content: center;
    font-size: 22px; color: var(--dim); }
}
@media (max-height: 560px) {
  .deck, .mixer { padding: 10px; gap: 8px; }
  .transport .btn { min-height: 64px; }

}

/* Waveforms */
.waves { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.overview, .zoom { position: relative; background: #0a0a0d; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; touch-action: none; }
.overview { height: 56px; flex: none; }
.zoom { flex: 1; min-height: 60px; }
.overview canvas, .zoom canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ov-head, .ov-cue { position: absolute; top: 0; left: 0; width: 2px; height: 100%;
  display: none; pointer-events: none; will-change: transform; }
.ov-head { background: #fff; }
.ov-cue { background: #ffb020; }
.deck { overflow: hidden; }

/* BPM */
.bpm { display: flex; align-items: center; gap: 8px; }
.bpm-box { display: flex; flex-direction: column; min-width: 78px; }
.bpm-box:first-child { min-width: 96px; }
.bpm-box small { color: var(--dim); font-size: 12px; letter-spacing: .1em; }
.bpm-box b { font-size: 24px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bpm-orig.busy { font-size: 16px; color: var(--dim); font-weight: 600; line-height: 29px; }
.bpm .btn.small { margin-left: auto; min-width: 56px; padding: 0 10px; }
.bpm .btn.small + .btn.small { margin-left: 0; }

/* Master / sync / grid / nudge */
.deck-head .master-btn { margin-left: auto; }
.deck-head .btn.small { min-width: 72px; padding: 0 12px; }
.btn.master-btn.active { background: #ffb020; color: #000; border-color: #ffb020; }
.btn.sync-btn.active { background: var(--accent); color: #000; }
.btn:disabled { opacity: .35; pointer-events: none; }
.adjust { display: flex; align-items: center; gap: 8px; }
.adj-label { color: var(--dim); font-size: 13px; letter-spacing: .1em; }
.nudge-label { margin-left: auto; }
.adjust .btn.small { min-width: 52px; padding: 0 10px; }

/* Compact layout: everything must fit an iPad landscape viewport */
.deck, .mixer { padding: 12px; gap: 8px; }
.deck-label { font-size: 28px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.title-row .track-name { font-size: 18px; flex: 1; min-width: 0; min-height: 0; }
.title-row .times { font-size: 20px; gap: 8px; flex: none; }
.title-row .times .total::before { content: "/ "; }
.transport .btn { min-height: 60px; font-size: 24px; }
.btn.load-btn { min-height: 44px; }
.btn.small { min-height: 44px; }
input[type=range] { height: 36px; }
input[type=range]::-webkit-slider-thumb { margin-top: -14px; width: 36px; height: 36px; }
.overview { height: 48px; }
.zoom { min-height: 70px; }
.bpm { gap: 6px; }
.bpm-box { min-width: 64px; }
.bpm-box:first-child { min-width: 80px; }
.bpm-box b { font-size: 22px; }
.bpm .btn.small { min-width: 48px; padding: 0 8px; }
.row { margin-bottom: 0; }

/* Phase meter */
.phase { margin-bottom: 8px; }
.phase-title { color: var(--dim); font-size: 13px; letter-spacing: .1em; margin-bottom: 6px; }
.phase-bar { position: relative; height: 18px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.phase-center { position: absolute; left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; background: #fff; }
.phase-fill { position: absolute; top: 0; height: 100%; width: 0; }
.phase-fill.ok { background: #3ddc84; }
.phase-fill.warn { background: #ffb020; }
.phase-fill.bad { background: #ff5c5c; }
.phase-ends { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; margin-top: 3px; }
.phase-read { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* BPM row: room for AUTO */
.bpm-box { min-width: 56px; }
.bpm-box:first-child { min-width: 70px; }
.bpm .btn.small { min-width: 44px; padding: 0 6px; font-size: 14px; letter-spacing: 0; }
.bpm .bpm-auto.active { background: var(--panel2); color: var(--accent); border-color: var(--accent); }

/* Mixer strips: knobs, channel faders */
#console { grid-template-columns: 1fr 240px 1fr; }
.mixer { padding: 10px; gap: 6px; justify-content: flex-start; }
.strips { display: grid; grid-template-columns: 1fr 62px 1fr; column-gap: 2px; row-gap: 4px;
  align-items: center; justify-items: center; flex: 1; min-height: 0;
  grid-template-rows: repeat(5, auto) minmax(90px, 1fr); }
.knob-name { font-size: 12px; letter-spacing: .06em; color: var(--dim); font-weight: 700;
  text-align: center; white-space: nowrap; }
.knob { width: 56px; height: 56px; touch-action: none; cursor: ns-resize; border-radius: 50%; }
.knob svg { width: 100%; height: 100%; display: block; }
.knob .k-track { stroke: var(--panel2); }
.knob .k-cap { fill: #24242c; stroke: #3a3a46; stroke-width: 1.5; }
.knob.active .k-cap { fill: #30303a; }
.fader-cell { width: 56px; height: 100%; }
.fader { position: relative; touch-action: none; cursor: ns-resize; }
.f-groove { position: absolute; left: 50%; top: 4px; bottom: 4px; width: 8px; margin-left: -4px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; }
.f-thumb { position: absolute; left: 4px; right: 4px; top: 0; height: 40px; border-radius: 8px;
  border: 2px solid #000; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); will-change: transform; }
.xf { margin: 0; }
.xf-labels { font-size: 18px; }
.phase { margin-bottom: 0; }
.phase-read { font-size: 18px; }

/* Hot cues and loops */
.pads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pad { position: relative; overflow: hidden; appearance: none; height: 44px; border-radius: 10px;
  border: 2px solid var(--pc); background: var(--panel2); color: var(--pc); font-size: 20px;
  font-weight: 800; touch-action: none; cursor: pointer; }
.pad.set { background: var(--pc); color: #000; }
.pad::after { content: ""; position: absolute; left: 0; bottom: 0; height: 5px; width: 0;
  background: #000; opacity: .55; }
.pad.pressing::after { width: 100%; transition: width 600ms linear; }
.loops { display: flex; gap: 6px; }
.loops .btn.small { flex: 1; min-width: 0; padding: 0; font-size: 16px; min-height: 40px; }
.loops .btn.small:last-child, .loops .loop-half { background: var(--panel2); }
.btn.loop-btn.active { background: #35e0d0; color: #000; border-color: #35e0d0; }

/* Mixer header (QUANTIZE) and tighter mixer column */
.mixer-head { display: flex; align-items: center; justify-content: space-between; }
.mixer-title { font-size: 15px; letter-spacing: .12em; }
.q-btn { min-width: 52px !important; padding: 0 !important; font-size: 18px !important; }
.q-btn.active { background: #ffb020; color: #000; border-color: #ffb020; }
.knob { width: 48px; height: 48px; }
.mixer { gap: 4px; }
.phase-ends { margin-top: 2px; }
.phase-bar { height: 14px; }
.phase-read { font-size: 16px; margin-top: 0; }

/* Deck rows: compact so everything fits an iPad landscape viewport */
.btn.small { min-height: 40px; }
.adjust .btn.small, .bpm .btn.small, .deck-head .btn.small { min-height: 40px; }
.overview { height: 40px; }
.transport .btn { min-height: 52px; font-size: 22px; }
.deck { gap: 6px; }
.zoom { min-height: 56px; }
.pitch .row .btn.small { min-height: 36px; }
