/* ==========================================================================
   Skot — interface d'administration
   Thème sombre unique (color-scheme: dark) : c'est un outil de studio, pensé
   pour être utilisé en cabine. Les couleurs de données sont validées pour la
   vision des couleurs (deutan/protan/tritan) sur la surface --surface-1.
   ========================================================================== */

:root {
    color-scheme: dark;

    /* -- Surfaces -- */
    --plane: #0b0c10;
    --surface-1: #15171d;
    --surface-2: #1b1e26;
    --surface-3: #232733;
    --surface-4: #2b3040;

    /* -- Encres (contrastes vérifiés >= 4.5:1 sur --surface-1) -- */
    --ink-1: #f2f4f8;
    --ink-2: #a8aebd;
    --ink-3: #7c8496;

    /* -- Traits -- */
    --line: #242833;
    --rule: #2e3342;
    --ring: rgba(144, 101, 255, 0.45);

    /* -- Marque (chrome de l'interface, jamais des données) --
       Teintes relevées sur le logo : le dégradé du trait va du violet
       #9065FF au bleu #5F9FFE. Voir docs/brand/. */
    --brand: #9065ff;
    --brand-end: #5f9ffe;
    --brand-soft: #a98fff;
    --brand-wash: rgba(144, 101, 255, 0.13);
    --brand-gradient: linear-gradient(135deg, #9065ff 0%, #5f9ffe 100%);

    /* -- Séries de données -- */
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;

    /* -- États -- */
    --good: #0ca30c;
    --warn: #fab219;
    --danger: #d03b3b;
    --danger-ink: #ef6b6b;

    /* -- Rythme -- */
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 12px 32px -12px rgba(0, 0, 0, 0.7);
    --shadow-3: 0 28px 60px -20px rgba(0, 0, 0, 0.85);

    --sidebar-w: 248px;
    --player-h: 76px;

    --ease: cubic-bezier(0.22, 0.85, 0.3, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --fast: 140ms;
    --mid: 260ms;
    --slow: 520ms;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

* {
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-1);
    background-color: var(--plane);
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--brand-soft);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection {
    background: var(--brand-wash);
}

/* Barres de défilement discrètes */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-thumb {
    background: var(--surface-4);
    border-radius: 99px;
    border: 3px solid transparent;
    background-clip: content-box;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(24px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    to {
        background-position-x: -200%;
    }
}

@keyframes aurora {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
    }

    33% {
        transform: translate3d(6%, -4%, 0) scale(1.15);
    }

    66% {
        transform: translate3d(-5%, 5%, 0) scale(0.95);
    }
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(144, 101, 255, 0.45);
    }

    100% {
        box-shadow: 0 0 0 14px rgba(144, 101, 255, 0);
    }
}

@keyframes bar-dance {

    0%,
    100% {
        transform: scaleY(0.35);
    }

    50% {
        transform: scaleY(1);
    }
}

/* Entrée en cascade : `--i` est posé par le JS sur chaque élément. */
.stagger > * {
    animation: fade-up var(--slow) var(--ease-out) backwards;
    animation-delay: calc(var(--i, 0) * 45ms);
}

.view-enter {
    animation: fade-up 380ms var(--ease-out);
}

/* ==========================================================================
   Typographie & utilitaires
   ========================================================================== */

h1,
h2,
h3,
h4 {
    line-height: 1.2;
    letter-spacing: -0.015em;
    font-weight: 650;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.125rem;
}

h3 {
    font-size: 0.95rem;
}

a {
    color: var(--brand-soft);
}

.muted {
    color: var(--ink-3);
}

.secondary {
    color: var(--ink-2);
}

.eyebrow {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.numeric {
    font-variant-numeric: tabular-nums;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

.icon {
    width: 1em;
    height: 1em;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ==========================================================================
   Boutons
   ========================================================================== */

.btn {
    --btn-bg: var(--surface-3);
    --btn-ink: var(--ink-1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    min-height: 38px;
    font-size: 0.875rem;
    font-weight: 560;
    color: var(--btn-ink);
    background: var(--btn-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: transform var(--fast) var(--ease),
        background-color var(--fast) var(--ease),
        box-shadow var(--fast) var(--ease),
        opacity var(--fast) var(--ease);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--surface-4);
}

.btn:active:not(:disabled) {
    transform: translateY(0) scale(0.985);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    --btn-ink: #ffffff;
    background: var(--brand-gradient);
    box-shadow: 0 6px 18px -8px rgba(144, 101, 255, 0.9);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #9f7bff 0%, #78afff 100%);
    box-shadow: 0 10px 24px -8px rgba(144, 101, 255, 1);
}

.btn-ghost {
    background: transparent;
    border-color: var(--rule);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-3);
}

.btn-danger {
    --btn-ink: var(--danger-ink);
    background: transparent;
    border-color: rgba(208, 59, 59, 0.4);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(208, 59, 59, 0.14);
    border-color: var(--danger);
}

.btn-sm {
    padding: 5px 11px;
    min-height: 30px;
    font-size: 0.8rem;
    gap: 6px;
}

.btn-icon {
    padding: 0;
    width: 36px;
    min-height: 36px;
    border-radius: 50%;
}

.btn-icon.btn-sm {
    width: 30px;
    min-height: 30px;
}

.btn .icon {
    width: 1.05em;
    height: 1.05em;
}

/* ==========================================================================
   Champs de formulaire
   ========================================================================== */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > label,
.label {
    font-size: 0.8rem;
    font-weight: 560;
    color: var(--ink-2);
}

.field-hint {
    font-size: 0.75rem;
    color: var(--ink-3);
}

.input,
.select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    color: var(--ink-1);
    transition: border-color var(--fast) var(--ease),
        box-shadow var(--fast) var(--ease),
        background-color var(--fast) var(--ease);
}

.input::placeholder {
    color: var(--ink-3);
}

.input:hover,
.select:hover {
    border-color: var(--surface-4);
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-wash);
    background: var(--surface-1);
}

.input[aria-invalid="true"] {
    border-color: var(--danger);
}

.select {
    appearance: none;
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
        linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
    background-position: calc(100% - 17px) center, calc(100% - 12px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

/* Zone de dépôt de fichier : l'input natif est masqué mais reste focusable. */
.filedrop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface-2);
    border: 1px dashed var(--rule);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--fast) var(--ease),
        background-color var(--fast) var(--ease);
}

.filedrop:hover,
.filedrop.is-over {
    border-color: var(--brand);
    background: var(--brand-wash);
}

.filedrop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.filedrop .icon {
    width: 22px;
    height: 22px;
    color: var(--brand-soft);
}

.filedrop-text {
    min-width: 0;
    font-size: 0.85rem;
}

.filedrop-name {
    color: var(--ink-1);
    font-weight: 560;
}

.filedrop-preview {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-3);
}

