:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --bg-input: #1a1a2e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --success: #4caf50;
    --border: #2a2a4a;
    --scrollbar: #2a2a4a;
    /* Référencées par .selection-bar et la barre supérieure mobile. */
    --sidebar-width: 220px;
    --topbar-height: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
}

/* 100dvh : la hauteur suit l'apparition/disparition de la barre d'adresse mobile.
   La ligne 100vh reste comme repli pour les navigateurs qui ignorent dvh. */
#app {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    flex-shrink: 0;
}

.sidebar-logo {
    text-align: center;
    padding: 0 16px 20px;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sidebar-user {
    padding: 12px 16px;
    font-size: 0.85em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sidebar-user strong { color: var(--text-primary); display: block; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95em;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-link:hover { background: rgba(233,69,96,0.1); color: var(--text-primary); }
.nav-link.active { background: rgba(233,69,96,0.2); color: var(--accent); border-right: 3px solid var(--accent); }

.nav-spacer { flex: 1; }

.sidebar-version {
    padding: 8px 12px 4px;
    font-size: 0.75em;
    color: var(--text-secondary);
    opacity: 0.7;
    text-align: center;
}

/* Bascule de langue FR | EN (sidebar, écran de connexion, écran de verrouillage) */
.lang-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 12px 0;
}

.lang-switch button {
    background: none;
    border: none;
    width: auto;
    padding: 2px 6px;
    font-size: 0.75em;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    opacity: 0.7;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s, opacity 0.15s;
}

.lang-switch button:hover {
    opacity: 1;
    color: var(--text-primary);
}

.lang-switch button.active {
    color: var(--accent);
    opacity: 1;
    cursor: default;
}

.lang-switch-sep {
    font-size: 0.75em;
    color: var(--text-secondary);
    opacity: 0.4;
}

/* Barre supérieure mobile (burger). Masquée au-dessus du palier, cf. @media plus bas. */
.app-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    height: var(--topbar-height);
    flex-shrink: 0;
    padding: 0 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.topbar-burger {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5em;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
}

.topbar-title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--accent);
}

