/* ==========================================================================
   Ikka — bot de musique et arcs du groupe
   Sobre, typographique, accent lilas. Sombre par défaut, clair au choix.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0e0c12;
  --surface: #16131c;
  --surface-2: #1d1925;
  --surface-3: #27222f;
  --surface-raised: #2b2534;
  --border: rgba(236, 228, 255, 0.07);
  --border-strong: rgba(236, 228, 255, 0.13);
  --text: #f2eef8;
  --text-2: #aaa2b8;
  --text-3: #766f84;

  --accent: #bba6f2;
  --accent-hover: #cbb9f7;
  --accent-ink: #1b1428;
  --accent-text: #c7b5f6;
  --accent-soft: rgba(187, 166, 242, 0.12);
  --accent-glow: rgba(160, 130, 230, 0.22);

  --danger: #f2948f;
  --danger-soft: rgba(242, 148, 143, 0.12);
  --success: #93d7b4;
  --warning: #f0c674;

  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
  --shadow-md: 0 12px 32px -14px rgba(0, 0, 0, 0.6);
  --focus: 0 0 0 3px rgba(187, 166, 242, 0.45);

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f7f5fa;
  --surface: #ffffff;
  --surface-2: #f4f1f8;
  --surface-3: #ebe6f2;
  --surface-raised: #ffffff;
  --border: rgba(44, 26, 78, 0.08);
  --border-strong: rgba(44, 26, 78, 0.15);
  --text: #1c1724;
  --text-2: #645c72;
  --text-3: #978fa3;

  --accent: #7c5fc9;
  --accent-hover: #6c4fbb;
  --accent-ink: #ffffff;
  --accent-text: #6a4cb9;
  --accent-soft: rgba(124, 95, 201, 0.10);
  --accent-glow: rgba(124, 95, 201, 0.16);

  --danger: #c4413b;
  --danger-soft: rgba(196, 65, 59, 0.08);
  --success: #2f8a5c;
  --warning: #9a6200;

  --shadow-lg: 0 30px 70px -34px rgba(52, 30, 92, 0.30);
  --shadow-md: 0 12px 30px -16px rgba(52, 30, 92, 0.22);
  --focus: 0 0 0 3px rgba(124, 95, 201, 0.30);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --bg: #f7f5fa;
    --surface: #ffffff;
    --surface-2: #f4f1f8;
    --surface-3: #ebe6f2;
  --surface-raised: #ffffff;
    --border: rgba(44, 26, 78, 0.08);
    --border-strong: rgba(44, 26, 78, 0.15);
    --text: #1c1724;
    --text-2: #645c72;
    --text-3: #978fa3;

    --accent: #7c5fc9;
    --accent-hover: #6c4fbb;
    --accent-ink: #ffffff;
    --accent-text: #6a4cb9;
    --accent-soft: rgba(124, 95, 201, 0.10);
    --accent-glow: rgba(124, 95, 201, 0.16);

    --danger: #c4413b;
    --danger-soft: rgba(196, 65, 59, 0.08);
    --success: #2f8a5c;
    --warning: #9a6200;

    --shadow-lg: 0 30px 70px -34px rgba(52, 30, 92, 0.30);
    --shadow-md: 0 12px 30px -16px rgba(52, 30, 92, 0.22);
    --focus: 0 0 0 3px rgba(124, 95, 201, 0.30);
  }
}

/* --- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(1200px 520px at 50% -220px, var(--accent-glow), transparent 70%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img { display: block; }

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Miniatures YouTube 4:3 (hqdefault, sddefault) : bandes noires rognées. */
img.letterboxed { transform: scale(1.34); }

:focus-visible { outline: none; box-shadow: var(--focus); }

::selection { background: var(--accent-soft); }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Affichage selon la connexion : `data-auth` vaut pending, in ou out. */
body:not([data-auth="in"]) [data-auth="in"],
body:not([data-auth="out"]) [data-auth="out"] { display: none !important; }
/* Réservé aux membres du serveur Discord (édition des arcs). */
body:not([data-member="true"]) [data-member] { display: none !important; }

html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 16px; }

/* --- Structure ----------------------------------------------------------- */

.shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px 72px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 72px;
}

