/* Improvium — base styles, mobile-first dark theme
   Thèmes : surcharge des variables via [data-theme="..."] sur <html>.
   Le défaut sur :root reproduit le thème "improvium" (back-compat). */

:root, [data-theme="improvium"] {
    --bg: #060912;
    --bg-elev: #131826;
    --bg-elev-2: #1f2638;
    --text: #ffffff;
    --text-muted: #9bb;
    --primary: #2563eb;
    --primary-fg: #fff;
    --link: #93c5fd;
    --link-hover: #bfdbfe;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --seed: #7df;
    --border: #2a3550;
    --radius: 10px;
    --gap: 1rem;
    /* Palette tuiles WP-OS : couleurs saturées pour contraste max avec le fond */
    --tile-1: #1d4ed8; --tile-1-fg: #fff; /* bleu profond */
    --tile-2: #059669; --tile-2-fg: #fff; /* émeraude */
    --tile-3: #ea580c; --tile-3-fg: #fff; /* orange vif */
    --tile-4: #9333ea; --tile-4-fg: #fff; /* violet */
    --tile-5: #dc2626; --tile-5-fg: #fff; /* rouge */
    --tile-6: #0891b2; --tile-6-fg: #fff; /* teal */
    --tile-7: #facc15; --tile-7-fg: #111; /* jaune ambre */
    --tile-8: #db2777; --tile-8-fg: #fff; /* magenta */
}

[data-theme="onyx"] {
    --bg: #000;
    --bg-elev: #0a0a0a;
    --bg-elev-2: #141414;
    --text: #ffffff;
    --text-muted: #888;
    --primary: #a4c400;
    --primary-fg: #111;
    --link: #a4c400;
    --link-hover: #c8e64a;
    --border: #2a2a2a;
    /* Palette WP Lumia originale, hyper-saturée */
    --tile-1: #a4c400; --tile-1-fg: #111; /* lime */
    --tile-2: #00aba9; --tile-2-fg: #fff; /* teal */
    --tile-3: #1ba1e2; --tile-3-fg: #fff; /* cyan */
    --tile-4: #aa00ff; --tile-4-fg: #fff; /* violet */
    --tile-5: #e51400; --tile-5-fg: #fff; /* rouge vif */
    --tile-6: #fa6800; --tile-6-fg: #fff; /* orange */
    --tile-7: #f0a30a; --tile-7-fg: #111; /* ambre */
    --tile-8: #d80073; --tile-8-fg: #fff; /* magenta */
}

[data-theme="cobalt"] {
    --bg: #00102a;
    --bg-elev: #001b3d;
    --bg-elev-2: #002852;
    --text: #ffffff;
    --text-muted: #a0bcd9;
    --primary: #1ba1e2;
    --primary-fg: #fff;
    --link: #66d8ff;
    --link-hover: #a8e8ff;
    --border: #0e3a6a;
    --tile-1: #1ba1e2; --tile-1-fg: #fff; /* cyan */
    --tile-2: #0050ef; --tile-2-fg: #fff; /* cobalt vif */
    --tile-3: #00d4ff; --tile-3-fg: #001; /* cyan clair */
    --tile-4: #7e3ff2; --tile-4-fg: #fff; /* violet */
    --tile-5: #00aba9; --tile-5-fg: #fff; /* teal */
    --tile-6: #facc15; --tile-6-fg: #111; /* jaune contrasté */
    --tile-7: #fa6800; --tile-7-fg: #fff; /* orange */
    --tile-8: #ec4899; --tile-8-fg: #fff; /* rose */
}

[data-theme="magenta"] {
    --bg: #0a0a0a;
    --bg-elev: #181818;
    --bg-elev-2: #242424;
    --text: #ffffff;
    --text-muted: #aaa;
    --primary: #ec4899;
    --primary-fg: #fff;
    --link: #ff66c4;
    --link-hover: #ff99d6;
    --border: #333;
    --tile-1: #ec4899; --tile-1-fg: #fff; /* magenta vif */
    --tile-2: #facc15; --tile-2-fg: #111; /* jaune scène */
    --tile-3: #a855f7; --tile-3-fg: #fff; /* violet */
    --tile-4: #14b8a6; --tile-4-fg: #fff; /* teal */
    --tile-5: #ef4444; --tile-5-fg: #fff; /* rouge */
    --tile-6: #3b82f6; --tile-6-fg: #fff; /* bleu */
    --tile-7: #84cc16; --tile-7-fg: #111; /* lime */
    --tile-8: #f97316; --tile-8-fg: #fff; /* orange */
}