.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--fast) var(--ease);
}

.checkline:hover {
    background: var(--surface-3);
}

.checkline input {
    accent-color: var(--brand);
    width: 16px;
    height: 16px;
    flex: none;
}

.checkline.is-locked {
    opacity: 0.75;
    cursor: default;
}

/* ==========================================================================
   Connexion
   ========================================================================== */

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

/* Voile animé : trois halos qui dérivent lentement derrière la carte. */
.aurora {
    position: fixed;
    inset: -30%;
    z-index: 0;
    filter: blur(90px);
    opacity: 0.5;
    pointer-events: none;
}

.aurora span {
    position: absolute;
    border-radius: 50%;
    animation: aurora 22s var(--ease) infinite;
}

.aurora span:nth-child(1) {
    width: 46vw;
    height: 46vw;
    top: 8%;
    left: 12%;
    background: #9065ff;
}

.aurora span:nth-child(2) {
    width: 38vw;
    height: 38vw;
    top: 38%;
    right: 8%;
    background: #5f9ffe;
    animation-duration: 28s;
    animation-direction: reverse;
}

.aurora span:nth-child(3) {
    width: 30vw;
    height: 30vw;
    bottom: 6%;
    left: 42%;
    background: #7078f8;
    animation-duration: 34s;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: min(400px, 100%);
    padding: 32px;
    background: color-mix(in srgb, var(--surface-1) 88%, transparent);
    backdrop-filter: blur(16px);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    animation: pop-in var(--slow) var(--ease-out);
}

.auth-card form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.auth-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    font-size: 0.85rem;
    color: var(--danger-ink);
    background: rgba(208, 59, 59, 0.1);
    border: 1px solid rgba(208, 59, 59, 0.3);
    border-radius: var(--radius-sm);
    animation: pop-in var(--mid) var(--ease-out);
}

/* ==========================================================================
   Identité
   ========================================================================== */

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    background: var(--brand-gradient);
    box-shadow: 0 8px 20px -10px var(--brand);
    overflow: hidden;
}

