/* ------------------------------------------------------------
   CRATE : style
   Idée : fond noir, onglets en texte à gauche, feuilles blanches
   empilées comme des intercalaires (référence Untitled), un seul
   accent rouge. Pas de contours sur les boutons.
   ------------------------------------------------------------ */
:root {
  --bg: #000;
  --paper: #fff;
  --ink: #0a0a0a;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --line: #2a2a2a;
  --fill: #161616;
  --accent: #ff1a1a;
  --heart: #ff8c8c;
  --font: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  padding-block: 28px 80px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; text-wrap: balance; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.02em; color: var(--muted); }
.view { max-width: 820px; margin: 0 auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Les deux cercles ---------- */
.top { display: flex; justify-content: center; gap: 16px; margin-bottom: 32px; }
.circle {
  width: clamp(44px, 9vw, 60px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--paper);
  background: transparent;
  cursor: pointer;
  transition: background .25s, transform .25s;
}
.circle:hover { transform: scale(1.06); }
.circle.on { background: var(--paper); }

/* ---------- Mise en page : onglets à gauche ---------- */
/* Les onglets sont collés au bord gauche de l'écran ; le contenu reste centré */
.layout { display: block; }
.subnav {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  position: fixed; top: 130px; left: max(24px, env(safe-area-inset-left, 0px)); z-index: 5;
}
.navitem {
  background: none; border: 0; padding: 5px 0; cursor: pointer;
  font-size: 18px; letter-spacing: -0.01em; color: var(--muted); text-align: left;
  transition: color .15s;
}
.navitem:hover { color: var(--text); }
.navitem.on { color: var(--paper); font-weight: 500; }
.content { min-width: 0; }

.tab { display: none; }
.tab.on { display: block; }
.title { font-size: clamp(28px, 6vw, 44px); }
.sub { color: var(--muted); margin: 6px 0 24px; max-width: 60ch; }
.title-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.title-row .sub { margin-bottom: 0; }
.sort { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
select, input[type=text], input[type=url], input[type=password], input[type=search], textarea {
  background: var(--fill); border: 0; border-radius: 10px; padding: 9px 12px;
}
select { padding-right: 8px; color: var(--text); }
select option { background: #111; color: var(--text); }

/* ---------- Boutons (sans contour) ---------- */
.btn {
  display: inline-block; border: 0; background: var(--fill); color: var(--text);
  border-radius: 999px; padding: 8px 18px; cursor: pointer; font-size: 14px; text-decoration: none;
  transition: background .2s, color .2s;
}
.btn:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.btn.solid { background: var(--paper); color: var(--ink); }
.btn.solid:hover { background: var(--accent); color: #fff; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px; }
.link:hover { color: var(--text); }
.link.tiny { font-size: 12px; margin-top: 28px; padding-left: 0; }
.ghost {
  border: 0; background: var(--fill); color: var(--text); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: 14px; transition: background .15s, color .15s;
}
.ghost:hover { background: #242424; }
.ghost.on { background: var(--paper); color: var(--ink); }
.n { font-family: var(--mono); font-size: 11px; opacity: .65; margin-left: 2px; }
.n:empty { display: none; }

/* Cœur, Note, Copier : sans fond, sans contour */
.act {
  border: 0; background: none; cursor: pointer; padding: 6px 8px; font-size: 14px;
  color: var(--muted); display: inline-flex; align-items: center; transition: color .15s;
}
.act:hover:not(:disabled) { color: var(--text); }
.act:disabled { opacity: .3; cursor: default; }
.act svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; transition: fill .15s, stroke .15s; }
.act.liked, .act.liked:hover { color: var(--heart); }
.act.liked svg { fill: var(--heart); stroke: var(--heart); }

/* ---------- Lecteur ---------- */
.player { position: relative; aspect-ratio: 16/9; background: #0c0c0c; border-radius: 14px; overflow: hidden; }
.player iframe, .player #yt { position: absolute; inset: 0; width: 100%; height: 100%; }
.player-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: var(--muted); pointer-events: none; }
.player.has-video .player-empty { display: none; }

/* Fine bande "tirer un sample" sous le lecteur */
.shuffle-bar {
  display: grid; place-items: center; width: 100%; height: 26px; margin-top: 6px;
  border: 0; border-radius: 8px; background: var(--paper); color: var(--ink); cursor: pointer;
  transition: background .2s, color .2s, transform .1s;
}
.shuffle-bar:hover:not(:disabled) { background: var(--accent); color: #fff; }
.shuffle-bar:active:not(:disabled) { transform: scale(.995); }
.shuffle-bar:disabled { opacity: .5; cursor: default; }

.now { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin: 14px 0 0; }
.now-text { min-width: 0; flex: 1 1 260px; }
.now h2 { font-size: 22px; overflow-wrap: anywhere; }
.now-actions { display: flex; align-items: center; gap: 2px; }
.msg { min-height: 0; margin: 6px 0 0; }
.msg:empty { display: none; }
.note-box { display: grid; gap: 8px; margin-top: 10px; }
.note-box textarea { width: 100%; resize: vertical; }
.note-box .btn { justify-self: start; }

/* ---------- Filtres ---------- */
.filters { margin-top: 28px; display: grid; gap: 0; justify-items: start; }
.filters .ghost { margin-bottom: 14px; }
/* Menu des filtres : texte simple, soulignement fin sur l'onglet ouvert, "Tout effacer" à droite */
.filter-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 0 26px; width: 100%; border-bottom: 1px solid #1d1d1d; }
.ftab {
  position: relative; background: none; border: 0; padding: 9px 0 10px; cursor: pointer;
  font-size: 15px; color: var(--muted); transition: color .15s;
}
.ftab:hover { color: var(--text); }
.ftab.on { color: var(--paper); }
.ftab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--paper); }
.link.reset { margin-left: auto; font-size: 13px; text-decoration: none; padding: 9px 0 10px; }
.link.reset:hover { text-decoration: underline; }
.filter-panel { width: 100%; padding: 18px 0 4px; display: grid; gap: 14px; }
.filter-panel input[type=search] { width: 100%; background: var(--fill); }
.axis { display: grid; grid-template-columns: 74px minmax(0, 1fr) 74px; align-items: center; gap: 14px; }
.axis span:last-child { text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow-y: auto; align-content: flex-start; }
.chip {
  border: 0; background: var(--fill); color: var(--text); border-radius: 999px;
  padding: 5px 13px; cursor: pointer; font-size: 14px; transition: background .15s, color .15s;
}
.chip:hover { background: #242424; }
.chip.on { background: var(--paper); color: var(--ink); }

/* Curseur de durée (deux poignées sur une ligne) */
.range { position: relative; height: 28px; margin: 4px 8px 0; }
.range .track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--fill); }
.range .fill { position: absolute; top: 0; bottom: 0; background: var(--paper); border-radius: 2px; }
.range input[type=range] {
  position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none; height: 28px;
}
.range input[type=range]::-webkit-slider-runnable-track { background: none; height: 28px; }
.range input[type=range]::-moz-range-track { background: none; height: 28px; }
.range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto; cursor: grab;
  width: 18px; height: 18px; margin-top: 5px; border-radius: 50%; background: var(--paper); border: 0;
}
.range input[type=range]::-moz-range-thumb { pointer-events: auto; cursor: grab; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); border: 0; }
.range-ticks { display: flex; justify-content: space-between; margin: 0 8px; }
.range-read { text-align: center; color: var(--text); }

