* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #040822;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
  overscroll-behavior: none;
}
#starfield {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, #0d1248 0%, #040822 70%);
}
#app {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(4, 8, 34, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky; top: 0; z-index: 5;
  gap: 10px;
}
.toolbar .side { display: flex; align-items: center; gap: 8px; min-width: 40px; }
.toolbar .title { font-weight: 600; font-size: 16px; flex: 1; text-align: center; }
.icon-btn {
  background: rgba(255,255,255,0.08); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.2); }
.logo-badge {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(160deg, #0d1248, #16b8c9);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}

/* ---------- Liste / sezioni colorate ---------- */
.content { flex: 1; overflow-y: auto; padding: 10px 12px 40px; }
.section-bar {
  width: 100%; border: none; border-radius: 12px;
  padding: 14px 16px; margin: 14px 0 6px;
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
}
.section-bar.red { background: rgba(255, 59, 48, 0.55); }
.section-bar.red-light { background: rgba(255, 59, 48, 0.35); }
.section-bar.blue { background: rgba(10, 132, 255, 0.55); }
.section-bar .plus { margin-left: auto; opacity: 0.85; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; margin-bottom: 6px; border-radius: 10px;
  cursor: pointer; user-select: none;
}
.list-row.red { background: rgba(255, 59, 48, 0.15); }
.list-row.blue { background: rgba(10, 132, 255, 0.15); }
.list-row:active { filter: brightness(1.3); }
.list-row .row-icon { font-size: 18px; width: 22px; text-align: center; opacity: 0.9; }
.list-row .row-title { flex: 1; font-size: 15px; }
.list-row .row-sub { font-size: 12px; opacity: 0.6; }
.list-row .row-actions { display: flex; gap: 6px; }
.row-actions button {
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  border-radius: 7px; padding: 6px 8px; font-size: 13px; cursor: pointer;
}

.artwork {
  width: 42px; height: 42px; border-radius: 6px; object-fit: cover;
  background: rgba(255,255,255,0.08); flex-shrink: 0;
}

.empty-hint { opacity: 0.5; text-align: center; padding: 40px 20px; font-size: 14px; }

/* ---------- Sheet / modal ---------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet {
  background: #0d1248; width: 100%; max-width: 520px;
  border-radius: 16px 16px 0 0; padding: 18px;
  max-height: 80vh; overflow-y: auto;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 12px; font-size: 16px; }
.sheet input[type="text"], .sheet input[type="url"] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06); color: #fff; font-size: 15px; margin-bottom: 10px;
}
.sheet .row { display: flex; gap: 10px; margin-top: 10px; }
.btn {
  padding: 12px 16px; border-radius: 999px; border: 1px solid rgba(0,229,255,0.6);
  background: rgba(0,229,255,0.22); color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer; flex: 1; text-align: center;
}
.btn:disabled { opacity: 0.35; }
.btn.secondary { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.25); }
.btn.danger { background: rgba(255,59,48,0.25); border-color: rgba(255,59,48,0.6); }
.btn.orange { background: rgba(255,149,0,0.28); border-color: rgba(255,149,0,0.7); }

.warn-box {
  background: rgba(255,59,48,0.18); border: 1px solid rgba(255,59,48,0.5);
  border-radius: 12px; padding: 16px; margin-bottom: 12px;
}
.warn-box .warn-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }

.progress-line { font-size: 13px; opacity: 0.75; margin-top: 8px; text-align: center; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #00e5ff;
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Menu contestuale semplice ---------- */
.menu-list button {
  display: block; width: 100%; text-align: left; padding: 12px 6px;
  background: none; border: none; color: #fff; font-size: 15px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.menu-list button.danger-text { color: #ff6b5e; }

/* ---------- Player ---------- */
.player-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 14px; min-height: 0;
}
.player-inner { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 8px; }

canvas.spectrum-canvas { width: 100%; display: block; border-radius: 10px; }
canvas.waveform-canvas { width: 100%; height: 110px; display: block; border-radius: 8px; cursor: pointer; touch-action: none; }

.key-bpm-row {
  text-align: center; color: #00e5ff; font-size: 17px; font-weight: 600;
  min-height: 22px;
}
.times-row { display: flex; justify-content: space-between; font-size: 13px; opacity: 0.8; }
.track-title { text-align: center; font-size: 16px; font-weight: 600; margin: 2px 0; word-break: break-word; }

.transport-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 6px 0; }
.play-btn {
  width: 64px; height: 64px; border-radius: 50%; border: none;
  background: rgba(0,229,255,0.25); border: 1px solid rgba(0,229,255,0.7);
  color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.nav-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.1); color: #fff; font-size: 18px; cursor: pointer;
}

.speed-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.speed-row input[type=range] { flex: 1; }

.section-controls { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.section-controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cyan-btn {
  padding: 10px 14px; border-radius: 999px; background: rgba(0,229,255,0.22);
  border: 1px solid rgba(0,229,255,0.6); color: #fff; font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.cyan-btn:disabled { opacity: 0.35; }
.cyan-btn.active-orange { background: rgba(255,149,0,0.28); border-color: rgba(255,149,0,0.7); }

.active-section-banner {
  text-align: center; font-size: 13px; padding: 8px; border-radius: 10px;
  background: rgba(0,229,255,0.12); border: 1px solid rgba(0,229,255,0.35);
}

.metronome-row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-top: 4px; }
.metronome-row input[type=range] { flex: 1; }

.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0; background: rgba(255,255,255,0.2);
  border-radius: 999px; transition: 0.2s;
}
.toggle-slider:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #00e5ff; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

.song-header {
  padding: 8px 4px; font-size: 12px; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.03em;
  margin-top: 12px;
}

.section-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; margin-bottom: 6px; border-radius: 10px;
  background: rgba(255,255,255,0.06); cursor: pointer;
}
.section-row.completed { background: rgba(52,199,89,0.22); }
.section-row.last-listened { border: 2px solid rgba(52,199,89,0.7); }
.section-row .check-circle {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.section-row.completed .check-circle { background: #34c759; border-color: #34c759; }
.section-row .sec-name { flex: 1; }
.section-row .sec-times { font-size: 12px; opacity: 0.6; }
.badge-last { font-size: 11px; background: rgba(52,199,89,0.3); padding: 3px 7px; border-radius: 999px; }

select.picker {
  background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; padding: 8px; font-size: 13px; margin-bottom: 10px;
}