.brand-glyph {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.brand-mark:hover .brand-glyph {
    animation: quarter-turn 600ms var(--ease-out);
}

@keyframes quarter-turn {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(90deg);
    }
}

/* -- Écran de connexion : le vinyle en visuel principal -- */

.auth-brand {
    display: grid;
    justify-items: center;
    gap: 2px;
    text-align: center;
}

.auth-disc {
    width: 132px;
    height: 132px;
    margin-bottom: 14px;
    border-radius: 50%;
    animation: spin 26s linear infinite;
    filter: drop-shadow(0 12px 28px rgba(144, 101, 255, 0.35));
}

.auth-brand .brand-name {
    font-size: 1.35rem;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--ink-3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ==========================================================================
   Ossature de l'application
   ========================================================================== */

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 14px;
    background: var(--surface-1);
    border-right: 1px solid var(--line);
    z-index: 30;
}

.sidebar-head {
    padding: 4px 8px 0;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-label {
    padding: 14px 10px 6px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    font-size: 0.875rem;
    font-weight: 540;
    color: var(--ink-2);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: color var(--fast) var(--ease),
        background-color var(--fast) var(--ease);
}

.nav-item .icon {
    width: 18px;
    height: 18px;
    flex: none;
}

.nav-item:hover {
    color: var(--ink-1);
    background: var(--surface-2);
}

.nav-item.is-active {
    color: var(--ink-1);
    background: var(--brand-wash);
}

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 50%;
    width: 3px;
    height: 20px;
    background: var(--brand);
    border-radius: 0 3px 3px 0;
    transform: translateY(-50%);
    animation: fade-in var(--mid) var(--ease-out);
}

.sidebar-foot {
    margin-top: auto;
    display: grid;
    gap: 8px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    background: var(--surface-2);
    border-radius: var(--radius);
    min-width: 0;
}

.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    border-radius: 50%;
    background: var(--brand-gradient);
}

.user-chip-meta {
    min-width: 0;
    line-height: 1.3;
}

.user-chip-name {
    font-size: 0.85rem;
    font-weight: 600;
}

