:root {
  --bg: #0b0f17; --surface: #141a24; --surface-2: #1c2431; --surface-3: #26303f;
  --border: #2a3546; --text: #e7edf6; --muted: #94a3b8;
  --accent: #6366f1; --accent-h: #4f46e5; --danger: #dc2626; --danger-h: #b91c1c;
  --radius: 14px; --radius-sm: 10px;
}
* { box-sizing: border-box; }
/* Les composants (.lightbox, .uploader…) définissent display:flex/grid, ce qui
   sinon l'emporterait sur l'attribut hidden et laisserait la visionneuse
   recouvrir la page en permanence. On force hidden à gagner partout. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
/* Garde-fou : jamais de défilement horizontal. clip (et non hidden) pour ne
   pas casser le position:sticky de la barre du haut. */
html { overflow-x: clip; }
body { overflow-x: clip; max-width: 100%; }
img, video { max-width: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 9px 14px; border-radius: var(--radius-sm); font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-h); }

/* Icônes SVG : rendu identique sur tous les téléphones (contrairement aux
   caractères Unicode ⏻ ⛊ 🗑 qui dépendent de la police du système). */
.ic { width: 20px; height: 20px; display: block; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.ic-fill { display: block; fill: currentColor; stroke: none; }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 34px 28px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 46px; color: var(--accent); line-height: 1; }
.login-card h1 { margin: 12px 0 2px; font-size: 1.6rem; letter-spacing: .5px; }
.login-sub { margin: 0 0 20px; color: var(--muted); }
.login-input {
  width: 100%; padding: 14px 16px; font-size: 16px; text-align: center; letter-spacing: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); margin-bottom: 12px;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn { width: 100%; padding: 14px; font-weight: 700; font-size: 1rem;
  background: var(--accent); border: none; border-radius: var(--radius-sm); color: #fff; }
.login-btn:hover { background: var(--accent-h); }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .92rem; }
.alert-warn { background: rgba(217,119,6,.16); border: 1px solid rgba(217,119,6,.5); color: #fcd34d; }
.alert-danger { background: rgba(220,38,38,.16); border: 1px solid rgba(220,38,38,.5); color: #fca5a5; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(11,15,23,.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: .5px; white-space: nowrap; min-width: 0; }
.tabs { display: flex; gap: 6px; margin-left: 4px; }
.tab {
  padding: 7px 14px; border-radius: 999px; color: var(--muted); font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }
.tab .count { font-size: .78rem; background: var(--surface); padding: 1px 8px; border-radius: 999px; color: var(--muted); }
.actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.admin-badge { font-size: .7rem; font-weight: 800; letter-spacing: 1px; color: #fca5a5;
  border: 1px solid rgba(220,38,38,.5); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }

/* Téléphone : la barre se réorganise sur deux lignes plutôt que de déborder. */
@media (max-width: 600px) {
  .topbar { gap: 8px 10px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand { font-size: .98rem; }
  .tabs { order: 3; width: 100%; margin-left: 0; }   /* onglets pleine largeur, 2e ligne */
  .tab { flex: 1; justify-content: center; }
  .actions { gap: 6px; }
  .btn { padding: 9px 11px; }
  #upload-btn .btn-label { display: none; }           /* garder juste « ＋ » */
}

/* ---------- Grille ---------- */
.gallery { padding: 14px; }
.grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 700px) { .grid { gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; border: none; padding: 0;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .25s ease, opacity .3s; opacity: 0; }
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.05); }
.tile .dur {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.72);
  color: #fff; font-size: .75rem; font-weight: 600; padding: 2px 7px; border-radius: 6px;
}
.tile .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; filter: drop-shadow(0 2px 10px rgba(0,0,0,.6));
  pointer-events: none; opacity: .92;
}
.tile .play .ic-fill { width: 46px; height: 46px; }
.empty { text-align: center; padding: 80px 20px; color: var(--muted); display: grid; gap: 16px; place-items: center; }

/* ---------- Visionneuse ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(6,9,14,.97);
  display: flex; flex-direction: column; }
.lb-stage { flex: 1; display: grid; place-items: center; overflow: hidden; padding: 12px; min-height: 0; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 6px; background: #000; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 54px; height: 84px; border: none; border-radius: 12px;
  background: rgba(20,26,36,.5); color: #fff;
  display: grid; place-items: center;
}
.lb-nav .ic { width: 30px; height: 30px; }
.lb-nav:hover { background: rgba(38,48,63,.8); }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-close { position: absolute; top: 12px; right: 14px; z-index: 3; width: 44px; height: 44px;
  border: none; border-radius: 50%; background: rgba(20,26,36,.6); color: #fff;
  display: grid; place-items: center; }
.lb-close:hover { background: rgba(38,48,63,.9); }
.lb-bar { display: flex; align-items: center; gap: 14px; padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(11,15,23,.6); border-top: 1px solid var(--border); }
.lb-counter { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.lb-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: .9rem; }
.lb-tools { display: flex; gap: 8px; }
@media (max-width: 560px) { .lb-name { display: none; } .lb-nav { width: 44px; height: 66px; font-size: 2rem; } }

/* ---------- Uploader ---------- */
.uploader { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: min(360px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0,0,0,.5); overflow: hidden; }
.up-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--border); font-weight: 700; }
.up-list { max-height: 46vh; overflow-y: auto; padding: 8px 14px 14px; }
.up-item { padding: 8px 0; }
.up-item .row { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; margin-bottom: 5px; }
.up-item .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .st { color: var(--muted); white-space: nowrap; }
.up-item .st.ok { color: #86efac; } .up-item .st.err { color: #fca5a5; }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.drop-hint { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center;
  background: rgba(99,102,241,.14); border: 3px dashed var(--accent); }
.drop-hint div { background: var(--surface); padding: 20px 34px; border-radius: var(--radius);
  font-size: 1.3rem; font-weight: 700; }

/* ---------- Admin ---------- */
.admin-wrap { padding: 20px; max-width: 900px; margin: 0 auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
.mono { font-family: ui-monospace, monospace; }
.muted { color: var(--muted); }
.pill { padding: 3px 10px; border-radius: 999px; background: var(--surface-3); font-size: .8rem; font-weight: 600; }
.pill-red { background: rgba(220,38,38,.2); color: #fca5a5; }
