/* Watch Dogs — console de vidéosurveillance personnelle.
   Fond pierre, surfaces plâtre, écrans encre. L'ambre ne sert qu'aux mouvements, le rouge qu'à REC. */
:root {
  --stone: #e4e6e3; --plaster: #f4f5f2; --white: #fbfbf9;
  --ink: #14201e; --ink-2: #1b2a27; --ink-3: #0d1614;
  --text: #17231f; --muted: #5c6965; --line: #cbd0ca; --line-soft: #dadeda;
  --pine: #1e5148; --pine-hi: #266a5e; --pine-tint: #dbe7e3; --teal: #36a08c;
  --amber: #ff9a1f; --amber-hi: #ffb552; --red: #d9402f; --red-tint: #f6dcd8;
  --ok-tint: #d9eadf; --ok: #1d6b45;
  --strong: #14201e; --link: #1e5148; --link-hi: #266a5e; --focus: #1e5148; --line-hi: var(--line-hi); --glow: #f1f3ef;
  --alert-bd: #e8bbb5; --alert-fg: #7d2118; --notice-bd: #b9d6c4; --notice-fg: #14502f; --danger-fg: #d9402f; --danger-bd: #e3b4ad; --pill-bad: #8a261a;
  color-scheme: light;
  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --rail: 232px;
}
/* ---------- Thème sombre : choisi par le bouton, sinon suit le réglage de l'appareil ---------- */
:root[data-theme="dark"] {
  --stone: #0d1311; --plaster: #151f1c; --white: #1a2623;
  --ink: #101a17; --ink-2: #17231f; --ink-3: #080d0c;
  --text: #dbe5e1; --muted: #93a39d; --line: #2b3935; --line-soft: #223029;
  --pine-hi: #2a6d60; --pine-tint: #1b2e29; --teal: #3fb39d;
  --red-tint: #3a1c19; --ok-tint: #173126; --ok: #6fd49c;
  --strong: #eef4f1; --link: #6cc9b3; --link-hi: #94dccb; --focus: #6cc9b3; --line-hi: #46564f; --glow: #17231f;
  --alert-bd: #6a2e28; --alert-fg: #ffb4a8; --notice-bd: #2c5a44; --notice-fg: #a7e3c3; --danger-fg: #ff8a7a; --danger-bd: #6a2e28; --pill-bad: #ffb4a8;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --stone: #0d1311; --plaster: #151f1c; --white: #1a2623;
    --ink: #101a17; --ink-2: #17231f; --ink-3: #080d0c;
    --text: #dbe5e1; --muted: #93a39d; --line: #2b3935; --line-soft: #223029;
    --pine-hi: #2a6d60; --pine-tint: #1b2e29; --teal: #3fb39d;
    --red-tint: #3a1c19; --ok-tint: #173126; --ok: #6fd49c;
    --strong: #eef4f1; --link: #6cc9b3; --link-hi: #94dccb; --focus: #6cc9b3; --line-hi: #46564f; --glow: #17231f;
    --alert-bd: #6a2e28; --alert-fg: #ffb4a8; --notice-bd: #2c5a44; --notice-fg: #a7e3c3; --danger-fg: #ff8a7a; --danger-bd: #6a2e28; --pill-bad: #ffb4a8;
      color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--stone); color: var(--text); font: 15px/1.55 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hi); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.012em; line-height: 1.2; color: var(--strong); }
