/* Surveillance Vault — thème sombre prioritaire, mobile first */
:root {
  --bg: #0a0a0c;
  --bg-elev: #111215;
  --card: #16171b;
  --card-hover: #1c1d22;
  --border: #25272d;
  --text: #f2f2f4;
  --muted: #9b9da5;
  --faint: #6b6d75;
  --accent: #b3243c;
  --accent-strong: #d2364f;
  --accent-soft: rgba(179, 36, 60, 0.16);
  --ok: #2fbf71;
  --warn: #f0a020;
  --err: #e5484d;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f4f6; --bg-elev: #ffffff; --card: #ffffff; --card-hover: #f7f7f9;
    --border: #e2e3e8; --text: #15161a; --muted: #5d5f67; --faint: #8a8c94;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ structure */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.04em; font-size: 14px; text-transform: uppercase; }
.brand svg { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-bottom)); }
.page-title { font-size: 26px; font-weight: 700; margin: 4px 0 16px; letter-spacing: -0.01em; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 24px 0 10px; font-weight: 600; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: var(--tap); justify-content: center;
  text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 500;
  border-radius: var(--radius-sm);
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--text); }
.tabbar a[aria-current="page"] svg { color: var(--accent-strong); }

@media (min-width: 900px) {
  .app { flex-direction: row; }
  .tabbar {
    position: sticky; top: 0; height: 100vh; width: 220px; flex: none;
    display: flex; flex-direction: column; gap: 4px; padding: 20px 12px;
    border-top: 0; border-right: 1px solid var(--border);
  }
  .tabbar::before { content: "Surveillance Vault"; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; padding: 0 12px 18px; color: var(--muted); }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: 15px; }
  .tabbar a[aria-current="page"] { background: var(--card); }
  .shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .main { padding-bottom: 40px; }
  .topbar .brand { display: none; }
}

/* ------------------------------------------------------------------ cartes */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid .wide { grid-column: 1 / -1; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.card h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card .big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.card .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card.link { text-decoration: none; display: block; transition: background 0.15s; }
.card.link:hover { background: var(--card-hover); }

.hero {
  display: flex; align-items: center; gap: 14px; padding: 18px;
  background: linear-gradient(135deg, var(--accent-soft), transparent 60%), var(--card);
}
.hero .title { font-size: 18px; font-weight: 600; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(47, 191, 113, 0.15); }
.dot.warning { background: var(--warn); box-shadow: 0 0 0 4px rgba(240, 160, 32, 0.15); }
.dot.error { background: var(--err); box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.15); }

.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--accent-strong); border-radius: 3px; }

.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .label { flex: 1; min-width: 0; }
.row .value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* ------------------------------------------------------------------ formulaires */
.form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--faint); margin-top: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-width: 0; /* WebKit : largeur intrinsèque des champs sinon débordante */ min-height: var(--tap); padding: 12px 14px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; font-size: 16px; /* 16px : pas de zoom auto sur iOS */
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; gap: 12px; align-items: center; min-height: var(--tap); padding: 10px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent-strong); flex: none; margin: 0; }
/* une case dans un .field ne doit pas hériter du style des libellés de champ */
.field label.check { display: flex; margin: 0; color: var(--text); font-size: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--card-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.icon { padding: 0; width: var(--tap); }
.btn svg { width: 20px; height: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elev); font-size: 14px; }
.alert.error { border-color: rgba(229, 72, 77, 0.4); background: rgba(229, 72, 77, 0.08); }
.alert.warning { border-color: rgba(240, 160, 32, 0.4); background: rgba(240, 160, 32, 0.08); }
.alert.ok { border-color: rgba(47, 191, 113, 0.4); background: rgba(47, 191, 113, 0.08); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 13px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent-strong);
}
.chip.neutral { background: var(--border); color: var(--muted); }
.chip.ok { background: rgba(47, 191, 113, 0.14); color: var(--ok); }
.chip.warning { background: rgba(240, 160, 32, 0.14); color: var(--warn); }

