/* =============================================================
   Livecam — thème inspiré de l'interface YouTube
   ============================================================= */

/* Jeu de couleurs sombre : valeur par défaut et base du mode automatique. */
:root {
  --bg:        #0f0f0f;
  --surface:   #212121;
  --surface-2: #181818;
  --hover:     #272727;
  --border:    #303030;
  --text:      #f1f1f1;
  --text-2:    #aaaaaa;
  --text-3:    #717171;
  --brand:     #ff0000;
  --accent:    #3ea6ff;
  --chip:      #272727;
  --chip-on:   #f1f1f1;
  --chip-on-t: #0f0f0f;
  --ok:        #2ba640;
  --warn:      #ffd24c;
  --danger:    #f44336;
  --shadow:    0 4px 32px rgba(0,0,0,.6);
}

/* Mode automatique : le système décide, sauf choix explicite du visiteur. */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg:        #ffffff;
    --surface:   #ffffff;
    --surface-2: #f9f9f9;
    --hover:     #f2f2f2;
    --border:    #e5e5e5;
    --text:      #0f0f0f;
    --text-2:    #606060;
    --text-3:    #909090;
    --accent:    #065fd4;
    --chip:      #f2f2f2;
    --chip-on:   #0f0f0f;
    --chip-on-t: #ffffff;
    --shadow:    0 4px 32px rgba(0,0,0,.15);
  }
}