/* -- Zone principale -- */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 28px;
    background: color-mix(in srgb, var(--plane) 82%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar-title {
    min-width: 0;
}

.topbar-title p {
    font-size: 0.85rem;
    color: var(--ink-3);
}

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

.content {
    flex: 1;
    padding: 26px 28px calc(36px + var(--player-offset, 0px));
    max-width: 1320px;
    width: 100%;
}

.menu-toggle {
    display: none;
}

/* ==========================================================================
   Cartes & grilles
   ========================================================================== */

.card {
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}

.card-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h2,
.card-head h3 {
    min-width: 0;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-kpi {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.grid-cards {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.section {
    margin-bottom: 26px;
}

.section:last-child {
    margin-bottom: 0;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

/* -- Tuiles de statistique -- */

.stat {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Hauteur commune : les tuiles restent alignées, avec ou sans sparkline. */
    min-height: 128px;
    padding: 16px 18px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color var(--mid) var(--ease),
        transform var(--mid) var(--ease);
}

.stat:hover {
    transform: translateY(-2px);
    border-color: var(--rule);
}

.stat-value {
    margin-top: 6px;
    font-size: 2rem;
    font-weight: 660;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-foot {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--ink-3);
}

/* Bande de tendance, calée en bas de la tuile et débordant jusqu'à ses
   bords. Elle ne recouvre plus le libellé de bas de tuile. */
.stat-spark {
    margin: 10px -18px -16px;
    height: 44px;
    opacity: 0.9;
    pointer-events: none;
}

/* ==========================================================================
   Graphiques (SVG, sans librairie)
   ========================================================================== */

.chart {
    position: relative;
    width: 100%;
}

.chart svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.chart-grid line {
    stroke: var(--line);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.chart-axis line {
    stroke: var(--rule);
    stroke-width: 1;
}

.chart-tick {
    font-size: 11px;
    fill: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.chart-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Tracé qui se dessine à l'apparition. */
.chart-line.is-drawing {
    stroke-dasharray: var(--len);
    stroke-dashoffset: var(--len);
    animation: draw 900ms var(--ease-out) forwards;
}

@keyframes draw {
    to {
        stroke-dashoffset: 0;
    }
}

.chart-dot {
    stroke: var(--surface-1);
    stroke-width: 2;
}

.chart-bar {
    transition: opacity var(--fast) var(--ease);
}

.chart-hit {
    fill: transparent;
    cursor: pointer;
}

.chart-hit:hover + .chart-bar,
.chart-bar.is-hot {
    opacity: 0.82;
}

.chart-crosshair {
    stroke: var(--rule);
    stroke-width: 1;
    pointer-events: none;
}

.chart-tooltip {
    position: absolute;
    z-index: 5;
    min-width: 128px;
    padding: 9px 11px;
    background: var(--surface-3);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
    pointer-events: none;
    font-size: 0.8rem;
    transform: translate(-50%, -100%);
    transition: opacity var(--fast) var(--ease);
}

.chart-tooltip-date {
    color: var(--ink-3);
    font-size: 0.72rem;
    margin-bottom: 3px;
}

.chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.chart-tooltip-key {
    width: 12px;
    height: 2px;
    border-radius: 2px;
    flex: none;
}

.chart-tooltip-value {
    font-weight: 660;
    font-variant-numeric: tabular-nums;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    color: var(--ink-2);
}

.legend-key {
    width: 14px;
    height: 2px;
    border-radius: 2px;
    flex: none;
}

/* Petits multiples : une carte = une chanson = une seule série. */
.grid-sparks {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.spark-card {
    padding: 14px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color var(--mid) var(--ease),
        transform var(--mid) var(--ease);
}

.spark-card:hover {
    transform: translateY(-2px);
    border-color: var(--rule);
}

.spark-card-total {
    font-size: 1.35rem;
    font-weight: 660;
    letter-spacing: -0.02em;
}

/* Vue tableau : toute valeur d'un graphique reste accessible sans survol. */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th,
td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    background: var(--surface-2);
}

tbody tr {
    transition: background-color var(--fast) var(--ease);
}

tbody tr:hover {
    background: var(--surface-2);
}

tbody tr:last-child td {
    border-bottom: 0;
}

td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

th.num {
    text-align: right;
}

details.table-view {
    margin-top: 12px;
}

details.table-view > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--ink-2);
    cursor: pointer;
    list-style: none;
    padding: 4px 0;
}

details.table-view > summary::-webkit-details-marker {
    display: none;
}

details.table-view > summary::before {
    content: "▸";
    transition: transform var(--fast) var(--ease);
}

details.table-view[open] > summary::before {
    transform: rotate(90deg);
}

details.table-view > summary:hover {
    color: var(--ink-1);
}

/* ==========================================================================
   Musique : albums, chansons, artistes
   ========================================================================== */

.album-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--mid) var(--ease),
        border-color var(--mid) var(--ease),
        box-shadow var(--mid) var(--ease);
}

.album-card:hover {
    transform: translateY(-3px);
    border-color: var(--rule);
    box-shadow: var(--shadow-2);
}

.cover {
    position: relative;
    aspect-ratio: 1;
    background: var(--surface-3);
    overflow: hidden;
}

.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--slow) var(--ease);
}

.album-card:hover .cover img {
    transform: scale(1.05);
}

.cover-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: var(--ink-3);
    background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
}

.cover-fallback .icon {
    width: 32%;
    height: 32%;
}

.album-body {
    padding: 12px 14px 14px;
    min-width: 0;
}

.album-title {
    font-weight: 600;
    font-size: 0.925rem;
}

.album-meta {
    font-size: 0.78rem;
    color: var(--ink-3);
}

.song-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    transition: background-color var(--fast) var(--ease);
}

.song-row:hover {
    background: var(--surface-2);
}

.song-row.is-playing {
    background: var(--brand-wash);
}

.song-index {
    width: 22px;
    flex: none;
    text-align: right;
    font-size: 0.8rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.song-main {
    min-width: 0;
    flex: 1;
}

.song-title {
    font-size: 0.9rem;
    font-weight: 540;
}

.song-artists {
    font-size: 0.78rem;
    color: var(--ink-3);
}

.song-plays {
    flex: none;
    font-size: 0.8rem;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.song-actions {
    flex: none;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--fast) var(--ease);
}

/* -- Mode réorganisation des pistes -- */

.song-row.is-reordering {
    background: var(--surface-2);
    border: 1px solid var(--rule);
    margin-bottom: 6px;
    cursor: grab;
    transition: transform var(--fast) var(--ease),
        opacity var(--fast) var(--ease),
        box-shadow var(--fast) var(--ease);
}

.song-row.is-reordering:active {
    cursor: grabbing;
}

.song-row.is-dragging {
    opacity: 0.45;
}

/* Le repère de dépôt est un liseré, pas un déplacement : faire bouger les
   lignes sous le curseur rend la cible instable. */
.song-row.is-drop-target {
    box-shadow: inset 0 3px 0 0 var(--brand);
}

.drag-handle {
    display: grid;
    place-items: center;
    flex: none;
    color: var(--ink-3);
}

.drag-handle .icon {
    width: 18px;
    height: 18px;
    stroke-width: 3;
    stroke-linecap: round;
}

.song-row:hover .song-actions,
.song-row:focus-within .song-actions {
    opacity: 1;
}

.artist-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 14px;
    text-align: center;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: transform var(--mid) var(--ease),
        border-color var(--mid) var(--ease);
}

