:root {
  color-scheme: dark;
  --bg: #000000;
  --text: #f5f5f7;
  --muted: #9a94a8;
  --surface: #17141f;
  --border: rgba(255,255,255,.08);
  --app-accent: #7b6ef7;
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── Header ── */
.app-header {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
}
.app-header img { height: 34px; object-fit: contain; }
.nos-radios-link {
  align-self: flex-start;
  margin-left: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 800;
}

/* ── Screens ── */
main#screens { flex: 1; min-height: 0; position: relative; }
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ── Carousel (cartes flottantes avec "peek" des voisines) ── */
.carousel {
  flex: 1;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 9vw 0;
  align-items: center;
}
.carousel-mono { overflow-x: hidden; padding: 4px 4vw 0; }
.carousel::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 82vw;
  max-width: 360px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 20px 22px;
  background: var(--card-bg, #222);
  color: var(--card-text, #fff);
  border-radius: 26px;
  box-shadow: 0 20px 45px rgba(0,0,0,.45);
}
.carousel-mono .card { flex-basis: 100%; max-width: 420px; }

.card-head { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 14px; }
.card-wordmark { height: 22px; object-fit: contain; border-radius: 6px; }
.card-live-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.card-cover { width: 100%; aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: rgba(0,0,0,.15); margin-bottom: 18px; display: flex; align-items: center; justify-content: center; }
.card-cover img { width: 100%; height: 100%; object-fit: contain; }
.card-title { font-size: 19px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; min-height: 24px; line-height: 1.25; }
.card-artist { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin-top: 4px; margin-bottom: 20px; min-height: 18px; font-family: ui-monospace, "SF Mono", monospace; }

.play-btn {
  width: 100%;
  max-width: 260px;
  padding: 15px 0;
  border-radius: 40px;
  border: none;
  background: rgba(0,0,0,.18);
  color: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 14px;
}

.card-secondary-actions { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.itunes-btn, .share-btn {
  background: rgba(0,0,0,.14);
  border: none;
  color: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 20px;
  text-decoration: none;
  cursor: pointer;
}
.card-status { font-size: 12px; opacity: .8; min-height: 16px; }

/* ── Grille "Nos radios" ── */
.grid-screen-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; flex-shrink: 0; }
.grid-back-btn { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.station-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 4px 16px 16px;
}
.grid-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  border: none;
  background: var(--tile-bg, #222);
  color: var(--tile-text, #fff);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px;
  cursor: pointer;
  overflow: hidden;
}
.grid-tile-badge { position: absolute; top: 8px; left: 8px; right: 8px; font-size: 8px; font-weight: 800; letter-spacing: .04em; text-align: left; opacity: .85; }
.grid-tile img { width: 44%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; }
.grid-tile-name { font-size: 11px; font-weight: 800; text-align: center; line-height: 1.2; }

/* ── Historique (pastilles colorées, assorties à la station active) ── */
.history { flex-shrink: 0; max-height: 28vh; overflow-y: auto; padding: 14px 16px calc(90px + env(safe-area-inset-bottom)); }
.history-title { font-size: 13px; color: var(--muted); margin: 0 0 10px; text-align: center; }
.history-list { list-style: none; margin: 0 auto; padding: 0; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--history-bg, var(--surface));
  color: var(--history-text, var(--text));
  border-radius: 14px;
  padding: 8px 12px;
}
.history-cover, .history-cover-ph { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; background: rgba(0,0,0,.15); flex-shrink: 0; }
.history-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-time { font-size: 10px; opacity: .75; }
.history-song { font-size: 13px; font-weight: 800; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-artist { font-size: 11px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.history-itunes { text-decoration: none; font-size: 15px; }
.history-share { background: none; border: none; color: inherit; opacity: .8; font-size: 14px; font-weight: 700; cursor: pointer; padding: 4px; }

/* ── Podcasts (webview) ── */
.podcasts-frame { flex: 1; width: 100%; border: none; }

/* ── Mini-lecteur persistant (carte blanche, façon Nova) ── */
.miniplayer {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(70px + env(safe-area-inset-bottom));
  background: #fff;
  color: #111;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  z-index: 20;
}
.mp-cover { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: rgba(0,0,0,.08); }
.mp-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mp-title { font-size: 13px; font-weight: 800; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-artist { font-size: 11px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-play-btn { width: 38px; height: 38px; border-radius: 50%; border: none; background: #111; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mp-icon { width: 16px; height: 16px; fill: #fff; }

/* ── Tab bar ── */
.tabbar {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid var(--border);
  background: #0a0a0f;
  padding-top: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.tab { flex: 1; background: none; border: none; color: var(--muted); font-size: 11px; font-weight: 800; padding: 4px 0; cursor: pointer; }
.tab.active { color: var(--app-accent); }

/* ── Sleep timer (dans le header, à droite du logo) ── */
.sleep-btn { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; background: none; border: none; color: var(--text); cursor: pointer; z-index: 5; display: flex; }
.sleep-btn svg { width: 22px; height: 22px; }
.sleep-btn.active { color: var(--app-accent); }
.sleep-panel {
  position: absolute;
  top: 100%; right: 16px;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
}
.sleep-option { background: none; border: none; color: var(--text); font-size: 13px; text-align: left; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.sleep-option:hover { background: rgba(255,255,255,.08); }
.sleep-cancel { color: #ff6b6b; }

/* ── Bandeau d'installation ── */
.install-banner { position: fixed; left: 10px; right: 10px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 40; }
.install-banner-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.install-banner-btn { background: #fff; color: #000; border: none; border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.install-banner-close { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; margin-left: auto; }
.install-share-icon { font-size: 16px; }