[data-theme="cinema"] {
    --bg: #120c08;
    --bg-elev: #1f1813;
    --bg-elev-2: #2c2218;
    --text: #fbf3df;
    --text-muted: #c8b08a;
    --primary: #dc143c;
    --primary-fg: #fff;
    --link: #f4a261;
    --link-hover: #f8c89c;
    --border: #4a3825;
    --tile-1: #dc143c; --tile-1-fg: #fff; /* crimson vif */
    --tile-2: #d97706; --tile-2-fg: #fff; /* sépia chaud */
    --tile-3: #facc15; --tile-3-fg: #111; /* doré projecteur */
    --tile-4: #991b1b; --tile-4-fg: #fff; /* bordeaux */
    --tile-5: #ea580c; --tile-5-fg: #fff; /* orange feu */
    --tile-6: #166534; --tile-6-fg: #fff; /* vert sapin */
    --tile-7: #7c2d12; --tile-7-fg: #fff; /* terre brulée */
    --tile-8: #0e7490; --tile-8-fg: #fff; /* cyan rétro */
}

[data-theme="clair"] {
    --bg: #faf9f5;
    --bg-elev: #ffffff;
    --bg-elev-2: #ece9de;
    --text: #0a0a0a;
    --text-muted: #555;
    --primary: #6d28d9;
    --primary-fg: #fff;
    --link: #5b21b6;
    --link-hover: #6d28d9;
    --border: #d4d2c5;
    /* Tuiles fortement saturées pour ressortir sur fond clair */
    --tile-1: #6d28d9; --tile-1-fg: #fff; /* violet profond */
    --tile-2: #047857; --tile-2-fg: #fff; /* vert profond */
    --tile-3: #c2410c; --tile-3-fg: #fff; /* orange brulé */
    --tile-4: #be185d; --tile-4-fg: #fff; /* magenta profond */
    --tile-5: #0e7490; --tile-5-fg: #fff; /* cyan profond */
    --tile-6: #115e59; --tile-6-fg: #fff; /* teal profond */
    --tile-7: #ca8a04; --tile-7-fg: #fff; /* jaune ocre */
    --tile-8: #991b1b; --tile-8-fg: #fff; /* rouge profond */
}

[data-theme="monochrome"] {
    --bg: #000000;
    --bg-elev: #161616;
    --bg-elev-2: #262626;
    --text: #ffffff;
    --text-muted: #a0a0a0;
    --primary: #ffffff;
    --primary-fg: #000;
    --link: #d4d4d4;
    --link-hover: #ffffff;
    --danger: #f5f5f5;
    --warning: #d4d4d4;
    --success: #e5e5e5;
    --seed: #c0c0c0;
    --border: #404040;
    /* Dégradé de gris : du blanc pur au quasi-noir, contraste max avec le bg */
    --tile-1: #ffffff; --tile-1-fg: #000; /* blanc pur */
    --tile-2: #d4d4d4; --tile-2-fg: #000; /* gris très clair */
    --tile-3: #a3a3a3; --tile-3-fg: #000; /* gris clair */
    --tile-4: #737373; --tile-4-fg: #fff; /* gris moyen */
    --tile-5: #525252; --tile-5-fg: #fff; /* gris foncé */
    --tile-6: #404040; --tile-6-fg: #fff; /* gris très foncé */
    --tile-7: #fafafa; --tile-7-fg: #000; /* presque blanc */
    --tile-8: #2a2a2a; --tile-8-fg: #fff; /* charbon */
}

/* L'utilisateur a posé un accent custom inline sur <body> :
   on s'en sert sur les tuiles "accent" et sur les boutons primary. */
body[style*="--accent"] {
    --primary: var(--accent);
    --tile-1: var(--accent);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 16px;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }

.muted { color: var(--text-muted); font-size: .9rem; }

/* AUTH */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    background: var(--bg-elev);
    padding: 2rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.auth-card h1 { margin-top: 0; font-size: 1.6rem; }
.auth-card .form-group, .auth-card form > div { margin-bottom: 1rem; }
.auth-card label { display: block; margin-bottom: .25rem; font-size: .9rem; color: var(--text-muted); }
.auth-card input[type=email],
.auth-card input[type=password],
.auth-card input[type=text] {
    width: 100%;
    padding: .65rem .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}
.btn-primary {
    background: var(--primary);
    color: var(--primary-fg);
    border: 0;
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-link { color: var(--text-muted); text-decoration: none; padding: .75rem 1rem; }
.btn-link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; padding: 0; font: inherit; }