.artist-card:hover {
    transform: translateY(-3px);
    border-color: var(--rule);
}

.artist-photo {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-3);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--ink-2);
}

.badge-admin {
    background: var(--brand-wash);
    color: var(--brand-soft);
}

.badge-you {
    background: rgba(12, 163, 12, 0.14);
    color: var(--good);
}

/* ==========================================================================
   Direct
   ========================================================================== */

.live-state {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 650;
    color: var(--ink-2);
}

.live-state.is-on {
    color: var(--ink-1);
}

.live-dot {
    width: 10px;
    height: 10px;
    flex: none;
    border-radius: 50%;
    background: var(--surface-4);
}

/* À l'antenne : le point bat, comme un voyant de cabine. */
.live-dot.is-on {
    background: var(--danger-ink);
    animation: live-pulse 2s var(--ease) infinite;
}

@keyframes live-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(208, 59, 59, 0.5);
    }

    100% {
        box-shadow: 0 0 0 10px rgba(208, 59, 59, 0);
    }
}

.live-identity {
    gap: 14px;
    margin-top: 6px;
}

.live-photo {
    width: 56px;
    height: 56px;
}

.live-title {
    font-size: 1.12rem;
    font-weight: 650;
}

.badge-live {
    background: rgba(208, 59, 59, 0.16);
    color: var(--danger-ink);
}

/* Clé d'émission et commande ffmpeg : du texte à recopier, donc chasse fixe
   et défilement horizontal plutôt qu'un retour à la ligne trompeur. */
.key-line {
    gap: 10px;
    margin-top: 8px;
}

.key-value {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    overflow-x: auto;
    white-space: nowrap;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    color: var(--ink-1);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

/* Une URL n'a pas d'espace où se couper : sur un écran étroit, elle
   déborderait de sa carte. */
.live-hint code {
    overflow-wrap: anywhere;
}

/* Direct : la barre de position n'a pas de sens sur un flux sans fin. */
.player.is-live .player-scrub input {
    visibility: hidden;
}

/* Album programmé : sorti nulle part ailleurs que dans la console. */
.badge-upcoming {
    margin-top: 6px;
    background: var(--brand-wash);
    color: var(--brand-soft);
}

.badge-upcoming svg {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   Formulaire d'upload
   ========================================================================== */

.upload-grid {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.track {
    display: grid;
    gap: 14px;
    padding: 16px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    animation: pop-in var(--mid) var(--ease-out);
}

.track.is-removing {
    animation: fade-out-shrink var(--mid) var(--ease) forwards;
}

@keyframes fade-out-shrink {
    to {
        opacity: 0;
        transform: scale(0.97);
    }
}

.track-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.track-num {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--brand-soft);
    background: var(--brand-wash);
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
}

.track-artists {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2px;
    max-height: 168px;
    overflow-y: auto;
    padding: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.progress {
    height: 6px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    border-radius: 99px;
    background: var(--brand-gradient);
    transition: width 180ms var(--ease);
}

.upload-status {
    display: grid;
    gap: 10px;
    padding: 16px;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    animation: pop-in var(--mid) var(--ease-out);
}

/* ==========================================================================
   Lecteur
   ========================================================================== */

.player {
    position: fixed;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--player-h);
    padding: 0 20px;
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    animation: slide-up var(--mid) var(--ease-out);
}

@keyframes slide-up {
    from {
        transform: translateY(100%);
    }

    to {
        transform: none;
    }
}

.player-cover {
    width: 46px;
    height: 46px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-3);
    /* Le disque tourne tant que la lecture est en cours et se fige à la
       pause : `animation-play-state` conserve l'angle atteint, là où
       retirer l'animation ferait sauter la pochette à zéro. */
    animation: spin 8s linear infinite;
    animation-play-state: paused;
    box-shadow: 0 0 0 1px var(--rule), inset 0 0 0 4px rgba(0, 0, 0, 0.35);
}

.player.is-playing .player-cover {
    animation-play-state: running;
}

.brand-sub {
    white-space: nowrap;
}

.player-meta {
    min-width: 0;
    width: clamp(120px, 20%, 220px);
}

.player-scrub {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.player-time {
    font-size: 0.75rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
    flex: none;
}

input[type="range"] {
    flex: 1;
    min-width: 60px;
    height: 4px;
    appearance: none;
    background: var(--surface-3);
    border-radius: 99px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid var(--surface-1);
    transition: transform var(--fast) var(--ease);
}

input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.25);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 2px solid var(--surface-1);
    border-radius: 50%;
    background: var(--brand);
}

