/* Style volontairement léger : polices système, icônes SVG intégrées, aucune dépendance.
   Look « classique » assumé : angles droits, contours nets, aplats opaques, boutons en relief,
   pas d'ombres floues ni d'animations — plus facile à lire et à prendre en main. */
:root {
  --bg: #fbfaf6;
  --card: #ffffff;
  --surface: #ffffff;       /* menus, fenêtres : toujours opaques */
  --fg: #1d1d1b;
  --muted: #5c5b55;
  --line: #e2e0d8;          /* fonds neutres (survol, pistes) */
  --border: #8c8a82;        /* contours des blocs, champs, tableaux */
  --accent: #2f6b3a;
  --accent-soft: #e2efe3;
  --warn: #b26a00;
  --warn-soft: #fbeed5;
  --danger: #a3321f;
  --danger-soft: #f8e1dc;
  --sun: #f6e9b4;
  --sun-strong: #d99a00;
  --radius: 0;
  --radius-sm: 0;
  --shadow: none;
  /* Relief des boutons : clair en haut à gauche, sombre en bas à droite (inversé quand on appuie). */
  --bevel: inset 2px 2px 0 rgba(255, 255, 255, .45), inset -2px -2px 0 rgba(0, 0, 0, .3);
  --bevel-pressed: inset 2px 2px 0 rgba(0, 0, 0, .3), inset -2px -2px 0 rgba(255, 255, 255, .25);
  --control-h: 40px;
  --gutter: 16px;
  --tabbar-h: 0px; /* hauteur de la barre d'onglets du bas, uniquement sur mobile */
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171714;
    --card: #1f1f1b;
    --surface: #242420;
    --fg: #ecebe5;
    --muted: #a8a69e;
    --line: #34332e;
    --border: #6e6c64;
    --accent: #7cc48a;
    --accent-soft: #23352a;
    --warn: #e0a43a;
    --warn-soft: #3a2e17;
    --danger: #e27a66;
    --danger-soft: #3d231d;
    --sun: #38331c;
    --sun-strong: #f0c24b;
    --bevel: inset 2px 2px 0 rgba(255, 255, 255, .2), inset -2px -2px 0 rgba(0, 0, 0, .5);
    --bevel-pressed: inset 2px 2px 0 rgba(0, 0, 0, .5), inset -2px -2px 0 rgba(255, 255, 255, .12);
  }
}

/* Couleur de fond selon l'affluence sur le drive : vert (peu utilisé), jaune (modérément), rouge (fortement).
   Fixée au vert tant que le nombre d'utilisateurs actifs n'est pas disponible (voir loadLevel dans energy.js). */