.btn-google {
    display: inline-block;
    padding: .65rem 1rem;
    background: #fff;
    color: #111;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
}
.divider {
    display: flex;
    align-items: center;
    margin: 1rem 0;
    color: var(--text-muted);
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.divider span { padding: 0 .75rem; font-size: .85rem; }

/* FLASH */
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .95rem;
}
.flash-success { background: rgba(16,185,129,.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }
.flash-error   { background: rgba(239,68,68,.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

/* APP SHELL */
.app-shell { min-height: 100vh; padding-bottom: 2rem; }
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}
.app-header a { text-decoration: none; }
.app-header strong { color: var(--text); }
.app-header nav { display: flex; gap: 1rem; align-items: center; }

.app-section { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-head h1 { margin: 0; }
.page-head-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.quota-badge {
    background: var(--bg-elev-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: .35rem .75rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}
.quota-badge-full {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
    border-color: #ef4444;
}
.btn-primary.is-disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}
.dash-card.is-locked {
    opacity: .65;
    border-style: dashed;
}

/* WP-OS LIVE TILES — composant principal du dashboard et soundboard */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .5rem;
    margin: 1rem 0 2rem;
}
.tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    background: var(--bg-elev-2);
    color: var(--text);
    text-decoration: none;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
    will-change: transform;
    overflow: hidden;
    position: relative;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.tile:active { transform: scale(.97); }
.tile-icon { font-size: 2.5rem; line-height: 1; }
.tile-label {
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .9rem;
    line-height: 1.2;
}
.tile-sub {
    font-size: .75rem;
    opacity: .8;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-top: .15rem;
}
.tile--wide { aspect-ratio: 2 / 1; grid-column: span 2; }
.tile-label, .tile-sub { display: block; }
.tile--small {
    aspect-ratio: 1;
    padding: .5rem;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: .25rem;
}
.tile--small .tile-icon { font-size: 1.4rem; }
.tile--small .tile-label {
    font-size: .7rem;
    letter-spacing: .03em;
    word-break: break-word;
    line-height: 1.1;
}
@media (prefers-reduced-motion: reduce) {
    .tile, .tile:hover, .tile:active { transition: none; transform: none; }
}

/* APPEARANCE PICKER */
.appearance-form { max-width: 720px; }
.theme-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-top: .5rem;
}
.theme-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .75rem;
    background: var(--bg-elev);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s ease, transform .15s ease;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card.is-selected { border-color: var(--primary); }
.theme-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.theme-swatch {
    width: 100%;
    aspect-ratio: 2 / 1;
    display: flex;
    gap: 4px;
    padding: 6px;
    border-radius: 4px;
    background: var(--bg);
}
.theme-swatch--default {
    background: var(--bg-elev-2);
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
}
.theme-swatch .theme-tile {
    flex: 2;
    border-radius: 2px;
    background: var(--primary);
}
.theme-swatch .theme-tile-2 {
    flex: 1;
    border-radius: 2px;
}
.theme-name { font-weight: 600; }
.theme-mood { font-size: .75rem; color: var(--text-muted); }

.accent-picker {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    margin-top: .5rem;
}
.accent-picker input[type="color"] {
    width: 60px; height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    cursor: pointer;
    padding: 2px;
}
.accent-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: .35rem;
    max-width: 480px;
    margin-top: .5rem;
}
.accent-swatch {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform .1s ease, border-color .1s ease;
}
.accent-swatch:hover { transform: scale(1.1); }
.accent-swatch.is-selected { border-color: var(--text); transform: scale(1.1); }

/* TABS PIVOT (companion) — sépare Jingles / Ambiances sous la carte papier */
.tabs-nav {
    display: flex;
    gap: 1.5rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 1rem;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tabs-nav .tab {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .65rem 0;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color .15s ease;
}
.tabs-nav .tab:hover { color: var(--text); }
.tabs-nav .tab.is-active {
    color: var(--text);
    font-weight: 600;
}
.tabs-nav .tab.is-active::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}
.tab-status { vertical-align: middle; }
.tab-panel { padding: 0 1.25rem 1rem; }
.tabs-stop-all {
    margin-left: auto;
    align-self: center;
    background: var(--danger);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: .4rem .85rem;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, transform .1s ease;
}
.tabs-stop-all:hover { background: #b91c1c; }
.tabs-stop-all:active { transform: scale(.96); }
@media (max-width: 640px) {
    .tabs-nav { gap: 1rem; padding: 0 .75rem; }
    .tabs-nav .tab { font-size: .95rem; }
    .tab-panel { padding: 0 .75rem 1rem; }
}

/* OVERLAY FIN DE SESSION (companion) — affiché quand l'arbitre clôt */
.companion-ended-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    padding: 1rem;
    backdrop-filter: blur(4px);
}
.companion-ended-card {
    background: var(--bg-elev);
    border: 2px solid var(--warning);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    max-width: 420px;
    text-align: center;
    color: var(--text);
}
.companion-ended-card h2 { margin: 0 0 .75rem; font-size: 1.5rem; }
.companion-ended-card p { margin: 0; color: var(--text-muted); line-height: 1.5; }

/* GRILLE AMBIANCES (companion) — tuiles wide tap-able, palette décalée */
.sb-amb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .5rem;
}
.sb-amb-grid .tile-ambiance {
    /* Wide aspect 2:1 pour bien différencier des jingles carrés */
    grid-column: span 1;
    aspect-ratio: 2 / 1;
    position: relative;
}
.sb-amb-grid .tile-ambiance .tile-icon { font-size: 1.6rem; }
.tile-ambiance.is-playing {
    /* Pulse subtil pour signaler la lecture en cours */
    animation: ambiance-pulse 1.6s ease-in-out infinite;
    box-shadow: 0 0 0 3px rgba(255,255,255,.5), 0 8px 24px rgba(0,0,0,.45);
}
.tile-ambiance.is-playing::after {
    content: '▶';
    position: absolute;
    top: 6px; right: 8px;
    font-size: .9rem;
    color: rgba(255,255,255,.95);
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
@keyframes ambiance-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
    .tile-ambiance.is-playing { animation: none; }
}