.key-box { margin-top: 12px; display: grid; gap: 10px; padding: 16px; background: #0f0f0f; border-radius: 14px; }
.key-box p { margin: 0; color: var(--muted); font-size: 14px; }
.key-box .btn { justify-self: start; }

/* ---------- Pile d'intercalaires (liste de morceaux / dossiers) ---------- */
.stack { display: flex; flex-direction: column; padding-top: 6px; }
.row { --x: 0%; position: relative; margin-top: -14px; cursor: pointer; }
.row:first-child { margin-top: 0; }
.row .tab-label {
  margin-left: var(--x); width: fit-content; min-width: min(260px, 100%); max-width: min(100%, 70%);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: var(--paper); color: var(--ink);
  border: 1.5px solid var(--bg); border-bottom: 0; border-radius: 14px 14px 0 0;
  padding: 11px 18px 4px; position: relative; z-index: 1;
  transition: transform .2s, background .2s, color .2s;
}
.row .tab-label b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .tab-label small { font-family: var(--mono); font-size: 11px; opacity: .6; white-space: nowrap; }
.row::after { content: ""; display: block; height: 18px; background: var(--paper); border-radius: 8px 8px 0 0; position: relative; box-shadow: 0 -1.5px 0 var(--bg); transition: background .2s; }
.row:hover .tab-label { transform: translateY(-4px); }
.row.on .tab-label, .row.on::after { background: var(--accent); color: #fff; }
.row-tools { display: flex; gap: 4px; }
.row-tools button { border: 0; background: none; cursor: pointer; font-size: 13px; padding: 0 4px; color: inherit; opacity: .55; }
.row-tools button:hover { opacity: 1; }
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- Liste simple des likes ---------- */
.plain { display: flex; flex-direction: column; align-items: flex-start; }
.item { background: none; border: 0; padding: 8px 0; font-size: 17px; color: var(--text); text-align: left; cursor: pointer; transition: color .15s; }
.item:hover { color: var(--muted); }

/* ---------- Statistiques ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 32px; }
.stat { background: var(--fill); border-radius: 14px; padding: 16px; display: grid; gap: 6px; }
.stat strong { font-size: 30px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
h3 { margin: 28px 0 12px; font-size: 18px; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr; gap: 12px; align-items: center; font-size: 14px; }
.bar i { display: block; height: 10px; border-radius: 5px; background: var(--paper); transition: width .5s; }
.bar:first-child i { background: var(--accent); }
.bar em { font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.fine { margin-top: 28px; }

/* ---------- Bibliothèque ---------- */
.crumbs { margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); font: inherit; text-decoration: underline; }
.newform { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.newform input { flex: 1 1 200px; min-width: 0; }
.uploader { margin-top: 14px; }
.audio-bar { position: sticky; bottom: 12px; margin-top: 24px; padding: 12px 16px; background: var(--paper); color: var(--ink); border-radius: 14px; display: grid; gap: 6px; }
.audio-bar .mono { color: #555; }
.audio-bar audio { width: 100%; }

/* Sur écran étroit, il n'y a plus de place sur le côté : les onglets passent au-dessus */
@media (max-width: 1100px) {
  .subnav { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 20px; }
}
@media (max-width: 520px) {
  .axis { grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 8px; }
  .filter-menu { gap: 0 16px; }
}
@media (max-width: 700px) {
  .navitem { font-size: 16px; }
  .bar { grid-template-columns: 90px 1fr; gap: 8px; }
  .row .tab-label { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
