:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #1f6feb; --accent-text: #fff; --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e; --hover: #f0f3f8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --card: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --line: #2b313c;
          --accent: #4c8dff; --hover: #232936; --ok: #3fb950; --warn: #d29922; --bad: #f85149; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); padding-bottom: 80px; }
.hidden { display: none !important; }
h1 { font-size: 1.2rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
header { display: flex; align-items: center; gap: 1rem; padding: .7rem 16px; background: var(--card);
         border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
nav { display: flex; gap: .3rem; flex: 1; flex-wrap: wrap; }
nav button { background: transparent; color: var(--text); border: 0; padding: .45rem .8rem; border-radius: 6px; }
nav button.active { background: var(--accent); color: var(--accent-text); }
section.tab { padding: 16px; max-width: 1200px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.split { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
button { font: inherit; cursor: pointer; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
         border-radius: 6px; padding: .45rem .9rem; }
button.ghost { background: transparent; color: var(--accent); }
button.small { padding: .2rem .55rem; font-size: .85rem; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
         border-radius: 6px; padding: .45rem .6rem; width: 100%; }
textarea { min-height: 160px; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
label.inline { flex-direction: row; align-items: center; gap: .3rem; white-space: nowrap; }
label.inline input { width: auto; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 200px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; align-items: end; }
.list { list-style: none; padding: 0; margin: .8rem 0 0; }
.list li { padding: .45rem .55rem; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.list li:hover { background: var(--hover); }
.list li.active { background: var(--accent); color: var(--accent-text); }
.list li .n { opacity: .75; font-size: .85rem; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); min-height: 1.2em; margin: .4rem 0 0; }
.tracks { list-style: none; padding: 0; margin: .6rem 0 0; }
.tracks li { display: flex; align-items: center; gap: .5rem; padding: .35rem .4rem; border-bottom: 1px solid var(--line); }
.tracks li.dragging { opacity: .4; }
.tracks li.over { border-top: 2px solid var(--accent); }
.tracks .num { width: 2.4em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.tracks .t { flex: 1; min-width: 0; }
.tracks .t b, .tracks .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks .t span { color: var(--muted); font-size: .85rem; }
.tracks .handle { cursor: grab; color: var(--muted); padding: 0 .3rem; user-select: none; }
.badge { font-size: .75rem; padding: .05rem .4rem; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--bad); border-color: var(--bad); }
.stats { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .3rem 0 .9rem; font-size: .9rem; }
.stats div b { display: block; font-size: 1.15rem; }
/* grille d'albums avec pochettes */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.1rem .9rem; margin-top: .8rem; }
@media (max-width: 480px) { .albums { grid-template-columns: repeat(2, 1fr); gap: .9rem .6rem; } }
.album { cursor: pointer; display: flex; flex-direction: column; gap: .15rem; min-width: 0; border-radius: 10px; outline: none; }
.album .h { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: .35rem; }
.album .a { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: .4rem; align-items: center; }
.cover-wrap { position: relative; }
.cover { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; display: grid; place-items: center;
         background: linear-gradient(135deg, hsl(var(--h) 45% 48%), hsl(calc(var(--h) + 50) 50% 28%));
         box-shadow: 0 2px 8px rgba(0,0,0,.18); transition: transform .15s, box-shadow .15s; }
.cover .ph { color: rgba(255,255,255,.85); font-size: 2.4rem; font-weight: 700; letter-spacing: .05em; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.album:hover .cover, .album:focus-visible .cover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.28); }
.album:focus-visible .cover { outline: 3px solid var(--accent); outline-offset: 2px; }
.cover-wrap .add { position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; padding: 0; border-radius: 50%;
                   font-size: 1.3rem; line-height: 1; opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
                   box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.album:hover .add, .album:focus-within .add { opacity: 1; transform: none; }
@media (hover: none) { .cover-wrap .add { opacity: 1; transform: none; } }

/* fiche album (îlot) */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(8,10,14,.6); backdrop-filter: blur(6px);
         display: flex; justify-content: center; align-items: flex-start; padding: 5vh 16px 100px; overflow-y: auto; }
.modal-card { position: relative; width: min(920px, 100%); background: var(--card); border-radius: 18px; overflow: hidden;
              box-shadow: 0 25px 70px rgba(0,0,0,.5); animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-card .close { position: absolute; top: 12px; right: 12px; z-index: 3; width: 38px; height: 38px; padding: 0; border-radius: 50%;
                     background: rgba(0,0,0,.35); border: 0; color: #fff; font-size: 1.5rem; line-height: 1; }
.hero { position: relative; display: flex; gap: 28px; align-items: flex-end; padding: 32px; color: #fff; overflow: hidden;
        background: linear-gradient(135deg, hsl(var(--h) 40% 32%), hsl(calc(var(--h) + 50) 45% 16%)); }
.hero::before { content: ""; position: absolute; inset: -60px; background: var(--img, none) center / cover;
                filter: blur(45px) brightness(.5) saturate(1.4); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.35)); }
.hero > * { position: relative; z-index: 1; }
.hero .cover.big { width: 260px; flex: none; border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.55); }
.hero .cover.big .ph { font-size: 4rem; }
.hero .meta { min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.hero .kind { text-transform: uppercase; font-size: .75rem; letter-spacing: .12em; opacity: .8; }
.hero h2 { font-size: clamp(1.5rem, 3.5vw, 2.4rem); line-height: 1.1; margin: 0; overflow-wrap: anywhere; }
.hero .artist { font-size: 1.1rem; font-weight: 600; }
.hero .facts { opacity: .85; font-size: .9rem; }
.hero .actions { margin-top: .8rem; }
.hero .actions button { padding: .55rem 1.2rem; border-radius: 99px; }
.hero button.light { color: #fff; border-color: rgba(255,255,255,.7); }
.hero .src { font-size: .72rem; opacity: .6; margin-top: .3rem; }
@media (max-width: 640px) {
  .modal { padding: 0 0 90px; }
  .modal-card { border-radius: 0; min-height: 100%; }
  .hero { flex-direction: column; align-items: center; text-align: center; padding: 56px 16px 24px; gap: 18px; }
  .hero .cover.big { width: min(280px, 72vw); }
  .hero .actions { justify-content: center; }
}
.album-tracks { margin: 0; padding: 8px 20px 20px; }
.album-tracks li { border-bottom: 1px solid var(--line); border-radius: 6px; }
.album-tracks li:hover { background: var(--hover); }
.album-tracks li.disc { font-weight: 600; color: var(--muted); font-size: .85rem; padding-top: .9rem; border: 0; background: none; }
.tracks li.playing b { color: var(--accent); }
.tracks li.playing .num { color: var(--accent); font-weight: 700; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: .8rem; }
.table th, .table td { text-align: left; padding: .4rem; border-bottom: 1px solid var(--line); }
.logs { max-height: 300px; overflow: auto; font-size: .78rem; background: var(--bg); padding: .5rem; border-radius: 6px; white-space: pre-wrap; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login .card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .8rem; }
.player { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line);
          display: flex; align-items: center; gap: .6rem; padding: .5rem 16px; z-index: 40; }
.player img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex: none; }
@media (max-width: 560px) { .player { flex-wrap: wrap; } .player audio { flex-basis: 100%; } }
.player span { flex: 0 1 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.player audio { flex: 1; min-width: 0; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
         padding: .55rem 1rem; border-radius: 8px; z-index: 50; max-width: calc(100% - 32px); }
code { background: var(--bg); padding: .05rem .35rem; border-radius: 4px; word-break: break-all; }
details { margin-top: .8rem; }
summary { cursor: pointer; color: var(--accent); }
