:root {
  --bg: #0b0c10;
  --panel: rgba(20, 22, 28, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8e8ec;
  --muted: #8b8d98;
  --accent: #ffd86b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#viz {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

button, input, .file-btn {
  font: inherit;
  color: inherit;
}

button, .file-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled), .file-btn:hover { background: rgba(255, 255, 255, 0.16); }
button:disabled { opacity: 0.4; cursor: default; }

/* ---- barre du haut ---- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

#track { display: flex; gap: 10px; align-items: center; min-width: 0; max-width: 48ch; }
#thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
#track > div { min-width: 0; }
#title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#artist { color: var(--muted); font-size: 12px; }

#load-form { display: flex; gap: 6px; flex: 1 1 320px; max-width: 560px; }
#url {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}
#url:focus { outline: 1px solid var(--accent); }

/* ---- contrôles bas ---- */
#controls {
  position: fixed;
  left: 16px; bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}
#play { width: 52px; height: 52px; border-radius: 50%; font-size: 20px; padding: 0; }
#settings-btn { width: 40px; height: 40px; border-radius: 50%; padding: 0; font-size: 18px; }
#status { color: var(--muted); font-size: 12px; }

/* ---- panneau réglages ---- */
#settings {
  position: fixed;
  right: 16px; bottom: 16px;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}
#settings h2 { margin: 0 0 12px; font-size: 15px; }
#settings label { display: block; margin-bottom: 14px; }
#settings output { float: right; color: var(--accent); font-variant-numeric: tabular-nums; }
#settings input[type="range"] { width: 100%; margin: 6px 0 2px; accent-color: var(--accent); }
#settings small { color: var(--muted); font-size: 11px; }
#stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 12px; }
#stats dt { color: var(--muted); }
#stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 11px; margin: 0; }

/* ---- progression / erreurs ---- */
#progress {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, 80vw);
  text-align: center;
}
#progress-label { margin-bottom: 8px; color: var(--muted); }
.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#progress.indeterminate #progress-fill { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

#error {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 14px;
  background: rgba(120, 30, 30, 0.92);
  border: 1px solid rgba(255, 120, 120, 0.4);
  border-radius: 8px;
  cursor: pointer;
}

/* ---- drag & drop ---- */
#drop {
  position: fixed;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: rgba(11, 12, 16, 0.85);
  font-size: 24px;
  text-align: center;
  pointer-events: none;
}
#drop small { display: block; font-size: 13px; color: var(--muted); margin-top: 6px; }

[hidden] { display: none !important; }

@media (max-width: 600px) {
  #topbar { padding: 8px 10px; gap: 8px; }
  #track { max-width: 100%; }
  #load-form { flex-basis: 100%; }
  #controls { left: 10px; bottom: 10px; }
  #settings { right: 10px; left: 10px; width: auto; bottom: 76px; }
}
