/* Styles communs. Couleurs d'état : jamais seules (toujours doublées d'un texte ou d'un symbole). */
:root {
  --fond: #f4f6f8; --carte: #fff; --texte: #1b2430; --doux: #5b6676; --bord: #d5dbe3; --accent: #1d4ed8; --accent-texte: #fff;
  --ok: #176b43; --ok-fond: #e3f5ec; --orange: #9a4a00; --orange-fond: #fff1dc; --rouge: #a31515; --rouge-fond: #fde4e4;
  --appel-fond: #e6efff; --rayon: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #11161d; --carte: #1a2230; --texte: #e8edf4; --doux: #9aa6b8; --bord: #2d384a; --accent: #6b9bff; --accent-texte: #0c1220;
    --ok: #6fd6a2; --ok-fond: #143325; --orange: #ffb35c; --orange-fond: #3a2610; --rouge: #ff8f8f; --rouge-fond: #3d1717; --appel-fond: #172a4d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
a { color: var(--accent); }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

button { cursor: pointer; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); border-radius: 8px; padding: .55em 1em; min-height: 44px; }
button.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); font-weight: 600; }
button.danger { color: var(--rouge); border-color: var(--rouge); }
button:disabled { opacity: .55; cursor: default; }
input { width: 100%; padding: .6em .7em; min-height: 44px; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); }
label { display: block; font-weight: 600; margin: .8em 0 .25em; }
label.case { display: flex; gap: .5em; align-items: center; font-weight: 400; }
label.case input { width: auto; min-height: 0; }