/* PANNEAU RÉGLAGES AUDIO — fondu, volumes, sortie audio. Pliable, persisté. */
.audio-settings {
    margin: 1rem 1.25rem 2rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    color: var(--text);
}
.audio-settings > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: .95rem;
    padding: .25rem 0;
    user-select: none;
}
.audio-settings[open] > summary { margin-bottom: .75rem; }
.audio-settings-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .4rem 0;
    flex-wrap: wrap;
}
.audio-settings-row label {
    flex: 0 0 130px;
    font-size: .9rem;
    color: var(--text-muted);
}
.audio-settings-row input[type="range"] {
    flex: 1 1 200px;
    accent-color: var(--primary);
    min-width: 140px;
}
.audio-settings-row select {
    flex: 1 1 200px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .35rem .5rem;
    font-size: .9rem;
    min-width: 140px;
}
.audio-settings-value {
    flex: 0 0 60px;
    text-align: right;
    font-family: ui-monospace, monospace;
    font-size: .85rem;
    color: var(--text-muted);
}
.audio-warning, .audio-advice {
    background: rgba(245,158,11,.15);
    border-left: 3px solid var(--warning);
    padding: .5rem .75rem;
    margin: .25rem 0 .75rem;
    font-size: .85rem;
    border-radius: 4px;
}
.audio-advice {
    background: rgba(96,165,250,.12);
    border-left-color: #60a5fa;
    color: var(--text-muted);
}
.audio-settings-hint {
    margin: 1rem 0 0;
    font-size: .75rem;
    color: var(--text-muted);
}

/* BANDEAU REPRISE DE SESSION — affiché si une session non terminée est détectée */
.resume-banner:not([hidden]) {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    background: rgba(245,158,11,.18);
    border-bottom: 2px solid var(--warning);
    color: var(--text);
    padding: .65rem 1rem;
    font-size: .9rem;
}
.resume-banner-text { flex: 1 1 220px; min-width: 0; }
.resume-banner .btn-primary {
    background: var(--warning);
    border-color: var(--warning);
    color: #111;
    padding: .35rem .85rem;
}
.resume-banner .btn-link {
    color: var(--text-muted);
}

/* TUILES VERROUILLÉES + LONG-PRESS — pads soundboard avec sécurité anti-accident */
.tile.is-locked {
    filter: grayscale(.6) brightness(.75);
}
.tile.is-locked .tile-lock {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: .9rem;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
/* Long-press : barre de progression en bas du pad qui se remplit en 600ms */
.tile.is-pressing::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 4px;
    background: rgba(255,255,255,.9);
    transform-origin: left;
    animation: long-press-fill 600ms linear forwards;
    pointer-events: none;
    border-radius: 0 0 4px 4px;
}
@keyframes long-press-fill {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}
.tile.is-armed {
    filter: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,.75), 0 8px 24px rgba(0,0,0,.45);
}
.tile.is-fired {
    animation: tile-fire .25s ease-out;
}
@keyframes tile-fire {
    0%   { transform: scale(.95); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.play-shell.session-locked .tile {
    /* Quand le verrou de session est ACTIF, tous les pads ont l'air verrouillés */
    filter: grayscale(.4) brightness(.85);
}
.play-shell.session-locked .topbar-btn.is-active {
    background: var(--warning);
    color: #111;
}
@media (prefers-reduced-motion: reduce) {
    .tile.is-pressing::before, .tile.is-fired { animation: none; }
}

/* Couleurs des tuiles : application via classe .tile--N (1 à 8) */
.tile--c1 { background: var(--tile-1); color: var(--tile-1-fg); }
.tile--c2 { background: var(--tile-2); color: var(--tile-2-fg); }
.tile--c3 { background: var(--tile-3); color: var(--tile-3-fg); }
.tile--c4 { background: var(--tile-4); color: var(--tile-4-fg); }
.tile--c5 { background: var(--tile-5); color: var(--tile-5-fg); }
.tile--c6 { background: var(--tile-6); color: var(--tile-6-fg); }
.tile--c7 { background: var(--tile-7); color: var(--tile-7-fg); }
.tile--c8 { background: var(--tile-8); color: var(--tile-8-fg); }

.coupon-form {
    display: flex;
    gap: .75rem;
    align-items: stretch;
    flex-wrap: wrap;
    max-width: 480px;
}
.coupon-form input[type="text"] {
    flex: 1 1 200px;
    min-width: 0;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    font-size: 1rem;
}
.coupon-form input[type="text"]:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.25rem;
}
.admin-form h2 {
    margin: 0;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: .35rem;
}
.admin-form label {
    display: block;
    color: var(--text);
    font-size: .9rem;
    font-weight: 500;
}
.admin-form label small {
    display: block;
    margin-top: .25rem;
    font-weight: 400;
    color: var(--text-muted);
}
.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="number"],
.admin-form input[type="date"],
.admin-form input[type="password"],
.admin-form select,
.admin-form textarea {
    display: block;
    margin-top: .35rem;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .55rem .75rem;
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}
.admin-form textarea { min-height: 80px; resize: vertical; }
.admin-form button[type="submit"] { align-self: flex-start; }