html[data-theme="light"] {
  --bg:        #ffffff;
  --surface:   #ffffff;
  --surface-2: #f9f9f9;
  --hover:     #f2f2f2;
  --border:    #e5e5e5;
  --text:      #0f0f0f;
  --text-2:    #606060;
  --text-3:    #909090;
  --accent:    #065fd4;
  --chip:      #f2f2f2;
  --chip-on:   #0f0f0f;
  --chip-on-t: #ffffff;
  --shadow:    0 4px 32px rgba(0,0,0,.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", "Arial", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- en-tête ---------- */

.masthead {
  /* Au-dessus de toute échelle de bibliothèque tierce : Leaflet va
     jusqu'à 1000 pour ses contrôles. L'isolation du cadre de carte
     suffirait, mais une seconde barrière évite qu'un composant futur
     posé hors de ce cadre repasse devant le menu du compte. */
  position: sticky; top: 0; z-index: 1100;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: var(--bg);
}
.masthead .start { display: flex; align-items: center; gap: 12px; flex: none; }
.masthead .end   { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text); flex: none;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

/* Le bouton « burger » n'a de sens que si la barre latérale est
   escamotable, c'est-à-dire sous 1100px. Déclaré APRÈS .icon-btn pour
   ne pas se faire écraser par son display:grid. */
.burger { display: none !important; }

.logo { display: flex; align-items: center; gap: 6px; }
.logo-mark { width: 28px; height: 28px; display: grid; place-items: center; flex: none; }
.logo-mark svg { width: 26px; height: 26px; }
.logo-mark img { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }
.logo-text { font-size: 20px; font-weight: 500; letter-spacing: -.6px; }
.logo-text sup { font-size: 10px; color: var(--text-2); margin-left: 2px; top: -.7em; }

.searchbar { display: flex; flex: 1; max-width: 560px; margin: 0 auto; }
.searchbar input {
  flex: 1; min-width: 0; height: 40px; padding: 0 16px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-right: none;
  border-radius: 20px 0 0 20px; color: var(--text);
}
.searchbar input::placeholder { color: var(--text-3); }
.searchbar input:focus { outline: none; border-color: var(--accent); }
.searchbar button {
  width: 64px; height: 40px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 0 20px 20px 0;
  display: grid; place-items: center;
}
.searchbar button svg { width: 22px; height: 22px; fill: var(--text); }

/* ---------- avatar et menu du compte ---------- */

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 500; text-transform: uppercase;
  overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.owner { background: var(--brand); }
.avatar.admin { background: #8a4dff; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }

.account { position: relative; }
.account-btn { border-radius: 50%; padding: 0; display: block; }
.account-menu {
  position: absolute; right: 0; top: 46px; z-index: 60;
  min-width: 250px; padding: 8px 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.account-menu[hidden] { display: none; }
.account-head { display: flex; gap: 12px; align-items: center; padding: 8px 16px 14px; }
.account-head b { display: block; font-size: 15px; font-weight: 500; }
.account-head span { color: var(--text-2); font-size: 13px; }
.account-sep { height: 1px; background: var(--border); margin: 4px 0; }
.account-item {
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 0 16px; height: 40px;
  font-size: 14px; text-align: left; color: var(--text);
}
.account-item:hover { background: var(--hover); }
.account-item svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.account-item.danger { color: var(--brand); }

/* ---------- sélecteur de langue ---------- */

.lang { position: relative; }
.lang-menu {
  position: absolute; right: 0; top: 46px; z-index: 60;
  min-width: 170px; padding: 8px 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.lang-menu[hidden] { display: none; }
.lang-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 0 16px; height: 38px;
  font-size: 14px; text-align: left;
}
.lang-item:hover { background: var(--hover); }
.lang-item .code {
  font-size: 11px; color: var(--text-3); width: 22px; flex: none;
}
.lang-item.on { font-weight: 500; }
.lang-item.on .code { color: var(--brand); }

/* ---------- ossature ---------- */

.shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: 56px;
  width: 240px; flex: none;
  height: calc(100vh - 56px);
  overflow-y: auto; padding: 12px;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.content { flex: 1; min-width: 0; padding: 8px 24px 60px; }

.nav-item {
  display: flex; align-items: center; gap: 24px;
  width: 100%; padding: 0 12px; height: 40px;
  border-radius: 10px; color: var(--text);
  font-size: 14px; text-align: left;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--hover); font-weight: 500; }
.nav-item svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { color: var(--text-3); font-size: 12px; flex: none; }

.nav-group { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.nav-group:last-child { border-bottom: none; }
.nav-title { padding: 8px 12px 4px; font-size: 14px; font-weight: 500; }

.nav-sub {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 36px; padding: 0 12px 0 24px;
  border-radius: 10px; text-align: left;
  color: var(--text-2); font-size: 13px;
}
.nav-sub:hover { background: var(--hover); color: var(--text); }
.nav-sub.active { background: var(--hover); color: var(--text); font-weight: 500; }
.nav-sub .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); flex: none; }
.nav-sub.active .dot { background: var(--brand); }
.nav-sub .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sub .count { font-size: 11px; color: var(--text-3); }

/* ---------- barre d'options ---------- */

.chips {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 0 16px;
  position: sticky; top: 56px; z-index: 20;
  background: var(--bg);
}
.chip {
  height: 32px; padding: 0 12px; border-radius: 8px;
  background: var(--chip); color: var(--text);
  font-size: 14px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent;
}
.chip:hover { background: var(--hover); }
.chip.on { background: var(--chip-on); color: var(--chip-on-t); }
.chip svg { width: 16px; height: 16px; fill: currentColor; }
.chip-sep { width: 1px; height: 20px; background: var(--border); }

/* ---------- titres ---------- */

.page-head { padding: 12px 0 4px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* ---------- grille de caméras ---------- */

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}
.grid[data-cols="1"] { grid-template-columns: 1fr; }
.grid[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.grid[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
.grid[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }

.card { display: flex; flex-direction: column; }

.player {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; background: #000;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: 0; border: 0; background: #000;
  display: grid; place-items: center; cursor: pointer;
}
.poster img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .8; transition: opacity .2s;
}
.poster:hover img { opacity: 1; }
.poster .play-badge {
  position: relative; z-index: 2;
  width: 56px; height: 40px; border-radius: 10px;
  background: rgba(0,0,0,.65);
  display: grid; place-items: center; transition: background .15s;
}
.poster:hover .play-badge { background: var(--brand); }
.poster .play-badge svg { width: 18px; height: 18px; fill: #fff; }

.live-tag {
  position: absolute; z-index: 3; left: 8px; top: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  background: rgba(0,0,0,.75); border-radius: 4px;
  font-size: 11px; font-weight: 500; letter-spacing: .3px;
  color: #fff; text-transform: uppercase;
}
.live-tag .bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.card.playing .live-tag .bullet { animation: blink 2s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.locked-tag {
  position: absolute; z-index: 3; right: 8px; bottom: 8px;
  height: 22px; padding: 0 8px;
  background: rgba(0,0,0,.75); border-radius: 4px;
  font-size: 11px; color: #fff;
  display: inline-flex; align-items: center;
}
.card.locked .poster img { opacity: .35; filter: grayscale(.5); }

.card-meta { display: flex; gap: 12px; padding: 12px 4px 0; }
/* La pastille porte la catégorie parente et mène à sa mosaïque. */
.card-meta .bullet-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); flex: none;
  display: grid; place-items: center;
  color: var(--text-2); font-size: 12px; font-weight: 500;
  text-transform: uppercase;
  transition: background .15s, color .15s;
}
.card-meta .bullet-icon:hover {
  background: var(--brand); color: #fff;
}

/* Le titre ouvre la caméra seule. */
.card-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 15px; font-weight: 500; line-height: 1.35;
  color: var(--text);
}
a.card-title:hover { color: var(--accent); }

.card-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card-sub a:hover { color: var(--text); }
.card-cat:hover { color: var(--accent) !important; text-decoration: underline; }

/* Fil de retour sous le titre de page. */
.crumb { color: var(--accent); }
.crumb:hover { text-decoration: underline; }

/* ---------- mode plein écran de la mosaïque ---------- */

/* Le bandeau est listé explicitement : il vivait dans l'en-tête et
   disparaissait avec lui ; sorti de l'en-tête pour occuper la largeur, il
   n'était plus couvert par cette règle. */
body.cinema .masthead,
body.cinema .banner,
body.cinema .sidebar,
body.cinema .page-head { display: none; }
body.cinema .content { padding: 0; }
body.cinema .chips {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 10px 16px; z-index: 50;
  background: rgba(15,15,15,.86);
  backdrop-filter: blur(8px);
  opacity: 1;
  transform: none;
  transition: opacity .25s ease, transform .25s ease;
}

/* Masquage automatique après quelques secondes d'inactivité. La zone
   de survol reste active au-dessus de l'écran pour faire revenir la
   barre à l'approche du pointeur. */
body.cinema.bar-hidden .chips {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}
body.cinema .chips:hover,
body.cinema .chips:focus-within {
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto;
}

/* Bande sensible sous le bord haut : ramène la barre même quand elle
   est entièrement masquée. */
body.cinema::before {
  content: "";
  position: fixed; top: 0; left: 0; right: 0; height: 60px;
  z-index: 49;
}

body.cinema .chips select.loop-seconds {
  height: 28px; padding: 0 6px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px;
}
/* Le choix de durée n'a de sens qu'en plein écran. */
.loop-duration { display: none; }
body.cinema .loop-duration { display: inline-flex; align-items: center; gap: 6px; }

/* Mode défilement : la tuile hors écran est « garée ».

   Surtout pas display:none ni retrait du DOM : le lecteur serait déchargé
   et devrait tout recharger à son retour, ce que YouTube finit par brider.
   On la sort donc du flux de la grille — les tuiles visibles la remplissent
   alors seules — en la laissant rendue, à taille normale et dans la fenêtre,
   pour que le navigateur ne suspende pas sa lecture. Elle est simplement
   invisible et hors d'atteinte du pointeur. */
.card.loop-parked {
  position: fixed;
  top: 0; left: 0;
  width: 320px; height: 180px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
.card.loop-parked .card-meta { display: none; }

body.cinema.looping .card .player { border-radius: 0; }
/* Uniquement en plein écran : hors de ce mode, la page doit rester
   défilable normalement. */
body.cinema.looping { overflow: hidden; }
body.cinema .grid { padding: 0; gap: 2px; }
body.cinema .card-meta { display: none; }
body.cinema .player { border-radius: 0; }

/* ---------- messages ---------- */

.empty { max-width: 480px; margin: 80px auto; text-align: center; color: var(--text-2); }
.empty h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.empty p { margin: 0 0 20px; }

.flash {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 16px;
  background: var(--surface); border-left: 4px solid var(--accent);
}
.flash.ok   { border-left-color: var(--ok); }
.flash.err  { border-left-color: var(--danger); }
.flash.warn { border-left-color: var(--warn); }

/* ---------- formulaires ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
/* Un interrupteur est aussi un <label> : la règle ci-dessus le rendait
   « block », sa piste restait alors en ligne et large de zéro, et le
   bouton rond venait se poser sur le texte. */
.field label.switch { display: flex; margin-bottom: 0; font-size: 14px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.textarea { min-height: 88px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
input[type="file"] { font-size: 13px; color: var(--text-2); }

/* Bloc secondaire replié (création de catégorie depuis le formulaire caméra). */
.sub-field {
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-left: 2px;
}
.sub-field[hidden] { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 18px;
  background: var(--chip); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.brand { background: var(--brand); color: #fff; }
.btn.brand:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; height: 40px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.switch { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--border); position: relative; flex: none; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-2); transition: transform .15s, background .15s;
}
.switch input:checked + .track { background: rgba(62,166,255,.4); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--accent); }
.switch .switch-text b { display: block; font-weight: 500; }
.switch .switch-text span { color: var(--text-2); font-size: 12px; }

/* ---------- authentification ---------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px;
}
.auth-box h1 { margin: 16px 0 4px; font-size: 22px; }
.auth-box .lead { color: var(--text-2); margin: 0 0 24px; font-size: 13px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; font-size: 13px; }
.auth-links a { color: var(--accent); }
.auth-links a:hover { text-decoration: underline; }

/* ---------- panneaux (membre et administration) ---------- */

.admin-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 8px 0 20px; }
.admin-head h1 { margin: 0; font-size: 22px; font-weight: 700; flex: 1; min-width: 0; }

.panel {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.panel > h2 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.panel > .panel-sub { color: var(--text-2); font-size: 13px; margin: 0 0 16px; }

.cols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.row-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 10px 12px;
  color: var(--text-2); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--hover); }
table.data .actions { text-align: right; white-space: nowrap; }

.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 4px; font-size: 11px; font-weight: 500;
  background: var(--chip); color: var(--text-2);
}
/* Les rangs sont rendus par .role-tag, seul jeu de couleurs — voir plus
   bas. Les anciennes règles .tag.owner/.admin/.member ont été retirées
   pour qu'un même rôle ne s'affiche pas en violet ici et en orange là.
   Celle-ci ne désigne pas un rang mais une caméra réservée. */
.tag.restricted { background: rgba(62,166,255,.15); color: var(--accent); }
.tag.off   { background: rgba(244,67,54,.12); color: var(--danger); }
.tag.on    { background: rgba(43,166,64,.15); color: var(--ok); }

.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat .k { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat .d { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-top: 8px; }
.spark .bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .8; }
.spark .bar:hover { opacity: 1; background: var(--brand); }
.spark-axis { display: flex; justify-content: space-between; color: var(--text-3); font-size: 11px; margin-top: 6px; }

.bar-row { display: grid; grid-template-columns: 1fr 60px; gap: 12px; align-items: center; padding: 7px 0; }
.bar-row .lab { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .meter { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 5px; }
.bar-row .meter i { display: block; height: 100%; background: var(--accent); }
.bar-row .num { text-align: right; color: var(--text-2); font-size: 13px; }

.hint-text { color: var(--text-3); font-size: 12px; }

/* ---------- adaptation mobile ---------- */

@media (max-width: 1100px) {
  .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 35;
    background: var(--bg);
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .content { padding: 8px 16px 60px; }
  .searchbar { max-width: none; }
  .burger { display: grid !important; }
}

@media (max-width: 720px) {
  .masthead { gap: 8px; padding: 0 8px; }
  .searchbar { display: none; }
  .grid, .grid[data-cols] { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .logo-text { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- pages d'erreur ---------- */

.error-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 24px;
}
.error-wrap .logo { margin-bottom: 32px; }
.error-code {
  font-size: 96px; font-weight: 700; line-height: 1;
  letter-spacing: -4px; color: var(--brand);
  opacity: .9;
}
.error-wrap h1 { margin: 12px 0 8px; font-size: 24px; font-weight: 500; }
.error-wrap p {
  margin: 0 0 28px; max-width: 460px;
  color: var(--text-2); line-height: 1.6;
}
.error-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- liens de bas de menu ---------- */

.nav-footer {
  padding: 16px 12px 8px;
  display: flex; flex-wrap: wrap; gap: 8px 12px;
}
.nav-footer a {
  color: var(--text-3); font-size: 12px; line-height: 1.5;
}
.nav-footer a:hover { color: var(--text-2); }
.nav-copy {
  padding: 4px 12px 16px;
  color: var(--text-3); font-size: 11px;
}

/* ---------- pages de contenu (légales, contact) ---------- */

.doc { max-width: 760px; }
.doc h2 { font-size: 16px; font-weight: 500; margin: 24px 0 8px; }
.doc h2:first-child { margin-top: 0; }
.doc dl { margin: 0 0 4px; }
.doc dt { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; margin-top: 12px; }
.doc dd { margin: 2px 0 0; }
.doc .prose { white-space: pre-wrap; line-height: 1.7; }

/* ---------- actions communautaires sous une tuile ---------- */

/* Une seule ligne, sans repli : avec les libellés, la barre réclamait
   601 px pour 435 disponibles en quatre colonnes sur un écran de 1920 —
   le repli était donc inévitable. En icônes seules, elle tient en 280 px
   et reste alignée quels que soient les boutons présents. */
.card-actions {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; flex-wrap: nowrap;
}
.card-actions .inline { display: inline; }
.act {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; flex: none;
  height: 28px; width: 28px; padding: 0; border-radius: 14px;
  background: var(--chip); color: var(--text-2);
  font-size: 12px; white-space: nowrap;
  border: none; cursor: pointer;
}
.act:hover { background: var(--hover); color: var(--text); }
.act svg { width: 14px; height: 14px; fill: currentColor; }
.act.on { color: var(--brand); }
.act.on svg { fill: var(--brand); }
.act.muted { cursor: default; }
.act.muted:hover { background: var(--chip); color: var(--text-2); }
.act .n { font-variant-numeric: tabular-nums; }

/* ---------- pastille de notification ---------- */

.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 500; line-height: 18px;
  text-align: center; flex: none;
}

/* ---------- sélecteur de caméras d'une mosaïque ---------- */

.pick-list {
  max-height: 420px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px;
}
.pick-group {
  font-size: 12px; font-weight: 500; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .4px;
  padding: 12px 6px 4px;
}
.pick-group:first-child { padding-top: 2px; }
.pick {
  display: flex; align-items: center; gap: 10px;
  padding: 6px; border-radius: 6px; cursor: pointer;
  font-size: 14px;
}
.pick:hover { background: var(--hover); }

/* ---------- carte ---------- */

.map-canvas {
  height: 60vh; min-height: 380px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);

  /* Leaflet empile ses calques jusqu'à z-index 700 (bulles) et ses
     contrôles jusqu'à 1000. Sans contexte d'empilement propre, ces
     valeurs rivalisent directement avec celles de l'interface, et le
     menu du compte finit sous la carte. « isolation » enferme toute
     cette échelle à l'intérieur du cadre, qui se comporte alors comme
     un seul élément de niveau 0. */
  position: relative;
  z-index: 0;
  isolation: isolate;
}
.leaflet-popup-content { font-family: inherit; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content a { color: #065fd4; }

/* ---------- sous-catégories repliables ---------- */

.nav-group.tree { position: relative; }
.nav-group.tree .nav-children { display: none; }
.nav-group.tree.open .nav-children { display: block; }

.nav-chevron {
  position: absolute; top: 4px; right: 6px;
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  display: grid; place-items: center;
  color: var(--text-2);
}
.nav-chevron:hover { background: var(--hover); color: var(--text); }
.nav-chevron svg {
  width: 18px; height: 18px; fill: currentColor;
  transition: transform .18s;
}
.nav-group.tree.open .nav-chevron svg { transform: rotate(180deg); }
/* Laisse la place au chevron sans écraser le compteur. */
.nav-group.tree > .nav-item { padding-right: 38px; }
.nav-group.tree > .nav-item .count { margin-right: 4px; }

/* ---------- modification rapide depuis une tuile ---------- */

.quick { margin-top: 8px; }
.hidden-tag { flex: none; }
.quick-note {
  margin: 10px 0 0; font-size: 12px; color: var(--ok, #2ba640);
}
.quick-note.err { color: var(--brand); }

.quick-panel {
  margin-top: 8px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.quick-panel .field { margin-bottom: 10px; }
.quick-panel .input,
.quick-panel .select { height: 34px; font-size: 13px; }
.quick-panel label { font-size: 12px; }

/* Interrupteurs resserrés : la tuile est étroite. */
.switch.compact { margin: 6px 0; gap: 8px; }
.switch.compact .switch-text { font-size: 13px; }
.switch.compact .switch-text b { font-weight: 400; }

.quick-buttons { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.quick-delete { margin-top: 8px; }

/* Une caméra masquée reste visible des administrateurs, mais en retrait
   pour qu'on la distingue au premier coup d'œil. */
.card.is-hidden .player { opacity: .5; }
.card.is-hidden .card-title { color: var(--text-2); }

/* ---------- bandeau d'annonce ---------- */

.banner {
  /* Pleine largeur, tout en haut du document : le bandeau précède
     l'en-tête et n'est contraint par aucune colonne. Il défile avec la
     page — l'en-tête, lui, reste collé en haut. */
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px; line-height: 1.5;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
  box-sizing: border-box;
}
.banner svg { width: 18px; height: 18px; flex: none; fill: currentColor; }
.banner-text { flex: 1; min-width: 0; }
.banner-close {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: inherit; opacity: .7;
}
.banner-close:hover { background: rgba(0, 0, 0, .12); opacity: 1; }

/* Trois niveaux de criticité. Les couleurs sont fixes, indépendantes du
   thème clair ou sombre : une alerte ne doit pas se fondre dans le décor. */
.banner.level-low    { background: #fff4c2; color: #5c4700; }
.banner.level-medium { background: #ffd9a8; color: #6b3500; }
.banner.level-high   { background: #ffd2d0; color: #7a1410; }

/* La couleur ne doit pas être le seul indice : le trait de gauche
   s'épaissit avec la gravité, lisible aussi sans distinguer les teintes. */
.banner.level-low    { border-left: 4px solid #d9a400; }
.banner.level-medium { border-left: 6px solid #e07000; }
.banner.level-high   { border-left: 8px solid #c00; }

@media (max-width: 700px) {
  .banner { padding: 10px 12px; font-size: 13px; }
}

/* ---------- barres de répartition (statistiques) ---------- */

.meter {
  height: 8px; border-radius: 4px;
  background: var(--surface); overflow: hidden;
}
.meter span {
  display: block; height: 100%;
  background: var(--accent); border-radius: 4px;
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ---------- pied de page : code libre du propriétaire ---------- */

/* Un marqueur de mesure n'affiche rien : le bloc ne doit alors laisser
   aucune trace visible, d'où le filet et la marge portés par le contenu
   plutôt que par le bloc lui-même. */
.page-foot {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
.page-foot:empty { display: none; }
.page-foot a { color: var(--text-2); text-decoration: underline; }
.page-foot a:hover { color: var(--text); }
.page-foot img { max-width: 100%; height: auto; vertical-align: middle; }
.page-foot p { margin: 0 0 6px; }
.page-foot p:last-child { margin-bottom: 0; }

/* ---------- journal des versions ---------- */

.chg-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.chg-head .spacer { flex: 1; }
.chg-version {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

/* ---------- rendu Markdown des pages légales ---------- */

.markdown { line-height: 1.7; }
.markdown h2 { font-size: 18px; font-weight: 500; margin: 26px 0 8px; }
.markdown h3 { font-size: 15px; font-weight: 500; margin: 20px 0 6px; }
.markdown h4 { font-size: 14px; font-weight: 500; margin: 16px 0 4px; }
.markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown p { margin: 0 0 12px; }
.markdown ul, .markdown ol { margin: 0 0 12px; padding-left: 22px; }
.markdown li { margin: 4px 0; }
.markdown a { color: var(--accent); }
.markdown a:hover { text-decoration: underline; }
.markdown code {
  background: var(--surface); padding: 1px 5px; border-radius: 4px;
  font-size: 13px;
}
.markdown blockquote {
  margin: 0 0 12px; padding: 2px 0 2px 14px;
  border-left: 3px solid var(--border); color: var(--text-2);
}
.markdown blockquote p:last-child { margin-bottom: 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- accessibilité ---------- */

/* Le focus doit rester visible au clavier. On ne le montre pas au clic
   souris, où il parasiterait, d'où :focus-visible plutôt que :focus. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Lien d'évitement : premier élément atteint au clavier, il permet de
   sauter la navigation pour aller droit au contenu. */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 1200;
  padding: 10px 16px; border-radius: 0 0 8px 0;
  background: var(--brand); color: #fff;
}
.skip-link:focus { left: 0; }

/* Mouvement réduit : on coupe transitions et animations. La rotation des
   caméras, elle, est une fonction demandée, pas une décoration — elle
   reste active, mais sans effet de transition. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- bouton de thème : une icône par état ---------- */

.theme-btn svg { display: none; }
html[data-theme="auto"]  .theme-btn .ico-auto,
html[data-theme="light"] .theme-btn .ico-light,
html[data-theme="dark"]  .theme-btn .ico-dark { display: block; }
/* Repli si l'attribut manque : on montre l'état automatique. */
html:not([data-theme]) .theme-btn .ico-auto { display: block; }

/* ---------- page de profil sur deux colonnes ---------- */

/* L'identité tient à gauche, le reste s'empile à droite : sur un écran
   large, tout se lisait auparavant en une seule colonne étroite avec un
   vide à droite. */
.profile-cols { align-items: start; }
.profile-col { display: grid; gap: 20px; align-items: start; }

@media (min-width: 1000px) {
  .profile-cols { grid-template-columns: minmax(320px, 420px) minmax(320px, 1fr); }
}

/* ---------- étiquette de rôle dans le menu de compte ---------- */

.role-tag {
  display: inline-block; margin-top: 5px;
  padding: 2px 9px; border-radius: 10px;
  font-size: 11px; font-weight: 500; line-height: 17px;
  letter-spacing: .2px;
}
/* Couleurs fixes, indépendantes du thème : le rang doit se lire d'un
   coup d'œil en clair comme en sombre. Le texte est foncé sur fond
   clair pour rester lisible dans les deux cas. */
.role-tag.role-member    { background: #d6f5dd; color: #125c2a; }
.role-tag.role-moderator { background: #fdf0b8; color: #6b5200; }
.role-tag.role-admin     { background: #ffdcb0; color: #7a3d00; }
.role-tag.role-owner     { background: #ffd2d0; color: #8a1512; }

/* ---------- heure locale dans la légende d'une tuile ---------- */

.cam-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- invitation à s'inscrire (page de proposition) ---------- */

.signup-call {
  display: flex; gap: 16px; align-items: center;
  flex-wrap: wrap; justify-content: space-between;
}
.signup-actions { display: flex; gap: 8px; flex: none; }

/* Le formulaire reste lisible mais inactif : on montre ce qui sera
   demandé, sans laisser croire qu'on peut l'envoyer. */
.panel.is-preview { opacity: .6; }
.panel.is-preview input,
.panel.is-preview textarea,
.panel.is-preview select,
.panel.is-preview button { pointer-events: none; }

/* ---------- clignotement du séparateur de l'heure ---------- */

.cam-time .sep {
  animation: blink-sep 1s step-end infinite;
}
@keyframes blink-sep {
  0%, 50%  { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
/* Un clignotement permanent est précisément ce que ce réglage vise. */
@media (prefers-reduced-motion: reduce) {
  .cam-time .sep { animation: none; opacity: 1; }
}

/* ---------- disparition d'une tuile rétablie ---------- */

.card.is-leaving {
  transition: opacity .45s ease, transform .45s ease;
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .card.is-leaving { transition: none; }
}

/* ---------- comparaison jour à jour ---------- */

.recent-table td { font-size: 15px; }
.trend {
  display: inline-block; margin-left: 8px;
  font-size: 12px; font-weight: 500;
}
.trend.up   { color: #2ba640; }
.trend.down { color: var(--brand); }

/* ---------- catégories groupées par racine ---------- */

.cat-toolbar {
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap; margin-bottom: 14px;
}

.cat-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}
.cat-group > summary {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px;
  cursor: pointer; user-select: none;
  background: var(--surface);
  list-style: none;
}
.cat-group > summary::-webkit-details-marker { display: none; }
.cat-group > summary::before {
  content: "▸";
  color: var(--text-3);
  transition: transform .15s;
  display: inline-block;
}
.cat-group[open] > summary::before { transform: rotate(90deg); }
.cat-group > summary:hover { background: var(--hover); }
.cat-name { font-weight: 500; flex: none; }
.cat-group > summary .hint-text { flex: 1; min-width: 0; }
.cat-group table { margin: 0; }
.cat-group .cat-self td { background: var(--surface-2); }
.cat-group.is-hidden-by-filter { display: none; }

/* ---------- liste des caméras : filtres, santé, réordonnancement ---------- */

.cam-filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center; margin-bottom: 16px;
}

.pager {
  display: flex; gap: 6px; align-items: center;
  justify-content: center; flex-wrap: wrap;
  margin-top: 18px;
}

/* Pastille de santé. La couleur ne suffit pas : l'infobulle donne l'état
   et la date, et le gris se distingue des deux autres par sa clarté. */
.health { font-size: 15px; line-height: 1; cursor: help; }
.health.ok      { color: #2ba640; }
.health.stale   { color: #d9a400; }
.health.down    { color: var(--brand); }
.health.unknown { color: var(--text-3); }

.drag-handle {
  display: inline-block; margin-right: 8px;
  color: var(--text-3); cursor: grab;
  letter-spacing: -3px; user-select: none;
}
table.is-sortable tbody tr { cursor: grab; }
table.is-sortable tbody tr.is-dragging { opacity: .45; }
table.is-sortable.is-saving { opacity: .7; }
table.is-sortable.is-saved  { outline: 2px solid #2ba640; outline-offset: 2px; }
table.is-sortable.is-failed { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  table.is-sortable.is-saved,
  table.is-sortable.is-failed { outline-width: 3px; }
}

/* ---------- catalogue en arborescence ---------- */

.view-switch {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.view-switch .spacer { flex: 1; }

.tree-hint { margin: 0 0 12px; }

.tree-root {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  background: var(--surface);
}
.tree-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.tree-head.sub {
  padding: 8px 14px 8px 26px;
  background: transparent;
  border-bottom: 1px dashed var(--border);
}
.tree-head .spacer { flex: 1; }
.tree-name { font-weight: 500; }
.tree-head.sub .tree-name { font-weight: 400; }

.tree-sub { border-top: 1px solid var(--border); }
.tree-subs:empty { display: none; }

.tree-cams { list-style: none; margin: 0; padding: 0; }
.tree-cam {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 40px;
  border-bottom: 1px solid var(--border-soft, rgba(128,128,128,.15));
}
.tree-cam:last-child { border-bottom: none; }
.tree-cam .spacer { flex: 1; }
.tree-cam:hover { background: var(--hover); }

/* Zone de dépôt vide : sans repère visible, on ne saurait pas qu'on peut
   y déposer une caméra. */
.tree-empty {
  padding: 10px 14px 10px 40px;
  font-style: italic;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin: 6px 14px 10px 26px;
}

.tree .is-dragging { opacity: .4; }
.tree.is-saving { opacity: .75; }
.tree.is-saved  { outline: 2px solid #2ba640; outline-offset: 3px; border-radius: 12px; }
.tree.is-failed { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 12px; }

/* ---------- actions groupées, cartes de statistiques, état vide ---------- */

.bulk-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-card { text-align: center; }
.stat-value { font-size: 30px; font-weight: 600; line-height: 1.1; }
.stat-label { color: var(--text-2); font-size: 13px; margin-top: 4px; }

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state p { margin: 0 0 14px; color: var(--text-2); }

/* ---------- fiabilité, navigation, aide clavier ---------- */

.uptime { font-variant-numeric: tabular-nums; font-weight: 500; }
.uptime.good { color: #2ba640; }
.uptime.fair { color: #d9a400; }
.uptime.poor { color: var(--brand); }

.cam-nav { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 12px; }

.kbd-help {
  position: fixed; inset: 0; z-index: 1300;
  background: rgba(0, 0, 0, .6);
  display: grid; place-items: center;
}
.kbd-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 24px; min-width: 280px;
}
.kbd-panel div { display: flex; gap: 14px; align-items: center; padding: 5px 0; }
.kbd-panel kbd {
  min-width: 44px; text-align: center;
  padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: inherit; font-size: 12px;
}

/* ---------- message affiché sans JavaScript ---------- */

.noscript-note {
  display: flex; align-items: center; gap: 10px;
  width: 100%; box-sizing: border-box;
  padding: 10px 16px;
  font-size: 14px; line-height: 1.5;
  background: #ffd9a8; color: #6b3500;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
  border-left: 6px solid #e07000;
}
.noscript-note svg { width: 18px; height: 18px; flex: none; fill: currentColor; }

/* ---------- sprite d'icônes ---------- */

/* Défini une fois en tête de page, référencé par <use> : recopier chaque
   icône dans chaque tuile pesait 16 % du poids de la mosaïque. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; fill: currentColor; }

/* ---------- bandeau de visite d'un compte ---------- */

/* Volontairement voyant et non masquable : agir au nom de quelqu'un
   d'autre sans s'en souvenir serait la pire façon d'utiliser la fonction. */
.impersonation-bar {
  display: flex; align-items: center; gap: 12px;
  width: 100%; box-sizing: border-box;
  padding: 10px 16px;
  background: #4a2d8f; color: #fff;
  font-size: 14px; line-height: 1.5;
  position: sticky; top: 0; z-index: 1200;
}
.impersonation-bar svg { width: 18px; height: 18px; flex: none; fill: currentColor; }
.impersonation-bar span { flex: 1; min-width: 0; }
.impersonation-bar .btn {
  flex: none; background: #fff; color: #4a2d8f; border-color: #fff;
}
.impersonation-bar .btn:hover { background: #f0ecff; }

/* ---------- vignette de repli (flux sans image) ---------- */

/* Un dégradé neutre plutôt qu'un gris plat : la tuile reste lisible à
   côté de ses voisines illustrées, sans prétendre montrer une image. */
.poster-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; padding: 12px; text-align: center;
  background: linear-gradient(135deg, #2b3040 0%, #1a1d26 100%);
  color: #e8eaf0;
}
.pf-name {
  font-size: 15px; font-weight: 500; line-height: 1.3;
  max-width: 90%;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.pf-host { font-size: 12px; opacity: .65; }

/* ---------- bulle de la carte ---------- */

.map-popup { min-width: 170px; }
.map-popup strong { display: block; margin-bottom: 2px; }
.map-thumb {
  display: block; width: 100%; max-width: 220px;
  aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 6px; margin-bottom: 8px;
  background: #1a1d26;
}
/* Flux sans vignette : on nomme la source plutôt que laisser un vide. */
.map-thumb-alt {
  display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 220px; aspect-ratio: 16 / 9;
  border-radius: 6px; margin-bottom: 8px;
  background: linear-gradient(135deg, #2b3040 0%, #1a1d26 100%);
  color: #cfd4e0; font-size: 12px; text-align: center; padding: 6px;
}

/* ---------- suppression rapide sous une caméra ---------- */

/* Rouge dès le repos, contrairement aux autres actions : le geste est
   irréversible, il ne doit pas se confondre avec ses voisins. */
.act.danger { color: var(--brand); }
.act.danger:hover,
.act.danger:focus-visible {
  background: var(--brand);
  color: #fff;
}
.act.danger .ic { fill: currentColor; }

/* ---------- texte réservé aux lecteurs d'écran ---------- */

/* Retiré de l'affichage sans l'être de l'arbre d'accessibilité :
   display:none ou visibility:hidden le rendraient muet aussi. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Sans libellé visible, le bouton ne doit pas rester large et vide. */
.act.danger { gap: 0; }

/* ---------- voile masquant l'interface du lecteur ---------- */

/* Transparent mais présent : il intercepte le survol, que le lecteur ne
   voit donc plus. Il se place sous le bouton d'affiche (z-index 3) pour
   ne pas empêcher le démarrage, et sous la barre d'actions du site. */
.player-shield {
  position: absolute; inset: 0; z-index: 2;
  background: transparent; cursor: default;
}
.card:not(.playing) .player-shield { display: none; }

/* Le bouton « j'aime » porte un compteur : il lui faut la place du
   chiffre, contrairement aux autres qui sont carrés. */
.act:has(.n) { width: auto; padding: 0 9px; gap: 4px; }
.act .n { font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- défilement réservé au plein écran ---------- */

/* Hors plein écran, le bouton et son sélecteur de durée allongeaient la
   barre d'options au point de repousser les vidéos vers le bas. Le
   défilement n'a de toute façon d'intérêt qu'en plein écran : on le
   réserve à ce mode plutôt que de le laisser encombrer la mosaïque. */
body:not(.cinema) [data-action="loop"],
body:not(.cinema) .loop-duration {
  display: none;
}

/* ---------- navigation dans les réglages ---------- */

.set-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 0 0 18px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.set-tab {
  padding: 5px 11px; border-radius: 14px;
  font-size: 13px; text-decoration: none;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border);
}
.set-tab:hover { background: var(--hover); color: var(--text); }

/* Décalage sous l'en-tête collant, sinon le titre visé se retrouve
   caché derrière lui après le saut. */
.set-head { scroll-margin-top: 80px; }

/* ---------- calendrier des statistiques ---------- */

.cal-head {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-bottom: 14px;
}
.cal-head .is-off { opacity: .35; pointer-events: none; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
}
.cal-dow {
  text-align: center; font-size: 12px; color: var(--text-3);
  padding-bottom: 4px;
}
.cal-cell {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 56px; padding: 5px 6px;
  border: 1px solid var(--border); border-radius: 8px;
  text-decoration: none; color: var(--text);
  background: var(--surface);
}
.cal-cell.is-empty { border: none; background: none; }
.cal-cell.is-none { color: var(--text-3); background: transparent; }
.cal-n { font-size: 12px; color: var(--text-3); }
.cal-v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Quatre paliers : le rythme du mois se lit sans comparer les nombres. */
.cal-cell.n1 { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.cal-cell.n2 { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); }
.cal-cell.n3 { background: color-mix(in srgb, var(--accent) 44%, var(--surface)); }
.cal-cell.n4 { background: color-mix(in srgb, var(--accent) 64%, var(--surface)); color: #fff; }
.cal-cell.n4 .cal-n { color: rgba(255,255,255,.75); }
a.cal-cell:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.is-on { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.is-today .cal-n { font-weight: 700; color: var(--accent); }

/* ---------- répartition horaire ---------- */

.hours {
  display: flex; align-items: flex-end; gap: 3px;
  height: 130px; margin: 10px 0 18px;
}
.hour {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; height: 100%;
}
.hour-bar {
  width: 100%; background: var(--accent); border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.hour-lbl { font-size: 10px; color: var(--text-3); margin-top: 3px; height: 12px; }

.dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.dim h4 { margin: 0 0 6px; font-size: 13px; color: var(--text-2); }

/* ---------- mise à jour par archive signée ---------- */

.upd-obstacles { margin: 10px 0 0; padding-left: 20px; color: var(--danger); line-height: 1.7; }
.upd-howto { margin-top: 16px; }
.upd-howto summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
.upd-howto summary:hover { color: var(--text); }
.upd-howto p { margin: 12px 0 6px; font-size: 13px; color: var(--text-2); }
.upd-cmd {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.upd-backups { margin: 10px 0 14px; padding-left: 20px; line-height: 1.8; }

/* ---------- panel : entrées groupées par usage ---------- */

/* Les seize entrées d'administration sont réparties en petits ensembles.
   Le titre d'ensemble doit se lire comme une structure, pas comme une
   entrée de plus : d'où la casse, la taille et la couleur en retrait. */
.nav-set { margin-bottom: 2px; }
.nav-set:last-child { margin-bottom: 0; }
.nav-set-title {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;          /* le triangle par défaut est remplacé */
}
.nav-set-title::-webkit-details-marker { display: none; }
.nav-set-title:hover { background: var(--hover); color: var(--text-2); }
.nav-set-title span:first-child { flex: 1; min-width: 0; }
.nav-set-chev {
  width: 14px; height: 14px; flex: none;
  fill: currentColor; opacity: .7;
  transition: transform .15s ease;
}
.nav-set[open] > .nav-set-title .nav-set-chev { transform: rotate(90deg); }
/* Déplié, le compteur du titre ferait doublon avec ceux des entrées. */
.nav-set[open] > .nav-set-title .nav-set-badge { display: none; }

/* Groupées, les entrées sont plus nombreuses à l'écran : elles se
   resserrent, et l'icône se rapproche de son libellé. */
.nav-group .nav-set .nav-item { height: 36px; gap: 14px; font-size: 13.5px; }
.nav-group .nav-set .nav-item svg { width: 19px; height: 19px; }

/* Repère de position : la teinte de fond seule se confond avec le survol.
   Le trait est posé en élément à part — une ombre intérieure épouserait
   l'arrondi et se lirait comme un croissant. */
.nav-item.active { position: relative; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}

/* ---------- panel : qui est connecté ---------- */

.nav-who {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-2);
}
.nav-who-mark {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 600;
}
.nav-who-text { min-width: 0; line-height: 1.35; }
.nav-who-text b {
  display: block; font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-who-text small { color: var(--text-3); font-size: 11.5px; }
/* Une signature tient en 88 caractères : la hauteur par défaut d'une
   zone de texte ferait un carré vide sous une seule ligne. */
.upd-sig { min-height: 52px; }

/* ---------- dépose de fichiers ---------- */

/* Le champ d'origine reste dans la zone et reste cliquable : il couvre
   toute la surface, de sorte qu'un clic n'importe où ouvre le sélecteur.
   Sans JavaScript, cette zone n'existe pas et le champ s'affiche nu. */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  min-height: 92px; padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--text-3); }
.dropzone.over {
  border-color: var(--accent);
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-2));
}
.dropzone input[type="file"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.dropzone-text { color: var(--text-2); font-size: 13px; line-height: 1.5; pointer-events: none; }
.dropzone-file {
  color: var(--text); font-size: 12.5px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
  pointer-events: none;
}
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone.has-file .dropzone-text { display: none; }

/* ---------- écoulement des panneaux ---------- */

/* Une grille range les panneaux en colonnes fixes : trois cartes de
   hauteurs très différentes laissent alors de grands vides sous les
   courtes. Un écoulement en colonnes les empile au plus serré — l'ordre
   de lecture devient colonne par colonne, ce qui convient à des réglages
   indépendants les uns des autres. */
.panel-flow { columns: 3 300px; column-gap: 20px; }
.panel-flow > .panel {
  break-inside: avoid;
  page-break-inside: avoid;   /* navigateurs plus anciens */
  margin: 0 0 20px;
  display: inline-block;      /* évite qu'une carte soit coupée en deux */
  width: 100%;
}
@media (max-width: 1100px) { .panel-flow { columns: 2 300px; } }
@media (max-width: 720px)  { .panel-flow { columns: 1; } }

/* ---------- barre d'enregistrement ---------- */

/* Sur une page longue, un bouton posé à la fin se cherche : celui-ci
   reste au bas de l'écran tant que le formulaire est à l'écran. */
.form-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  margin: 4px 0 0; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-1);
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
@media (prefers-reduced-motion: no-preference) { .form-bar { transition: box-shadow .15s; } }

/* ---------- pages « formulaire et liste » ---------- */

/* Une grille à colonnes égales donnait au formulaire autant de place
   qu'à la liste : le tableau des caméras débordait alors de sa carte,
   boutons d'action compris. Le formulaire est borné, la liste prend ce
   qui reste. */
.admin-split {
  display: grid; gap: 20px; align-items: start;
  grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
}
@media (max-width: 1000px) { .admin-split { grid-template-columns: 1fr; } }

/* Et si la liste reste trop étroite — écran mince, colonnes nombreuses —
   le tableau défile dans sa carte plutôt que d'en sortir. Le défilement
   est porté par une enveloppe : rendre le tableau lui-même « block »
   désolidarise l'en-tête du corps, et les colonnes ne s'alignent plus. */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.table-wrap table.data { min-width: 100%; }

/* ---------- visiteurs présents ---------- */

.live-panel h2 { display: flex; align-items: center; gap: 8px; }
.live-dot {
  width: 9px; height: 9px; flex: none;
  border-radius: 50%;
  background: var(--ok, #16a34a);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok, #16a34a) 60%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: live-pulse 2.4s ease-out infinite; }
  @keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok, #16a34a) 55%, transparent); }
    70%  { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
  }
}

.live-figures { display: flex; flex-wrap: wrap; gap: 28px; margin: 14px 0 4px; }
.live-fig b {
  display: block;
  font-size: 30px; font-weight: 650; line-height: 1.1;
  font-variant-numeric: tabular-nums;   /* le chiffre ne doit pas danser */
}
.live-fig span { color: var(--text-3); font-size: 12.5px; }

/* Un bref éclat au changement : sur une page qu'on ne fixe pas, un
   chiffre qui bouge en silence passe inaperçu. */
@media (prefers-reduced-motion: no-preference) {
  .live-fig b.bump { animation: live-bump .5s ease-out; }
  @keyframes live-bump {
    0%   { color: var(--accent); transform: translateY(-2px); }
    100% { color: inherit; transform: none; }
  }
}

.live-places { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.live-place {
  padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-2); font-size: 12.5px;
}
.live-place b { color: var(--text); margin-left: 4px; }

/* ---- Tâches planifiées ---- */
/* La ligne de crontab est faite pour être sélectionnée d'un geste et
   collée ailleurs : elle ne se replie pas, elle défile. */
.cron-task { padding: 14px 0; border-bottom: 1px solid var(--border); }
.cron-task:last-child { border-bottom: 0; padding-bottom: 0; }
.cron-task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cron-task p { margin: 4px 0 8px; }
.cron-line {
  margin: 0; padding: 10px 12px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px;
}
.cron-line code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; color: var(--text); white-space: pre;
  -webkit-user-select: all; user-select: all;
}
.cron-how { margin: 0; padding-left: 20px; color: var(--text-2); }
.cron-how li { margin-bottom: 8px; line-height: 1.55; }

/* =============================================================
   Thème « Bleu nuit »
   -------------------------------------------------------------
   Un thème ne redéfinit que les variables de couleur : la mise en
   page, les espacements et les composants restent communs. Ajouter
   un thème revient donc à écrire un bloc comme celui-ci, sans
   toucher au reste de la feuille.

   Le rouge de --brand est conservé : c'est la pastille « en direct »,
   et elle doit rester lisible comme un signal, pas se fondre dans
   l'habillage. Seul --accent, qui porte les actions, passe au bleu.
   ============================================================= */

html[data-skin="ocean"] {
  --bg:        #0d1b2e;
  --surface:   #16293f;
  --surface-2: #112033;
  --hover:     #1d3550;
  --border:    #22405f;
  --text:      #e9f0f8;
  --text-2:    #9db2c8;
  --text-3:    #6d839b;
  --accent:    #1a73e8;
  --chip:      #1d3550;
  --chip-on:   #1a73e8;
  --chip-on-t: #ffffff;
  --shadow:    0 4px 32px rgba(3,12,24,.6);
}

@media (prefers-color-scheme: light) {
  html[data-skin="ocean"][data-theme="auto"] {
    --bg:        #f4f8fd;
    --surface:   #ffffff;
    --surface-2: #eaf1fa;
    --hover:     #e1ebf7;
    --border:    #cfdeef;
    --text:      #0d1b2e;
    --text-2:    #4a6076;
    --text-3:    #7b8ea3;
    --accent:    #0b57d0;
    --chip:      #e1ebf7;
    --chip-on:   #1a73e8;
    --chip-on-t: #ffffff;
    --shadow:    0 4px 32px rgba(13,27,46,.14);
  }
}

html[data-skin="ocean"][data-theme="light"] {
  --bg:        #f4f8fd;
  --surface:   #ffffff;
  --surface-2: #eaf1fa;
  --hover:     #e1ebf7;
  --border:    #cfdeef;
  --text:      #0d1b2e;
  --text-2:    #4a6076;
  --text-3:    #7b8ea3;
  --accent:    #0b57d0;
  --chip:      #e1ebf7;
  --chip-on:   #1a73e8;
  --chip-on-t: #ffffff;
  --shadow:    0 4px 32px rgba(13,27,46,.14);
}

/* L'entrée courante du menu est pleine, et non simplement survolée :
   c'est ce qui distingue le plus ce thème à l'œil. */
html[data-skin="ocean"] .nav-item.active {
  background: var(--accent);
  color: #fff;
}
html[data-skin="ocean"] .nav-item.active .count,
html[data-skin="ocean"] .nav-item.active svg { color: #fff; fill: #fff; }
html[data-skin="ocean"] .nav-item.active::before { background: transparent; }

/* Un filet bleu sépare l'en-tête du contenu, comme dans la maquette. */
html[data-skin="ocean"] .topbar { border-bottom-color: var(--accent); }

/* ---- Choix du thème dans l'administration ---- */
.skin-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.skin-card { border: 2px solid var(--border); border-radius: 12px; padding: 0; overflow: hidden; background: var(--surface-2); }
.skin-card.on { border-color: var(--accent); }
.skin-swatch { display: flex; height: 92px; }
.skin-swatch span { flex: 1; }
.skin-body { padding: 12px 14px; }
.skin-body h3 { margin: 0 0 4px; font-size: 15px; }
.skin-body p { margin: 0 0 12px; color: var(--text-2); font-size: 13px; line-height: 1.5; }

/* ---- Monétisation ---- */
/* Un encart publicitaire se tient à distance du contenu et ne le pousse
   pas : sans hauteur réservée, l'arrivée de la régie ferait sauter la
   page sous le curseur. */
.ad-slot { display: block; margin: 16px 0; min-height: 90px; text-align: center; }
.ad-slot.ad-bottom { margin-top: 28px; }
.donate-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border);
}
.money-mode {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.money-mode.on { border-color: var(--accent); background: var(--surface-2); }
.money-mode input { margin-top: 3px; flex: none; }
.money-mode > span { display: flex; flex-direction: column; gap: 2px; }

/* Drapeau d'une rubrique pays, à la place de l'icône générique. Même
   gabarit que les icônes voisines pour garder l'alignement. */
.nav-flag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; flex: none; font-size: 18px; line-height: 1;
}

/* ---- Page d'une caméra : ce qu'il y a sous la vidéo ---- */
.cam-facts { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.cam-fact {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px; min-width: 180px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.cam-fact .k { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.cam-fact .v { font-size: 22px; font-weight: 500; color: var(--text); }
.cam-fact .d { font-size: 12px; color: var(--text-2); }

.related { margin-top: 28px; }
.related h2 { font-size: 18px; margin: 0 0 12px; }
.related-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.related-card { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; }
.related-thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 10px; background: #000;
}
.related-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.related-card:hover .related-thumb img { transform: scale(1.04); }
.related-thumb .live-tag { position: absolute; top: 8px; left: 8px; }
.related-name { font-weight: 500; line-height: 1.3; }
.related-cat { font-size: 13px; color: var(--text-2); }
