:root {
  --bg: #0b1220;
  --panel: #121b2d;
  --panel2: #1b2740;
  --line: rgba(255, 255, 255, .08);
  --text: #e8edf7;
  --muted: #94a1b9;
  --accent: #f97316;
  --accent-text: #111827;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; fill: currentColor; flex: none; }
h1 { font-size: 24px; margin: 0; line-height: 1.2; }

/* ------------------------------------------------------------------ en-tête */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 18, 32, .9);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-weight: 700; font-size: 18px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { order: 3; width: 100%; display: flex; gap: 4px; padding: 4px; background: var(--panel); border-radius: 12px; }
.tabs a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600;
}
.tabs a .ic { width: 20px; height: 20px; }
.tabs a.on { background: var(--panel2); color: var(--text); }
.tabs a.on .ic { color: var(--accent); }
@media (min-width: 720px) {
  .tabs { order: 0; width: auto; }
  .tabs a { flex: none; }
}
.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center; flex: none;
  border: 0; border-radius: 50%; background: none; color: inherit;
}
@media (hover: hover) { .icon-btn:hover { background: rgba(255, 255, 255, .08); } }

/* ------------------------------------------------------------------ contenu */
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; }
body.has-player main { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
.head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 6px 0 18px; }
.loading { padding: 48px 0; text-align: center; color: var(--muted); }
.empty {
  padding: 36px 20px; text-align: center; color: var(--muted);
  background: var(--panel); border: 1px dashed rgba(255, 255, 255, .15); border-radius: var(--radius);
}
.empty p { margin: 0 0 14px; }
.empty p:last-child { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--panel2); font-weight: 600;
}
.btn .ic { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
@media (hover: hover) { .btn:not(:disabled):hover { filter: brightness(1.12); } }

/* cartes (playlists, albums) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; } }
.card {
  display: block; overflow: hidden; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); transition: transform .15s;
}
.card:active { transform: scale(.98); }
.cover { display: grid; place-items: center; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--panel2); }
.cover.ph .ic { width: 40%; height: 40%; fill: rgba(255, 255, 255, .85); }
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-comment {
  margin-top: 4px; font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* en-tête de playlist / d'album */
.back { display: inline-flex; align-items: center; gap: 2px; margin: 2px 0 14px -6px; color: var(--muted); font-weight: 600; }
.hero { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 18px; }
.hero .cover.big { width: 150px; flex: none; border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.hero-text { min-width: 0; }
.hero h1 { font-size: 26px; margin: 2px 0 6px; overflow-wrap: anywhere; }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.comment { margin: 0 0 6px; white-space: pre-line; overflow-wrap: anywhere; }
.meta { margin: 0; font-size: 13px; color: var(--muted); }
@media (max-width: 520px) {
  .hero:not(.flat) { flex-direction: column; align-items: center; text-align: center; }
  .hero .cover.big { width: 190px; }
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
@media (max-width: 520px) { .actions .btn { flex: 1 1 auto; } }

/* liste des chansons */
.songs { display: flex; flex-direction: column; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.song {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left;
}
.song:last-child { border-bottom: 0; }
.song:active { background: var(--panel2); }
@media (hover: hover) { .song:hover { background: rgba(255, 255, 255, .035); } }
.num { display: flex; justify-content: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.s-main { min-width: 0; display: flex; flex-direction: column; }
.s-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-comment { margin-top: 2px; font-size: 13px; font-style: italic; color: #c9d2e4; overflow-wrap: anywhere; }
.s-end { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { padding: 1px 6px; font-size: 10px; font-weight: 700; letter-spacing: .05em; border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; }
.song.playing .s-title { color: var(--accent); }
.eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; height: 35%; background: var(--accent); border-radius: 1px; }
.song.playing .n { display: none; }
.song.playing .eq { display: inline-flex; }
body.is-playing .song.playing .eq i { animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s !important; }
.eq i:nth-child(3) { animation-delay: -.6s !important; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }

/* photos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 4px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; } }
.thumb { aspect-ratio: 1; padding: 0; border: 0; overflow: hidden; border-radius: 6px; background: var(--panel2); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.lightbox {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  background: #000; touch-action: pan-y pinch-zoom;
}
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-user-select: none; user-select: none; }
.lb-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 18px 16px; font-size: 14px;
  background: linear-gradient(rgba(0, 0, 0, .75), transparent); color: #fff;
}
.lb-info { color: #bbb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px;
  display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff;
}
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }

/* ------------------------------------------------------------------ lecteur */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 4px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(18, 27, 45, .97); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
}
.p-inner { max-width: 1100px; margin: 0 auto; }
.p-seekrow { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#p-cur, #p-dur { min-width: 38px; }
#p-dur { text-align: right; }
.p-toggle { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.p-toggle .ic { width: 20px; height: 20px; }
.p-toggle.on { color: var(--accent); }
.p-row { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.p-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; text-align: left; }
#p-cover { width: 50px; height: 50px; flex: none; object-fit: cover; border-radius: 10px; background: var(--panel2); }
.p-text { min-width: 0; display: flex; flex-direction: column; }
#p-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#p-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-ctrl { display: flex; align-items: center; gap: 2px; flex: none; }
.p-btn { width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--text); }
.p-btn .ic { width: 28px; height: 28px; }
.p-btn.p-play { width: 56px; height: 56px; background: var(--accent); color: var(--accent-text); }
.p-btn.p-play .ic { width: 30px; height: 30px; }
.p-btn:active { transform: scale(.94); }

input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 30px; margin: 0; background: none; --p: 0%; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p), rgba(255, 255, 255, .2) var(--p));
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border: 0; border-radius: 50%; background: #fff; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }

/* ------------------------------------------------------------------ fenêtres, formulaires */
.backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .6); }
.modal {
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
}
@media (min-width: 600px) {
  .backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; padding-bottom: 20px; }
}
.modal h2 { margin: 0 0 16px; font-size: 20px; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; outline: none;
  background: var(--bg); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 76px; resize: vertical; }
.file-pick {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 12px; font-weight: 600; text-align: center; cursor: pointer;
  border: 1.5px dashed rgba(255, 255, 255, .28); border-radius: 12px;
}
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-pick:focus-within { border-color: var(--accent); }
.file-info { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.progress { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar { flex: 1; height: 8px; overflow: hidden; border-radius: 4px; background: var(--panel2); }
.bar i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }
.pct { min-width: 70px; font-size: 13px; text-align: right; color: var(--muted); }
.error { margin: 0 0 10px; color: #fca5a5; }
.error:empty { display: none; }
.errors { padding-left: 18px; color: #fca5a5; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px;
  background: #e8edf7; color: #0b1220; font-weight: 600; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
body.has-player .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }

/* ------------------------------------------------------------------ connexion */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--accent) 32%, transparent), transparent 65%), var(--bg);
}
.login-card { width: 100%; max-width: 380px; padding: 28px 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
.login-card .logo { display: block; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; }
.login-card h1 { text-align: center; }
.login-card .sub { margin: 4px 0 22px; text-align: center; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 4px; }