.btn-link {
    background: none;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    padding: 0;
}

/* DASHBOARD */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--gap);
    margin-top: 1.5rem;
}
.dash-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-decoration: none;
    color: var(--text);
    transition: transform .1s;
}
.dash-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.dash-icon { font-size: 2rem; display: block; margin-bottom: .5rem; }
.dash-card h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.dash-card p { margin: 0; color: var(--text-muted); font-size: .9rem; }

.badge-pro { background: var(--primary); color: var(--primary-fg); padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; }
.badge-seed { background: rgba(123,221,255,.15); color: var(--seed); padding: .1rem .4rem; border-radius: 4px; font-size: .7rem; margin-left: .25rem; }

/* CATEGORY LIST */
.cat-list { list-style: none; padding: 0; }
.cat-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.cat-icon { font-size: 1.3rem; }
.cat-name { font-weight: 600; }
.cat-count { color: var(--text-muted); font-size: .85rem; }
.cat-actions { margin-left: auto; font-size: .85rem; }

/* TOPIC LIST */
.topic-layout { display: grid; grid-template-columns: 200px 1fr; gap: 1.5rem; }
@media (max-width: 720px) { .topic-layout { grid-template-columns: 1fr; } }
.topic-sidebar .cat-tabs { list-style: none; padding: 0; }
.topic-sidebar .cat-tabs li a {
    display: block; padding: .5rem .75rem; border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.topic-sidebar .cat-tabs li.active a { background: var(--bg-elev-2); }
.topic-list ul { list-style: none; padding: 0; }
.topic-row { padding: .6rem .75rem; border-bottom: 1px solid var(--border); display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topic-text { flex: 1; }
.topic-actions { font-size: .85rem; }

/* LEVEL */
.level-list { list-style: none; padding: 0; }
.level-item {
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; margin-bottom: 1rem;
}
.level-item h3 { margin: 0 0 .25rem; }
.chip {
    display: inline-block;
    background: var(--bg-elev-2);
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .85rem;
    margin: .15rem .15rem 0 0;
}
.level-actions { margin-top: .5rem; font-size: .9rem; display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }

/* PLAY SHELL — layout B (split) */
.play-shell {
    display: grid;
    grid-template-rows: auto auto 1fr;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--bg-elev), var(--bg));
}
.play-topbar {
    display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
    padding: .6rem .75rem;
    background: rgba(0,0,0,.3);
    backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 10;
}
.play-topbar .back {
    font-size: 1.5rem; text-decoration: none; color: var(--text);
    line-height: 1; padding: 0 .25rem;
}
.play-topbar select {
    flex: 1 1 160px; min-width: 0;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    padding: .5rem;
    border-radius: var(--radius);
    font-size: .95rem;
}
.play-counter { color: var(--text-muted); font-size: .85rem; white-space: nowrap; margin-left: auto; }
.play-session-label {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .25rem .65rem;
    font-size: .8rem;
    font-weight: 600;
    font-family: ui-monospace, monospace;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: auto;
}
.play-session-label + .play-counter { margin-left: 0; }
@media (max-width: 640px) {
    .play-session-label { font-size: .7rem; padding: .2rem .5rem; }
}

.play-topic {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 1.5rem 1.25rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    min-height: 180px;
    gap: 1rem;
}

/* CARTE PAPIER — la carte de tirage façon carte de jeu de société */
.draw-card {
    --card-rot: -1.5deg;
    background:
        /* texture papier subtile via SVG noise inline */
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
        linear-gradient(135deg, #fdfaf2, #f0e8d6);
    color: #1a1410;
    border-radius: 6px;
    padding: 1.5rem 1.75rem 1.25rem;
    width: 100%;
    max-width: 520px;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 1px 0 rgba(255,255,255,.6) inset,
        0 12px 32px rgba(0,0,0,.45),
        0 4px 8px rgba(0,0,0,.25);
    transform: rotate(var(--card-rot));
    transition: transform .2s ease;
    position: relative;
}
.draw-card:active { transform: rotate(var(--card-rot)) scale(1.01); }

@keyframes deal-in {
    0%   { transform: translateY(-150%) rotate(-15deg) scale(.9); opacity: 0; }
    60%  { opacity: 1; }
    100% { transform: rotate(var(--card-rot)) scale(1); opacity: 1; }
}
.draw-card.deal-in {
    animation: deal-in .65s cubic-bezier(.25,.46,.45,.94) backwards;
}
@media (prefers-reduced-motion: reduce) {
    .draw-card.deal-in { animation: none; }
}

.draw-card-header {
    text-align: left;
    border-bottom: 1px dashed rgba(26,20,16,.25);
    padding-bottom: .65rem;
    margin-bottom: 1rem;
}
.draw-card-cat {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--primary);
}