.player-play {
    animation: pulse-ring 2.4s var(--ease) infinite;
}

/* ==========================================================================
   Modale
   ========================================================================== */

dialog.modal {
    /* Le reset `* { margin: 0 }` annule le `margin: auto` natif de <dialog>,
       qui est ce qui centre la boîte dans la « top layer ». */
    margin: auto;
    width: min(540px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    color: var(--ink-1);
    background: var(--surface-1);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    overflow: visible;
}

dialog.modal::backdrop {
    background: rgba(4, 5, 8, 0.66);
    backdrop-filter: blur(3px);
    animation: fade-in var(--mid) var(--ease-out);
}

dialog.modal[open] {
    animation: pop-in var(--mid) var(--ease-out);
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.modal-body {
    display: grid;
    gap: 16px;
    padding: 20px;
    max-height: min(60vh, 520px);
    overflow-y: auto;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toasts {
    position: fixed;
    right: 18px;
    bottom: calc(18px + var(--player-offset, 0px));
    z-index: 60;
    transition: bottom var(--mid) var(--ease);
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface-3);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--ink-3);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
    font-size: 0.85rem;
    pointer-events: auto;
    animation: slide-in-right var(--mid) var(--ease-out);
}

.toast.is-out {
    animation: fade-out-shrink var(--fast) var(--ease) forwards;
}

.toast-success {
    border-left-color: var(--good);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-info {
    border-left-color: var(--series-1);
}

.toast .icon {
    width: 17px;
    height: 17px;
    flex: none;
    margin-top: 1px;
}

.toast-success .icon {
    color: var(--good);
}

.toast-error .icon {
    color: var(--danger-ink);
}

.toast-info .icon {
    color: var(--series-1);
}

/* ==========================================================================
   États : chargement, vide
   ========================================================================== */

.skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg,
            var(--surface-2) 30%,
            var(--surface-3) 50%,
            var(--surface-2) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
}

.skeleton-card {
    height: 108px;
    border-radius: var(--radius);
}

.spinner {
    width: 18px;
    height: 18px;
    flex: none;
    border: 2px solid var(--surface-4);
    border-top-color: var(--brand-soft);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.empty {
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 48px 20px;
    text-align: center;
    border: 1px dashed var(--rule);
    border-radius: var(--radius);
    color: var(--ink-3);
}

.empty .icon {
    width: 34px;
    height: 34px;
    color: var(--surface-4);
}

.empty-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-2);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 960px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform var(--mid) var(--ease-out);
        box-shadow: var(--shadow-3);
    }

    .sidebar.is-open {
        transform: none;
    }

    .scrim {
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(4, 5, 8, 0.6);
        animation: fade-in var(--fast) var(--ease-out);
    }

    .menu-toggle {
        display: inline-flex;
    }

    .topbar,
    .content {
        padding-left: 16px;
        padding-right: 16px;
    }

    .player {
        left: 0;
    }

    .player-meta {
        width: auto;
        flex: 1;
    }

    .player-scrub {
        display: none;
    }
}

@media (max-width: 520px) {
    .stat-value {
        font-size: 1.6rem;
    }

    .topbar-title p {
        display: none;
    }
}

/* ==========================================================================
   Accessibilité : mouvement réduit
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .auth-disc,
    .player-cover {
        animation: none !important;
    }

    .btn:hover:not(:disabled),
    .stat:hover,
    .album-card:hover,
    .artist-card:hover,
    .spark-card:hover {
        transform: none;
    }
}