h1 { font-size: 1.65rem; font-weight: 650; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; font-weight: 650; margin: 0 0 .75rem; }
p { margin: 0 0 .85rem; }
code { font: .86em ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--stone); border: 1px solid var(--line-soft); border-radius: 6px; padding: .08em .4em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Formulaires ---------- */
label { display: block; margin: 0 0 14px; font-size: .9rem; font-weight: 550; color: var(--strong); }
input, select { display: block; width: 100%; min-height: 42px; margin-top: 6px; padding: 9px 12px; font: inherit; font-weight: 400; color: var(--text); background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
input:hover, select:hover { border-color: var(--line-hi); }
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input.code { font-size: 1.5rem; letter-spacing: .22em; text-align: center; font-weight: 600; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%235c6965' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
:root[data-theme="dark"] select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%2393a39d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%2393a39d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>"); } }
button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px; font: inherit; font-weight: 600; text-align: center; text-decoration: none; color: #fff; background: var(--pine); border: 1px solid var(--pine); border-radius: 8px; cursor: pointer; }
button:hover, a.button:hover { background: var(--pine-hi); border-color: var(--pine-hi); color: #fff; }
button:active { transform: translateY(1px); }
button.ghost { min-height: 36px; padding: 6px 12px; color: var(--strong); background: transparent; border-color: var(--line); font-weight: 550; }
button.ghost:hover { background: var(--plaster); border-color: var(--line-hi); color: var(--strong); }
button.danger { color: var(--danger-fg); border-color: var(--danger-bd); }
button.danger:hover { background: var(--red-tint); color: var(--danger-fg); border-color: var(--danger-fg); }
button:disabled { opacity: .4; cursor: default; transform: none; background: transparent; }
form button[type=submit]:not(.ghost) { margin-top: 4px; }
label.check { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1rem; }
label.check input { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--pine); }
details { margin: 4px 0 16px; }
summary { cursor: pointer; font-size: .9rem; font-weight: 550; color: var(--link); }
details[open] summary { margin-bottom: 10px; }

/* ---------- Messages ---------- */
.alert, .notice { margin: 0 0 16px; padding: 11px 14px; border-radius: 8px; border: 1px solid; font-size: .93rem; }
.alert { background: var(--red-tint); border-color: var(--alert-bd); color: var(--alert-fg); }
.notice { background: var(--ok-tint); border-color: var(--notice-bd); color: var(--notice-fg); }
.notice a, .alert a { color: inherit; font-weight: 600; }
.alert.small { font-size: .85rem; }

/* ---------- Connexion / 2FA (pages sans menu) ---------- */
body.center { display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 50% -10%, var(--glow) 0, transparent 70%), var(--stone); }
.card { width: 100%; max-width: 480px; padding: 28px; background: var(--plaster); border: 1px solid var(--line); border-radius: 14px; }
.card.narrow { max-width: 390px; }
body.center .card h1 { margin-top: 18px; }
.mark { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--strong); text-decoration: none; letter-spacing: -.01em; }
.lens { flex: none; width: 30px; height: 30px; }
.steps { padding-left: 1.2rem; color: var(--muted); }
.steps li { margin-bottom: .35rem; }
.qr { background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: 12px; width: 240px; max-width: 100%; margin: 14px auto; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: block; text-align: center; font-size: 1.02rem; letter-spacing: .08em; padding: 8px; }
ul.codes { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
ul.codes li { text-align: center; }
ul.codes code { display: block; padding: 9px; font-size: 1rem; letter-spacing: .08em; background: var(--white); }

/* ---------- Gabarit : menu latéral + scène ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 18px; background: var(--ink); color: #dfe8e4; }
.rail .mark { color: #fff; padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #b7c4bf; font-weight: 550; text-decoration: none; }
.nav-item svg { flex: none; width: 20px; height: 20px; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.on { background: rgba(255, 255, 255, .11); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.rail-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, .12); display: flex; flex-direction: column; gap: 10px; }
.rail-foot .who { font-size: .9rem; color: #b7c4bf; overflow: hidden; text-overflow: ellipsis; }
.rail-foot form { margin: 0; }
.rail-foot button.ghost { width: 100%; color: #dfe8e4; border-color: rgba(255, 255, 255, .22); }
.rail-foot button.ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .4); }
.mtop { display: none; }
.stage { min-width: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 30px 32px 56px; }
.pagehead { margin-bottom: 22px; }
.pagehead p { margin: 0; color: var(--muted); }
.crumbs { margin: 0 0 14px; font-size: .92rem; }
.crumbs a { font-weight: 550; }
.crumbs span { color: var(--muted); margin: 0 6px; }

/* ---------- Mur de caméras ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.tile { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--ink-3); border: 5px solid var(--ink); border-radius: 12px; outline: 1px solid var(--line); text-decoration: none; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--pine); transform: translateY(-2px); }
.tile video-stream { display: block; width: 100%; height: 100%; pointer-events: none; }
.tile video-stream video { object-fit: cover; }
.tile .label { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 8px; padding: 4px 11px 4px 9px; font-size: .88rem; font-weight: 600; color: #fff; background: rgba(13, 22, 20, .72); backdrop-filter: blur(6px); border-radius: 999px; }
.tile .label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.tile .rec, .rec { display: inline-block; padding: 0 7px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; line-height: 1.5; color: #fff; background: var(--red); border-radius: 4px; }
.full { background: var(--ink-3); border: 6px solid var(--ink); border-radius: 14px; overflow: hidden; outline: 1px solid var(--line); }
.full video-stream { display: block; width: 100%; }
video-stream video { width: 100%; height: 100%; object-fit: contain; background: var(--ink-3); }
.tile video::-webkit-media-controls, .tile video::-webkit-media-controls-enclosure, .tile video::-webkit-media-controls-panel { display: none !important; }
video-stream .info { font-size: .85rem; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }

/* ---------- Panneaux de réglages ---------- */
.card.wide { max-width: 760px; margin: 0 0 18px; padding: 24px 26px; }
.camlist { list-style: none; padding: 0; margin: 4px 0 14px; border-top: 1px solid var(--line); }
.camlist li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line-soft); }
.camlist li a { display: flex; align-items: center; gap: 10px; font-weight: 550; text-decoration: none; }
.camlist li a:hover { text-decoration: underline; }
.camlist form { margin: 0; }
.ico { flex: none; width: 18px; height: 18px; color: var(--muted); }
.camrow { padding: 16px 0; border-top: 1px solid var(--line-soft); margin: 0; }
.camrow:first-of-type { border-top: 0; padding-top: 4px; }
.camhead { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 8px; }
.pill { display: inline-block; padding: 1px 10px; font-size: .8rem; font-weight: 600; border-radius: 999px; background: var(--stone); color: var(--muted); }
.pill.ok { background: var(--ok-tint); color: var(--ok); }
.pill.bad { background: var(--red-tint); color: var(--pill-bad); }
.stat { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 4px; }
.stat strong { font-size: 1.15rem; font-weight: 650; }