.draw-card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem 0;
}
.draw-card-instruction {
    color: rgba(26,20,16,.55);
    font-style: italic;
    font-size: 1rem;
}
.draw-card-quote {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
    font-size: clamp(1.4rem, 4vw, 2rem);
    line-height: 1.35;
    font-weight: 400;
    quotes: "« " " »";
}
.draw-card-quote::before { content: open-quote; opacity: .55; }
.draw-card-quote::after { content: close-quote; opacity: .55; }

.draw-card-footer {
    text-align: right;
    margin-top: 1rem;
    border-top: 1px dashed rgba(26,20,16,.25);
    padding-top: .65rem;
}
.draw-card-stamp {
    display: inline-block;
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: .15em;
    color: #c70039;
    border: 2px solid #c70039;
    padding: .15rem .55rem;
    transform: rotate(-8deg);
    background: rgba(199,0,57,.04);
}

/* Mobile : carte plus compacte */
@media (max-width: 640px) {
    .draw-card {
        padding: 1.1rem 1.2rem 1rem;
        min-height: 200px;
        max-width: 100%;
    }
    .draw-card-quote { font-size: clamp(1.1rem, 5vw, 1.5rem); }
}
.topic-meta { color: var(--seed); font-size: .9rem; margin-bottom: 1rem; letter-spacing: 1px; }
.topic-meta .dot { margin: 0 .35rem; opacity: .5; }
.topic-text {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 1.5rem;
    max-width: 560px;
}
.btn-draw {
    background: var(--primary);
    color: var(--primary-fg);
    border: 0;
    padding: 1rem 2rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37,99,235,.4);
}
.btn-draw:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-end-session {
    margin-top: 1rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    cursor: pointer;
}
.btn-end-session:hover { background: var(--danger); color: var(--primary-fg); border-color: var(--danger); }

.topbar-btn {
    background: var(--bg-elev-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .35rem .55rem;
    cursor: pointer;
    font-size: 1rem;
}
.topbar-btn:hover { background: var(--primary); }
.topbar-btn.is-active {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245,158,11,.25);
}