/* Voile derrière le tiroir. Comme la barre supérieure, inactif sur grand écran. */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Écrans de connexion et de verrouillage */
.auth-shell {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* « safe » évite que le haut du formulaire soit rogné (et donc inatteignable) quand le
       contenu dépasse la hauteur de l'écran ; le centrage reste effectif sinon. */
    justify-content: safe center;
    padding: 16px 0;
    /* body est en overflow:hidden : sans cela, un formulaire plus haut que l'écran (connexion
       par jeton sur un petit téléphone) ne pourrait pas défiler. */
    overflow-y: auto;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Main content */
.main-content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

/* Flex plutôt que des flottants : les outils (tri, tout sélectionner) peuvent ainsi passer à la
   ligne sur écran étroit au lieu de chevaucher le titre. */
.card-title {
    font-size: 0.8em;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Inputs */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
textarea, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 10px 14px;
    width: 100%;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #555; cursor: not-allowed; }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #3a3a5a; }
.btn-danger { background: #c0392b; color: white; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 6px 12px; font-size: 0.8em; }

/* URL input bar */
.url-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.url-bar input { flex: 1; min-width: 0; }

/* Rangée « champ + bouton(s) » réutilisable (ex. mot de passe d'accès dans les Paramètres). */
.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.field-row .form-group { flex: 1 1 200px; margin: 0; }
.field-row .btn { height: 38px; }

/* Progress bar */
.progress-bar-container {
    background: var(--bg-input);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
    margin: 12px 0;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75em;
    font-weight: 600;
}

/* Log output */
.log-output {
    background: #0d0d1a;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82em;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    /* pre-wrap ne coupe pas un mot insécable : une URL longue déborderait horizontalement. */
    overflow-wrap: anywhere;
    line-height: 1.5;
}

/* Album info */
.album-info {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.album-info img {
    width: 120px;
    height: 120px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.album-details h3 { margin-bottom: 4px; }
.album-details p { color: var(--text-secondary); font-size: 0.9em; margin: 2px 0; }

/* Settings grid */
/* min(280px, 100%) : la grille retombe d'elle-même sur une colonne quand le conteneur est plus
   étroit que 280px, sans media query. */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.setting-item label { font-size: 0.9em; cursor: pointer; }
.setting-item input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.85em; color: var(--text-secondary); margin-bottom: 4px; }

/* Search results */
.search-results { margin-top: 16px; }

.search-result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.search-result-row:hover { background: rgba(233,69,96,0.05); }

.search-result-row > .btn { flex-shrink: 0; }

.search-result-row img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

/* min-width:0 est indispensable : sans lui un élément flex refuse de descendre sous la largeur
   de son contenu, et text-overflow:ellipsis n'a aucun effet. */
.search-result-info { flex: 1; min-width: 0; }
.search-result-info .title { font-weight: 600; }
.search-result-info .artist { color: var(--text-secondary); font-size: 0.85em; }

.artist-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.artist-avatar-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2em;
    flex-shrink: 0;
}

.artist-block { border-bottom: 1px solid var(--border); }
.artist-block:last-child { border-bottom: none; }

.artist-row { cursor: pointer; border-bottom: none; }
.artist-row.expanded { background: rgba(233,69,96,0.08); }

.expand-icon {
    color: var(--text-secondary);
    font-size: 1.1em;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.artist-albums {
    padding: 0 10px 10px 72px;
    animation: slideDown 0.2s ease-out;
}

.artist-album-row {
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    padding: 8px 10px !important;
}

.artist-album-row:last-child { border-bottom: none !important; }

.artist-album-row img {
    width: 42px !important;
    height: 42px !important;
    border-radius: 4px;
}

.artist-albums-loading {
    padding: 12px 0;
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* Selection */
.select-checkbox {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.search-result-row.selected { background: rgba(233,69,96,0.1); }

/* margin-left:auto pousse le groupe d'outils à droite du titre (ex-float). */
.select-all-btn {
    margin-left: auto;
    color: var(--accent) !important;
    font-size: 0.85em !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    text-decoration: none;
}

.select-all-btn:hover { text-decoration: underline; }

/* Sorting */
.sort-select {
    width: auto;
    max-width: 100%;
    padding: 3px 8px;
    font-size: 0.85em;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}

/* Seul dans sa barre : pas de titre pour le pousser, on s'en charge ici. */
.artist-albums-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 4px;
}

.selection-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 220px);
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
    animation: slideUp 0.2s ease-out;
}

.selection-bar span {
    flex: 1;
    font-weight: 600;
    font-size: 0.95em;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Quality selector */
.quality-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quality-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.15s;
}

.quality-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233,69,96,0.1);
}

/* Template Help */
.template-help {
    background: rgba(15, 52, 96, 0.3);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.template-help-toggle {
    padding: 10px 14px;
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9em;
    font-weight: 600;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.template-help-toggle::before {
    content: "\25B6";
    font-size: 0.65em;
    transition: transform 0.2s;
}

.template-help[open] > .template-help-toggle::before {
    transform: rotate(90deg);
}

.template-help-toggle:hover { color: var(--accent-hover); }

.template-help-content {
    padding: 4px 14px 14px;
}

.template-section {
    margin-bottom: 12px;
}

.template-section-title {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(233,69,96,0.2);
}

.template-subsection {
    margin-bottom: 12px;
}

.template-subsection > summary {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.template-subsection > summary::before {
    content: "+ ";
    color: var(--accent);
}

.template-subsection[open] > summary::before {
    content: "- ";
}

.template-tokens {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 4px 0;
}

.token {
    display: inline-block;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.78em;
    color: #7ec8e3;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.token:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233,69,96,0.08);
    transform: translateY(-1px);
}

.token:active {
    transform: translateY(0);
    background: rgba(233,69,96,0.15);
}

.template-hint {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-top: 10px;
    font-style: italic;
}

/* ──────────────────────────────────────────────────────────────────────────
   File d'attente de téléchargement

   .queue-row est volontairement distincte de .search-result-row : sous 640px, la règle
   `.search-result-row .btn::before` remplace le contenu de TOUT .btn descendant par une flèche ⬇,
   ce qui écraserait les glyphes ▲ ▼ ✕ ↻ des actions de la file.
   ────────────────────────────────────────────────────────────────────────── */

.queue-toolbar { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.queue-count {
    color: var(--text-primary);
    background: var(--bg-card);
    border-radius: 10px;
    padding: 2px 8px;
    letter-spacing: 0;
    text-transform: none;
}

.queue-list { display: flex; flex-direction: column; }

.queue-empty {
    color: var(--text-secondary);
    font-size: 0.85em;
    font-style: italic;
    padding: 6px 2px;
}

.queue-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
}

.queue-row:last-child { border-bottom: none; }

.queue-row.running { background: rgba(233,69,96,0.08); border-left-color: var(--accent); }
.queue-row.done { opacity: 0.6; }
.queue-row.failed { border-left-color: #c0392b; }
.queue-row.cancelled { opacity: 0.6; border-left-color: var(--text-secondary); }

.queue-row img,
.queue-thumb-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    flex-shrink: 0;
    object-fit: cover;
}

.queue-thumb-placeholder {
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: center;
    padding: 2px;
    overflow: hidden;
}

/* min-width:0 : sans lui, un élément flex refuse de descendre sous la largeur de son contenu et
   l'ellipse ne se déclenche jamais. */
.queue-info { flex: 1; min-width: 0; }

.queue-info .title,
.queue-info .sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-info .title { font-weight: 600; font-size: 0.9em; }
.queue-info .sub { color: var(--text-secondary); font-size: 0.8em; }
.queue-info .err { color: #e74c3c; font-size: 0.75em; }

.queue-status {
    flex-shrink: 0;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    white-space: nowrap;
}

.queue-status.running { background: var(--accent); color: white; }
.queue-status.done { background: var(--success); color: white; }
.queue-status.failed { background: #c0392b; color: white; }

.queue-actions { display: flex; gap: 6px; flex-shrink: 0; }

.queue-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    line-height: 1;
    transition: background 0.2s;
}

.queue-btn:hover:not(:disabled) { background: #3a3a5a; }
.queue-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.queue-btn.danger:hover:not(:disabled) { background: #c0392b; }

/* Pastille du menu : le compteur des éléments restants. .nav-link est déjà en flex, un
   margin-left:auto suffit à la pousser contre le bord droit, tiroir mobile compris. */
.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: white;
    font-size: 0.7em;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Marque « déjà téléchargé » en page Recherche. Toujours posée en FRÈRE du bouton, jamais en
   enfant : à l'intérieur, la règle ::before du palier 640px l'avalerait. */
.queue-done-mark {
    color: var(--success);
    font-size: 0.95em;
    flex-shrink: 0;
    line-height: 1;
}

/* Toast notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    z-index: 9999;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 1.2s forwards;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Un « URL invalide » sur fond vert serait trompeur. */
.toast-notification.error { background: #c0392b; }

@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }

/* ──────────────────────────────────────────────────────────────────────────
   Responsive
   768px : bascule en tiroir, la barre latérale sort du flux.
   640px : densité des listes de résultats.
   480px : téléphone, boutons pleine largeur.
   ────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Barre supérieure au-dessus du contenu, tiroir par-dessus le tout. */
    #app { flex-direction: column; }

    .app-topbar { display: flex; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(78vw, 260px);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        overflow-y: auto;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop { display: block; pointer-events: none; }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

    .main-content { padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); }

    /* Plus de barre latérale dans le flux : la barre de sélection part du bord. */
    .selection-bar {
        left: 0;
        flex-wrap: wrap;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    }

    .selection-bar span { flex: 1 1 100%; }
    .selection-bar .btn { flex: 1 1 auto; }

    /* La barre est fixe : sans réserve, elle masque la dernière ligne de résultats. Elle passe
       sur deux lignes ici (libellé, puis boutons), d'où les 110px. */
    .main-content:has(.selection-bar) {
        padding-bottom: calc(110px + env(safe-area-inset-bottom));
    }

    /* Le champ prend la ligne, les boutons se partagent la suivante. */
    .url-bar input { flex: 1 1 100%; }
    .url-bar .btn { flex: 1 1 auto; }

    /* Sous 16px, iOS Safari zoome sur le champ au focus et ne revient jamais en arrière. */
    input[type="text"], input[type="password"], input[type="email"], input[type="number"],
    textarea, select { font-size: 16px; }

    .sort-select { font-size: 14px; }
}

@media (max-width: 640px) {
    .search-result-row { gap: 8px; padding: 8px 4px; }

    .search-result-row img,
    .artist-avatar,
    .artist-avatar-placeholder { width: 40px; height: 40px; }

    .artist-avatar-placeholder { font-size: 1em; }
    .artist-album-row img { width: 36px !important; height: 36px !important; }

    /* Une seule ligne chacun, tronquée : le bouton garde ainsi sa place. */
    .search-result-info .title,
    .search-result-info .artist {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Le libellé cède la place à une flèche : « Télécharger tout » est intenable ici. */
    .search-result-row .btn .btn-label { display: none; }
    .search-result-row .btn::before { content: "\2B07"; font-size: 1.1em; line-height: 1; }
    .search-result-row .btn-sm { padding: 8px 10px; }

    .artist-albums { padding: 0 4px 10px 16px; }

    .album-info img { width: 80px; height: 80px; }
    .album-details h3 { font-size: 1.05em; }

    .queue-row { gap: 8px; padding: 8px 4px; }
    .queue-row img,
    .queue-thumb-placeholder { width: 34px; height: 34px; }
    .queue-status { font-size: 0.62em; padding: 2px 6px; }
}

@media (max-width: 480px) {
    .card { padding: 14px 12px; }

    /* Le tri passe sous le titre plutôt que de le comprimer. */
    .sort-select { flex: 1 1 100%; width: 100%; }

    .quality-group { display: grid; grid-template-columns: 1fr 1fr; }
    .quality-btn { padding: 10px 8px; }

    .field-row .form-group { flex: 1 1 100%; }
    .field-row .btn { flex: 1 1 auto; }

    .toast-notification {
        left: 12px;
        right: 12px;
        bottom: calc(16px + env(safe-area-inset-bottom));
        text-align: center;
    }

    /* Les actions passent sur leur propre ligne : trois boutons de 30px tiennent alors même à
       320px, alors qu'en ligne ils comprimeraient le libellé jusqu'à l'illisible. */
    .queue-row { flex-wrap: wrap; }
    .queue-actions { flex: 1 1 100%; justify-content: flex-end; }
    .queue-toolbar { margin-left: 0; flex: 1 1 100%; }
    .queue-toolbar .btn { flex: 1 1 auto; }
}

/* Écrans tactiles : cibles élargies et surbrillances de survol neutralisées — sur mobile un
   :hover reste « collé » après un tap. */
@media (hover: none) {
    .btn { min-height: 40px; }
    .queue-btn { width: 36px; height: 36px; }
    .select-checkbox { width: 22px; height: 22px; }
    .token { padding: 6px 10px; }

    .queue-btn:hover:not(:disabled) { background: var(--border); }
    .queue-btn.danger:hover:not(:disabled) { background: var(--border); }
    .search-result-row:hover { background: transparent; }
    .search-result-row.selected:hover { background: rgba(233,69,96,0.1); }
    .artist-row.expanded:hover { background: rgba(233,69,96,0.08); }
    .nav-link:hover { background: none; color: var(--text-secondary); }
    .nav-link.active:hover { background: rgba(233,69,96,0.2); color: var(--accent); }
    .token:hover {
        border-color: var(--border);
        color: #7ec8e3;
        background: var(--bg-input);
        transform: none;
    }
}

/* ── Voile de reconnexion ──────────────────────────────────────────────────────
   Blazor pose lui-même les classes components-reconnect-{show,failed,rejected} sur
   #components-reconnect-modal ; on ne fait que les habiller. Le lien avec le thème compte
   ici plus qu'ailleurs : c'est l'écran que l'application mobile montre le plus souvent,
   à chaque retour au premier plan. */
#components-reconnect-modal { display: none; }

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.94);
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

.reconnect-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    max-width: 320px;
    text-align: center;
    color: var(--text-primary);
    font-size: 0.9em;
}

/* Un seul des trois messages est visible, selon l'état posé par Blazor. */
#components-reconnect-modal [data-state] { display: none; margin-bottom: 14px; }
#components-reconnect-modal.components-reconnect-show [data-state="show"] { display: block; }
#components-reconnect-modal.components-reconnect-failed [data-state="failed"] { display: block; }
#components-reconnect-modal.components-reconnect-rejected [data-state="rejected"] { display: block; }

/* Le rechargement est automatique ; le bouton n'est là que si le script a été empêché
   d'agir (hors ligne, ou garde-fou anti-boucle déclenché). */
#components-reconnect-modal .reconnect-reload { display: none; }
#components-reconnect-modal.components-reconnect-failed .reconnect-reload,
#components-reconnect-modal.components-reconnect-rejected .reconnect-reload { display: inline-block; }

.reconnect-spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 14px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: reconnect-spin 0.9s linear infinite;
}

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