:root {
  --bg: #121212;
  --bg2: #181818;
  --card: #242424;
  --card2: #2e2e2e;
  --text: #ffffff;
  --muted: #a7a7a7;
  --accent: #f5a623;
  --accent2: #ff6b4a;
  --danger: #ff5c5c;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabs-h: 58px;
  --mini-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; }
.hidden { display: none !important; }

#app { display: flex; flex-direction: column; height: 100%; }
#topbar { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 10px) 16px 8px;
  background: linear-gradient(var(--bg) 70%, transparent); position: sticky; top: 0; z-index: 5; }
#topbar h1 { flex: 1; font-size: 24px; margin: 0; font-weight: 800; letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { font-size: 22px; min-width: 40px; height: 40px; border-radius: 20px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--text); }
.icon-btn.big { font-size: 26px; }
.icon-btn.on { color: var(--accent); }
#back { font-size: 34px; margin-left: -8px; }

#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 24px); }

h2 { font-size: 20px; margin: 22px 0 12px; font-weight: 800; }
.t1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 7px 14px; border-radius: 16px; background: var(--card); font-size: 14px; white-space: nowrap; }
.chip.active { background: var(--accent); color: #111; font-weight: 600; }

/* Grilles et listes */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 6px;
  overflow: hidden; height: 56px; text-align: left; }
.tile .art { width: 56px; height: 56px; border-radius: 0; flex: none; }
.tile span { font-size: 13px; font-weight: 700; padding-right: 8px; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.row-scroll { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.row-scroll::-webkit-scrollbar { display: none; }
.card { width: 140px; flex: none; text-align: left; }
.card .art { width: 140px; height: 140px; margin-bottom: 8px; }
.card .t1 { font-size: 14px; font-weight: 600; }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 8px 0; text-align: left; width: 100%; }
.item .meta { flex: 1; min-width: 0; }
.item.playing .t1 { color: var(--accent); }
.item .more { color: var(--muted); font-size: 20px; min-width: 36px; height: 36px; }
.item .badge { font-size: 11px; color: var(--muted); }

.art { border-radius: 4px; background: var(--card2) center/cover no-repeat; display: flex;
  align-items: center; justify-content: center; color: rgba(255,255,255,.85); font-size: 22px;
  width: 48px; height: 48px; flex: none; overflow: hidden; }
.art.sm { width: 42px; height: 42px; font-size: 18px; }
.art.round { border-radius: 50%; }
.art.xl { width: min(82vw, 380px); height: min(82vw, 380px); margin: 18px auto 26px; font-size: 90px;
  border-radius: 8px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }

.hero { display: flex; gap: 16px; align-items: flex-end; margin: 10px 0 18px; }
.hero .art { width: 128px; height: 128px; font-size: 52px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.hero h3 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.actions { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.play-btn { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #111;
  font-size: 22px; display: inline-flex; align-items: center; justify-content: center; }
.btn { padding: 10px 18px; border-radius: 22px; background: var(--card); font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); color: #111; }
.btn.ghost { border: 1px solid #555; background: none; }
.btn.danger { color: var(--danger); }
.link { color: var(--muted); font-size: 14px; text-decoration: underline; }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 10px; }
.empty p { margin: 6px 0 16px; }

.search { width: 100%; padding: 11px 14px; border-radius: 8px; border: 0; background: #fff; color: #111;
  font-size: 16px; margin: 4px 0 12px; }

/* Barre d'onglets */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: linear-gradient(transparent, rgba(0,0,0,.92) 30%);
  z-index: 10; }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); gap: 2px; }
#tabs button span { font-size: 20px; line-height: 1; }
#tabs button.active { color: var(--text); }

/* Mini-lecteur */
#mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabs-h) + var(--safe-b) + 4px);
  height: var(--mini-h); background: #3a2a14; border-radius: 8px; z-index: 11; overflow: hidden; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 8px; height: 100%; }
.mini-meta { flex: 1; min-width: 0; }
.mini-progress { position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; background: rgba(255,255,255,.2); }
#mini-bar { height: 100%; width: 0; background: #fff; }

/* Lecteur plein écran */
#player { position: fixed; inset: 0; z-index: 30; background: linear-gradient(#5a3d14, var(--bg) 70%);
  padding: calc(var(--safe-t) + 8px) 22px calc(var(--safe-b) + 20px); display: flex; flex-direction: column;
  overflow-y: auto; animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.player-top { display: flex; align-items: center; justify-content: space-between; }
.player-top .t2 { font-weight: 600; color: var(--text); }
.player-meta { display: flex; align-items: center; gap: 10px; }
.player-meta > div { flex: 1; min-width: 0; }
.pt1 { font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#seek { width: 100%; margin: 18px 0 4px; accent-color: #fff; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.controls { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 22px; }
.controls .play-btn { width: 66px; height: 66px; font-size: 26px; background: #fff; }
.pill { padding: 6px 12px; border-radius: 14px; background: rgba(255,255,255,.12); font-size: 14px; font-weight: 600; min-width: 48px; }
.pill.on { background: var(--accent); color: #111; }
#queue-btn { align-self: center; }

/* Feuille */
#sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: #282828;
  border-radius: 14px 14px 0 0; padding: 10px 18px calc(var(--safe-b) + 18px); max-height: 82vh; overflow-y: auto;
  animation: up .2s ease; }
#sheet h4 { margin: 8px 0 12px; font-size: 17px; }
#sheet .opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 0; font-size: 16px; text-align: left; }
#sheet .opt .ic { width: 26px; text-align: center; font-size: 19px; }
#sheet label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
#sheet input[type=text], #sheet select { width: 100%; padding: 11px; border-radius: 8px; border: 1px solid #444;
  background: #1c1c1c; color: var(--text); font-size: 16px; }
#sheet .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.grabber { width: 38px; height: 4px; border-radius: 2px; background: #555; margin: 0 auto 8px; }
.seg { display: flex; background: #1c1c1c; border-radius: 8px; padding: 3px; margin-top: 4px; }
.seg button { flex: 1; padding: 9px; border-radius: 6px; font-size: 14px; }
.seg button.on { background: var(--card2); font-weight: 600; }
.progress-wrap { height: 6px; background: #444; border-radius: 3px; overflow: hidden; margin: 12px 0 6px; }
.progress-wrap div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 18px);
  background: #fff; color: #111; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50;
  max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #2a2a2a; font-size: 14px; }
.stat b { font-weight: 600; }
.reco .item .art { border-radius: 6px; }
.note { font-size: 12px; color: var(--muted); margin: 8px 0; line-height: 1.4; }
.ep-progress { height: 3px; background: #444; border-radius: 2px; margin-top: 5px; overflow: hidden; }
.ep-progress div { height: 100%; background: var(--accent); }