/* ------------------------------------------------------------------ pages pleines (setup, login) */
.center-page { width: 100%; overflow-x: hidden; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
.panel { width: 100%; max-width: 460px; min-width: 0; }
.panel .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.panel .logo svg { width: 40px; height: 40px; }
.panel h1 { font-size: 24px; margin: 0 0 6px; }
.panel p.lead { color: var(--muted); margin: 0 0 20px; }
.steps { display: flex; gap: 4px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps span.done { background: var(--accent); }
.steps span.current { background: var(--accent-strong); }

.recovery-code {
  font-family: var(--mono); font-size: 17px; line-height: 1.8; letter-spacing: 0.04em;
  padding: 16px; border-radius: var(--radius-sm); background: var(--bg-elev);
  border: 1px dashed var(--accent); word-break: break-all; text-align: center; user-select: all;
}
.fingerprint { font-family: var(--mono); font-size: 22px; letter-spacing: 0.08em; text-align: center; padding: 12px; }

/* ------------------------------------------------------------------ chargement / toasts */
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent-strong); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 40px; }
.skeleton { background: linear-gradient(90deg, var(--card) 0%, var(--card-hover) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts { position: fixed; z-index: 100; left: 16px; right: 16px; bottom: calc(84px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: 460px; width: 100%; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); font-size: 14px; animation: rise 0.2s ease-out; }
.toast.error { border-color: rgba(229, 72, 77, 0.5); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.offline-banner { position: sticky; top: 0; z-index: 50; background: var(--warn); color: #111; text-align: center; font-size: 13px; font-weight: 600; padding: calc(4px + var(--safe-top)) 8px 4px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty svg { width: 42px; height: 42px; margin: 0 auto 12px; color: var(--faint); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ------------------------------------------------------------------ timeline */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1; }
.filters { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
.filters .field label { font-size: 13px; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.chips button { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--border); background: var(--card); font-size: 14px; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.day-heading { position: sticky; top: calc(56px + var(--safe-top)); z-index: 5; padding: 10px 0 6px; background: var(--bg); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) {
  .timeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
  .timeline .day-heading { grid-column: 1 / -1; top: 0; }
  .event-item { flex-direction: column; align-items: stretch; }
  .event-item .thumb { width: 100%; }
}
.event-item {
  display: flex; gap: 12px; align-items: center; padding: 8px; text-decoration: none;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  content-visibility: auto; contain-intrinsic-size: auto 96px;
}
.event-item:hover { background: var(--card-hover); }
.thumb { position: relative; width: 132px; flex: none; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--bg-elev); }
.thumb img { width: 100%; height: 100%; object-fit: cover; animation: fade 0.25s ease-out; }
.thumb:not(.loaded):not(.no-thumb) { background: linear-gradient(90deg, var(--bg-elev) 0%, var(--card-hover) 50%, var(--bg-elev) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.thumb.no-thumb::after { content: ""; position: absolute; inset: 0; background: center / 28px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6d75' stroke-width='1.6'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 16 5-5 4 4 3-3 6 6'/%3E%3C/svg%3E"); }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px; font-size: 12px; font-weight: 600; background: rgba(0, 0, 0, 0.65); color: #fff; font-variant-numeric: tabular-nums; }
@keyframes fade { from { opacity: 0; } }
.event-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.event-meta .time { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.event-meta .where { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-meta .tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.star { color: var(--faint); background: none; border: 0; padding: 8px; margin: -8px; cursor: pointer; }
.star svg { width: 22px; height: 22px; }
.star[aria-pressed="true"] { color: #f5c542; }
.sentinel { height: 40px; }

/* ------------------------------------------------------------------ calendrier */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head h2 { flex: 1; margin: 0; font-size: 20px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 640px; margin: 0 auto; }
.cal-head { max-width: 640px; margin-left: auto; margin-right: auto; }
.cal-grid .dow { text-align: center; font-size: 12px; color: var(--faint); font-weight: 600; text-transform: uppercase; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; background: var(--card); border: 1px solid var(--border); text-decoration: none; font-variant-numeric: tabular-nums;
}
.cal-day.cal-empty { background: transparent; border-color: transparent; color: var(--faint); }
.cal-day.today { border-color: var(--accent-strong); }
.cal-day .n { font-weight: 600; }
.cal-day .count { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 8px; padding: 0 6px; min-width: 20px; text-align: center; }
.cal-day.heat-2 { background: color-mix(in srgb, var(--accent) 18%, var(--card)); }
.cal-day.heat-3 { background: color-mix(in srgb, var(--accent) 34%, var(--card)); }

/* ------------------------------------------------------------------ lecteur */
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; outline: none; user-select: none; -webkit-user-select: none; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.player-center[hidden] { display: none; }
.player-big { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 72px; height: 72px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(6px); }
.player-big svg { width: 32px; height: 32px; margin-left: 4px; }
.player-message { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); text-align: center; padding: 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 14px; }
.player-message.info { background: rgba(0, 0, 0, 0.55); }
.player-controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 10px 6px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); color: #fff; transition: opacity 0.25s; }
.player.playing:not(.show-controls) .player-controls { opacity: 0; pointer-events: none; }
.player-track { position: relative; height: 22px; display: flex; align-items: center; }
.player-buffered { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); pointer-events: none; }
.player-progress { position: relative; width: 100%; margin: 0; accent-color: var(--accent-strong); background: transparent; }
.player-row { display: flex; align-items: center; gap: 2px; }
.player-row .spacer { flex: 1; }
.pbtn { width: 40px; height: 40px; border: 0; background: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; }
.pbtn:hover { background: rgba(255, 255, 255, 0.12); }
.pbtn svg { width: 22px; height: 22px; }
.pbtn.ptext { width: auto; padding: 0 8px; font-weight: 700; font-size: 14px; }
.ptime, .preal { font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.preal { color: rgba(255, 255, 255, 0.8); }
.pvolume { width: 80px; accent-color: #fff; }
@media (max-width: 600px) { .pvolume, .preal { display: none; } }

.event-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.event-head h1 { margin: 0; font-size: 20px; }
.event-head .sub { color: var(--muted); font-size: 14px; }
.event-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
dialog { padding: 20px; }
.request-card { border-color: var(--accent); }

/* ------------------------------------------------------------------ direct */
.live-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .live-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.live-card { padding: 0; overflow: hidden; }
.live-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; }
.live-head .spacer { flex: 1; }
.live-stage { aspect-ratio: 16 / 9; background: #000; position: relative; }
.live-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.live-start { position: absolute; inset: 0; width: 100%; border: 0; background: none; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 600; }
.live-start svg { width: 40px; height: 40px; }

/* icônes : taille par défaut, jamais déformées */
svg[aria-hidden="true"] { flex: none; }
.row > svg { width: 20px; height: 20px; color: var(--muted); }
.row > svg:last-child { color: var(--faint); }
.empty svg { display: block; }

/* ======================================================================
   Animations et micro-interactions
   Durées courtes (120–350 ms), courbes douces, rien de bloquant.
   ====================================================================== */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* entrée de page : le contenu monté juste après une navigation glisse en place, en cascade */
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
.main[data-enter] > * { animation: page-in 0.32s var(--ease-out) both; }
.main[data-enter] > *:nth-child(2) { animation-delay: 30ms; }
.main[data-enter] > *:nth-child(3) { animation-delay: 60ms; }
.main[data-enter] > *:nth-child(4) { animation-delay: 90ms; }
.main[data-enter] > *:nth-child(5) { animation-delay: 120ms; }
.main[data-enter] > *:nth-child(n + 6) { animation-delay: 150ms; }
.main[data-enter] .grid > * { animation: page-in 0.36s var(--ease-out) both; animation-delay: calc(80ms + var(--i, 0) * 35ms); }

/* panneaux plein écran (connexion, assistant) : chaque étape arrive en douceur */
@keyframes panel-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } }
.center-page .panel { animation: panel-in 0.4s var(--ease-out) both; }
.steps span { transition: background-color 0.4s var(--ease-out), transform 0.4s var(--ease-out); }
.steps span.current { transform: scaleY(1.5); }

/* barre d'onglets : pastille active et icône qui « répond » au toucher */
.tabbar a { position: relative; transition: color 0.2s ease; }
.tabbar a svg { transition: transform 0.25s var(--ease-spring), color 0.2s ease; }
.tabbar a:active svg { transform: scale(0.86); }
.tabbar a[aria-current="page"] svg { transform: translateY(-1px); }
@media (max-width: 899px) {
  .tabbar a::before {
    content: ""; position: absolute; top: 4px; left: 50%; width: 44px; height: 30px; border-radius: 15px;
    background: var(--accent-soft); transform: translateX(-50%) scale(0.6); opacity: 0;
    transition: transform 0.3s var(--ease-spring), opacity 0.2s ease;
  }
  .tabbar a[aria-current="page"]::before { transform: translateX(-50%) scale(1); opacity: 1; }
  .tabbar a svg, .tabbar a span { position: relative; }
}
@media (min-width: 900px) { .tabbar a { transition: background-color 0.2s ease, color 0.2s ease; } .tabbar a:hover { background: var(--card); } }

/* boutons */
.btn { transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s var(--ease-out), box-shadow 0.2s ease; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(179, 36, 60, 0.35); }
.btn:focus-visible, .row:focus-visible, .event-item:focus-visible, a.card:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* cartes et lignes cliquables */
.card.link, .event-item, a.row, .cal-day { transition: background-color 0.18s ease, transform 0.2s var(--ease-out), box-shadow 0.2s ease, border-color 0.18s ease; }
.card.link:active, .event-item:active, a.row:active { transform: scale(0.985); }
a.row .label { transition: transform 0.2s var(--ease-out); }
a.row > svg:last-child { transition: transform 0.2s var(--ease-out), color 0.2s ease; }
@media (hover: hover) {
  .card.link:hover, .event-item:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); border-color: color-mix(in srgb, var(--border) 50%, var(--accent) 50%); }
  a.row:hover > svg:last-child { transform: translateX(3px); color: var(--text); }
  a.cal-day:hover { transform: scale(1.06); border-color: var(--accent-strong); }
  .thumb img { transition: transform 0.4s var(--ease-out); }
  .event-item:hover .thumb img { transform: scale(1.05); }
}

/* champs */
input, select, textarea { transition: border-color 0.15s ease, box-shadow 0.2s ease; }
@keyframes check-pop { 50% { transform: scale(1.18); } }
.check input:checked { animation: check-pop 0.25s var(--ease-spring); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.alert.error:not([hidden]) { animation: shake 0.35s ease; }

/* timeline : chaque nouvel événement apparaît en cascade (seulement les nouveaux) */
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } }
.event-item { animation: item-in 0.35s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 28ms); }
.day-heading { animation: item-in 0.3s var(--ease-out) both; }
.skeleton-item { height: 92px; border-radius: var(--radius); border: 1px solid var(--border); }
@media (min-width: 900px) { .skeleton-item { height: 230px; } }

/* favori : étoile qui « éclate » */
@keyframes star-pop { 0% { transform: scale(1); } 35% { transform: scale(1.45) rotate(-12deg); } 70% { transform: scale(0.92); } 100% { transform: scale(1); } }
@keyframes star-ring { from { transform: scale(0.4); opacity: 0.8; } to { transform: scale(1.8); opacity: 0; } }
.star, .btn.fav { position: relative; }
.star.pop svg, .btn.fav.pop svg { animation: star-pop 0.45s var(--ease-out); }
.star.pop::after { content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #f5c542; animation: star-ring 0.5s ease-out forwards; pointer-events: none; }
.star[aria-pressed="true"] svg, .btn.fav[aria-pressed="true"] svg { color: #f5c542; filter: drop-shadow(0 0 6px rgba(245, 197, 66, 0.45)); }

/* états : le point vert « respire », l'erreur attire l'œil sans clignoter */
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 4px rgba(47, 191, 113, 0.15); } 50% { box-shadow: 0 0 0 7px rgba(47, 191, 113, 0.05); } }
@keyframes alarm { 0%, 100% { box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.18); } 50% { box-shadow: 0 0 0 8px rgba(229, 72, 77, 0.04); } }
.hero .dot.ok, .live-head .dot.ok { animation: breathe 2.8s ease-in-out infinite; }
.hero .dot.error { animation: alarm 1.6s ease-in-out infinite; }
.bar > span { transition: width 0.9s var(--ease-out); }
.main[data-enter] .bar > span { animation: bar-grow 0.9s var(--ease-out) both; animation-delay: 0.15s; }
@keyframes bar-grow { from { width: 0; } }

/* toasts : entrée par le bas, sortie en fondu */
.toast { animation: toast-in 0.32s var(--ease-spring); transition: opacity 0.2s ease, transform 0.2s ease; }
.toast.leaving { opacity: 0; transform: translateY(6px) scale(0.98); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }

/* boîtes de dialogue */
dialog[open] { animation: panel-in 0.28s var(--ease-out); }
dialog[open]::backdrop { animation: fade 0.25s ease; }

/* calendrier : glissement selon le sens de navigation */
@keyframes cal-next { from { opacity: 0; transform: translateX(24px); } }
@keyframes cal-prev { from { opacity: 0; transform: translateX(-24px); } }
.cal-grid.from-next { animation: cal-next 0.3s var(--ease-out); }
.cal-grid.from-prev { animation: cal-prev 0.3s var(--ease-out); }
.cal-day .count { transition: transform 0.2s var(--ease-spring); }
a.cal-day:hover .count { transform: scale(1.12); }

/* lecteur : gros bouton lecture, double-tap ±10 s */
.player-big { transition: transform 0.2s var(--ease-spring), background-color 0.2s ease; }
.player-big:hover { transform: translate(-50%, -50%) scale(1.08); background: rgba(179, 36, 60, 0.75); }
.player-big:active { transform: translate(-50%, -50%) scale(0.94); }
.player-skip {
  position: absolute; top: 0; bottom: 0; width: 38%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; pointer-events: none; opacity: 0;
}
.player-skip.left { left: 0; border-radius: 0 50% 50% 0 / 0 50% 50% 0; background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.18), transparent 70%); }
.player-skip.right { right: 0; border-radius: 50% 0 0 50% / 50% 0 0 50%; background: radial-gradient(circle at 70% 50%, rgba(255, 255, 255, 0.18), transparent 70%); }
.player-skip.show { animation: skip-flash 0.6s ease-out; }
@keyframes skip-flash { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
.pbtn { transition: background-color 0.15s ease, transform 0.12s var(--ease-out); }
.pbtn:active { transform: scale(0.9); }

/* code de récupération et empreinte : révélation douce */
@keyframes reveal { from { opacity: 0; filter: blur(6px); letter-spacing: 0.2em; } }
.recovery-code, .fingerprint { animation: reveal 0.6s var(--ease-out) both; }

/* respect du réglage « réduire les animations » */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ======================================================================
   Accueil
   ====================================================================== */
.home-hello { margin: 8px 0 14px; }
.home-date { margin: 0; color: var(--muted); font-size: 14px; }
.home-title { margin: 2px 0 6px; font-size: 32px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.home-summary { margin: 0; color: var(--muted); font-size: 16px; }

.home-status {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--card);
  text-decoration: none; font-size: 15px; font-weight: 500;
  transition: background-color 0.18s ease, transform 0.15s var(--ease-out);
}
.home-status .home-status-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-status > svg { width: 18px; height: 18px; color: var(--faint); }
.home-status.ok { background: linear-gradient(90deg, rgba(47, 191, 113, 0.1), var(--card) 70%); }
.home-status.ok .dot { animation: breathe 2.8s ease-in-out infinite; }
.home-status.warning { border-color: rgba(240, 160, 32, 0.45); background: rgba(240, 160, 32, 0.08); }
.home-status.error { border-color: rgba(229, 72, 77, 0.5); background: rgba(229, 72, 77, 0.1); }
.home-status.error .dot { animation: alarm 1.6s ease-in-out infinite; }
.home-status:active { transform: scale(0.985); }

.home-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.home-alert {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); text-decoration: none;
}
.home-alert > svg:first-child { width: 24px; height: 24px; color: var(--accent-strong); }
.home-alert > div { flex: 1; min-width: 0; font-size: 14px; }
.home-alert strong { font-size: 15px; }
.home-alert > svg:last-child { width: 18px; height: 18px; color: var(--muted); }

.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 4px 0 8px; }
@media (min-width: 900px) { .quick-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.quick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 12px 12px;
  min-height: 104px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border);
  text-decoration: none; transition: background-color 0.18s ease, transform 0.18s var(--ease-out), border-color 0.18s ease;
}
.quick-top { display: flex; align-items: flex-start; justify-content: space-between; width: 100%; margin-bottom: 8px; }
.quick-badge { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.quick-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 8px;
  background: var(--accent-soft); color: var(--accent-strong); transition: transform 0.25s var(--ease-spring);
}
.quick-top .quick-icon { margin-bottom: 0; }
.quick-icon svg { width: 22px; height: 22px; }
.quick-label { font-weight: 650; font-size: 15px; }
.quick-hint { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.quick:active { transform: scale(0.96); }
.quick:active .quick-icon { transform: scale(0.9); }
@media (hover: hover) {
  .quick:hover { background: var(--card-hover); border-color: color-mix(in srgb, var(--border) 40%, var(--accent) 60%); transform: translateY(-2px); }
  .quick:hover .quick-icon { transform: scale(1.08) rotate(-4deg); }
}
.main[data-enter] .quick { animation: page-in 0.36s var(--ease-out) both; }
.main[data-enter] .quick:nth-child(2) { animation-delay: 40ms; }
.main[data-enter] .quick:nth-child(3) { animation-delay: 80ms; }
.main[data-enter] .quick:nth-child(4) { animation-delay: 120ms; }
.main[data-enter] .quick:nth-child(5) { animation-delay: 160ms; }
.main[data-enter] .quick:nth-child(6) { animation-delay: 200ms; }

.home-section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.section-head a { color: var(--accent-strong); text-decoration: none; font-weight: 600; font-size: 14px; }
.section-head .muted { font-size: 14px; }

.latest { position: relative; display: block; border-radius: calc(var(--radius) + 4px); overflow: hidden; text-decoration: none; transition: transform 0.25s var(--ease-out); }
.latest .latest-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: 0; }
.latest-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 30%, rgba(0, 0, 0, 0.78));
}
.latest-play {
  align-self: center; margin-top: auto; margin-bottom: auto; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: #fff; transition: transform 0.25s var(--ease-spring), background-color 0.2s ease;
}
.latest-play svg { width: 28px; height: 28px; margin-left: 3px; }
.latest-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: rgba(255, 255, 255, 0.85); font-size: 14px; }
.latest-meta strong { color: #fff; font-size: 17px; }
.latest-meta .chip { background: rgba(179, 36, 60, 0.85); color: #fff; }
.latest:active { transform: scale(0.985); }
@media (hover: hover) {
  .latest:hover .latest-play { transform: scale(1.1); background: rgba(179, 36, 60, 0.85); }
  .latest:hover .latest-thumb img { transform: scale(1.03); }
}
@media (min-width: 900px) { .latest { max-width: 760px; } }

.strip {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px;
  margin: 0 -16px; padding-left: 16px; padding-right: 16px; scroll-padding-inline: 16px; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip-item {
  flex: none; width: 168px; scroll-snap-align: start; text-decoration: none;
  animation: item-in 0.35s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms);
}
.strip-item .thumb { width: 100%; border-radius: 12px; transition: transform 0.2s var(--ease-out); }
.strip-item:active .thumb { transform: scale(0.96); }
.strip-meta { display: flex; flex-direction: column; padding: 6px 2px 0; font-size: 13px; color: var(--muted); }
.strip-meta strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.strip-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cam-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .cam-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cam-tile { position: relative; display: block; border-radius: var(--radius); overflow: hidden; text-decoration: none; background: var(--card); border: 1px solid var(--border); transition: transform 0.2s var(--ease-out), border-color 0.2s ease; }
.cam-thumb { width: 100%; border-radius: 0; }
.cam-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.cam-name { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.cam-tile:active { transform: scale(0.97); }
@media (hover: hover) { .cam-tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--border) 40%, var(--accent) 60%); } }

.home-footer {
  display: flex; align-items: center; gap: 8px; margin-top: 26px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px dashed var(--border); text-decoration: none; font-size: 14px; color: var(--muted);
}
.home-footer svg { width: 18px; height: 18px; }
.home-footer > svg:first-child { color: var(--accent-strong); }
.home-footer .spacer { flex: 1; }
.home-footer .sep { color: var(--faint); }
@media (max-width: 520px) { .home-footer .sep, .home-footer > span:nth-child(4), .home-footer .spacer + .muted { display: none; } .home-footer .spacer { flex: 1; } }

.home-columns { display: flex; flex-direction: column; }
@media (min-width: 1100px) {
  .home-columns { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .home-columns .latest { max-width: none; }
  .home-columns .cam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