.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 600; letter-spacing: -0.01em; }
.brand-name { font-size: 15.5px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 2.5px;
  background: linear-gradient(145deg, #cbb8f8, #9478d8);
  box-shadow: 0 6px 18px -6px rgba(148, 120, 216, 0.7);
}
.brand-mark span { width: 3px; border-radius: 2px; background: #1b1428; }
.brand-mark span:nth-child(1) { height: 6px; }
.brand-mark span:nth-child(2) { height: 14px; }
.brand-mark span:nth-child(3) { height: 10px; }
.brand-mark span:nth-child(4) { height: 5px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.nav { display: flex; gap: 2px; margin-right: auto; margin-left: 12px; }
.nav a {
  padding: 7px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }

.layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.col-main, .col-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }

@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
  .col-side { position: sticky; top: 20px; }
}

/* --- Boutons ------------------------------------------------------------- */

.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), opacity .15s;
}
.btn:hover { background: var(--surface-3); }
.btn .icon { width: 16px; height: 16px; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; gap: 6px; border-radius: 9px; }
.btn.sm .icon { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn:disabled, .icon-btn:disabled { opacity: 0.38; cursor: default; pointer-events: none; }

.icon-btn {
  appearance: none;
  position: relative;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--text-2);
  cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.lg { width: 46px; height: 46px; }
.icon-btn.lg .icon { width: 22px; height: 22px; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .icon { width: 15px; height: 15px; }
.icon-btn.solid { border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); width: 40px; height: 40px; }
.icon-btn.solid:hover { background: var(--accent-hover); color: var(--accent-ink); }
.icon-btn[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.icon-btn.leave, .icon-btn.leave:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn[aria-pressed="true"]::after {
  content: ""; position: absolute; bottom: 3px; left: 50%;
  width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor;
}
.icon-btn.play {
  width: 58px; height: 58px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 10px 28px -10px var(--accent);
}
.icon-btn.play:hover { background: var(--accent-hover); color: var(--accent-ink); }
.icon-btn.play .icon { width: 24px; height: 24px; }

[aria-busy="true"] { cursor: progress; opacity: 0.6; }

/* --- Compte -------------------------------------------------------------- */

.account { display: flex; align-items: center; gap: 6px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 4px 0 4px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  font-size: 12.5px; font-weight: 600; color: var(--accent-ink);
  background: linear-gradient(145deg, #cbb8f8, #9478d8);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 13.5px; font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .icon-btn { width: 30px; height: 30px; }
.user-chip .icon-btn .icon { width: 15px; height: 15px; }

/* --- Compte à rebours (clin d'œil réservé à un membre) -------------------- */

.countdown {
  position: relative; overflow: hidden; isolation: isolate;
  margin: 16px 0 4px; padding: 26px 20px 30px;
  border-radius: 24px; border: 1px solid var(--border-strong);
  background:
    radial-gradient(110% 130% at 0% 0%, var(--accent-glow), transparent 60%),
    radial-gradient(90% 120% at 100% 100%, var(--accent-soft), transparent 65%),
    var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: countdown-in .7s var(--ease) both;
}
.countdown-kicker { font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-text); }
.countdown-number {
  margin: 4px 0 2px;
  font-size: clamp(96px, 24vw, 210px); font-weight: 700; line-height: .95; letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(165deg, var(--text) 25%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.countdown-label { font-size: clamp(22px, 5vw, 34px); font-weight: 700; letter-spacing: -0.02em; }
.countdown-sub { margin-top: 8px; color: var(--text-2); font-size: 14.5px; }
@keyframes countdown-in { from { opacity: 0; transform: translateY(-12px) scale(.97); } }

/* --- Cartes -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-meta { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.card-actions { display: flex; gap: 4px; }

.welcome { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 24px; }
.welcome-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.welcome-text { margin-top: 4px; color: var(--text-2); font-size: 14px; max-width: 46ch; }

/* --- Lecteur ------------------------------------------------------------- */

.player {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.player-ambient {
  position: absolute; inset: -40px; z-index: -1;
  background-size: cover; background-position: center;
  filter: blur(60px) saturate(1.2);
  opacity: 0;
  transform: scale(1.1);
  transition: opacity .8s var(--ease);
}
.player-ambient.is-visible { opacity: 0.28; }
:root[data-theme="light"] .player-ambient.is-visible { opacity: 0.2; }
.player::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent, var(--surface) 92%);
  opacity: 0.55;
}

.player-body { display: flex; align-items: center; gap: 22px; }

.cover {
  position: relative;
  width: 128px; height: 128px; flex: 0 0 auto;
  border-radius: 16px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--surface-3);
  box-shadow: var(--shadow-md);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { width: 36px; height: 36px; color: var(--text-3); stroke-width: 1.5; }

.track { min-width: 0; flex: 1; }
.eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-text);
}
.player.is-idle .eyebrow, .player.is-paused .eyebrow { color: var(--text-3); }
.track-title {
  margin-top: 6px;
  font-size: 24px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.track-title a:hover { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 4px; }
.track-sub { margin-top: 4px; font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.is-idle .track-title { font-size: 20px; color: var(--text-2); }

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.eq i { width: 2.5px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.35s; }
.eq i:nth-child(3) { animation-delay: -0.7s; }
.player.is-idle .eq, .player.is-paused .eq { display: none; }
@keyframes eq { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }

.progress { margin-top: 18px; }
.progress-track { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill {
  height: 100%; width: 100%; border-radius: inherit;
  background: var(--accent);
  transform-origin: left; transform: scaleX(0);
  transition: transform 1s linear;
}
.progress-fill.no-anim { transition: none; }
.progress-times {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.controls-side { display: flex; align-items: center; gap: 4px; }
.controls-side.end { justify-content: flex-end; }
.transport { display: flex; align-items: center; gap: 10px; }

.volume { display: flex; align-items: center; gap: 6px; }
.volume-value { width: 40px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.range {
  -webkit-appearance: none; appearance: none;
  width: 110px; height: 18px; margin: 0;
  background: transparent; cursor: pointer;
  --fill: 50%;
}
.range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill));
}
.range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--surface-3); }
.range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform .15s var(--ease);
}
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }
.range:hover::-webkit-slider-thumb { transform: scale(1.15); }
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }

