/* Thème Marée (validé le 2026-11-16, voir CLAUDE.md) : calme et sérieux,
   pour rassurer une commune ou un bailleur. Tous les tons passent par les
   jetons ci-dessous ; la variante sombre ne redéfinit que ces jetons. */

:root {
  --fond: #f2f6f8;
  --surface: #ffffff;
  --encre: #0f2740;
  --secondaire: #4f6275;
  --filet: #d5e0e8;
  --tuile: #e1e9ef;
  --action: #0b5cad;
  --action-survol: #08457f;
  --sur-action: #ffffff;
  --repere: #f5c84c;          /* fond seulement, jamais du texte sur clair */
  --alerte: #8a5a00;
  --commun-fond: #fff4cc;
  --commun-texte: #6b4e00;
  --libre: #0f5132;
  --libre-point: #1c8a57;
  --occupe: #9b2c1f;
  --occupe-point: #c2412f;
  --entete: #0f2740;
  --entete-texte: #ffffff;
  --entete-doux: #c3d2e1;
  --entete-repere: #f5c84c;
  --bulle-moi: #0f2740;
  --bulle-moi-texte: #ffffff;
  --rayon: 10px;
  --rayon-btn: 8px;
  --ombre: 0 1px 2px rgba(15, 39, 64, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0b1724; --surface: #13263a; --encre: #e6eef5; --secondaire: #a9bccd; --filet: #284560; --tuile: #1c3349;
    --action: #6aaef5; --action-survol: #8cc1f8; --sur-action: #0b1724; --alerte: #f2c461;
    --commun-fond: #3b3112; --commun-texte: #f7da85; --libre: #7fdcab; --libre-point: #3dbb7b; --occupe: #f5a497; --occupe-point: #e0604c;
    --entete: #07111c; --entete-doux: #a9bccd; --bulle-moi: #2a4a6b; --bulle-moi-texte: #ffffff; --ombre: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0b1724; --surface: #13263a; --encre: #e6eef5; --secondaire: #a9bccd; --filet: #284560; --tuile: #1c3349;
  --action: #6aaef5; --action-survol: #8cc1f8; --sur-action: #0b1724; --alerte: #f2c461;
  --commun-fond: #3b3112; --commun-texte: #f7da85; --libre: #7fdcab; --libre-point: #3dbb7b; --occupe: #f5a497; --occupe-point: #e0604c;
  --entete: #07111c; --entete-doux: #a9bccd; --bulle-moi: #2a4a6b; --bulle-moi-texte: #ffffff; --ombre: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--fond); color: var(--encre);
  font: 16px/1.4 'Atkinson Hyperlegible', system-ui, sans-serif;
}
h1, h2, h3 { font-family: 'Outfit', system-ui, sans-serif; margin: 0; line-height: 1.2; }
h1 { font-weight: 700; font-size: 26px; }
h2 { font-weight: 600; font-size: 16px; }
a { color: var(--action); }
a:hover { color: var(--action-survol); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
svg.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.ic.petit { width: 20px; height: 20px; }

/* Cadre : une colonne de téléphone, centrée sur ordinateur. */
.appli { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--fond); }
main.contenu { flex: 1; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 18px; }

/* En-tête marine, territoire en capitales jaunes. */
.entete { background: var(--entete); color: var(--entete-texte); padding: 20px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.entete-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.territoire { font-size: 13px; color: var(--entete-repere); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.nom-groupe { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 24px; }
.choix-groupe { display: flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.choix-groupe:disabled { cursor: default; }
.choix-groupe span { display: flex; flex-direction: column; }
.compteurs { font-size: 13px; color: var(--entete-doux); text-align: right; }
.recherche { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: var(--rayon); background: var(--surface); color: var(--encre); }
.recherche input { flex: 1; border: 0; background: none; outline: none; min-width: 0; }
.recherche svg { color: var(--secondaire); }

/* En-tête d'écran secondaire : retour + titre. */
.barre { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--entete); color: var(--entete-texte); min-height: 64px; }
.barre .titre { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.barre .titre strong { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre .titre span { font-size: 14px; color: var(--entete-doux); }
.btn-icone { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 22px; border: 0; background: none; color: inherit; cursor: pointer; text-decoration: none; flex-shrink: 0; }
.barre .btn-icone:hover { background: rgba(255, 255, 255, .1); color: inherit; }
.btn-icone.appel { background: var(--repere); color: #0f2740; }

/* Cartes et listes */
.carte { background: var(--surface); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 14px; box-shadow: var(--ombre); }
.liste { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ligne-objet { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--rayon); background: var(--surface); border: 1px solid var(--filet); color: inherit; text-decoration: none; min-height: 72px; }
.ligne-objet:hover { color: inherit; border-color: var(--secondaire); }
.ligne-objet .texte { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ligne-objet .texte strong { overflow: hidden; text-overflow: ellipsis; }
.doux { font-size: 14px; color: var(--secondaire); }
.tuile { width: 46px; height: 46px; border-radius: var(--rayon-btn); background: var(--tuile); color: var(--encre); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.tuile.commun { background: var(--commun-fond); color: var(--commun-texte); }
.tuile img { width: 100%; height: 100%; object-fit: cover; }
.tuile svg { width: 26px; height: 26px; stroke-width: 1.8; }

.section { display: flex; flex-direction: column; gap: 8px; }
.section > h2 { display: flex; align-items: center; gap: 8px; }
.pastille { font-family: 'Atkinson Hyperlegible', sans-serif; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--tuile); color: var(--encre); }
.pastille.commun { background: var(--commun-fond); color: var(--commun-texte); }
.pastille.alerte { background: var(--repere); color: #0f2740; }

/* Disponibilité : un point de couleur suivi d'un libellé. */
.dispo { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.dispo::before { content: ''; width: 8px; height: 8px; border-radius: 4px; background: currentColor; }
.dispo.libre { color: var(--libre); }
.dispo.libre::before { background: var(--libre-point); }
.dispo.occupe { color: var(--occupe); }
.dispo.occupe::before { background: var(--occupe-point); }
.dispo.attente { color: var(--alerte); }
.dispo.attente::before { background: var(--repere); }
.dispo.neutre { color: var(--secondaire); }
.dispo.neutre::before { background: var(--filet); }

/* Carte « chez vous en ce moment » : filet jaune à gauche. */
.encours { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--rayon); background: var(--surface); border: 1px solid var(--filet); box-shadow: inset 4px 0 0 var(--repere); }
.encours .texte { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.echeance { font-size: 14px; color: var(--alerte); font-weight: 700; }

/* Sélecteur segmenté Tout / En commun / Voisins */
.segments { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; padding: 4px; border-radius: var(--rayon); background: var(--tuile); }
.segments button { height: 38px; border: 0; border-radius: 7px; background: none; color: var(--secondaire); font-size: 14px; cursor: pointer; }
.segments button[aria-pressed="true"] { background: var(--surface); color: var(--encre); font-weight: 700; box-shadow: var(--ombre); }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--rayon-btn); border: 1px solid var(--encre); background: var(--surface); color: var(--encre); font-weight: 700; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { color: var(--encre); background: var(--tuile); }
.btn.primaire { background: var(--action); border-color: var(--action); color: var(--sur-action); }
.btn.primaire:hover { background: var(--action-survol); border-color: var(--action-survol); color: var(--sur-action); }
.btn.discret { border-color: var(--filet); }
.btn.danger { border-color: var(--occupe); color: var(--occupe); }
.btn.grand { min-height: 50px; flex: 1; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions > .btn { flex: 1; }
.pied { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--filet); }

/* Navigation du bas */
.nav { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border-top: 1px solid var(--filet); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; min-height: 44px; color: var(--secondaire); text-decoration: none; font-size: 12px; position: relative; }
.nav a[aria-current="page"] { color: var(--action); font-weight: 700; }
.nav .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--repere); color: #0f2740; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* Fiche objet */
.photo-objet { height: 170px; border-radius: var(--rayon); background: var(--tuile); color: var(--secondaire); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.photo-objet.commun { background: var(--commun-fond); color: var(--commun-texte); }
.photo-objet img { width: 100%; height: 100%; object-fit: cover; }
.photo-objet svg { width: 56px; height: 56px; stroke-width: 1.4; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.infos { margin: 0; display: grid; grid-template-columns: 104px 1fr; row-gap: 8px; column-gap: 12px; font-size: 15px; }
.infos dt { color: var(--secondaire); }
.infos dd { margin: 0; }

/* Calendrier deux semaines */
.cal-tete, .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.cal-tete { font-size: 12px; color: var(--secondaire); }
.cal span { padding: 8px 0; border-radius: var(--rayon-btn); background: var(--tuile); font-size: 14px; }
.cal .passe { background: none; color: var(--secondaire); }
.cal .pris { background: var(--occupe-point); color: #fff; font-weight: 700; }
.cal .attente { background: var(--repere); color: #0f2740; font-weight: 700; }
.cal .aujourdhui { outline: 2px solid var(--encre); outline-offset: -2px; font-weight: 700; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--secondaire); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legende i.pris { background: var(--occupe-point); }
.legende i.attente { background: var(--repere); }

/* Formulaires */
form.pile, .pile { display: flex; flex-direction: column; gap: 16px; }
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > label, .champ > .etiquette, fieldset legend { font-weight: 700; font-size: 15px; }
.saisie { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--filet); border-radius: var(--rayon-btn); background: var(--surface); color: var(--encre); }
textarea.saisie { min-height: 90px; resize: vertical; }
.aide { font-size: 14px; color: var(--secondaire); margin: 0; }
.deux { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puces label { position: relative; }
.puces input { position: absolute; opacity: 0; }
.puces span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--filet); background: var(--surface); cursor: pointer; font-size: 15px; }
.puces input:checked + span { background: var(--encre); border-color: var(--encre); color: var(--fond); font-weight: 700; }
.puces input:focus-visible + span { outline: 3px solid var(--action); outline-offset: 2px; }
.choix { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--filet); border-radius: var(--rayon); background: var(--surface); cursor: pointer; }
.choix input { margin: 3px 0 0; width: 20px; height: 20px; accent-color: var(--action); flex-shrink: 0; }
.choix:has(input:checked) { border-color: var(--action); box-shadow: inset 0 0 0 1px var(--action); }
.choix span { display: flex; flex-direction: column; gap: 2px; }
.choix small { font-size: 14px; color: var(--secondaire); }
.photo-saisie { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px dashed var(--secondaire); border-radius: var(--rayon); background: var(--surface); cursor: pointer; }
.photo-saisie input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-saisie:focus-within { outline: 3px solid var(--action); outline-offset: 2px; }
.photo-saisie .tuile { width: 64px; height: 64px; }

/* Réservation : étapes et fil */
.periode { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--rayon); background: var(--surface); border: 1px solid var(--filet); font-size: 15px; }
.etapes { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; font-size: 12px; text-align: center; color: var(--secondaire); }
.etapes li { display: flex; flex-direction: column; gap: 4px; }
.etapes li::before { content: ''; height: 4px; border-radius: 2px; background: var(--filet); }
.etapes li.faite { color: var(--libre); font-weight: 700; }
.etapes li.faite::before { background: var(--libre-point); }
.fil { display: flex; flex-direction: column; gap: 12px; }
.bulle { max-width: 80%; display: flex; flex-direction: column; gap: 4px; }
.bulle div { padding: 10px 14px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle small { font-size: 12px; color: var(--secondaire); }
.bulle.moi { align-self: flex-end; align-items: flex-end; }
.bulle.moi div { border-radius: 16px 16px 4px 16px; background: var(--bulle-moi); color: var(--bulle-moi-texte); }
.bulle.autre { align-self: flex-start; }
.bulle.autre div { border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--filet); }
.systeme { align-self: center; font-size: 13px; color: var(--secondaire); background: var(--tuile); padding: 4px 12px; border-radius: 12px; text-align: center; }
.saisie-message { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--filet); }
.saisie-message input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 23px; border: 1px solid var(--filet); background: var(--fond); }
.saisie-message button { width: 46px; height: 46px; border-radius: 23px; border: 0; background: var(--action); color: var(--sur-action); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

.encart { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--rayon); background: var(--surface); border: 1px solid var(--filet); box-shadow: inset 4px 0 0 var(--repere); font-size: 14px; }
.vide { text-align: center; color: var(--secondaire); padding: 24px 12px; }
.erreur { color: var(--occupe); font-weight: 700; margin: 0; }

/* Retour : deux grands choix d'état */
.etats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.etats label { position: relative; }
.etats input { position: absolute; opacity: 0; }
.etats span { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: var(--rayon); border: 1px solid var(--filet); background: var(--surface); font-weight: 700; cursor: pointer; }
.etats input:checked + span { border-color: var(--action); box-shadow: inset 0 0 0 2px var(--action); }
.etats input:focus-visible + span { outline: 3px solid var(--action); outline-offset: 2px; }
.etats svg { width: 32px; height: 32px; }

/* Feuille du bas (prendre maintenant, choisir un groupe) */
.voile { position: fixed; inset: 0; background: rgba(7, 17, 28, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.feuille { width: 100%; max-width: 560px; background: var(--fond); border-radius: 16px 16px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow: auto; }

/* Accueil sans session et entrée de démo */
.porte { max-width: 480px; margin: 0 auto; padding: 32px 20px; display: flex; flex-direction: column; gap: 18px; }
.porte .logo { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 32px; display: flex; align-items: center; gap: 10px; }
.porte .logo i { width: 14px; height: 14px; border-radius: 7px; background: var(--repere); }
.compte { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: var(--rayon); background: var(--surface); border: 1px solid var(--filet); text-align: left; cursor: pointer; min-height: 64px; }
.compte:hover { border-color: var(--action); }
.compte .texte { flex: 1; display: flex; flex-direction: column; }
.mention { font-size: 13px; color: var(--secondaire); text-align: center; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 16px; border-radius: var(--rayon); background: var(--encre); color: var(--fond); font-weight: 700; z-index: 20; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); }

/* Petits ajustements (la CSP interdit les styles en ligne) */
.pile.serre { gap: 8px; }
.liste.compacte { gap: 4px; font-size: 15px; }
.systeme.date { background: none; }
.en-ligne { display: inline; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; }
details > .liste { margin-top: 8px; }
.etire { flex: 1; display: flex; }
.coupe { overflow-wrap: anywhere; }
.lignes { white-space: pre-wrap; }
