:root {
  color-scheme: dark;
  --bg: #0d1014;
  --surface: #171b20;
  --surface-2: #1d2229;
  --surface-3: #262d34;
  --border: #303741;
  --border-soft: #242a31;
  --ink: #f5f6f3;
  --muted: #a3acb5;
  --dim: #77828b;
  --lime: #caf575;
  --lime-glow: rgba(202,245,117,.14);
  --orange: #ffbd8b;
  --danger: #ff9e9e;
  --radius: 22px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; min-height: 100dvh; margin: 0; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; background: radial-gradient(ellipse 80% 20% at 50% -7%, rgba(127,155,103,.09), transparent 85%), var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .38; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
svg { flex-shrink: 0; display: block; }
.app-shell { max-width: 1440px; margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 24px max(26px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--border-soft); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 13px; background: var(--lime); color: #141810; }
.brand-name { font-size: 20px; line-height: 1; font-weight: 850; letter-spacing: -.07em; }
.brand-subtitle { margin-top: 5px; font-size: 9px; color: var(--dim); letter-spacing: .18em; font-weight: 750; }
.top-status { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border-soft); background: rgba(255,255,255,.024); border-radius: 99px; color: var(--muted); padding: 7px 10px; font-size: 11px; white-space: nowrap; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px var(--lime-glow); }
.status-dot.offline { background: var(--orange); box-shadow: 0 0 0 3px rgba(255,189,139,.12); }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 27px 0 20px; }
.setlist-title-block { flex: 1; min-width: 0; }
.overline { margin: 0 0 7px; color: var(--dim); font-weight: 780; letter-spacing: .17em; font-size: 10px; text-transform: uppercase; }
.setlist-selector { display: flex; max-width: 100%; align-items: center; position: relative; width: max-content; }
.setlist-selector::after { content: ''; pointer-events: none; position: absolute; right: 5px; top: 49%; height: 7px; width: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-50%); }
.setlist-selector select { max-width: 100%; width: auto; min-width: 180px; background: transparent; border: 0; color: var(--ink); font-weight: 820; font-size: clamp(20px, 4vw, 29px); letter-spacing: -.05em; outline: 0; appearance: none; padding: 1px 23px 4px 0; line-height: 1.2; cursor: pointer; text-overflow: ellipsis; }
.setlist-selector select option { color: #171b20; font-size: 16px; }
.setlist-subtitle { color: var(--muted); margin: 5px 0 0; font-size: 12px; }
.mode-switch { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; display: inline-flex; padding: 4px; gap: 3px; flex-shrink: 0; }
.mode-button { min-height: 37px; padding: 0 13px; font-size: 12px; font-weight: 750; color: var(--muted); border: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 7px; background: transparent; white-space: nowrap; }
.mode-button.active { color: #151916; background: var(--lime); box-shadow: 0 1px 9px rgba(202,245,117,.14); }
.main-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 17px; }
.player-panel, .songs-panel { min-width: 0; }
.player-card { position: relative; border: 1px solid #384038; border-radius: var(--radius); background: radial-gradient(ellipse 85% 45% at 50% 0%, rgba(202,245,117,.065), transparent 80%), linear-gradient(130deg, #1a201e 0%, #15191d 64%, #171a1e 100%); padding: 24px; overflow: hidden; }
.player-card::before { content: ''; position: absolute; width: 180px; height: 180px; top: -132px; right: -96px; border-radius: 50%; background: rgba(202,245,117,.08); filter: blur(16px); pointer-events: none; }
.now-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.now-label { font-size: 10px; color: var(--lime); font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.now-count { font-size: 11px; color: var(--muted); border: 1px solid var(--border); background: #202624; border-radius: 6px; padding: 5px 8px; white-space: nowrap; }
.track-title { font-weight: 830; font-size: clamp(26px, 5.8vw, 39px); line-height: 1.07; letter-spacing: -.055em; margin: 0 0 7px; overflow-wrap: anywhere; }
.track-artist { margin: 0; font-size: 14px; color: var(--muted); }
.track-notes { margin: 13px 0 0; border-left: 3px solid var(--lime); color: #d5ddcc; background: rgba(202,245,117,.06); border-radius: 0 9px 9px 0; padding: 9px 11px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.tempo-wrap { margin: 19px auto 15px; text-align: center; }
.tempo-row { display: flex; gap: 11px; justify-content: center; align-items: baseline; }
.tempo-number { font-size: clamp(82px, 18vw, 118px); line-height: .98; font-weight: 850; letter-spacing: -.095em; color: var(--lime); font-variant-numeric: tabular-nums; }
.tempo-number.free { font-size: clamp(48px, 12vw, 78px); line-height: 1.35; letter-spacing: -.06em; }
.tempo-unit { color: var(--lime); opacity: .8; font-size: 15px; font-weight: 750; letter-spacing: .06em; }
.beat-dots { display: flex; justify-content: center; gap: 8px; min-height: 18px; align-items: center; margin-top: 12px; }
.beat-dot { height: 7px; width: 7px; border-radius: 50%; background: #48534a; transition: transform .09s ease, background-color .09s ease, box-shadow .09s ease; }
.beat-dot.downbeat { width: 9px; height: 9px; background: #708160; }
.beat-dot.pulse { transform: scale(1.52); background: var(--lime); box-shadow: 0 0 12px rgba(202,245,117,.67); }
.playback-controls { display: flex; justify-content: center; align-items: center; gap: clamp(18px, 5vw, 34px); margin: 17px 0 19px; }
.transport-button { display: grid; place-items: center; flex-shrink: 0; border: 0; border-radius: 50%; }
.transport-button.skip { width: 53px; height: 53px; color: var(--ink); background: #283029; border: 1px solid #394239; }
.transport-button.play { width: 78px; height: 78px; color: #10160c; background: var(--lime); box-shadow: 0 7px 37px rgba(202,245,117,.15); }
.transport-button.play:active, .button.primary:active { transform: scale(.975); }
.transport-button.play:disabled { background: #424b3e; color: #959c89; box-shadow: none; opacity: .65; }
.tempo-editor { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; }
.tempo-button { border: 1px solid #3d473d; border-radius: 9px; background: rgba(202,245,117,.055); min-width: 52px; height: 35px; padding: 0 9px; color: #d7e8ca; font-size: 12px; font-weight: 700; }
.tempo-editor-label { color: var(--dim); font-size: 10px; margin-right: 4px; }
.player-divider { height: 1px; background: #354039; margin: 21px 0 16px; opacity: .8; }
.player-settings { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.volume-group { flex: 1; min-width: 128px; display: flex; align-items: center; gap: 10px; }
.volume-group svg { color: var(--muted); }
.volume-group input[type=range] { flex: 1; min-width: 70px; accent-color: var(--lime); height: 18px; cursor: pointer; }
.bars-group { display: flex; align-items: center; gap: 10px; }
.bars-label { color: var(--muted); font-size: 11px; }
.bars-button, .wake-button { border: 1px solid #455043; border-radius: 7px; background: #293027; color: #dbeacf; padding: 6px 9px; font-size: 11px; font-weight: 720; display: inline-flex; align-items: center; gap: 6px; }
.wake-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 14px 0 0; }
.wake-row .player-tip { font-size: 10px; color: var(--dim); line-height: 1.4; }
.wake-button { background: transparent; border-color: #384039; color: var(--muted); white-space: nowrap; }
.wake-button.is-on { color: var(--lime); border-color: #596d45; }
.songs-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 19px; min-width: 0; }
.songs-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 13px; }
.section-title { margin: 0; font-size: 16px; font-weight: 795; letter-spacing: -.03em; }
.section-count { font-size: 11px; font-weight: 700; color: var(--muted); }
.queue-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .15em; font-weight: 800; color: var(--dim); margin: 18px 1px 9px; }
.queue-section-label.first { margin-top: 0; }
.queue-list, .edit-list { display: flex; flex-direction: column; gap: 5px; }
.queue-row { width: 100%; display: flex; align-items: center; text-align: left; gap: 13px; border: 1px solid transparent; border-radius: 11px; color: var(--ink); background: transparent; min-height: 58px; padding: 9px 11px; }
.queue-row:hover, .queue-row:focus-visible { background: #222830; }
.queue-row.active { background: #293329; border-color: #4a6240; }
.queue-index { width: 23px; color: var(--dim); font-size: 11px; font-weight: 720; font-variant-numeric: tabular-nums; text-align: center; }
.queue-row.active .queue-index { color: var(--lime); }
.queue-info { flex: 1; min-width: 0; }
.queue-name { color: var(--ink); font-weight: 710; font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
.queue-artist { font-size: 11px; color: var(--dim); margin-top: 3px; overflow-wrap: anywhere; }
.queue-bpm { flex-shrink: 0; text-align: right; color: var(--muted); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.queue-bpm small { display: block; font-size: 9px; color: var(--dim); font-weight: 650; margin-top: 2px; letter-spacing: .04em; }
.queue-row.active .queue-bpm { color: var(--lime); }
.empty-message { margin: 5px 0 20px; font-size: 12px; line-height: 1.55; color: var(--dim); }
.library-toolbar { margin-bottom: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; min-height: 38px; border: 1px solid transparent; padding: 8px 12px; font-weight: 730; font-size: 12px; line-height: 1.2; white-space: nowrap; }
.button.primary { background: var(--lime); color: #152013; border-color: var(--lime); }
.button.secondary { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
.button.quiet { background: #1c2324; border-color: #33403b; color: #cdd9cb; }
.button.danger-outline { border-color: rgba(255,158,158,.33); color: var(--danger); background: transparent; }
.button.small { padding: 7px 10px; min-height: 32px; font-size: 11px; }
.button.fill { width: 100%; }
.edit-section { margin-top: 15px; }
.edit-section:first-child { margin-top: 0; }
.edit-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.edit-section-title { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 830; }
.edit-row { border: 1px solid #2b3338; background: #1f252a; border-radius: 11px; min-height: 66px; padding: 7px 9px; display: flex; align-items: center; gap: 8px; position: relative; transition: border-color .12s ease, background-color .12s ease; }
.edit-row + .edit-row { margin-top: 5px; }
.edit-row.active { border-color: #5c7743; background: #273226; }
.edit-row.is-dragging { opacity: .85; z-index: 3; border-color: var(--lime); background: #354432; box-shadow: 0 8px 18px rgba(0,0,0,.22); }
.edit-row.drop-target:not(.is-dragging) { outline: 2px dashed var(--lime); outline-offset: -2px; }
.drag-handle { border: 0; background: none; color: #839084; border-radius: 7px; width: 31px; height: 40px; display: grid; place-items: center; touch-action: none; cursor: grab; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.edit-index { display: none; }
.edit-info { flex: 1; min-width: 0; }
.edit-name { display: block; font-weight: 720; color: var(--ink); font-size: 12px; line-height: 1.25; overflow-wrap: anywhere; }
.edit-artist { display: block; color: var(--dim); font-size: 10px; margin-top: 4px; }
.edit-bpm { color: var(--lime); flex-shrink: 0; font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 800; padding: 6px; background: #2f3a2e; border-radius: 6px; }
.edit-bpm.free { color: #c1bdde; background: #333040; }
.edit-row-buttons { display: flex; flex-direction: column; gap: 2px; }
.row-button { color: var(--muted); border: 0; padding: 0; background: transparent; display: grid; place-items: center; width: 23px; height: 22px; border-radius: 5px; }
.row-button:hover { background: #353e44; color: var(--ink); }
.edit-button { background: #30383b; border: 1px solid #465047; border-radius: 8px; color: var(--ink); width: 36px; height: 36px; display: grid; place-items: center; margin-left: 2px; }
.edit-help { color: var(--dim); font-size: 11px; margin: 10px 0 1px; line-height: 1.4; }
.new-song-button { width: 100%; background: none; color: var(--muted); border: 1px dashed #3e4749; border-radius: 10px; min-height: 40px; font-weight: 650; font-size: 12px; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.new-song-button:hover { border-color: var(--lime); color: var(--lime); }
.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 10px; color: var(--dim); padding-top: 22px; line-height: 1.5; }
.footer-right { color: #8f9d91; }
.footer-right svg { display: inline-block; vertical-align: -2px; }
.modal { border: 1px solid #414b48; border-radius: 19px; background: #1c2227; color: var(--ink); max-width: min(94vw, 520px); width: 100%; padding: 0; box-shadow: 0 24px 90px rgba(0,0,0,.7); max-height: min(90dvh, 900px); overflow: auto; }
.modal::backdrop { background: rgba(2,5,8,.82); backdrop-filter: blur(7px); }
.modal-inner { padding: 23px; display: flex; flex-direction: column; gap: 17px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 24px; letter-spacing: -.05em; }
.icon-button.close-modal { display: grid; place-items: center; font-size: 25px; border: 0; border-radius: 8px; width: 34px; height: 34px; color: var(--muted); background: #2a3236; }
.field { display: flex; flex-direction: column; gap: 7px; color: #cdd5d7; font-weight: 680; font-size: 12px; }
.field input, .field select, .field textarea { width: 100%; border-radius: 10px; border: 1px solid #485257; padding: 11px 12px; outline: none; color: var(--ink); background: #12181b; font-size: 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--lime); }
.field input:disabled { opacity: .5; }
.field input::placeholder, .field textarea::placeholder { color: #727c83; }
.form-columns { display: grid; grid-template-columns: 1fr 1.3fr; gap: 13px; }
.check-row { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; color: #dbe2e0; font-size: 12px; background: #242b2e; padding: 11px 12px; border: 1px solid #37413f; border-radius: 10px; }
.check-row input { accent-color: var(--lime); width: 17px; height: 17px; flex-shrink: 0; margin: 1px 0 0; }
.check-row span { display: flex; flex-direction: column; gap: 3px; }
.check-row small { font-size: 11px; line-height: 1.4; color: var(--muted); }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.modal-actions .danger-outline { margin-right: auto; }
#toast { position: fixed; z-index: 9999; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(15px); width: max-content; max-width: calc(100vw - 30px); border-radius: 12px; padding: 11px 16px; background: #e2f7c6; color: #162015; font-size: 12px; font-weight: 720; box-shadow: 0 10px 40px rgba(0,0,0,.38); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
#toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.error { background: #ffe4e1; color: #502623; }
@media (min-width: 900px) {
  .main-layout { grid-template-columns: minmax(340px, .88fr) minmax(420px, 1.12fr); align-items: start; gap: 19px; }
  .player-card { padding: 30px; }
  .songs-card { padding: 22px; }
  .queue-scroll { max-height: min(690px, calc(100dvh - 210px)); overflow: auto; scrollbar-width: thin; scrollbar-color: #4e5949 transparent; padding-right: 4px; }
  .player-panel { position: sticky; top: 18px; }
}
@media (max-width: 650px) {
  .app-shell { padding: max(14px, env(safe-area-inset-top)) 13px max(25px, env(safe-area-inset-bottom)); }
  .topbar { padding: 6px 3px 16px; }
  .brand-icon { width: 36px; height: 36px; }
  .brand-name { font-size: 19px; }
  .workspace-head { padding: 22px 3px 17px; align-items: flex-end; gap: 8px; }
  .setlist-selector select { font-size: clamp(18px, 5.3vw, 25px); min-width: 0; max-width: 57vw; }
  .setlist-subtitle { font-size: 11px; }
  .mode-button { min-height: 35px; padding: 0 10px; font-size: 11px; gap: 5px; }
  .mode-button svg { width: 13px; height: 13px; }
  .player-card { padding: 20px 19px; }
  .track-title { font-size: clamp(27px, 8.2vw, 36px); }
  .songs-card { padding: 17px 12px; }
  .queue-row { gap: 9px; padding: 9px 7px; }
  .edit-row { padding: 6px 5px; gap: 5px; }
  .edit-bpm { font-size: 11px; padding: 5px; }
  .library-toolbar .button { flex: 1 1 auto; }
  .app-footer { flex-direction: column; align-items: center; text-align: center; gap: 5px; }
}
@media (orientation: landscape) and (max-height: 600px) and (min-width: 560px) {
  .app-shell { padding: max(7px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left)); }
  .topbar { padding: 0 0 7px; }
  .brand-icon { width: 28px; height: 28px; border-radius: 9px; }
  .brand-icon svg { width: 20px; height: 20px; }
  .brand-name { font-size: 16px; }
  .brand-subtitle { display: none; }
  .top-status { font-size: 9px; padding: 5px 8px; }
  .workspace-head { padding: 8px 0; align-items: center; }
  .overline { display: none; }
  .setlist-selector select { font-size: 17px; }
  .setlist-subtitle { margin: 1px 0 0; font-size: 10px; }
  .mode-button { min-height: 30px; font-size: 11px; }
  .main-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; gap: 11px; }
  .player-card { padding: 11px 15px; border-radius: 15px; }
  .now-head { margin-bottom: 5px; }
  .now-label { font-size: 9px; }
  .now-count { font-size: 9px; padding: 3px 5px; }
  .track-title { font-size: clamp(19px, 3.6vw, 25px); line-height: 1.07; margin-bottom: 3px; }
  .track-artist { font-size: 11px; }
  .track-notes { margin-top: 6px; padding: 5px 7px; font-size: 10px; max-height: 34px; overflow: auto; }
  .tempo-wrap { margin: 3px auto 3px; }
  .tempo-number { font-size: clamp(50px, 12vh, 68px); }
  .tempo-number.free { font-size: clamp(30px, 8vh, 47px); }
  .tempo-unit { font-size: 11px; }
  .beat-dots { margin-top: 2px; min-height: 11px; gap: 7px; }
  .beat-dot { width: 5px; height: 5px; }
  .beat-dot.downbeat { width: 7px; height: 7px; }
  .playback-controls { margin: 5px 0 7px; gap: 14px; }
  .transport-button.skip { width: 37px; height: 37px; }
  .transport-button.skip svg { width: 17px; height: 17px; }
  .transport-button.play { width: 49px; height: 49px; }
  .transport-button.play svg { width: 20px; height: 20px; }
  .tempo-button { min-width: 37px; height: 27px; font-size: 10px; padding: 0 5px; }
  .tempo-editor { gap: 5px; }
  .tempo-editor-label { font-size: 9px; }
  .player-divider { margin: 9px 0 7px; }
  .player-settings { gap: 10px; }
  .bars-label { font-size: 10px; }
  .bars-button { padding: 4px 7px; }
  .wake-row { margin-top: 6px; }
  .wake-row .player-tip { display: none; }
  .wake-button { padding: 4px 7px; font-size: 10px; }
  .songs-card { border-radius: 15px; padding: 12px; }
  .songs-card-head { margin-bottom: 9px; }
  .queue-scroll { max-height: calc(100dvh - 114px); overflow-y: auto; overscroll-behavior: contain; }
  .queue-row { min-height: 43px; padding: 5px 8px; }
  .queue-name { font-size: 11px; }
  .queue-artist { font-size: 10px; }
  .queue-section-label { margin-top: 10px; }
  .app-footer { display: none; }
  .library-toolbar { margin-bottom: 8px; }
  .library-toolbar .button { min-height: 29px; padding: 5px 8px; font-size: 10px; }
  .edit-row { min-height: 49px; }
  .edit-row-buttons { flex-direction: row; }
  .edit-list { max-height: 50vh; overflow: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
/* Keep title and artist on separate lines in the compact queue. */
.queue-name, .queue-artist { display: block; }
@media (max-width: 650px) and (orientation: portrait) {
  .workspace-head { align-items: stretch; flex-direction: column; gap: 12px; }
  .setlist-selector { width: 100%; }
  .setlist-selector select { max-width: calc(100vw - 70px); }
  .mode-switch { width: 100%; }
  .mode-button { flex: 1; }
}
[hidden] { display: none !important; }