/* ---------- Lecture + frise ---------- */
.play { max-width: 1240px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar select { width: auto; margin: 0; min-width: 200px; font-weight: 600; }
.daynav { display: flex; gap: 6px; align-items: center; }
.daynav input { width: auto; margin: 0; min-height: 36px; padding: 5px 10px; }
.daynav button { white-space: nowrap; }
.player { position: relative; aspect-ratio: 16 / 9; max-height: 68vh; margin: 0 auto; overflow: hidden; background: var(--ink-3); border: 6px solid var(--ink); border-radius: 14px; outline: 1px solid var(--line); }
.player video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--ink-3); }
.vmsg { position: absolute; inset: 0 0 auto 0; padding: 9px 14px; text-align: center; font-size: .92rem; color: #fff; background: rgba(13, 22, 20, .82); pointer-events: none; }

.tl-wrap { margin: 16px 0 18px; padding: 16px 18px 14px; color: #dfe8e4; background: var(--ink); border-radius: 14px; }
.tl-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; }
.tl-head strong { font-family: var(--font-display); font-size: 1.7rem; font-weight: 650; color: #fff; letter-spacing: .01em; }
.tl-head .muted { color: #92a39d; }
.tl { position: relative; height: 88px; overflow: hidden; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--ink-3); border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; }
.tl:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
#tl-grid, #tl-cover, #tl-events { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .09); }
.seg { position: absolute; bottom: 0; height: 24px; min-width: 2px; background: var(--teal); opacity: .8; border-right: 1px solid var(--ink-3); }
.ev { position: absolute; top: 12px; bottom: 0; min-width: 6px; margin-left: -1px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--amber-hi), var(--amber) 55%, #f27a05); outline: 1px solid rgba(255, 255, 255, .92); box-shadow: 0 0 12px 2px rgba(255, 154, 31, .7); }
.ev::before { content: ""; position: absolute; left: 50%; top: -9px; width: 0; height: 0; transform: translateX(-50%); border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid var(--amber-hi); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 5px rgba(0, 0, 0, .9); pointer-events: none; z-index: 3; }
.playhead::before { content: ""; position: absolute; left: 50%; top: -1px; width: 12px; height: 12px; transform: translateX(-50%); background: #fff; border-radius: 0 0 6px 6px; }
.tip { position: absolute; top: 5px; transform: translateX(-50%); padding: 1px 9px; font-size: .8rem; font-weight: 600; color: #14201e; background: #fff; border-radius: 6px; pointer-events: none; z-index: 4; }
.axis { position: relative; height: 22px; margin-top: 6px; font-size: .76rem; color: #92a39d; }
.axis span { position: absolute; top: 0; white-space: nowrap; }
.tl-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.tl-controls .spacer { flex: 1; min-width: 4px; }
.tl-controls select { width: auto; margin: 0; min-height: 36px; padding: 5px 30px 5px 10px; }
.tl-wrap button.ghost { color: #dfe8e4; border-color: rgba(255, 255, 255, .22); }
.tl-wrap button.ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .4); }
.tl-wrap button.ghost:disabled { color: #dfe8e4; background: transparent; }
:root .tl-wrap select, .tl-wrap select { color: #dfe8e4; background-color: var(--ink-2); border-color: rgba(255, 255, 255, .22); background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%23b7c4bf' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
.tl-wrap .muted { color: #92a39d; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin: 12px 0 0; color: #92a39d; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.lg-rec { background: var(--teal); }
.lg-ev { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.card.wide.evcard { max-width: none; margin: 0; }
.evlist { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; max-height: 220px; overflow: auto; }
.evbtn { gap: 9px; min-height: 36px; padding: 5px 12px; font-weight: 600; color: var(--strong); background: var(--white); border-color: var(--line); }
.evbtn:hover { background: var(--white); border-color: var(--amber); color: var(--strong); }
.evbtn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 154, 31, .25); }

/* ---------- Téléphone : barre d'onglets en bas ---------- */
@media (max-width: 820px) {
  .shell { display: block; padding-bottom: 68px; }
  .mtop { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--ink); }
  .mtop .mark { color: #fff; }
  .mtop form { margin: 0; }
  .mtop button.ghost { color: #dfe8e4; border-color: rgba(255, 255, 255, .25); min-height: 34px; }
  .rail { position: fixed; z-index: 20; left: 0; right: 0; top: auto; bottom: 0; height: auto; flex-direction: row; gap: 0; padding: 0 6px env(safe-area-inset-bottom); border-top: 1px solid rgba(255, 255, 255, .12); }
  .rail > .mark, .rail-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; }
  .nav-item { flex: 1; flex-direction: column; gap: 3px; padding: 9px 4px 8px; font-size: .72rem; text-align: center; border-radius: 0; }
  .nav-item.on { box-shadow: inset 0 3px 0 var(--amber); background: transparent; }
  .wrap { padding: 20px 16px 36px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 22px 18px; }
  .card.wide { padding: 20px 18px; max-width: none; }
  .toolbar select { width: 100%; }
  .daynav { width: 100%; }
  .daynav input { flex: 1; min-width: 0; }
  .player, .full { border-width: 4px; border-radius: 12px; }
  .tl-wrap { padding: 14px 12px 12px; margin-left: -4px; margin-right: -4px; }
  .tl { height: 96px; }
  .tl-controls .spacer { flex-basis: 100%; height: 0; }
}
.card:not(.wide) form > button[type=submit], .card:not(.wide) a.button { width: 100%; }
form + p.muted { margin-top: 16px; }

/* ---------- Lieux, édition des caméras ---------- */
.place { margin-bottom: 30px; }
.place > h2 { margin: 0 0 12px; font-size: 1.15rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.hint { margin: -6px 0 14px; }
.camlist li > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.actions { display: flex; align-items: center; gap: 8px; flex: none; }
.actions form { margin: 0; }
a.button.ghost { min-height: 36px; padding: 6px 12px; color: var(--strong); background: transparent; border-color: var(--line); font-weight: 550; }
a.button.ghost:hover { background: var(--plaster); border-color: var(--line-hi); color: var(--strong); }
.formactions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.folder { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
@media (max-width: 820px) {
  .two { grid-template-columns: 1fr; }
  .camlist li { flex-wrap: wrap; }
}
.formactions + p { margin-top: 14px; }

/* ================= Bouton de thème ================= */
.theme-btn svg { flex: none; width: 18px; height: 18px; }
.theme-btn svg, .theme-btn .tt { display: none; }
.theme-btn .ti-auto, .theme-btn .tt-auto { display: inline-block; }
html[data-theme="light"] .theme-btn .ti-auto, html[data-theme="light"] .theme-btn .tt-auto,
html[data-theme="dark"] .theme-btn .ti-auto, html[data-theme="dark"] .theme-btn .tt-auto { display: none; }
html[data-theme="light"] .theme-btn .ti-light, html[data-theme="light"] .theme-btn .tt-light,
html[data-theme="dark"] .theme-btn .ti-dark, html[data-theme="dark"] .theme-btn .tt-dark { display: inline-block; }
.rail-foot .theme-btn { justify-content: flex-start; gap: 10px; }
.mtop .theme-btn { min-width: 36px; padding: 6px 9px; }
.mtop .theme-btn .tt { display: none !important; }
.mtop-actions { display: flex; align-items: center; gap: 8px; }
.mtop-actions form { margin: 0; }

/* ================= Affichage des vignettes (Direct) ================= */
.layoutbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 18px; }
.layoutbar .lbl { margin-right: 6px; }
.lbtn { min-height: 34px; padding: 4px 13px; font-size: .88rem; font-weight: 600; color: var(--strong); background: var(--plaster); border: 1px solid var(--line); border-radius: 999px; }
.lbtn:hover { background: var(--white); border-color: var(--line-hi); color: var(--strong); }
.lbtn[aria-pressed="true"] { color: #fff; background: var(--pine); border-color: var(--pine); }
html[data-cols="1"] .grid { grid-template-columns: minmax(0, 820px); }
/* 2×2, 3×3, 4×4 : toutes les caméras dans une seule grille, le lieu passe sur la vignette */
html[data-cols="2"] .places, html[data-cols="3"] .places, html[data-cols="4"] .places { display: grid; gap: 18px; }
html[data-cols="2"] .places { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html[data-cols="3"] .places { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
html[data-cols="4"] .places { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
html[data-cols="2"] .place, html[data-cols="3"] .place, html[data-cols="4"] .place,
html[data-cols="2"] .place .grid, html[data-cols="3"] .place .grid, html[data-cols="4"] .place .grid { display: contents; }
html[data-cols="2"] .place > h2, html[data-cols="3"] .place > h2, html[data-cols="4"] .place > h2 { display: none; }
.tile .label { max-width: calc(100% - 20px); }
.tile .label .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label .pl { display: none; font-weight: 500; opacity: .75; }
html[data-cols="2"] .tile .label .pl, html[data-cols="3"] .tile .label .pl, html[data-cols="4"] .tile .label .pl { display: inline; }
html[data-cols="3"] .tile { border-width: 4px; }
html[data-cols="4"] .tile { border-width: 3px; border-radius: 9px; }
html[data-cols="4"] .tile .label { left: 6px; bottom: 6px; padding: 2px 8px 2px 7px; font-size: .74rem; gap: 6px; }
html[data-cols="4"] .tile .label::before { width: 6px; height: 6px; }
html[data-cols="4"] .tile .rec { font-size: .62rem; padding: 0 5px; }

/* ================= Animations (sobres) ================= */
.btn, button, a.button, .nav-item, .tile, .lbtn, .card, input, select { transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .2s ease, transform .16s ease; }
button:active, a.button:active { transform: scale(.975); }
.tile { transition: border-color .2s ease, transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s ease; }
.tile:hover { box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .45); }
.tile:active { transform: scale(.985); }
.tile .label { transition: background-color .2s ease; }
.tile:hover .label { background: rgba(13, 22, 20, .88); }
/* tant que l'image n'est pas là, la vignette respire */
.tile { background-image: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .06) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 2.2s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes tileIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.wrap > * { animation: rise .38s cubic-bezier(.2, .7, .2, 1) both; }
.wrap > *:nth-child(2) { animation-delay: .04s; }
.wrap > *:nth-child(3) { animation-delay: .08s; }
.wrap > *:nth-child(4) { animation-delay: .12s; }
.wrap > *:nth-child(n+5) { animation-delay: .16s; }
.card { animation: rise .4s cubic-bezier(.2, .7, .2, 1) both; }
.notice, .alert { animation: slideDown .3s ease both; }
.grid.anim .tile { animation: tileIn .42s cubic-bezier(.2, .7, .2, 1) both, shimmer 2.2s ease-in-out .42s infinite; }
.grid.anim .tile:nth-child(2) { animation-delay: .05s, .47s; }
.grid.anim .tile:nth-child(3) { animation-delay: .10s, .52s; }
.grid.anim .tile:nth-child(4) { animation-delay: .15s, .57s; }
.grid.anim .tile:nth-child(5) { animation-delay: .20s, .62s; }
.grid.anim .tile:nth-child(6) { animation-delay: .25s, .67s; }
.grid.anim .tile:nth-child(n+7) { animation-delay: .30s, .72s; }
.vmsg { animation: fade .25s ease both; }
.evbtn { transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.evbtn:hover { transform: translateY(-1px); }
.nav-item.on { transition: none; }
html.theming, html.theming *, html.theming *::before, html.theming *::after { transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ================= Téléphone : confort au pouce ================= */
html { -webkit-tap-highlight-color: transparent; }
button, a.button, .nav-item, .lbtn, summary { touch-action: manipulation; }
@media (pointer: coarse) {
  button, a.button { min-height: 46px; }
  button.ghost, a.button.ghost { min-height: 44px; padding: 8px 14px; }
  .lbtn { min-height: 40px; padding: 6px 16px; }
  .evbtn { min-height: 42px; }
  .daynav input { min-height: 44px; }
  .tl-controls button { min-width: 44px; }
  label.check input { width: 22px; height: 22px; min-height: 22px; }
  .camlist li { padding: 13px 2px; }
}
@media (max-width: 820px) {
  input, select { font-size: 16px; }              /* évite le zoom automatique sur iPhone */
  .mtop { padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left)); }
  .wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .nav-item { min-height: 56px; justify-content: center; font-size: .74rem; }
  .nav-item svg { width: 22px; height: 22px; }
  .rail { background: var(--ink); }
  .layoutbar .lbtn[data-cols="3"], .layoutbar .lbtn[data-cols="4"] { display: none; }
  html[data-cols="1"] .grid { grid-template-columns: 1fr; }
  html[data-cols="2"] .places, html[data-cols="3"] .places, html[data-cols="4"] .places { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  html[data-cols="2"] .tile, html[data-cols="3"] .tile, html[data-cols="4"] .tile { border-width: 3px; border-radius: 9px; }
  html[data-cols="2"] .tile .label, html[data-cols="3"] .tile .label, html[data-cols="4"] .tile .label { left: 5px; bottom: 5px; padding: 2px 8px 2px 7px; font-size: .72rem; gap: 6px; }
  html[data-cols="2"] .tile .rec, html[data-cols="3"] .tile .rec, html[data-cols="4"] .tile .rec { font-size: .6rem; padding: 0 4px; }
  .tl { height: 104px; }
  .tl-head strong { font-size: 1.5rem; }
  .evlist { max-height: 180px; }
  .camrow .actions, .actions { flex-wrap: wrap; }
  .toolbar { gap: 8px; }
  .play { padding-left: 12px; padding-right: 12px; }
}
body.center { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
