/* Live Metronome Pro, web edition.
   Colours and proportions come from Themes/DarkTheme.xaml, Themes/LightTheme.xaml,
   Themes/Shared.xaml and MainWindow.xaml of the Windows app.

   Layouts:
   - 720 px and wider (tablets, desktop): the Windows three-column control panel.
   - narrower (phones): dial and transport side by side, options below, sticky play bar.
   - wide and at least 600 px tall: the app fills the screen and the lists scroll inside. */

:root {
  color-scheme: dark;
  --accent: #7C7BFF;
  --accent-dim: #24243F;
  --strong: #FF5C7A;
  --success: #33E1A1;
  --surface: #08080D;
  --surface-strong: #121219;
  --surface2: #1D1D2A;
  --text: #EEEFF7;
  --text-dim: #888DA6;
  --border: #2A2A3D;
  --accent-gradient: linear-gradient(135deg, #7C7BFF, #9E7BFF);
  --success-gradient: linear-gradient(135deg, #3DE0A6, #1FC98C);
  --strong-gradient: linear-gradient(135deg, #FF6E86, #FF4D6D);
  --accent-glow: rgba(124, 123, 255, 0.35);
  --success-glow: rgba(51, 225, 161, 0.55);
  --strong-glow: rgba(255, 92, 122, 0.55);
  --success-pad-glow: rgba(51, 225, 161, 0.7);
  --strong-pad-glow: rgba(255, 92, 122, 0.7);
  --panel-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  --tick-opacity: 0.32;
  --hint-opacity: 0.42;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Bahnschrift on Windows; its closest built-in relative on Apple devices is DIN Alternate. */
  --font-display: Bahnschrift, "DIN Alternate", "DIN Next", "Barlow", -apple-system, "Segoe UI", Roboto, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html[data-theme="light"] {
  color-scheme: light;
  --accent: #6C5CFF;
  --accent-dim: #E7E5FB;
  --strong: #F43F5E;
  --success: #10B981;
  --surface: #EBECF2;
  --surface-strong: #FFFFFF;
  --surface2: #E1E2EC;
  --text: #15161E;
  --text-dim: #6A6E80;
  --border: #DBDCE6;
  --accent-gradient: linear-gradient(135deg, #6C5CFF, #8B5CFF);
  --success-gradient: linear-gradient(135deg, #22C79A, #10B981);
  --strong-gradient: linear-gradient(135deg, #FF5C78, #F43F5E);
  --accent-glow: rgba(108, 92, 255, 0.3);
  --success-glow: rgba(16, 185, 129, 0.45);
  --strong-glow: rgba(244, 63, 94, 0.45);
  --success-pad-glow: rgba(16, 185, 129, 0.6);
  --strong-pad-glow: rgba(244, 63, 94, 0.6);
  --panel-shadow: 0 2px 12px rgba(21, 22, 30, 0.07);
  --tick-opacity: 0.2;
  --hint-opacity: 0.33;
}

/* --- Base ------------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--surface);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.35;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Installed on iOS the status bar floats over the page; keep its white text readable. */
html[data-theme="light"] body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--safe-top);
  background: rgba(21, 22, 30, 0.92);
  z-index: 90;
}

button, input, select { font: inherit; color: inherit; }
button { border: 0; margin: 0; background: none; padding: 0; cursor: pointer; }
button, .pad, .dial, .volume, .handle-cell, .setlist-handle, .segmented, .footer {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
svg { display: block; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 15px) calc(var(--safe-bottom) + 8px) calc(var(--safe-left) + 15px);
}

.panel {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--panel-shadow);
}

.label {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* --- Buttons ------------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.12s, transform 0.12s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active:not(:disabled) { opacity: 0.8; transform: scale(0.97); }
.btn:disabled { cursor: default; }
@media (hover: hover) { .btn:hover:not(:disabled) { opacity: 0.92; } }

.btn-accent { background: var(--accent); color: #fff; font-weight: 700; }
.btn-quiet { background: var(--surface2); color: var(--text); }
.btn-dim { color: var(--text-dim); }
.btn-gradient { background: var(--accent-gradient); color: #fff; font-weight: 700; }
.btn-danger { background: var(--strong); color: #fff; font-weight: 700; }
.btn-sm { min-height: 30px; padding: 7px 14px; font-size: 11px; font-weight: 700; }
.btn-md { height: 40px; font-size: 11px; font-weight: 700; }
.btn-lg { height: 46px; font-size: 13px; }
.btn-xl { width: 100%; height: 48px; font-size: 13px; font-weight: 700; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  transition: opacity 0.12s, transform 0.12s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn-sm { width: 36px; height: 36px; }
.icon-btn-sm svg { width: 17px; height: 17px; }
.icon-btn:active { opacity: 0.8; transform: scale(0.97); }
@media (hover: hover) { .icon-btn:hover { opacity: 0.92; } }

.theme-toggle {
  position: relative;
  width: 52px;
  height: 26px;
  border: 1px solid var(--accent-dim);
  border-radius: 13px;
  background: var(--surface2);
  transition: background 0.2s;
}
.theme-toggle::before { content: ""; position: absolute; inset: -8px -4px; } /* bigger touch target */
.theme-toggle[aria-checked="true"] { background: var(--accent); }
.theme-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  color: #4C4F69;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.theme-thumb svg { width: 12px; height: 12px; }
.theme-toggle[aria-checked="true"] .theme-thumb { transform: translateX(26px); }
.theme-sun { display: none; }
.theme-toggle[aria-checked="true"] .theme-sun { display: block; }
.theme-toggle[aria-checked="true"] .theme-moon { display: none; }

/* --- Selects ------------------------------------------------------------------------------ */

.select-wrap { position: relative; min-width: 0; }
.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 11px;
  width: 8px;
  height: 6px;
  margin-top: -3px;
  background: var(--text-dim);
  clip-path: polygon(0 0, 0 33%, 50% 100%, 100% 33%, 100% 0, 50% 67%);
  pointer-events: none;
}
.select {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.select-lg { height: 48px; font-size: 22px; font-weight: 400; font-family: var(--font-display); }
.select:focus-visible { border-color: var(--accent); outline: none; }
@media (hover: hover) { .select:hover { border-color: var(--accent-dim); } }
/* iOS zooms into form fields with text under 16 px. */
@media (pointer: coarse) { .select:not(.select-lg) { font-size: 16px; } }

/* --- Top panel ------------------------------------------------------------------------------ */

.top { position: relative; padding: 12px 25px 14px; }

.top-bar {
  position: absolute;
  top: 7px;
  right: 25px;
  z-index: 2;
}
.panel-brand { display: none; align-items: center; gap: 8px; font-size: 12px; font-weight: 900; opacity: 0.85; }
.panel-brand img { border-radius: 5px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.top-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(190px, 256px) minmax(206px, 236px);
  justify-content: space-between;
  align-items: center;
  column-gap: clamp(16px, 3.4vw, 34px);
  max-width: 780px;
  margin: 0 auto;
}

.tempo-col .label { margin: 0 0 8px 8px; font-size: 12px; }

.dial {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  transition: transform 0.085s ease-out;
}
.dial.pressed { transform: scale(0.985); cursor: grabbing; }
.dial-svg { width: 100%; height: 100%; overflow: visible; }
.dial-outer { fill: var(--surface-strong); stroke: var(--surface2); stroke-width: 2.2; }
.dial-inner { fill: var(--surface); opacity: 0.75; }
.dial-tick { stroke: var(--text-dim); stroke-width: 1.1; stroke-linecap: round; opacity: var(--tick-opacity); }
.dial-ring { fill: none; stroke: var(--accent-dim); stroke-width: 1.2; opacity: 0.45; }
.dial-hint text {
  fill: var(--text-dim);
  opacity: var(--hint-opacity);
  font-family: var(--font-ui);
  font-size: 6.2px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
}
.dial-center { fill: var(--surface-strong); stroke: var(--accent); stroke-width: 1.5; opacity: 0.95; }
.dial-bpm {
  fill: var(--accent);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
}
.dial-unit {
  fill: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.transport-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 256px;
  justify-self: center;
}

.start-btn {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100px;
  border-radius: 8px;
  background: var(--success-gradient);
  color: var(--surface-strong);
  box-shadow: 0 0 30px var(--success-glow);
  transition: transform 0.1s, opacity 0.1s, box-shadow 0.2s;
}
.start-btn svg { width: 46px; height: 46px; }
.start-btn:active { transform: scale(0.97); opacity: 0.85; }
.start-btn.running { background: var(--strong-gradient); box-shadow: 0 0 30px var(--strong-glow); }
.start-stop { display: none; }
.running .start-play { display: none; }
.running .start-stop { display: block; }

.nav-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nav-btn { height: 58px; background: var(--surface2); color: var(--text); }
.nav-btn svg { width: 28px; height: 28px; }
.nav-btn:disabled { opacity: 0.42; background: var(--surface); color: var(--text-dim); }

.save-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.save-btn { grid-column: 1 / -1; min-height: 40px; padding: 12px 4px; font-size: 11px; font-weight: 700; }
.save-row.has-update .save-btn { grid-column: auto; }

.options-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  margin-top: 40px; /* keeps SIGNATURE clear of the floating header buttons */
}
.options { display: grid; gap: 8px; min-width: 0; }
.field .label { margin-bottom: 6px; }
.field-sub { margin-top: -2px; }
.sig-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.sig-slash { margin: 0 10px; color: var(--text-dim); font-size: 30px; font-weight: 300; line-height: 1; }

.volume-label {
  align-self: center;
  margin: 21px 2px 0 10px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.volume {
  position: relative;
  display: flex;
  justify-content: center;
  width: 30px;
  margin-top: 21px; /* lines the cone's top up with the SIGNATURE dropdown */
  cursor: pointer;
  touch-action: none;
}
.volume-track { width: 18px; height: 100%; }
.volume-svg { width: 100%; height: 100%; }
.volume-empty { fill: var(--surface2); }
.volume-fill { fill: var(--accent); }
.volume-readout {
  position: absolute;
  top: 50%;
  right: calc(100% + 6px);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.volume.dragging .volume-readout { opacity: 1; }

.pads {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
.pad {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface2);
}
.pad-num { color: var(--text); font-size: 13px; font-weight: 700; line-height: 1; opacity: 0.45; }
.pad-dots { display: flex; gap: 3px; margin-top: 5px; }
.pad-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--text); opacity: 0.25; }
.pad-dots i.on { opacity: 1; }
.pad.accented { background: var(--accent-dim); border-color: var(--accent); }
.pad.active { background: var(--success-gradient); border-color: var(--success); box-shadow: 0 0 14px 2px var(--success-pad-glow); }
.pad.active.accented { background: var(--strong-gradient); border-color: var(--strong); box-shadow: 0 0 14px 2px var(--strong-pad-glow); }
.pad.active .pad-num { opacity: 0.7; }

/* --- Browser ----------------------------------------------------------------------------------- */

.browser { display: flex; flex-direction: column; overflow: hidden; }

.browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.segmented { display: flex; padding: 3px; border-radius: 7px; background: var(--surface2); }
.segmented button {
  padding: 6px 18px;
  border-radius: 5px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}
.segmented button[aria-selected="true"] { background: var(--accent-gradient); color: #fff; box-shadow: 0 0 6px var(--accent-glow); }
@media (hover: hover) {
  .segmented button[aria-selected="false"]:hover { background: var(--surface); color: var(--text); }
}

.browser-body { display: flex; flex-direction: column; }
.view { min-height: 0; }
.view-library { display: flex; flex-direction: column; padding: 12px; }
.section-title { margin: 0 0 12px 5px; color: var(--text-dim); font-weight: 600; }

.preset-list, .setlist-list { margin: 0; padding: 0; list-style: none; }
.preset-list { container-type: inline-size; }

.preset-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 125px auto;
  align-items: center;
  margin: 2px 4px 2px 0;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: var(--font-display);
  cursor: pointer;
}
.preset-row.selected { background: var(--accent-dim); border-color: var(--accent); }
@media (hover: hover) { .preset-row:hover { background: var(--surface2); } }

.handle-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: stretch;
  min-height: 44px;
  color: var(--text-dim);
}
.slot { font-size: 14px; font-weight: 600; }
.handle-dots { width: 19px; height: 12px; opacity: 0.6; }
html:not(.hide-handles) .handle-cell,
html:not(.hide-handles) .setlist-handle { cursor: grab; touch-action: none; }
.hide-handles .handle-dots, .hide-handles .setlist-handle { display: none; }

.preset-main { min-width: 0; margin: 0 12px 0 5px; }
.preset-name {
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.preset-meta { display: flex; gap: 6px; margin-top: 3px; }
.chip {
  padding: 1.5px 5px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}
.chip-bpm { display: none; }
.chip-bpm b { color: var(--accent); }
.preset-row.selected .chip { background: var(--surface-strong); }

.bpm-chip {
  justify-self: end;
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-right: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface2);
}
.bpm-chip b { color: var(--accent); font-size: 20px; font-weight: 800; line-height: 1.2; }
.bpm-chip span { color: var(--text-dim); font-size: 11px; font-weight: 700; }
.preset-row.selected .bpm-chip { background: var(--surface-strong); }

.row-actions { display: flex; gap: 6px; }
.row-play, .row-btn { display: grid; place-items: center; border-radius: 8px; transition: opacity 0.12s, transform 0.12s; }
.row-play { width: 42px; height: 42px; background: var(--success-gradient); color: #fff; }
.row-play svg { width: 17px; height: 17px; }
.row-play svg + svg { display: none; }
.row-play.playing { background: var(--strong-gradient); }
.row-play.playing svg:first-child { display: none; }
.row-play.playing svg + svg { display: block; }
.row-btn { width: 40px; height: 40px; background: var(--surface2); color: var(--text-dim); }
.row-btn svg { width: 16px; height: 16px; }
.row-btn.danger, .row-btn-sm.danger { color: var(--strong); }
.row-play:active, .row-btn:active, .row-btn-sm:active { opacity: 0.8; transform: scale(0.95); }

/* Narrow lists (phones, or the setlist pane next to the sidebar): BPM moves under the name. */
@container (max-width: 560px) {
  .preset-row { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 5px 4px; }
  .handle-cell { flex-direction: column; gap: 4px; }
  .preset-main { margin: 0 8px 0 2px; }
  .preset-name { font-size: 16px; }
  .bpm-chip { display: none; }
  .chip-bpm { display: inline-block; }
  .row-actions { gap: 4px; }
  .row-play { width: 44px; height: 44px; }
  .row-btn { width: 36px; height: 44px; }
}

.empty {
  padding: 18px 12px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
.empty b { color: var(--text); font-weight: 700; }

/* Setlists tab */
.view-setlists { display: grid; grid-template-columns: auto 6px minmax(0, 1fr); }
.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width, 260px);
  min-height: 0;
  padding: 12px 6px 12px 12px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px 5px; }
.sidebar-head .section-title { margin: 0; }
.setlist-list { font-family: var(--font-display); }
.setlist-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin: 1px 4px 1px 0;
  padding: 4px 6px 4px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.setlist-row.selected { background: var(--accent-dim); border-color: var(--accent); }
@media (hover: hover) { .setlist-row:hover { background: var(--surface2); } }
.setlist-handle { display: grid; place-items: center; align-self: stretch; width: 26px; flex: none; color: var(--text-dim); }
.setlist-handle .handle-dots { opacity: 0.5; }
.setlist-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding-left: 4px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row-btn-sm { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; color: var(--text-dim); }
.row-btn-sm svg { width: 15px; height: 15px; }
@media (hover: hover) { .row-btn-sm:hover { background: var(--surface); } }
.add-setlist { margin-top: 15px; min-height: 40px; font-size: 12px; }

.splitter {
  margin: 12px 0;
  border-radius: 3px;
  background: var(--surface2);
  cursor: col-resize;
  touch-action: none;
}
.splitter.dragging { background: var(--accent); }

.setlist-content { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 12px 12px 6px; }
.setlist-head { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 12px; }
.setlist-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.setlist-title.placeholder { color: var(--text-dim); font-size: 18px; font-weight: 600; }
.setlist-count { flex: none; color: var(--text-dim); }

.view-setlists:not(.sidebar-hidden) #showSidebarBtn { display: none; }
.view-setlists.sidebar-hidden .sidebar,
.view-setlists.sidebar-hidden .splitter { display: none; }
.view-setlists.sidebar-hidden .setlist-content { grid-column: 1 / -1; padding-left: 12px; }

/* Drag reorder */
.drag-ghost-list {
  position: fixed;
  z-index: 200;
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.drag-ghost-list > * {
  margin: 0 !important;
  border-color: var(--accent) !important;
  background: var(--surface-strong) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transform: scale(1.02);
}
.drag-source { visibility: hidden; }
.reordering > [data-id] { transition: transform 0.16s ease; }
.is-dragging, .is-dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }

/* --- Live view ------------------------------------------------------------------------------ */

/* The Live view button sits next to the selected setlist's name. */
.setlist-live { flex: none; margin-left: auto; }
.setlist-live svg { width: 17px; height: 17px; }

.live-mode .app, .live-mode .mini-bar, .live-mode .install-hint { display: none !important; }
.live-mode, .live-mode body { overflow: hidden; }

.live {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 12px) calc(var(--safe-left) + 12px);
  background: var(--surface);
}
.live-head { display: flex; align-items: center; gap: 10px; }
.live-exit { flex: none; height: 46px; padding: 0 16px 0 10px; font-size: 13px; font-weight: 700; }
.live-exit svg { width: 18px; height: 18px; }
.live-setlist { flex: 1; min-width: 0; }
.live-setlist .select { height: 46px; font-family: var(--font-display); font-size: 18px; font-weight: 700; }

.live-body { display: flex; flex: 1; flex-direction: column; gap: 12px; min-height: 0; }
.live-stage {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}
.live-pos { color: var(--text-dim); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.live-name {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.12;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.live-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.live-bpm { display: inline-flex; align-items: baseline; gap: 5px; margin-right: 4px; color: var(--text-dim); font-size: 13px; font-weight: 700; }
.live-bpm b { color: var(--accent); font-family: var(--font-display); font-size: 48px; font-weight: 800; line-height: 1; }
.live-meta .chip { padding: 4px 9px; font-size: 14px; }

.live-beats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.live-beats .pad { flex: 1 1 0; width: auto; min-width: 30px; max-width: 76px; height: 42px; }

.live-transport { display: grid; grid-template-columns: 1fr 1.7fr 1fr; gap: 10px; }
.live-nav, .live-play {
  display: grid;
  place-items: center;
  height: 78px;
  border-radius: 14px;
  transition: opacity 0.12s, transform 0.12s;
}
.live-nav { background: var(--surface2); color: var(--text); }
.live-nav svg { width: 32px; height: 32px; }
.live-nav:disabled { opacity: 0.35; }
.live-play { background: var(--success-gradient); color: var(--surface-strong); box-shadow: 0 0 26px var(--success-glow); }
.live-play.running { background: var(--strong-gradient); box-shadow: 0 0 26px var(--strong-glow); }
.live-play svg { width: 40px; height: 40px; }
.live-nav:active:not(:disabled), .live-play:active { opacity: 0.85; transform: scale(0.97); }

.live-upnext {
  min-height: 18px;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.live-upnext b { color: var(--text); }

.live-list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  list-style: none;
  font-family: var(--font-display);
}
.live-song {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 6px 14px 6px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.live-song + .live-song { margin-top: 2px; }
.live-song .num { position: relative; color: var(--text-dim); font-size: 15px; font-weight: 700; text-align: center; }
.live-song .name { overflow: hidden; font-size: 18px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.live-song .meta { color: var(--text-dim); font-size: 14px; font-weight: 700; white-space: nowrap; }
.live-song .meta b { color: var(--accent); font-size: 18px; }
.live-song.current { border-color: var(--accent); background: var(--accent-dim); }
.live-song.playing .num { color: transparent; }
.live-song.playing .num::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success-pad-glow);
}
@media (hover: hover) { .live-song:not(.current):hover { background: var(--surface2); } }
.live-empty { padding: 28px 16px; color: var(--text-dim); line-height: 1.5; text-align: center; }
.live-empty b { color: var(--text); }

/* Tablets, desktops and phones on their side: the stage and the song list side by side. */
@media (min-width: 720px), (orientation: landscape) and (min-width: 560px) {
  .live-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 1fr); }
  .live-stage { justify-content: center; overflow-y: auto; }
  .live-list { height: 100%; }
}
@media (min-width: 720px) and (min-height: 600px) {
  .live-stage { gap: 22px; padding: 28px; }
  .live-name { font-size: 44px; }
  .live-bpm b { font-size: 72px; }
  .live-beats .pad { height: 54px; }
  .live-nav, .live-play { height: 104px; }
  .live-nav svg { width: 40px; height: 40px; }
  .live-play svg { width: 52px; height: 52px; }
  .live-upnext { font-size: 16px; }
}
/* Short screens (phones on their side): tighter so everything fits without scrolling. */
@media (max-height: 520px) {
  .live { gap: 8px; }
  .live-stage { gap: 8px; padding: 10px 14px; }
  .live-name { font-size: 22px; -webkit-line-clamp: 1; }
  .live-meta { margin-top: 4px; }
  .live-bpm b { font-size: 34px; }
  .live-beats .pad { height: 30px; }
  .live-nav, .live-play { height: 58px; }
  .live-song { min-height: 46px; }
}

/* --- Footer --------------------------------------------------------------------------------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 5px 2px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 900; opacity: 0.85; }
.brand img { border-radius: 4px; }
.shortcuts { color: var(--text-dim); font-size: 10px; opacity: 0.5; text-align: center; }
@media not all and (hover: hover) { .shortcuts { display: none; } }
.support-btn { color: var(--text); }
.footer-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.btn-icon { display: contents; }
.btn-icon svg { width: 14px; height: 14px; }

.install-steps { margin: 0 0 16px; padding-left: 22px; line-height: 1.5; }
.install-steps li { margin-bottom: 10px; padding-left: 4px; }
.install-steps li::marker { color: var(--accent); font-weight: 700; }
.install-note { margin: -4px 0 16px; }

/* --- Sticky play bar ------------------------------------------------------------------------ */

.mini-bar {
  position: fixed;
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  bottom: calc(var(--safe-bottom) + 10px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-strong);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(calc(100% + 30px));
  transition: transform 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
}
.mini-bar.visible { opacity: 1; transform: none; pointer-events: auto; }
.modal-open .mini-bar { display: none; }
.mini-beat { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--surface2); }
.mini-beat.flash { animation: flash-weak 0.28s ease-out; }
.mini-beat.flash-strong { animation: flash-strong 0.28s ease-out; }
@keyframes flash-weak { from { background: var(--success); box-shadow: 0 0 10px var(--success-pad-glow); } }
@keyframes flash-strong { from { background: var(--strong); box-shadow: 0 0 10px var(--strong-pad-glow); } }
.mini-info { flex: 1; min-width: 0; line-height: 1.15; }
.mini-bpm { color: var(--accent); font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.mini-unit { margin-left: 4px; color: var(--text-dim); font-size: 10px; font-weight: 700; }
.mini-meta { overflow: hidden; color: var(--text-dim); font-size: 12px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.mini-nav {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
}
.mini-nav svg { width: 22px; height: 22px; }
.mini-nav:disabled { opacity: 0.4; }
.mini-play {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 48px;
  border-radius: 12px;
  background: var(--success-gradient);
  color: var(--surface-strong);
}
.mini-play svg { width: 24px; height: 24px; }
.mini-play.running { background: var(--strong-gradient); }

/* --- Modal ----------------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background: rgba(7, 10, 18, 0.4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.modal-card {
  width: min(var(--modal-width, 420px), 100%);
  padding: 24px;
  border: 1px solid var(--surface2);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.modal-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 15px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.modal-title svg { width: 16px; height: 16px; color: var(--strong); }
.modal-title-danger { margin-bottom: 10px; color: var(--strong); }
.modal-message { margin: 0 0 24px; font-size: 15px; line-height: 1.45; text-align: center; }
.modal-message-dim { margin-bottom: 20px; color: var(--text-dim); font-size: 13px; }
.modal-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-xl + .modal-buttons { margin-top: 12px; }
.modal-close-wide { width: 100%; margin-top: 12px; }
.text-input {
  display: block;
  width: 100%;
  height: 45px;
  margin: 0 0 20px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
}
.text-input:focus { border-color: var(--accent); }
.text-input::placeholder { color: var(--text-dim); }

.modal-card.modal-settings {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 32px);
  padding: 0;
}
.settings-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 24px 24px 0; }
.settings-title { margin: 0; font-size: 18px; font-weight: 700; }
.settings-subtitle { margin: 6px 0 18px; color: var(--text-dim); }
.settings-card { margin-bottom: 16px; padding: 18px; border-radius: 14px; background: var(--surface-strong); }
.settings-card h3 { margin: 0; font-size: 13px; font-weight: 700; }
.settings-card > p { margin: 6px 0 12px; color: var(--text-dim); }
.settings-card .select-wrap { margin-bottom: 14px; }
.field-label { display: block; margin: 0 0 6px 2px; color: var(--text-dim); font-size: 11px; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.hint { margin: 6px 0 0; color: var(--text-dim); font-size: 13px; }
.range-row { display: flex; justify-content: space-between; margin: 14px 0 6px; font-weight: 600; }
.range-row b { color: var(--text-dim); }
input[type="range"] { width: 100%; margin: 4px 0 8px; accent-color: var(--accent); }
.settings-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.settings-footer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 20px 24px 24px; }
.settings-footer .btn { padding: 0 6px; font-size: 12px; }

/* --- Toast & install hint ----------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  z-index: 150;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.install-hint {
  position: fixed;
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
}
.install-hint img { flex: none; border-radius: 9px; }
.install-hint-open .app { padding-bottom: calc(var(--safe-bottom) + 100px); }
.install-text { flex: 1; font-size: 14px; line-height: 1.4; }
.inline-icon { display: inline-block; width: 17px; height: 17px; vertical-align: -3px; color: var(--accent); }
.inline-icon svg { width: 100%; height: 100%; }

/* --- Wide and tall: the app fills the screen, lists scroll inside ---------------------------- */

@media (min-width: 720px) and (min-height: 600px) {
  .app { height: 100vh; height: 100dvh; }
  .browser { flex: 1 1 0; min-height: 230px; }
  .browser-body { flex: 1; min-height: 0; }
  .view { height: 100%; }
  .view-setlists .sidebar, .setlist-content { height: 100%; }
  .scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
}

/* --- Phones ------------------------------------------------------------------------------------- */

@media (max-width: 719px) {
  .app {
    gap: 10px;
    padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 96px) calc(var(--safe-left) + 10px);
  }

  .top { padding: 10px 14px 16px; }
  .top-bar {
    position: static;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .panel-brand { display: flex; }

  .top-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 14px;
    row-gap: 16px;
    max-width: 520px;
  }
  .tempo-col .label { margin-left: 4px; }
  .dial { margin: 0 auto; }
  .transport-col { max-width: none; }
  .start-btn { height: 88px; }
  .start-btn svg { width: 40px; height: 40px; }
  .nav-btn { height: 48px; }
  .save-row.has-update { grid-template-columns: 1fr; gap: 8px; }

  .options-col { grid-column: 1 / -1; margin-top: 0; }
  .options { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 10px; }
  .field-sig { grid-column: 1 / -1; }
  .field-sub { margin-top: 0; }

  .pads { margin-top: 0; }

  .browser-head { padding: 8px 10px; }
  .segmented button { padding: 7px 14px; }
  .label-long { display: none; }
  .view-library { padding: 10px 6px 8px 8px; }

  .view-setlists { display: flex; flex-direction: column; }
  .sidebar { width: auto; padding: 10px 6px 14px 8px; border-bottom: 1px solid var(--border); }
  .splitter { display: none; }
  .setlist-content { padding: 12px 6px 8px 8px; }
  .view-setlists.sidebar-hidden .setlist-content { padding-left: 8px; }
  .setlist-title { font-size: 20px; }

  .footer { justify-content: center; }
  .footer .brand, .footer .shortcuts { display: none; }

  .settings-scroll { padding: 20px 16px 0; }
  .settings-card { padding: 16px; }
  .settings-footer { grid-template-columns: 1fr 1fr; padding: 16px; }
  .settings-footer #setReset { grid-column: 1 / -1; }
  .settings-buttons { grid-template-columns: 1fr; }
  .modal-card { padding: 20px; }
}

@media (max-width: 360px) {
  .top { padding: 10px 10px 14px; }
  .top-grid { column-gap: 10px; }
  .panel-brand span { font-size: 11px; }
  .segmented button { padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