:root[data-load="low"] { --bg: #cfe8c9; }
:root[data-load="medium"] { --bg: #f6e3a4; }
:root[data-load="high"] { --bg: #f3c9c0; }
@media (prefers-color-scheme: dark) {
  :root[data-load="low"] { --bg: #1f3522; }
  :root[data-load="medium"] { --bg: #3a331a; }
  :root[data-load="high"] { --bg: #3d231d; }
}

/* ---------------------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
/* Les éléments stylés en flex/grid doivent quand même disparaître quand on leur met hidden. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 Verdana, Tahoma, "DejaVu Sans", "Segoe UI", sans-serif;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 1000px; margin: 0 auto; padding: var(--gutter); }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .35rem; }
h2 { font-size: 1.3rem; line-height: 1.25; margin: .75rem 0 .35rem; }
/* Titres de section des modules : petites majuscules, soulignées d'un trait. */
h3 {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0 0 .6rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
}
h4 { font-size: .95rem; margin: 1rem 0 .35rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; }
.good { color: var(--accent); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.big { font-size: 2.4rem; font-weight: 700; margin: 0; line-height: 1.1; }
.big-text { font-size: 1.2rem; font-weight: 600; }

/* Chiffres alignés partout où l'on affiche des mesures. */
.pill, .leaf-counter, .file-meta, .ring-label, .facts, .slots, .chip-count, .swatch, .big, .status {
  font-variant-numeric: tabular-nums;
}

/* Icônes SVG (voir ui.js) */
.ic { display: inline-flex; flex: none; width: 1.15em; height: 1.15em; vertical-align: -.2em; }
.ic svg { width: 100%; height: 100%; }
.ic.sun { color: var(--sun-strong); }
.hero-icon { width: 2.6rem; height: 2.6rem; color: var(--muted); }
.facts li { display: flex; align-items: flex-start; gap: .45rem; }
.facts li > .ic { margin-top: .15em; color: var(--accent); }

/* Contour clavier visible, sans gêner les clics à la souris. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------------------------------
   En-tête : marque, état du drive, compte
   --------------------------------------------------------------------------------------- */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: .6rem max(var(--gutter), env(safe-area-inset-right)) .6rem max(var(--gutter), env(safe-area-inset-left));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
}
.brand .ic { width: 1.4rem; height: 1.4rem; color: var(--sun-strong); }
.status { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .65rem;
  border-radius: 0;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
  background: var(--accent-soft);
  color: var(--accent);
}
.pill[data-tone="warn"], .pill[data-tone="medium"] { background: var(--warn-soft); color: var(--warn); }
.pill[data-tone="closed"], .pill[data-tone="low"] { background: var(--danger-soft); color: var(--danger); }
.pill[data-tone="none"] { background: var(--line); color: var(--muted); }
.account { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.leaf-counter {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .6rem;
  border-radius: 0;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.leaf-counter:hover { background: var(--accent-soft); }
/* Bandeau d'alerte, sous l'en-tête. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin: 0;
  padding: .55rem max(var(--gutter), env(safe-area-inset-left));
  font-size: .9rem;
  font-weight: 600;
  border-top: 1px solid var(--border);
  background: var(--warn-soft);
  color: var(--warn);
}
.banner .ic { margin-top: .1em; }
.banner[data-tone="closed"] { background: var(--danger-soft); color: var(--danger); }
.banner[data-tone="low"] { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------------------------------
   Onglets
   --------------------------------------------------------------------------------------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: .4rem var(--gutter) 0;
  border-bottom: 1px solid var(--border);
}
/* Onglets « intercalaires » : chaque onglet est une boîte, l'onglet actif se raccorde au contenu. */
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .8rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
  background: var(--line);
  border: 1px solid var(--border);
  border-bottom-color: var(--border);
  margin-bottom: -1px;
}
.tabs a:hover { background: var(--surface); }
.tabs a.active { background: var(--bg); border-bottom-color: var(--bg); border-top: 3px solid var(--accent); font-weight: 700; }
.tabs a.active .ic { color: var(--accent); }

/* ---------------------------------------------------------------------------------------
   Boutons et champs : 3 variantes (principal, secondaire, danger) + boutons discrets.
   --------------------------------------------------------------------------------------- */
button, .button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: var(--control-h);
  padding: .4rem 1rem;
  border: 1px solid var(--fg);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--bg);
  box-shadow: var(--bevel);
  touch-action: manipulation;
}
button:hover, .button:hover { filter: brightness(1.08); }
button:active, .button:active { box-shadow: var(--bevel-pressed); }
button.secondary { background: var(--surface); color: var(--accent); }
button.secondary:hover { background: var(--accent-soft); filter: none; }
button.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); filter: none; }
/* Boutons discrets : liens d'action, icônes. */
button.link { min-height: 0; padding: .25rem; border: none; background: none; box-shadow: none; color: var(--muted); font-weight: 500; text-decoration: underline; }
button.link.danger { color: var(--danger); }
button.ghost, .icon-btn {
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: var(--muted);
  font-weight: 500;
  padding: .4rem .6rem;
  min-height: 36px;
}
button.ghost:hover, .icon-btn:hover { background: var(--line); color: var(--fg); filter: none; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
button.small, .small { font-size: .85rem; min-height: 32px; padding: .2rem .6rem; }
button:disabled { opacity: .4; cursor: not-allowed; filter: none; box-shadow: none; }
/* Champs « en creux », comme sur les anciens formulaires. */
input {
  font: inherit;
  min-height: var(--control-h);
  padding: .4rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .25);
  background: var(--surface);
  color: inherit;
  max-width: 100%;
}
input:focus { border-color: var(--accent); }
select {
  font: inherit;
  min-height: var(--control-h);
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
}
select:focus { border-color: var(--accent); }
.deadline-field { display: flex; flex-wrap: wrap; gap: .4rem; font-weight: 400; }
input[type="number"] { width: 5.5em; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.15rem; height: 1.15rem; min-height: 0; box-shadow: none; }
label.inline { display: inline-flex; gap: .4rem; align-items: center; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin: .75rem 0; }
.row label { display: grid; gap: .2rem; }

/* ---------------------------------------------------------------------------------------
   Connexion / hors ligne
   --------------------------------------------------------------------------------------- */
.login { max-width: 440px; margin-top: 8vh; }
.login form { display: grid; gap: .85rem; margin-top: 1.25rem; }
.login label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.login input { width: 100%; }
.login .row { margin: .25rem 0 0; }
.login .row button { flex: 1 1 auto; }
#offline-view .hero-icon { color: var(--accent); margin-bottom: .5rem; }
.login form h3 { margin: 0; }
.switch-form { margin: 0; font-size: .9rem; }
.switch-form button.link { color: var(--accent); font-weight: 700; padding: 0 .1rem; }
/* Choix du profil à l'inscription : cadre « groupe d'options » à l'ancienne. */
.signup-profiles { margin: 0; padding: .6rem .75rem .5rem; border: 1px solid var(--border); }
.signup-profiles legend { padding: 0 .35rem; font-weight: 600; font-size: .9rem; }
.signup-profiles .choices { grid-template-columns: 1fr; gap: .5rem; }
.signup-profiles .choice { grid-template-columns: auto 1fr; align-items: center; column-gap: .5rem; padding: .55rem .65rem; font-weight: 400; }
.signup-profiles .choice .muted { grid-column: 2; font-size: .85rem; }
.signup-profiles > .muted { margin: .4rem 0 0; font-size: .8rem; }
.signup-facts { margin: 0; font-size: .9rem; }

/* ---------------------------------------------------------------------------------------
   Modules (cartes)
   --------------------------------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 1rem; margin: 1rem 0; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 1rem 0;
}
.cards .card { margin: 0; }
.card.admin { border-style: dashed; }
.facts { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .35rem; }
details summary { cursor: pointer; font-weight: 600; }

/* Jauge circulaire de batterie */
.ring { position: relative; width: 132px; height: 132px; margin: .25rem auto .75rem; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-track { stroke: var(--line); }
.ring-value { stroke: var(--accent); transition: stroke-dasharray .4s; }
.ring[data-tone="medium"] .ring-value { stroke: var(--warn); }
.ring[data-tone="low"] .ring-value { stroke: var(--danger); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.9rem; font-weight: 700; line-height: 1; }
.ring-label small { font-size: .9rem; font-weight: 600; color: var(--muted); }

/* Graphique batterie */
.chart { margin: 1rem 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.chart svg { width: 100%; height: 140px; display: block; color: var(--accent); }
.chart-line { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-low { stroke: var(--danger); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart figcaption { font-size: .85rem; margin-top: .5rem; }

/* ---------------------------------------------------------------------------------------
   Fichiers
   --------------------------------------------------------------------------------------- */
#tab-files { position: relative; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  margin: .5rem 0;
}
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-weight: 700; font-size: 1.15rem; min-width: 0; }
.breadcrumb a { color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.breadcrumb a:not(:last-child) { color: var(--muted); font-weight: 500; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--muted); font-weight: 400; }
.status { min-height: 1.5em; color: var(--muted); margin: .25rem 0; }

.file-list {
  list-style: none;
  margin: .5rem 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.file-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .5rem .35rem .35rem;
  border-bottom: 1px solid var(--border);
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--accent-soft); }
.file-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.file-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.file-row:only-child { border-radius: var(--radius); }
.file-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .3rem;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.file-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 0;
  background: var(--line);
  color: var(--muted);
}
.file-ic .ic { width: 1.3rem; height: 1.3rem; }
.file-ic.kind-folder { background: var(--accent-soft); color: var(--accent); }
.file-ic.kind-image { background: var(--sun); color: var(--sun-strong); }
.file-ic.kind-doc { background: var(--danger-soft); color: var(--danger); }
.file-ic.kind-owner { background: var(--accent-soft); color: var(--accent); }
.file-text { display: grid; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: .8rem; color: var(--muted); }
.file-actions { display: flex; align-items: center; gap: .15rem; flex: none; }

/* Menu « ⋯ » */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--line); color: var(--fg); }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 15;
  min-width: 11rem;
  display: grid;
  padding: .3rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
/* Sur les dernières lignes, le menu s'ouvre vers le haut (sinon il passe sous la barre d'onglets mobile). */
.file-row:nth-last-child(-n+2):not(:nth-child(-n+2)) .menu-list { top: auto; bottom: calc(100% + 4px); }
.menu-item {
  justify-content: flex-start;
  min-height: 38px;
  padding: .35rem .6rem;
  border: none;
  background: transparent;
  box-shadow: none;
  color: var(--fg);
  font-weight: 500;
}
.menu-item:hover { background: var(--line); filter: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

/* Dossier vide */
.empty {
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: 2.5rem 1rem;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty p { margin: .1rem 0; }
.empty-title { font-weight: 700; font-size: 1.05rem; }
@media (hover: none) { .drop-hint { display: none; } }

/* Zone de dépôt (glisser-déposer) */
.dropzone {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .5rem;
  text-align: center;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  background: color-mix(in srgb, var(--accent-soft) 92%, transparent);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  pointer-events: none;
}
.dropzone .hero-icon { color: var(--accent); }

/* ---------------------------------------------------------------------------------------
   Tableaux (créneaux, maintenance, horaires)
   --------------------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem; border-bottom: 1px solid var(--border); text-align: left; }
thead th { font-size: .8rem; color: var(--fg); font-weight: 700; background: var(--line); border-bottom: 2px solid var(--border); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

/* Créneaux */
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin: .75rem 0; font-size: .85rem; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: .4rem; }
.swatch {
  display: inline-grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.4rem;
  padding: 0 .3rem;
  border: 1px dashed var(--muted);
  border-radius: 0;
  font-size: .75rem;
  color: var(--fg);
}
.swatch.mine { background: var(--accent); border: 1px solid var(--accent); }
.badge {
  display: inline-block;
  margin-left: .4rem;
  padding: .05rem .45rem;
  border-radius: 0;
  background: var(--accent);
  color: var(--bg);
  font-size: .7rem;
  font-weight: 700;
  text-transform: none;
  vertical-align: .1em;
}
.slots th[scope="row"] { white-space: nowrap; font-weight: 600; text-transform: capitalize; }
.slots th .ic { margin-left: .15rem; }
/* En-tête des heures : chaque libellé est posé sur le bord gauche de sa colonne, le dernier sur le bord droit. */
.slots thead th.hour { position: relative; height: 3rem; padding: 1.55rem .25rem .3rem; text-align: center; vertical-align: bottom; }
.slots thead th.hour .tick { position: absolute; top: .35rem; left: 0; transform: translateX(-50%); white-space: nowrap; font-size: .8rem; }
.slots thead th.hour .tick-end { left: auto; right: .3rem; transform: none; } /* heure de fermeture, calée sur le bord droit */
.slots thead th.hour::before { content: ""; position: absolute; left: 0; top: 1.3rem; bottom: 0; border-left: 1px solid var(--border); }
.slots thead th.hour .ic { margin: 0; }
.slots td { text-align: center; padding: .25rem; min-width: 2.8rem; }
.slots td.closed { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 7px); }
.slots .peak { background: var(--sun); }
.slots tr.today > * { background-color: var(--accent-soft); }
.slots tr.today td.peak { background-color: var(--sun); box-shadow: inset 0 0 0 999px var(--accent-soft); }
.slots td button {
  width: 100%;
  min-height: 34px;
  padding: .2rem 0;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
  box-shadow: none;
  font-weight: 500;
}
.slots td button:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.slots td.mine button { background: var(--accent); color: var(--bg); border-style: solid; font-weight: 700; }
/* Ligne du jour : sur le fond vert, les cases gardent un contour et un fond nets pour rester visibles. */
.slots tr.today td button { background: var(--surface); border-color: var(--accent); color: var(--fg); }
.slots tr.today td.mine button { background: var(--accent); color: var(--bg); }
/* Contour noir épais : sinon la grille se confond avec le fond coloré par la batterie. */
.slots-wrap, .slot-day { border: 2px solid #000; }
.schedule { width: auto; }
.slot-days { display: none; }

/* Maintenance */
.maintenance th[scope="row"] { font-weight: 600; }
.maintenance td { vertical-align: top; min-width: 8rem; }
.maintenance td.mine { background: var(--accent-soft); }
.maintenance td.done { color: var(--accent); }
.maintenance .who { display: flex; align-items: center; gap: .3rem; font-weight: 600; }

/* Profil */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: .75rem; }
.choice {
  display: grid;
  gap: .25rem;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

/* Espaces de dépôt et connexion invitée */
.invite {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .65rem .8rem;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}
.invite .ic { margin-top: .15em; color: var(--accent); }
.row label.grow, .row input.grow { flex: 1 1 14rem; }
.row label.grow input { width: 100%; }
#tab-spaces .file-list { margin-bottom: 1rem; }
#tab-spaces .breadcrumb { margin: .75rem 0 .25rem; }
.space-description { white-space: pre-line; padding: .6rem .8rem; border-left: 3px solid var(--accent); background: var(--card); }
#tab-spaces .warn { display: flex; align-items: center; gap: .4rem; }
.note { font-size: .85rem; margin: .25rem 0; }
.accounts li { align-items: center; }
.danger-zone { border-color: var(--danger); }
/* Espace : documents du créateur et dépôts des participants, en deux blocs distincts. */
.zone-block { margin: 1.25rem 0; }
.zone-block h3 { display: flex; align-items: center; gap: .4rem; }
.owner-docs .file-list { border: 2px solid var(--accent); }
.confirm-dialog { width: min(480px, calc(100vw - 2 * var(--gutter))); }
.confirm-dialog h3 { display: flex; align-items: center; gap: .4rem; margin-top: 0; color: var(--danger); }
.confirm-dialog ul { margin: .25rem 0 .5rem; padding-left: 1.2rem; }
.confirm-dialog label { display: grid; gap: .3rem; font-weight: 600; }
.confirm-dialog input { width: 100%; }
.confirm-dialog .row { justify-content: flex-end; }
.deadline { display: flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--warn); }
.row label > .note { font-weight: 400; }

/* ---------------------------------------------------------------------------------------
   Notifications et aperçu
   --------------------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + var(--tabbar-h) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: .5rem;
  max-width: min(92vw, 640px);
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: var(--bg);
  box-shadow: var(--shadow);
  z-index: 30;
}
.toast .ic { width: 1.25rem; height: 1.25rem; }

dialog {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  max-width: 95vw;
  padding: 1rem;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog img { max-width: 100%; max-height: 80vh; display: block; border-radius: var(--radius-sm); }
dialog .close { float: right; margin: -.25rem -.25rem .25rem .5rem; }

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

/* ---------------------------------------------------------------------------------------
   Écrans tactiles : cibles d'au moins 44 px (recommandation Apple / WCAG).
   --------------------------------------------------------------------------------------- */
@media (pointer: coarse) {
  :root { --control-h: 44px; }
  .icon-btn { width: 44px; min-height: 44px; }
  button.ghost { min-height: 44px; }
  .menu-item { min-height: 44px; }
  .breadcrumb a { padding: .35rem 0; }
}

/* ---------------------------------------------------------------------------------------
   Mobile (moins de 700 px)
   --------------------------------------------------------------------------------------- */
@media (max-width: 700px) {
  :root {
    --gutter: 12px;
    --tabbar-h: 3.9rem;
  }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.25rem; }
  .big { font-size: 2rem; }
  .card { padding: .9rem; }

  /* En-tête : marque + compte sur la 1re ligne, pastilles d'état en dessous. */
  .topbar-inner { gap: .4rem .5rem; padding-top: .45rem; padding-bottom: .5rem; }
  .status { order: 3; width: 100%; }
  .pill { font-size: .8rem; }
  #logout-btn .label { display: none; }
  .banner { font-size: .85rem; }

  /* Place pour la barre d'onglets fixée en bas. */
  #app-view main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--gutter)); }

  /* Onglets : barre fixe en bas, icône + libellé. */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0;
    max-width: none;
    margin: 0;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--surface);
    border-top: 2px solid var(--border);
    border-bottom: none;
    box-shadow: none;
  }
  .tabs a {
    flex-direction: column;
    justify-content: center;
    gap: .15rem;
    min-height: var(--tabbar-h);
    margin: 0;
    padding: .3rem .1rem;
    font-size: .68rem;
    background: var(--surface);
    border: none;
    border-left: 1px solid var(--border);
    border-top: 3px solid transparent;
    text-align: center;
  }
  .tabs a:first-child { border-left: none; }
  .tabs a .ic { width: 1.4rem; height: 1.4rem; }
  /* Six onglets sur 360 px : libellés plus petits, coupés proprement si besoin. */
  .tabs a { min-width: 0; font-size: .64rem; }
  .tabs a > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabs a.active { background: var(--accent-soft); border-bottom: none; border-top-color: var(--accent); color: var(--accent); }

  /* Connexion */
  .login { margin-top: 4vh; }
  .login .row button { flex: 1 1 100%; }

  /* Fichiers : boutons d'action pleine largeur. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .actions > * { flex: 1 1 0; }
  .file-row { padding: .25rem .35rem .25rem .25rem; }
  .file-main { gap: .6rem; }
  .file-ic { width: 38px; height: 38px; }

  /* Créneaux : une carte par jour à la place de la grille. */
  .slots-wrap { display: none; }
  .slot-days { display: grid; gap: .75rem; margin: 1rem 0; }
  .slot-day { background: var(--card); border-radius: var(--radius); padding: .75rem; }
  .slot-day.today { box-shadow: inset 0 0 0 999px var(--accent-soft); }
  .slot-day h4 { margin: 0 0 .6rem; text-transform: capitalize; }
  .slot-day p { margin: 0; }
  .slot-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr)); gap: .4rem; }
  .slot-chip button {
    width: 100%;
    min-height: 52px;
    flex-direction: column;
    gap: 0;
    padding: .3rem .2rem;
    line-height: 1.2;
    background: var(--surface);
    color: var(--fg);
    border: 1px dashed var(--border);
    box-shadow: none;
    font-weight: 600;
  }
  .chip-hour { display: inline-flex; align-items: center; gap: .2rem; white-space: nowrap; font-size: .85rem; }
  .slot-chip.peak button { background: var(--sun); border-style: solid; border-color: transparent; }
  .slot-chip.mine button { background: var(--accent); color: var(--bg); border: 1px solid var(--accent); }
  .slot-chip.mine .ic.sun { color: inherit; }
  .chip-count { font-size: .72rem; font-weight: 500; opacity: .85; }

  /* Horaires (admin) : champs à l'aise. */
  .schedule { width: 100%; }
  .schedule th, .schedule td { padding: .35rem .25rem; }
  .row > input:not([type="checkbox"]):not([type="radio"]) { flex: 1 1 12rem; }
  .row > button { flex: 1 1 auto; }

  /* Maintenance : une carte par tâche, une ligne par semaine. */
  .maintenance-wrap { overflow: visible; background: none; border: none; }
  .maintenance, .maintenance tbody, .maintenance tr { display: block; }
  .maintenance thead { display: none; }
  .maintenance tr { margin-bottom: .75rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .maintenance th[scope="row"] { display: block; padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
  .maintenance td {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    align-items: center;
    gap: .15rem .5rem;
    min-width: 0;
    padding: .55rem .8rem;
    border-bottom: 1px solid var(--border);
  }
  .maintenance tr > td:last-child { border-bottom: none; }
  .maintenance td::before { content: attr(data-label); grid-row: span 3; font-size: .8rem; color: var(--muted); }
  .maintenance td > * { grid-column: 2; justify-self: start; }

  /* Notifications et aperçu d'image. */
  .toast { left: var(--gutter); right: var(--gutter); transform: none; max-width: none; }
  dialog { width: calc(100vw - 2 * var(--gutter)); padding: .75rem; }
  dialog img { max-height: 70vh; margin: 0 auto; }
}

/* Horaires d'accès : drive fermé (seuls les admins peuvent se connecter). */
.invite.closed { border-color: var(--warn); background: var(--warn-soft); }
.invite.closed .ic { color: var(--warn); }
.login label .note { font-weight: 400; }
/* Profil : sécurité du compte (mot de passe, email de récupération). */
.account-form { display: grid; gap: .6rem; margin-top: .5rem; }
.account-form label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.account-form input { width: 100%; }
.account-form + .account-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