.centre { max-width: 460px; margin: 6vh auto; padding: 0 1rem; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.1rem 1.2rem; }
.onglets { display: flex; gap: .4rem; margin: 1rem 0 .6rem; flex-wrap: wrap; }
.onglets button[aria-selected="true"] { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.erreur-form { color: var(--rouge); min-height: 1.4em; margin: .6em 0 0; }
.doux { color: var(--doux); }
.liste-sessions { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; }
.liste-sessions a { display: block; padding: .7em .9em; border: 1px solid var(--bord); border-radius: 8px; text-decoration: none; background: var(--carte); }

/* ── page de session ── */
.haut { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; background: var(--carte); border-bottom: 1px solid var(--bord); }
.haut h1 { margin: 0; font-size: 1.3rem; }
.haut .outils { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.code { font: 600 1rem ui-monospace, monospace; letter-spacing: .1em; padding: .15em .5em; border: 1px dashed var(--bord); border-radius: 6px; }
.etat-flux { font-size: .85rem; color: var(--doux); }
.etat-flux.coupe { color: var(--orange); font-weight: 600; }
.avert-son { margin: .8rem 1rem 0; padding: .7em 1em; border: 1px solid var(--orange); background: var(--orange-fond); color: var(--orange); border-radius: 8px; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
/* Avertissement « son désactivé » : fixe, hors du flux. Le masquer (au premier geste de l'utilisateur) ne doit pas faire
   remonter la page sous son doigt : un clic dont le contenu a bougé entre l'appui et le relâchement est perdu. */
.avert-son.flottant { position: fixed; bottom: 4.6rem; left: 1rem; right: 1rem; max-width: 560px; margin: 0 auto; z-index: 5; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.bandeau { margin: .8rem 1rem 0; padding: 1rem 1.2rem; border-radius: var(--rayon); background: var(--appel-fond); border: 2px solid var(--accent); display: grid; gap: .6rem; }
.bandeau strong { font-size: 1.25rem; }
.bandeau .actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 1rem; padding: 1rem 1rem 8rem; }   /* bas réservé : l'avertissement du son ne cache pas la dernière carte */
.ressource { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; display: grid; gap: .8rem; align-content: start; }
.ressource header { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.ressource h2 { margin: 0; font-size: 1.2rem; }
.badge { font-size: .8rem; font-weight: 700; padding: .15em .6em; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.statut-libre .badge { color: var(--ok); background: var(--ok-fond); }
.statut-appelee .badge { color: var(--accent); background: var(--appel-fond); }
.statut-occupee .badge { color: var(--doux); }
.occupant { display: grid; gap: .2rem; }
.occupant .qui { font-weight: 600; }
.chrono { font: 700 2.4rem/1.1 ui-monospace, "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums; padding: .15em .35em; border-radius: 8px; width: fit-content; }
.chrono.ok { color: var(--ok); background: var(--ok-fond); }
.chrono.orange { color: var(--orange); background: var(--orange-fond); }
.chrono.rouge { color: var(--rouge); background: var(--rouge-fond); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .chrono.rouge { animation: none; } }
.niveau { font-size: .9rem; font-weight: 600; min-height: 1.3em; }
.niveau.orange { color: var(--orange); } .niveau.rouge { color: var(--rouge); }
.file { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.file li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .5rem; align-items: baseline; padding: .4em .6em; border-radius: 8px; background: var(--fond); }
.file li.moi { outline: 2px solid var(--accent); }
.file .pos { font-weight: 700; color: var(--doux); }
.file .groupe, .file .attente { color: var(--doux); font-size: .85rem; }
.vide { color: var(--doux); font-style: italic; margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 10; width: min(92vw, 420px); }
.toast { background: var(--texte); color: var(--fond); padding: .7em 1em; border-radius: 8px; transition: opacity .4s; }
.toast.erreur { background: var(--rouge); color: #fff; }
.toast.fin { opacity: 0; }

/* ── gestion et administration ── */
.cache { position: absolute; left: -9999px; }
button.petit { min-height: 36px; min-width: 36px; padding: .25em .6em; font-size: .9rem; }
.barre-gestion, .actions-entree { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.barre-gestion { padding-top: .6rem; border-top: 1px dashed var(--bord); }
.file li.gere { grid-template-columns: 2rem 1fr auto; }
.file li.gere .actions-entree { grid-column: 1 / -1; }
.prio { color: var(--orange); font-weight: 700; }
.panneau { margin: .8rem 1rem 0; }
.gestion-panneau { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .7rem 1rem; }
.gestion-panneau summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.gestion-panneau .actions { margin-top: .6rem; }
.liste-simple { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .4rem; }
.liste-simple li { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .4em .6em; border-radius: 8px; background: var(--fond); }
.liste-simple.carte { padding: .8rem; }

dialog.dialogue { border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--carte); color: var(--texte); width: min(94vw, 480px); padding: 1.2rem; }
dialog.dialogue.large { width: min(94vw, 640px); }
dialog.dialogue::backdrop { background: rgba(0, 0, 0, .5); }
dialog.dialogue form { display: grid; gap: .6rem; }
dialog.dialogue select { width: 100%; min-height: 44px; padding: .4em; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); }
dialog.dialogue .actions { justify-content: flex-end; margin-top: .6rem; }
dialog.dialogue small { display: block; margin-top: .2rem; }

.admin { max-width: 1200px; margin: 0 auto; padding: 1rem; display: grid; gap: 1.6rem; }
.admin h2 { margin-bottom: .5rem; }
.ligne { display: flex; gap: .6rem; flex-wrap: wrap; }
.ligne input { flex: 1 1 260px; width: auto; }
.grille-admin { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 1rem; }
.bloc-session h3 { margin: 0; font-size: 1.15rem; }
.res-liste { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.res { display: grid; gap: .25rem; padding: .6em .8em; border: 1px solid var(--bord); border-radius: 8px; border-left-width: 6px; }
.res.statut-libre { border-left-color: var(--ok); }
.res.statut-appelee { border-left-color: var(--accent); }
.res.statut-occupee { border-left-color: var(--doux); }
.res-tete { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.res.flash { animation: flash 1.2s ease-in-out 5; background: var(--appel-fond); }
@keyframes flash { 50% { background: var(--orange-fond); } }
@media (prefers-reduced-motion: reduce) { .res.flash { animation: none; } }
.chrono.petit { font-size: 1.4rem; }
.defile { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.table th, .table td { text-align: left; padding: .45em .6em; border-bottom: 1px solid var(--bord); vertical-align: middle; }
.table input { min-height: 36px; width: 6rem; }
details.carte > summary { cursor: pointer; font-weight: 700; min-height: 32px; }
details.carte + details.carte { margin-top: .8rem; }
