/* ============ tokens ============ */
:root {
  --bg: #090b10;
  --surface: #12151d;
  --surface-2: #181c26;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #eef1f6;
  --text-2: #a2abbb;
  --text-3: #687285;
  --accent: #f5b301;
  --ok: #2fd67b;
  --warn: #f5b301;
  --danger: #ff3b5c;
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Inter", Roboto, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --top-h: 64px;
  --deck-h: 84px;
  --sheet-w: 420px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.4 var(--font); -webkit-font-smoothing: antialiased; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ============ top bar ============ */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 0 16px;
  background: rgba(9, 11, 16, .9); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.brand-mark.big { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 18px; display: block; }
.brand-text { min-width: 0; }
.brand-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; max-width: 44vw; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 7px 14px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 13.5px; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }
.tab-live { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.tab-edit { display: grid; opacity: .6; }
.tab-edit svg { width: 14px; height: 14px; }
.tab.add { color: var(--text-3); padding: 7px 9px; }

.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); display: grid; place-items: center; flex: none; }
.icon-btn:hover, .icon-btn.on { color: #fff; border-color: var(--line-2); background: var(--surface-2); }

.status-chip { height: 38px; padding: 0 12px; border-radius: 10px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-chip.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-chip.ok { color: #b8f0cf; }
.status-chip.warn .dot { background: var(--warn); animation: blink 1.4s infinite; }
.status-chip.warn { color: #ffe08a; }
.status-chip .net { display: grid; color: var(--text-3); padding-left: 8px; border-left: 1px solid var(--line-2); }
.status-chip .net svg { width: 15px; height: 15px; }
.net.cloud-synced { color: var(--ok); }
.net.cloud-syncing { color: #7fb4ff; animation: blink 1s infinite; }
.net.cloud-readonly, .net.cloud-badkey { color: var(--warn); }
.net.cloud-error { color: var(--danger); }
.team-card { padding: 14px; border-radius: 14px; border: 1.5px solid rgba(245,179,1,.45); background: rgba(245,179,1,.06); display: flex; flex-direction: column; gap: 12px; }
.team-card.on { border-color: rgba(47,214,123,.35); background: rgba(47,214,123,.06); }
.team-head { display: flex; gap: 12px; align-items: flex-start; }
.team-head > svg { width: 26px; height: 26px; color: var(--accent); margin-top: 2px; }
.team-card.on .team-head > svg { color: var(--ok); }
.team-head b { display: block; font-size: 14.5px; }
.team-head .st { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.45; }
.team-head .st.ok { color: #8ff0b8; } .team-head .st.bad { color: #ff8da1; } .team-head .st.busy { color: #9cc4ff; }
.input.code { font: 700 20px var(--mono); letter-spacing: .25em; text-align: center; height: 48px; }
.team-card .btn.primary { height: 48px; padding: 0 20px; font-size: 14px; }
.status-line { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 11px; background: rgba(0,0,0,.25); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.status-line .ci { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.status-line .ci svg { width: 14px; height: 14px; stroke-width: 3; }
.status-line.ok .ci { background: rgba(47,214,123,.15); color: var(--ok); }
.status-line.bad .ci { background: rgba(245,179,1,.15); color: var(--warn); }
.status-line .grow { flex: 1; }
.btn.block { width: 100%; }
.pill-s { margin-left: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.07); color: var(--text-2); }
.pill-s.cloud-synced { background: rgba(47,214,123,.14); color: #8ff0b8; }
.pill-s.cloud-readonly, .pill-s.cloud-badkey { background: rgba(245,179,1,.14); color: #ffd36b; }
.pill-s.cloud-error { background: rgba(255,59,92,.14); color: #ff8da1; }
@keyframes blink { 50% { opacity: .35; } }

.mode-seg { display: flex; padding: 3px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.mode-seg button { border: 0; background: none; height: 32px; padding: 0 14px; border-radius: 8px; font-weight: 650; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.mode-seg button.on[data-mode=live] { background: #fff; color: #0b0d12; }
.mode-seg button.on[data-mode=setup] { background: var(--accent); color: #1b1200; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mode-seg button.on .live-dot { background: var(--danger); }

/* ============ grid & cards ============ */
.stage { position: fixed; top: var(--top-h); bottom: calc(var(--deck-h) + var(--safe-b)); left: 0; right: 0; padding: 16px; transition: right .25s ease; display: flex; }
body.sheet-open .stage { right: var(--sheet-w); }
body.setup .stage { box-shadow: inset 0 0 0 2px rgba(245, 179, 1, .35); }
.grid { flex: 1; min-height: 0; display: grid; align-content: start; overflow-y: auto; padding: 2px; scrollbar-width: thin; scrollbar-color: #2a3040 transparent; }
.empty-board { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: var(--text-3); border: 1px dashed var(--line-2); border-radius: 16px; line-height: 1.7; }
.empty-board b { color: var(--text); }

.card {
  --c: #f5b301;
  position: relative; overflow: hidden; container-type: inline-size;
  display: flex; flex-direction: column; padding: 14px 14px 12px 18px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: transform .08s, border-color .15s, background .2s, box-shadow .2s;
  touch-action: manipulation;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.card:hover { border-color: var(--line-2); background: var(--surface-2); }
.card.hit, .card:active { transform: scale(.975); }

.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; min-width: 0; font-weight: 750; font-size: var(--title, 18px); line-height: 1.15; letter-spacing: .02em; text-transform: uppercase; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-key { flex: none; min-width: 26px; height: 24px; padding: 0 7px; border-radius: 7px; display: grid; place-items: center; font: 600 12px var(--mono); color: var(--text-2); background: rgba(0,0,0,.3); border: 1px solid var(--line-2); border-bottom-width: 2px; }
.card-file { margin-top: 5px; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.card-file svg { width: 13px; height: 13px; color: var(--c); }
.card-file span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-file.bad, .card-file.bad svg { color: #ff8da1; }

.card-mid { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.card-time { font: 600 var(--time, 30px)/1 var(--mono); color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.card-time.word { font: 650 13px var(--font); letter-spacing: .14em; text-transform: uppercase; }
.card.playing .card-time.word { font: 600 var(--time, 30px)/1 var(--mono); letter-spacing: -.02em; }
.card-onair { display: none; font-size: 10px; font-weight: 800; letter-spacing: .16em; color: #fff; background: var(--danger); padding: 3px 7px; border-radius: 5px; }
.card-edit { display: none; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.card-edit svg { width: 14px; height: 14px; }

.card-ctl { display: flex; gap: 6px; }
.pc { flex: 1; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--text-2); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 650; transition: background .12s, color .12s, opacity .15s; }
.pc svg { width: 15px; height: 15px; }
.pc:hover { background: rgba(255,255,255,.09); color: #fff; }
.card:not(.playing) .pc[data-act=stop], .card:not(.playing) .pc[data-act=fade] { opacity: .3; pointer-events: none; }
.card.playing .pc[data-act=stop] { background: var(--danger); border-color: transparent; color: #fff; }
.card.playing .pc[data-act=fade] { background: rgba(255,255,255,.12); color: #fff; }
.pc.on { color: var(--c); border-color: color-mix(in oklab, var(--c) 55%, transparent); background: color-mix(in oklab, var(--c) 14%, transparent); }
@container (max-width: 200px) { .pc span { display: none; } }

.card-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.card-bar i { display: block; height: 100%; width: 0; background: var(--c); }

.card.playing { border-color: var(--c); background: linear-gradient(160deg, color-mix(in oklab, var(--c) 26%, var(--surface)), var(--surface) 75%); box-shadow: 0 0 0 1px var(--c), 0 10px 40px -14px var(--c); }
.card.playing .card-time { color: #fff; }
.card.playing .card-onair { display: block; animation: blink 1.6s infinite; }
.card.fading { opacity: .7; }
.card.fading .card-onair { animation: none; background: var(--text-3); }
.card.warn::before { background: repeating-linear-gradient(180deg, #ff3b5c 0 6px, transparent 6px 10px); }

/* setup mode */
body.setup .card-ctl, body.setup .card-time, body.setup .card-onair { display: none !important; }
body.setup .card-edit { display: flex; }
body.setup .card:hover .card-edit { color: var(--accent); }
.card.selected { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent) !important; }
.card.selected .card-edit { color: var(--accent); }
.card.dragging { opacity: .35; }
.card.drag-over { box-shadow: 0 0 0 2px #fff !important; }
.card.add { align-items: center; justify-content: center; gap: 8px; border: 1.5px dashed var(--line-2); background: none; color: var(--text-3); font-weight: 650; }
.card.add::before { display: none; }
.card.add:hover { color: var(--accent); border-color: var(--accent); }
.card.add svg { width: 28px; height: 28px; }

/* ============ deck ============ */
.deck {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--deck-h) + var(--safe-b)); padding: 0 16px var(--safe-b); z-index: 20;
  display: grid; grid-template-columns: minmax(180px, 280px) 1fr auto auto auto; align-items: center; gap: 18px;
  background: rgba(12, 14, 20, .96); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.deck-now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.deck-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--dc, #39414f); box-shadow: 0 0 12px var(--dc, transparent); }
.deck:not(.idle) .deck-dot { animation: blink 1.4s infinite; }
.deck-meta { min-width: 0; }
.deck-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-file { color: var(--text-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck.idle .deck-title { color: var(--text-3); }
.deck-progress { min-width: 0; }
.deck-times { display: flex; justify-content: space-between; align-items: baseline; font: 600 12.5px var(--mono); color: var(--text-2); margin-bottom: 7px; font-variant-numeric: tabular-nums; }
#deckRemain { color: #fff; font-size: 22px; }
.deck.idle #deckRemain { color: var(--text-3); }
.deck-seek { padding: 8px 0; margin: -8px 0; cursor: pointer; touch-action: none; }
.deck.idle .deck-seek { cursor: default; }
.deck-bar { position: relative; height: 6px; border-radius: 99px; background: rgba(255,255,255,.07); transition: height .12s; }
.deck-bar i { position: relative; display: block; height: 100%; width: 0; border-radius: inherit; background: var(--dc, var(--accent)); }
.deck-bar i::after { content: ""; position: absolute; right: -8px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.6); opacity: 0; transition: opacity .12s; }
.deck:not(.idle) .deck-seek:hover .deck-bar, .deck-seek.dragging .deck-bar { height: 8px; }
.deck:not(.idle) .deck-seek:hover .deck-bar i::after, .deck-seek.dragging .deck-bar i::after { opacity: 1; }
@media (hover: none) { .deck:not(.idle) .deck-bar i::after { opacity: 1; } }
.deck-vol { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.deck-vol #volIcon { display: grid; }
.deck-vol input { width: 120px; }
.deck-btn { height: 52px; padding: 0 16px; border-radius: 12px; display: flex; align-items: center; gap: 9px; font-weight: 700; border: 1px solid var(--line-2); background: var(--surface-2); }
.deck-btn:active { transform: scale(.97); }
.deck-btn kbd { font: 600 11px var(--mono); padding: 2px 6px; border-radius: 5px; background: rgba(0,0,0,.3); border: 1px solid var(--line-2); opacity: .75; }
.deck-btn.stop { background: var(--danger); border-color: transparent; color: #fff; }
.deck-btn .ico { display: grid; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px; outline: none; background: linear-gradient(90deg, var(--accent) var(--p, 50%), rgba(255,255,255,.1) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0,0,0,.5); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; }

/* ============ side panel ============ */
.sheet {
  position: fixed; top: var(--top-h); right: 0; bottom: calc(var(--deck-h) + var(--safe-b)); width: var(--sheet-w); z-index: 30;
  display: flex; flex-direction: column; background: #10131a; border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .25s ease, visibility 0s linear .25s; visibility: hidden; user-select: text;
}
body.sheet-open .sheet { transform: none; visibility: visible; transition: transform .25s ease; box-shadow: -16px 0 40px -20px rgba(0,0,0,.8); }
.sheet-backdrop { display: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); position: relative; }
.sheet-head h2 { margin: 0; font-size: 17px; flex: 1; }
.sheet-head .sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; margin-top: 1px; }
.grab { display: none; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 18px 20px; scrollbar-width: thin; scrollbar-color: #2a3040 transparent; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

.sec { padding: 16px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.lbl { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 8px; }
.lbl.sm { font-weight: 550; margin-bottom: 6px; }
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.note { font-size: 12px; color: var(--text-3); line-height: 1.5; margin: 10px 0 0; }
.note b { color: var(--text-2); }
.bad { color: #ff8da1; }

.input { width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid var(--line-2); outline: none; }
.input:focus { border-color: rgba(245,179,1,.6); box-shadow: 0 0 0 3px rgba(245,179,1,.14); }
.input.sm { height: 32px; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a2abbb' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
select.input option { background: #181c26; }

.btn { height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: #20252f; }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: #1b1200; }
.btn.danger { color: #ff8da1; border-color: rgba(255,59,92,.3); background: rgba(255,59,92,.06); }
.btn.solid-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.ghost { background: none; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 42px; padding: 0; flex: none; }
.btn.grow { flex: 1; }

.files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.file-row .meta { flex: 1; min-width: 0; }
.file-row .nm { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .du { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.pbtn { width: 36px; height: 36px; border-radius: 9px; border: 0; background: rgba(255,255,255,.07); display: grid; place-items: center; flex: none; }
.pbtn svg { width: 14px; height: 14px; }
.pbtn.on { background: var(--accent); color: #000; }
.pbtn:disabled { opacity: .3; }
.x { width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--text-3); display: grid; place-items: center; flex: none; }
.x:hover { background: rgba(255,255,255,.08); color: #fff; }
.x.del:hover, .file-row [data-remove-track]:hover { background: rgba(255,59,92,.14); color: #ff8da1; }
.x svg { width: 15px; height: 15px; }
.empty-files { padding: 14px; text-align: center; font-size: 13px; color: var(--text-3); border: 1px dashed var(--line-2); border-radius: 11px; }

.upload-box { width: 100%; padding: 18px; border-radius: 13px; border: 1.5px dashed var(--line-2); background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-2); }
.upload-box:hover { border-color: var(--accent); color: #fff; }
.upload-box svg { width: 24px; height: 24px; color: var(--accent); margin-bottom: 4px; }
.upload-box b { color: #fff; font-size: 14px; }
.upload-box span { font-size: 12px; color: var(--text-3); }

.swatches { display: grid; grid-template-columns: repeat(12, 1fr); gap: 7px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; background: var(--c); padding: 0; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--c); }

.keycap { flex: none !important; min-width: 64px; height: 42px; padding: 0 12px; border-radius: 10px; display: inline-grid; place-items: center; font: 700 15px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 3px; background: rgba(0,0,0,.3); }
.keycap.listening { color: var(--accent); border-color: var(--accent); font-size: 12px; animation: blink 1s infinite; }

details.more summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13.5px; color: var(--text); }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s; }
details.more[open] summary::after { transform: rotate(225deg); }
details.more .hint { font-size: 11.5px; font-weight: 600; color: var(--text-3); background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 99px; }
.more-body { padding-top: 14px; }

.seg { display: flex; padding: 3px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid var(--line-2); }
.seg button { flex: 1; border: 0; background: none; height: 32px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: #2a3042; color: #fff; }
.seg.wrap { flex-wrap: wrap; margin-bottom: 10px; }
.seg.wrap button { flex: 1 1 auto; padding: 0 10px; white-space: nowrap; }

.switch-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch-row .txt { flex: 1; }
.switch-row .txt b { display: block; font-size: 13.5px; font-weight: 600; }
.switch-row .txt span { display: block; font-size: 12px; color: var(--text-3); }
.switch { width: 40px; height: 23px; border-radius: 99px; background: #2a3042; position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(17px); }

.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; }
.range-row .v { font: 600 12.5px var(--mono); color: var(--text-2); min-width: 44px; text-align: right; }

.wave-wrap { position: relative; height: 88px; border-radius: 11px; background: rgba(0,0,0,.35); border: 1px solid var(--line); overflow: hidden; cursor: crosshair; touch-action: none; }
.wave-wrap canvas { width: 100%; height: 100%; display: block; }
.wave-wrap .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 12px; }
.cue-shade { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.6); pointer-events: none; }
.cue-handle { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; }
.cue-handle::before { content: attr(data-l); position: absolute; top: 4px; font: 700 9px var(--mono); background: var(--accent); color: #000; padding: 2px 4px; border-radius: 4px; }
.cue-handle.s::before { left: 2px; }
.cue-handle.e::before { right: 2px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; display: none; }
.cue-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cue-time { margin-top: 8px; font: 12px var(--mono); color: var(--text-2); }

.checks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.check { display: flex; gap: 12px; padding: 11px 12px; border-radius: 11px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.check .ci { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check .ci svg { width: 14px; height: 14px; stroke-width: 3; }
.check.ok .ci { background: rgba(47,214,123,.15); color: var(--ok); }
.check.bad .ci { background: rgba(245,179,1,.15); color: var(--warn); }
.check b { display: block; font-size: 13px; }
.check span { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.steps { margin: 0 0 12px; padding-left: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.7; }
.steps b { color: #fff; }
.kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 13px; color: var(--text-2); }
.kbd-list kbd { font: 600 11.5px var(--mono); padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.35); border: 1px solid var(--line-2); border-bottom-width: 2px; color: #fff; justify-self: start; }

/* ============ overlays ============ */
.drop-overlay { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; background: rgba(5,7,11,.75); backdrop-filter: blur(6px); pointer-events: none; }
.drop-overlay.on { display: grid; }
.drop-card { padding: 36px 56px; border-radius: 20px; border: 2px dashed var(--accent); text-align: center; font-size: 16px; font-weight: 600; }
.drop-ico svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--accent); display: block; }

.modal-root { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; padding: 16px; background: rgba(4,6,10,.65); backdrop-filter: blur(6px); }
.modal-root.on { display: grid; }
.modal { width: min(420px, 100%); border-radius: 18px; background: #141822; border: 1px solid var(--line-2); padding: 22px; box-shadow: 0 30px 80px -20px #000; user-select: text; animation: pop .16s ease; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 14px; color: var(--text-2); line-height: 1.55; font-size: 13.5px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }

.toasts { position: fixed; left: 50%; bottom: calc(var(--deck-h) + var(--safe-b) + 14px); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 15px; border-radius: 11px; background: #1e2330; border: 1px solid var(--line-2); box-shadow: 0 14px 40px -10px #000; font-weight: 600; font-size: 13px; pointer-events: auto; animation: pop .18s ease; }
.toast.ok svg { color: var(--ok); }
.toast.warn svg { color: var(--warn); }
.toast.err svg { color: var(--danger); }
.toast.info svg { color: #7fb4ff; }
.toast .t-btn { border: 0; background: rgba(255,255,255,.1); padding: 5px 10px; border-radius: 7px; font-weight: 700; font-size: 12px; }
.toast.out { opacity: 0; transition: opacity .2s; }

.boot { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); transition: opacity .4s; padding: 20px; }
.boot.hide { opacity: 0; pointer-events: none; }
.boot-card { width: min(400px, 100%); text-align: center; }
.boot h1 { font-size: 19px; margin: 0 0 8px; }
.boot p { color: var(--text-2); margin: 0 0 20px; font-size: 13.5px; min-height: 20px; }
.boot-bar { height: 5px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.boot-actions { margin-top: 18px; display: flex; gap: 8px; justify-content: center; }

/* ============ touch devices: hide keyboard-only bits ============ */
@media (hover: none) {
  .card-key, .keys-only, .deck-btn kbd { display: none !important; }
}

/* ============ tablet / small laptop ============ */
@media (max-width: 1100px) {
  .brand-text { display: none; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .tabs { justify-self: center; max-width: none; }
  .status-chip .txt { display: none; }
  .status-chip.warn .txt { display: inline; }
  .deck { grid-template-columns: minmax(150px, 240px) 1fr auto auto; }
  .deck-vol { display: none; }
  :root { --sheet-w: 380px; }
}

/* ============ phone ============ */
@media (max-width: 720px) {
  :root { --top-h: 108px; --deck-h: 116px; }
  .topbar { grid-template-columns: 1fr auto; grid-template-rows: 56px 44px; gap: 0 8px; padding: 0 12px; align-items: center; }
  .brand-text { display: block; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-title { font-size: 14px; }
  .brand-sub { display: none; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; align-self: start; max-width: none; }
  .tab { flex: 1; justify-content: center; }
  .top-actions { gap: 6px; }
  .status-chip { padding: 0 11px; }
  .status-chip .net { border-left: 0; padding-left: 0; }
  .icon-btn { width: 36px; height: 36px; }
  .mode-seg button { padding: 0 10px; }

  .stage { padding: 10px 12px; }
  body.sheet-open .stage { right: 0; }

  .deck { grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; gap: 10px; padding: 10px 12px calc(10px + var(--safe-b)); align-content: center; }
  .deck-now { grid-column: 1; grid-row: 1; }
  .deck-progress { grid-column: 1 / -1; grid-row: 2; }
  .deck-btn { height: 44px; padding: 0 14px; }
  .deck-btn.fade .lbl { display: none; }
  #deckRemain { font-size: 18px; }

  /* panel becomes a bottom sheet */
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 88vh; height: 88dvh; border-left: 0; border-top: 1px solid var(--line-2); border-radius: 20px 20px 0 0; transform: translateY(100%); padding-bottom: var(--safe-b); z-index: 40; }
  body.sheet-open .sheet { transform: none; }
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
  .grab { display: block; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 99px; background: var(--line-2); }
  .sheet-head { padding-top: 18px; }
  .swatches { grid-template-columns: repeat(6, 1fr); gap: 10px; }
  .card { padding: 12px 12px 10px 16px; }
}
