:root {
  --bg: #000;
  --panel: rgba(16, 8, 8, .84);
  --ink: #f3e9e6;
  --mute: #b09a96;
  --line: rgba(255, 80, 50, .28);
  --accent: #ff4a2e;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000; }
}

:root[data-theme="dark"] { --bg: #000; }

*, *::before, *::after { box-sizing: inherit; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  overflow: hidden;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- Boutons & Formulaires génériques ---------- */
button, select, input[type="text"] {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.svg-icon {
  display: inline-block;
  vertical-align: middle;
  width: 1.1em;
  height: 1.1em;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.row { display: flex; gap: 8px; margin-top: 12px; }
.hint { font-size: 13px; color: var(--mute); margin: 10px 0 0; line-height: 1.4; }
.btn-mini { padding: 5px 9px; font-size: 12px; border-radius: 8px; }

/* ---------- Écran d'accueil & modale d'intro ---------- */
#intro, .hero-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
}

#intro h1, .hero-overlay h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 300;
  letter-spacing: .02em;
  text-wrap: balance;
}

#intro p, .hero-overlay p {
  margin: 0;
  text-wrap: balance;
  color: #d2c4c0;
  font-size: 15px;
  max-width: 36ch;
  line-height: 1.45;
}

#intro button, .hero-overlay button {
  padding: 12px 26px;
  font-size: 16px;
}

#go, #goimm, .btn-primary { width: 100%; max-width: 320px; }
#intro a, .hero-overlay a {
  color: var(--mute);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  padding: 8px;
}

/* ---------- Chips & Sélecteurs ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: rgba(14, 10, 16, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.chips button, .chips a {
  flex: 1 1 calc(33.333% - 8px);
  min-width: 90px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  transition: all .2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chips button:hover, .chips a:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  transform: translateY(-1px);
}

.chips button.act, .chips a.act {
  background: rgba(255, 74, 46, 0.22);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 14px rgba(255, 74, 46, 0.35);
}

/* ---------- Interface Player « Écoute 24/7 » ---------- */
.listen-hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
}

.listen-hud > * { pointer-events: auto; }

.listen-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.station-badge {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.station-badge .live-dot {
  width: 8px;
  height: 8px;
  background: #ff3b30;
  border-radius: 50%;
  box-shadow: 0 0 8px #ff3b30;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.85); }
}

.listen-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.track-card {
  width: 100%;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
  text-align: center;
}

.track-card b {
  display: block;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-card small {
  color: var(--mute);
  font-size: 12.5px;
  display: block;
  margin-top: 2px;
}

.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, .1);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .25s linear;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Interface Panneau Studio ---------- */
#bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  z-index: 4;
}

#panel {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

#head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 14px;
  gap: 8px;
}

#head b { font-weight: 600; font-size: 15px; }
#head span { display: flex; gap: 6px; }

#body { display: none; padding: 0; }
#panel.open #body { display: block; }

label {
  display: grid;
  grid-template-columns: 92px 1fr 60px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--mute);
  margin: 9px 0;
}

label span:last-child {
  white-space: nowrap;
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type=range] { width: 100%; accent-color: var(--accent); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  flex: 1;
  min-width: 0;
  padding: 7px 2px;
  font-size: 12.5px;
  border-color: transparent;
  background: none;
  color: var(--mute);
}

.tabs button.act {
  background: rgba(255, 255, 255, .08);
  border-color: var(--line);
  color: var(--ink);
}

.panes {
  max-height: min(46vh, 380px);
  overflow-y: auto;
  padding: 4px 14px 12px;
  overscroll-behavior: contain;
}

.pane { display: none; }
.pane.act { display: block; }

.trk {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.tn { flex: 1; min-width: 0; }
.tn b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn small { color: var(--mute); font-size: 12px; }
.trk button { padding: 6px 10px; min-width: 40px; }

.sec { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 6px; }
.sec h3 { margin: 8px 0 2px; font-size: 14px; font-weight: 600; }
.sec2 { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 6px; }

.sel {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--mute);
  margin: 9px 0;
}
.sel select { width: 100%; }
.sel input[type=text] { width: 100%; box-sizing: border-box; }

button.rec { width: 100%; margin-top: 8px; padding: 10px; }
button.rec.on { background: #e02b1c; border-color: #e02b1c; color: #fff; }

.box {
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}

.box h4 { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; color: var(--accent); }

textarea.desc-box {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 11.5px;
  color: var(--ink);
  background: rgba(0, 0, 0, .5);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
  font-family: monospace;
  line-height: 1.4;
}

#info { font-size: 13px; color: var(--mute); margin: 6px 0 0; line-height: 1.4; min-height: 1.2em; }
#exit, #badge {
  position: fixed;
  z-index: 6;
  top: calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(0, 0, 0, .6);
}
#exit { right: 12px; display: none; opacity: 0; transition: opacity .3s; }
body.imm #bar, body.imm .listen-hud { display: none; }
body.imm #exit { display: block; }
body.imm #exit.show { opacity: 1; }
#badge {
  left: 12px;
  display: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#badge.on { display: block; }
#badge.ready { cursor: pointer; background: #e02b1c; border-color: #e02b1c; color: #fff; }