/* Mode cue : pads en orange pour signaler le changement de comportement */
.play-shell.cue-mode .sb-pad {
    background: rgba(245,158,11,.15);
    border-color: #f59e0b;
}
.play-shell.cue-mode .sb-pad:hover {
    background: rgba(245,158,11,.4);
}
.play-shell.cue-mode .sb-amb-btn {
    color: #fbbf24;
}
.sb-pad.cue-flash {
    animation: cue-flash .6s;
}
@keyframes cue-flash {
    0%   { background: #f59e0b; transform: scale(1.05); }
    100% { background: rgba(245,158,11,.15); transform: scale(1); }
}

/* SHARE MODAL */
[hidden] { display: none !important; }
.share-modal:not([hidden]) {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.share-modal-content {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
}
.share-modal-content h2 { margin-top: 0; }
.share-qr {
    margin: 1.5rem 0;
    background: #fff;
    padding: .75rem;
    border-radius: var(--radius);
    display: inline-block;
}
.share-qr img { display: block; }
.share-url {
    font-family: monospace;
    font-size: .8rem;
    word-break: break-all;
    color: var(--text-muted);
    margin: .5rem 0 1.5rem;
}
.share-shortcode {
    display: block;
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: .35em;
    text-align: center;
    color: var(--primary);
    background: var(--bg-elev-2);
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: .65rem .5rem;
    margin: .5rem 0 1rem;
    user-select: all;
}

/* HOTKEYS HELP OVERLAY */
.hotkeys-help:not([hidden]) {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.hotkeys-help-content {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
}
.hotkeys-help-content h2 { margin-top: 0; }
.hotkeys-help-content ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    display: grid;
    gap: .5rem;
}
.hotkeys-help-content li {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .95rem;
}
.hotkeys-help-content kbd {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: .15rem .55rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: .85rem;
    min-width: 2em;
    text-align: center;
    box-shadow: 0 1px 0 rgba(0,0,0,.4);
}

/* Flash visuel quand un pad est déclenché par une touche 1-9 */
.sb-pad.hotkey-flash {
    background: var(--primary) !important;
    color: var(--primary-fg);
    transform: scale(1.05);
}

/* PIN TOGGLE (page Sons : « 📌 Sur mon écran ») */
.pin-toggle {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .8rem;
    cursor: pointer;
    user-select: none;
    transition: background .1s;
}
.pin-toggle:has(input:checked) {
    background: rgba(37,99,235,.2);
    border-color: var(--primary);
    color: var(--text);
}
.pin-toggle:not(:has(input:checked)) {
    color: var(--text-muted);
    opacity: .7;
}
.pin-toggle input { margin: 0; }

/* ADMIN LAYOUT */
.admin-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
@media (max-width: 720px) {
    .admin-shell { grid-template-columns: 1fr; }
}
.admin-sidebar {
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    color: var(--text);
}
.admin-sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.admin-sidebar nav a {
    display: block;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: .95rem;
}
.admin-sidebar nav a:hover { background: var(--bg-elev-2); }
.admin-sidebar nav a.active { background: var(--primary); color: var(--primary-fg); }
.admin-sidebar hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.admin-main {
    padding: 1.5rem 2rem;
    max-width: 1200px;
}

/* PAGE HEAD avec stats à droite */
.admin-page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.admin-page-head h1 { margin: 0; font-size: 1.6rem; }
.admin-page-head p { margin: .25rem 0 0; }

.admin-stats {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}
.admin-stats > div {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
}
.admin-stats .num { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.admin-stats .num small { font-size: .75rem; color: var(--text-muted); margin-left: .15rem; }
.admin-stats .lbl { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* CARD 2 COLONNES (form + presets) */
.admin-card-2col {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
}
@media (max-width: 900px) {
    .admin-card-2col { grid-template-columns: 1fr; }
}
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }
.btn-lg {
    padding: .85rem 1.5rem;
    font-size: 1rem;
    margin-top: .5rem;
}

/* Form inputs cohérents thème dark dans tout le panneau admin */
.admin-card-2col .form-group,
.admin-card-2col form > div {
    margin-bottom: 1rem;
}
.admin-card-2col label {
    display: block;
    margin-bottom: .35rem;
    font-size: .85rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: .25px;
}
.admin-card-2col input[type=text],
.admin-card-2col input[type=email],
.admin-card-2col input[type=password],
.admin-card-2col input[type=number],
.admin-card-2col input[type=search],
.admin-card-2col select,
.admin-card-2col textarea {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .65rem .8rem;
    font: inherit;
    font-size: .95rem;
    transition: border-color .12s, box-shadow .12s;
    box-sizing: border-box;
}
.admin-card-2col input:focus,
.admin-card-2col select:focus,
.admin-card-2col textarea:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}
.admin-card-2col textarea {
    min-height: 90px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.45;
}
.admin-card-2col select {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2rem;
    cursor: pointer;
}
.admin-card-2col input[type=number] {
    /* Évite la flèche perso pour rester lisible avec spinners natifs */
    appearance: textfield;
}
.admin-card-2col .help-block,
.admin-card-2col .form-help {
    color: var(--text-muted);
    font-size: .8rem;
    margin-top: .25rem;
}

/* PRESETS */
.admin-presets {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    align-self: start;
}
.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
    margin-top: .5rem;
}
.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    background: var(--bg-elev-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .35rem;
    cursor: pointer;
    transition: all .15s;
    font-size: .8rem;
    text-align: center;
}
.preset-btn:hover {
    background: var(--primary);
    color: var(--primary-fg);
    transform: translateY(-1px);
}
.preset-btn.preset-applied {
    background: var(--success);
    border-color: var(--success);
}
.preset-icon { font-size: 1.2rem; }
.preset-name { font-weight: 600; }
.preset-meta { font-size: .7rem; opacity: .7; }

/* GRID DE SOUND CARDS */
.sound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.sound-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: border-color .15s;
}
.sound-card:hover { border-color: var(--primary); }
.sound-card.is-shipped { background: rgba(123,221,255,.06); }
.sound-card-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}
.sound-card-icon { font-size: 1.5rem; }
.sound-card-name { flex: 1; font-size: 1rem; }
.badge-shipped, .badge-runtime {
    font-size: .7rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.badge-shipped { background: rgba(123,221,255,.2); color: var(--seed); }
.badge-runtime { background: rgba(245,158,11,.2); color: #fbbf24; }
.sound-card-audio {
    width: 100%;
    height: 32px;
    margin: .25rem 0 .5rem;
}
.sound-preview-btn {
    background: var(--bg-elev-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 48px; height: 48px;
    cursor: pointer;
    font-size: 1.2rem;
    margin: .5rem auto;
    display: block;
    transition: all .15s;
}
.sound-preview-btn:hover { background: var(--primary); border-color: var(--primary); }
.sound-preview-btn.is-playing { background: var(--success); border-color: var(--success); animation: pulse .8s infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
    50%      { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}
.sound-card-meta {
    display: flex;
    gap: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .5rem;
    overflow: hidden;
}
.sound-card-meta > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ADMIN TABLE */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 1rem;
}
.admin-table th, .admin-table td {
    padding: .65rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table thead {
    background: var(--bg-elev-2);
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: 1px;
    color: var(--text-muted);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr.is-self { background: rgba(245,158,11,.08); }
.admin-table tr:hover:not(.is-self) { background: var(--bg-elev-2); }
.admin-table code { background: var(--bg); padding: .1rem .4rem; border-radius: 4px; font-size: .85rem; }

.admin-search { display: flex; gap: .25rem; }
.admin-search input[type=search] {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .75rem;
    min-width: 240px;
    font: inherit;
}
.admin-search button {
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .75rem;
    cursor: pointer;
}

.badge-free {
    background: var(--bg-elev-2);
    color: var(--text-muted);
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* TIMER */
.play-timer {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    background: rgba(0,0,0,.3);
    padding: .5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.timer-display {
    font-variant-numeric: tabular-nums;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    min-width: 4ch;
    text-align: center;
}
.timer-display.timer-warning {
    color: #f59e0b;
    animation: timer-pulse 1s infinite;
}
.timer-display.timer-ended {
    color: var(--danger);
    animation: timer-pulse .3s 6;
}
@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}
.timer-btn {
    background: var(--bg-elev-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
}
.timer-btn:hover { background: var(--primary); }

/* TIMELINE (session detail) */
.timeline { list-style: none; padding: 0; }
.timeline-item {
    display: flex; align-items: center; gap: 1rem;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
}
.timeline-time {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: .85rem;
    min-width: 5em;
}
.timeline-icon { font-size: 1.2rem; }
.timeline-text { flex: 1; }

.play-soundboard {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.sb-row-label {
    color: var(--seed);
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: 2px;
    margin-bottom: .5rem;
}
.sb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: .5rem;
}
.sb-pad {
    /* Composé avec .tile.tile--small qui pose le visuel WP-OS.
       On garde uniquement les fallbacks en cas d'absence de .tile (a-href). */
    aspect-ratio: 1;
    cursor: pointer;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: .5rem;
    overflow: hidden;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.15;
}
.sb-pad:disabled { opacity: .4; cursor: not-allowed; }
.sb-amb-row {
    background: rgba(123,221,255,.08);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.sb-amb-row select {
    flex: 1 1 160px;
    min-width: 0;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    padding: .4rem .5rem;
    border-radius: 8px;
    font-size: .9rem;
}
.sb-amb-btn {
    background: transparent;
    color: var(--text);
    border: 0;
    width: auto;
    text-align: left;
    cursor: pointer;
    font-size: .9rem;
    padding: 0 .75rem;
}

/* PUBLIC PAGES */
.public-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; max-width: 1100px; margin: 0 auto;
}
.public-nav nav { display: flex; gap: 1rem; align-items: center; }
.public-shell { max-width: 1000px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 1rem; line-height: 1.15; }
.hero-sub { color: var(--text-muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto 2rem; }
.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--gap);
    margin: 3rem 0;
}
.feat {
    background: var(--bg-elev);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.feat-icon { font-size: 2rem; margin-bottom: .5rem; }
.feat h3 { margin: 0 0 .5rem; }
.feat p { margin: 0; color: var(--text-muted); font-size: .95rem; }

.cta-bottom { text-align: center; padding: 3rem 0; }

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap);
    margin: 2rem 0 3rem;
}
.price-card {
    background: var(--bg-elev);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.price-card h2 { margin: 0; }
.price-card .price { font-size: 1.4rem; color: var(--text-muted); margin: .5rem 0 1.5rem; }
.price-card ul { padding-left: 1.2rem; line-height: 1.8; font-size: .95rem; }
.price-card-pro { border-color: #f59e0b; }

.public-footer {
    border-top: 1px solid var(--border);
    margin-top: 4rem;
    padding: 2rem 1.5rem;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    color: var(--text-muted);
    font-size: .9rem;
}
.public-footer nav { display: flex; gap: 1.5rem; margin-top: .5rem; }

.prose { max-width: 720px; margin: 2rem auto; }
.prose h1 { margin-bottom: 1rem; }
.prose h2 { margin-top: 2rem; }
.prose ul { line-height: 1.7; }

/* RESPONSIVE — écran de jeu sur mobile portrait */
@media (max-width: 640px) {
    .play-topbar { padding: .5rem .6rem; gap: .35rem; }
    .play-topbar .back { font-size: 1.35rem; padding: 0; }
    .play-topbar select { font-size: .9rem; padding: .4rem .5rem; flex-basis: 120px; }
    .topbar-btn { padding: .3rem .45rem; font-size: .9rem; }
    .play-counter { display: none; }

    .play-topic { padding: 1rem 1rem .75rem; min-height: 0; }
    .topic-text { font-size: clamp(1.1rem, 5vw, 1.6rem); margin-bottom: 1rem; }
    .btn-draw { padding: .85rem 1.5rem; font-size: 1rem; width: 100%; }
    .btn-end-session { width: 100%; }

    .play-soundboard { padding: .75rem .75rem 1.5rem; gap: .75rem; }
    .sb-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: .4rem;
    }
    .sb-pad { font-size: .7rem; padding: .35rem; line-height: 1.1; }
    .sb-row-label { font-size: .7rem; letter-spacing: 1px; margin-bottom: .25rem; }
    .sb-amb-row { padding: .5rem; }
    .sb-amb-row .muted { font-size: .75rem !important; }

    .hotkeys-help-content { padding: 1.25rem; }
    .hotkeys-help-content li { font-size: .85rem; }
}

/* Desktop large — laisse plus de respiration au sujet, soundboard sur 1 ligne */
@media (min-width: 900px) {
    .play-topic { padding: 2.5rem 2rem 1.5rem; }
    .topic-text { max-width: 720px; }
    .sb-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