/* --- Recherche ----------------------------------------------------------- */

.search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 46px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.search-icon { position: absolute; left: 16px; color: var(--text-3); }
.search-input {
  flex: 1; min-width: 0; height: 40px;
  border: 0; outline: 0; background: transparent;
  font-size: 15px;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus-visible { box-shadow: none; }

.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

/* --- Listes de titres ---------------------------------------------------- */

.tracklist { list-style: none; margin: 0 -8px; padding: 0; }
.track-row {
  display: grid;
  grid-template-columns: 26px 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 12px;
  transition: background-color .15s var(--ease);
}
.track-row:hover, .track-row:focus-within { background: var(--surface-2); }
.track-row .idx { font-size: 13px; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.track-row .idx .icon { width: 15px; height: 15px; margin: 0 auto; display: block; }
.thumb {
  width: 44px; height: 44px; border-radius: 9px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .icon { width: 16px; height: 16px; }
.track-text { min-width: 0; }
.track-text .t { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-text .s { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: flex; align-items: center; gap: 2px; }
.row-end .dur { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; padding: 0 6px; }
.row-actions { display: flex; align-items: center; gap: 2px; }
.row-actions .icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Avec une souris, les actions remplacent la durée au survol (et au focus clavier). */
@media (hover: hover) {
  .row-end { position: relative; }
  .tracklist:not(.compact) .row-actions {
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    padding-left: 12px;
    background: linear-gradient(to right, transparent, var(--surface-2) 12px);
    opacity: 0; transition: opacity .15s var(--ease);
  }
  .track-row:hover .row-actions, .track-row:focus-within .row-actions { opacity: 1; }
}

.tracklist.compact .track-row { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 7px 8px; }
.tracklist.compact .idx {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-3);
}
.tracklist.compact .track-row:hover .idx { background: var(--surface-3); }
.tracklist.compact .row-actions { opacity: 1; }

.empty {
  display: grid; justify-items: center; gap: 6px;
  padding: 28px 16px; text-align: center;
  color: var(--text-3); font-size: 13.5px;
}
.empty .icon { width: 22px; height: 22px; stroke-width: 1.6; margin-bottom: 2px; }
.empty strong { color: var(--text-2); font-weight: 500; }

.skeleton { height: 60px; margin: 0 8px 6px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Bibliothèque (onglets) ---------------------------------------------- */

.tabs {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px;
  padding: 4px; margin-bottom: 16px;
  border-radius: 12px; background: var(--surface-2);
}
.tab {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; border-radius: 9px;
  background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.tab .icon { width: 15px; height: 15px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface-raised); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }

.fav-form { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 8px; margin-bottom: 12px; }
.fav-form .input:first-child { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-hint { margin-bottom: 12px; color: var(--text-2); font-size: 13px; }
.join-form { grid-template-columns: minmax(0, 1fr) 40px; margin: 12px 0 0; }
.join-form .input:first-child { grid-column: auto; }

/* --- Notifications ------------------------------------------------------- */

.toasts {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  max-width: 100%;
  padding: 11px 16px 11px 13px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toast-in .25s var(--ease);
}
.toast .icon { width: 17px; height: 17px; }
.toast.ok .icon { color: var(--success); }
.toast.err .icon { color: var(--danger); }
.toast.leaving { animation: toast-out .2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* --- Dialogue ------------------------------------------------------------ */

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog form { padding: 24px; }
.dialog::backdrop { background: rgba(10, 7, 16, 0.6); backdrop-filter: blur(4px); }
.dialog[open] { animation: toast-in .2s var(--ease); }
.dialog-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.dialog-text { margin-top: 6px; color: var(--text-2); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

/* --- Arcs du groupe ------------------------------------------------------ */

.arcs { margin-top: 64px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-kicker { font-size: 11.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-text); }
.section-title { margin-top: 4px; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }

.arcs-current { display: grid; gap: 20px; }
.arcs-group { margin-top: 36px; }
.group-title {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3);
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Teinte propre à chaque jeu (--arc-hue, posée par le script). */
.arc-art {
  position: relative; overflow: hidden;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 85% 10%, hsl(calc(var(--arc-hue, 265) + 35) 70% 62% / 0.85), transparent 60%),
    linear-gradient(150deg, hsl(var(--arc-hue, 265) 55% 46%), hsl(calc(var(--arc-hue, 265) - 25) 50% 22%));
  color: rgba(255, 255, 255, 0.92);
}
.arc-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.arc-art-label {
  font-size: 30px; font-weight: 700; letter-spacing: -0.03em; text-align: center; padding: 0 16px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.25);
}
.arc-art .icon { width: 30px; height: 30px; stroke-width: 1.6; opacity: 0.85; }

.arc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: hsl(var(--arc-hue, 265) 60% 78%);
  background: hsl(var(--arc-hue, 265) 60% 60% / 0.14);
}
:root[data-theme="light"] .arc-chip { color: hsl(var(--arc-hue, 265) 55% 34%); background: hsl(var(--arc-hue, 265) 55% 45% / 0.11); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .arc-chip { color: hsl(var(--arc-hue, 265) 55% 34%); background: hsl(var(--arc-hue, 265) 55% 45% / 0.11); }
}
.arc-chip .icon { width: 14px; height: 14px; }

.arc-live { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--success); }
.arc-live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 0 currentColor; animation: live 2s ease-out infinite;
}
.arc-wip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--warning); }
.arc-wip .icon { width: 14px; height: 14px; }

@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

.arc-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.arc-period { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.arc-summary { color: var(--text-2); font-size: 14.5px; white-space: pre-line; }
.arc-edit { position: absolute; top: 14px; right: 14px; z-index: 1; }

/* Arc en cours : grande carte, visuel à gauche. */
.arc-feature {
  position: relative;
  display: grid; grid-template-columns: 300px minmax(0, 1fr);
  border: 1px solid var(--border-strong); border-radius: 24px; overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.arc-feature .arc-art { min-height: 100%; }
.arc-feature .arc-art-label { font-size: 38px; }
.arc-feature-body { display: grid; gap: 14px; align-content: start; padding: 26px 28px 28px; }
.arc-feature-title { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.12; padding-right: 36px; }

/* Infos pour rejoindre. */
.access-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.access-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px;
  padding: 10px 8px 10px 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.access-label { grid-column: 1; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.access-value {
  grid-column: 1; min-width: 0;
  font: 500 14.5px/1.4 ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.access-value { color: var(--accent-text); font-family: var(--font); }
a.access-value:hover { text-decoration: underline; text-underline-offset: 3px; }
.access-item .icon-btn { grid-column: 2; grid-row: 1 / span 2; }
.access-item.locked .access-value { display: flex; align-items: center; gap: 6px; font-family: var(--font); font-size: 13.5px; color: var(--text-3); }
.access-item.locked .access-value .icon { width: 14px; height: 14px; }
.access-item.locked a { color: var(--accent-text); }
.access-heading { font-size: 12px; font-weight: 600; color: var(--text-2); margin-top: 6px; }

/* Arcs à venir. */
.arc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.arc-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.arc-card .arc-art { height: 120px; }
.arc-card .arc-art-label { font-size: 24px; }
.arc-card-body { display: grid; gap: 10px; align-content: start; padding: 16px 18px 18px; }
.arc-card-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; padding-right: 30px; }
.arc-card .arc-edit { top: 10px; right: 10px; background: rgba(0, 0, 0, 0.32); color: #fff; }
.arc-card .access-list { grid-template-columns: minmax(0, 1fr); }

/* Arcs précédents : frise. */
.arc-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.arc-timeline::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--border-strong); }
.arc-past { position: relative; padding-left: 34px; }
.arc-past + .arc-past { margin-top: 14px; }
.arc-past::before {
  content: ""; position: absolute; left: 1px; top: 22px;
  width: 14px; height: 14px; border-radius: 50%;
  background: hsl(var(--arc-hue, 265) 55% 55%);
  box-shadow: 0 0 0 4px var(--bg);
}
.arc-past-card {
  position: relative;
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; align-items: start;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.arc-past-card .arc-art { width: 64px; height: 64px; border-radius: 12px; }
.arc-past-card .arc-art-label { font-size: 22px; padding: 0; }
.arc-past-body { display: grid; gap: 6px; min-width: 0; }
.arc-past-title { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; padding-right: 30px; }
.arc-past .arc-summary { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.arc-past-card .arc-edit { top: 8px; right: 8px; }

.arcs-empty {
  display: grid; justify-items: center; gap: 8px;
  padding: 44px 20px; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  color: var(--text-3); font-size: 14px;
}
.arcs-empty .icon { width: 26px; height: 26px; stroke-width: 1.5; }
.arcs-empty strong { color: var(--text); font-size: 16px; font-weight: 600; }

/* --- Formulaire d'arc ---------------------------------------------------- */

.dialog.wide { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 0; }
.field-hint { font-size: 12.5px; color: var(--text-3); margin-top: -2px; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; font: inherit; font-size: 14px; }
select.input { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: right 16px top 18px, right 11px top 18px; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="date"].input { color-scheme: inherit; }
.access-rows { display: grid; gap: 8px; }
.access-row { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) auto auto; gap: 8px; align-items: center; }
.access-row .input { height: 38px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.access-row .check { font-size: 12.5px; }
.form-error { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 13.5px; }
.push-left { margin-right: auto; }

/* --- Petits écrans ------------------------------------------------------- */

@media (max-width: 640px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .topbar { height: 64px; }
  .user-name { display: none; }
  .player { padding: 18px; border-radius: 20px; }
  .player-body { gap: 16px; }
  .cover { width: 84px; height: 84px; border-radius: 12px; }
  .track-title { font-size: 18px; }
  .player.is-idle .track-title { font-size: 17px; }
  .progress { margin-top: 12px; }
  .controls { grid-template-columns: 1fr auto; grid-template-areas: "transport transport" "side end"; row-gap: 14px; }
  .transport { grid-area: transport; justify-content: center; }
  .controls-side { grid-area: side; }
  .controls-side.end { grid-area: end; }
  .range { width: 84px; }
  .volume-value { display: none; }
  .card { padding: 16px; }
  .search-input { font-size: 16px; } /* évite le zoom automatique sur iOS */
  .search .btn { padding: 0 14px; }
  .track-row { grid-template-columns: 20px 40px minmax(0, 1fr) auto; gap: 10px; }
  .thumb { width: 40px; height: 40px; }
  .row-end .dur { display: none; }
  .welcome { padding: 20px; }
  .nav { display: none; }
  .arcs { margin-top: 48px; }
  .section-title { font-size: 24px; }
  .arc-feature { grid-template-columns: minmax(0, 1fr); border-radius: 20px; }
  .arc-feature .arc-art { min-height: 0; height: 150px; }
  .arc-feature-body { padding: 18px 18px 20px; }
  .arc-feature-title { font-size: 24px; }
  .arc-feature .arc-edit { background: rgba(0, 0, 0, 0.32); color: #fff; }
  .access-list { grid-template-columns: minmax(0, 1fr); }
  .arc-past-card { grid-template-columns: 48px minmax(0, 1fr); gap: 12px; }
  .arc-past-card .arc-art { width: 48px; height: 48px; }
  .arc-past-card .arc-art-label { font-size: 18px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .access-row { grid-template-columns: minmax(0, 1fr) auto; }
  .access-row .input:nth-child(2) { grid-column: 1; grid-row: 2; }
  .access-row .check { grid-column: 2; grid-row: 1; }
  .access-row .icon-btn { grid-column: 2; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Sans bibliothèque (visiteur non connecté), la colonne principale se centre. */
@media (min-width: 980px) {
  body:not([data-auth="in"]) .layout,
  body:not([data-auth="in"]) .arcs { grid-template-columns: minmax(0, 1fr); max-width: 780px; margin-left: auto; margin-right: auto; }
}
