/* ══════════════════════════════════════════════════════════════
   Assistant Louis — système de design.

   Principes : peu de couleurs, beaucoup d'air, une seule teinte
   d'accent qui ne sert qu'à signaler. La couleur porte du SENS
   (urgence, aujourd'hui, en attente) — jamais de la décoration.
   ══════════════════════════════════════════════════════════════ */

:root {
    /* Surfaces */
    --fond:        #f5f5f7;
    --surface:     #ffffff;
    --surface-2:   #eeeef2;
    --surface-3:   #e5e5ea;
    --separateur:  rgba(60, 60, 67, .14);
    --separateur-fort: rgba(60, 60, 67, .26);

    /* Texte */
    --texte:    #1d1d1f;
    --texte-2:  rgba(60, 60, 67, .62);
    --texte-3:  rgba(60, 60, 67, .34);

    /* Accent : le bleu système Apple. Une seule teinte de marque, sobre. */
    --accent:      #0071e3;
    --accent-doux: rgba(0, 113, 227, .10);
    --bureau:      #5856d6;                          /* indigo : le créneau bureau */
    --bureau-doux: rgba(88, 86, 214, .11);
    --rdv:         #1f8a70;                          /* vert sarcelle : le rendez-vous client */
    --rdv-doux:    rgba(31, 138, 112, .12);

    /* Signaux d'urgence — la couleur ne sert qu'à ça */
    --u1: #d70015;  --u1-doux: rgba(215, 0, 21, .10);
    --u2: #c2620a;  --u2-doux: rgba(194, 98, 10, .10);   /* ambre = U2 seulement, jamais de marque */
    --u3: #0071e3;  --u3-doux: rgba(0, 113, 227, .10);
    --u4: #6e6e73;  --u4-doux: rgba(110, 110, 115, .10);
    --ok: #1d7a35;

    /* Profondeur */
    --ombre-1: 0 .5px 1px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.05);
    --ombre-2: 0 2px 8px rgba(0,0,0,.07), 0 8px 28px rgba(0,0,0,.08);
    --ombre-3: 0 12px 48px rgba(0,0,0,.20);

    /* Géométrie */
    --r-s: 8px;  --r-m: 12px;  --r-l: 16px;  --r-xl: 22px;
    --barre-h: 52px;
    --outil-h: 48px;
    --heure-h: 52px;
    /* Barre d'onglets : n'existe que sur mobile (voir la media query en bas). */
    --tab-h: 0px;
    --tab-total: 0px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --fond:        #000000;
        --surface:     #1c1c1e;
        --surface-2:   #2c2c2e;
        --surface-3:   #3a3a3c;
        --separateur:  rgba(84, 84, 88, .40);
        --separateur-fort: rgba(84, 84, 88, .68);

        --texte:    #f5f5f7;
        --texte-2:  rgba(235, 235, 245, .60);
        --texte-3:  rgba(235, 235, 245, .30);

        --accent:      #2997ff;
        --accent-doux: rgba(41, 151, 255, .16);
        --bureau:      #5e5ce6;
        --bureau-doux: rgba(94, 92, 230, .18);
        --u1: #ff453a;  --u1-doux: rgba(255, 69, 58, .16);
        --u2: #ff9f0a;  --u2-doux: rgba(255, 159, 10, .16);
        --u3: #2997ff;  --u3-doux: rgba(41, 151, 255, .16);
        --u4: #98989d;  --u4-doux: rgba(152, 152, 157, .16);
        --ok: #30d158;

        --ombre-1: 0 .5px 1px rgba(0,0,0,.4);
        --ombre-2: 0 2px 10px rgba(0,0,0,.5);
        --ombre-3: 0 12px 48px rgba(0,0,0,.7);

        color-scheme: dark;
    }
}

* { box-sizing: border-box; min-width: 0; }

/* L'attribut hidden doit TOUJOURS gagner sur un display: déclaré ailleurs —
   sinon un modal « display: grid » reste affiché alors qu'il est marqué caché. */
[hidden] { display: none !important; }

html, body {
    margin: 0; height: 100%;
    background: var(--fond); color: var(--texte);
    font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
          Roboto, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    letter-spacing: -.011em;

    /* Verrous : rien ne défile ni ne « swipe » horizontalement, la page ne rebondit pas. */
    overflow-x: hidden;
    overscroll-behavior: none;
    touch-action: pan-y;
    -webkit-text-size-adjust: 100%;
}
body { position: relative; max-width: 100vw; }

/* Ce qui déborde se coupe proprement au lieu de pousser la page. */
p, h1, h2, h3, span, div { overflow-wrap: anywhere; }

button, input, select, textarea {
    font: inherit; color: inherit; letter-spacing: inherit;
    /* 16 px minimum : en dessous, iOS zoome sur le champ au focus. */
    font-size: 16px;
}
button { -webkit-tap-highlight-color: transparent; }

/* Un select qui ressemble à nos champs, chevron compris, sur tous les navigateurs. */
select {
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 34px !important;
}

/* Éléments d'interface : ni sélection de texte ni menu contextuel au maintien. */
.barre, .barre-onglets, .outils, .fab, .segments, .filtres, .choix,
.bande-jours, .entete-jours, .mois-jours, .fleches {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* Aucun double-tap-zoom sur ce qui se tape : le tap répond tout de suite. */
a, button, [role="button"], .case, .ligne-heure, .bloc-evt, .tache, .urgent-item,
.creneau, .onglet, .nav-lien, .segment, .filtre, .bande-jour, .puce-evt {
    touch-action: manipulation;
}
/* Les zones qui défilent : verticalement seulement. */
.zone-agenda, .page-pleine, .fil, .page-chat { touch-action: pan-y; }

/* ═══════════════════════  Barre supérieure  ═══════════════════ */

.barre {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 14px;
    height: calc(var(--barre-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--separateur);
}

.marque { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 590; }
.pastille {
    width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 0 3.5px var(--accent-doux);
}

.nav { display: flex; gap: 2px; margin-left: auto; }
.nav-lien {
    position: relative; display: flex; align-items: center; gap: 7px;
    padding: 6px 14px; border-radius: 999px;
    color: var(--texte-2); text-decoration: none; font-size: 14px; font-weight: 500;
    transition: background .18s ease, color .18s ease;
}
.nav-lien:hover { color: var(--texte); }
.nav-lien.actif { background: var(--surface-2); color: var(--texte); font-weight: 590; }
.point { width: 7px; height: 7px; border-radius: 50%; background: var(--u1); flex: none; }

.actions { display: flex; gap: 1px; margin-left: auto; }
.nav + .actions { margin-left: 0; }
.icone {
    width: 34px; height: 34px; border: 0; border-radius: var(--r-s);
    background: transparent; color: var(--texte-2);
    display: grid; place-items: center;
    cursor: pointer; text-decoration: none;
    transition: background .18s ease, color .18s ease;
}
.icone svg { display: block; }
.icone:hover { background: var(--surface-2); color: var(--texte); }
.icone.actif { color: var(--accent); }

/* ═══════════════  Barre d'onglets (mobile seulement)  ════════ */

.barre-onglets {
    display: none;                                    /* activée en media query */
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--separateur);
    justify-content: space-around; align-items: stretch;
}
.onglet {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; position: relative;
    color: var(--texte-3); text-decoration: none;
    font-size: 10.5px; font-weight: 520; letter-spacing: 0;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s ease;
}
.onglet svg { display: block; }
.onglet.actif { color: var(--accent); }
.onglet .point { position: absolute; top: 7px; right: calc(50% - 16px); }

/* ═════════════════════  Contrôle segmenté  ════════════════════ */

.segments {
    display: inline-flex; padding: 2px; gap: 2px;
    background: var(--surface-2); border-radius: 9px;
}
.segment {
    border: 0; background: transparent; color: var(--texte-2);
    padding: 5px 14px; border-radius: 7px; cursor: pointer;
    font-size: 13px; font-weight: 510;
    transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.segment[aria-pressed="true"] {
    background: var(--surface); color: var(--texte);
    font-weight: 590; box-shadow: var(--ombre-1);
}

/* ══════════════════════  Barre d'outils  ═════════════════════ */

.outils {
    display: flex; align-items: center; gap: 12px;
    height: var(--outil-h); padding: 0 16px;
    border-bottom: .5px solid var(--separateur);
    background: var(--fond);
    position: sticky; top: calc(var(--barre-h) + env(safe-area-inset-top)); z-index: 30;
}
.periode {
    margin: 0;                                        /* c'est un <h1> : sans ça la barre gonfle */
    font-size: 17px; font-weight: 640; letter-spacing: -.02em;
    min-width: 0; flex: 1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fleches { display: flex; gap: 1px; }
.fleche {
    width: 30px; height: 30px; border: 0; border-radius: var(--r-s);
    background: transparent; color: var(--texte-2); cursor: pointer;
    display: grid; place-items: center; font-size: 15px;
}
.fleche:hover { background: var(--surface-2); color: var(--texte); }
.bouton-fin {
    margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.aujourdhui {
    border: .5px solid var(--separateur-fort); background: var(--surface);
    color: var(--texte); padding: 5px 13px; border-radius: 999px;
    font-size: 13px; font-weight: 510; cursor: pointer;
}
.aujourdhui:hover { background: var(--surface-2); }

/* ═══════════════════════════  Pages  ═════════════════════════ */

.page-agenda, .page-chat, .page-pleine {
    height: calc(100dvh - var(--barre-h) - env(safe-area-inset-top) - var(--tab-total));
    position: relative;
}
.page-agenda { display: flex; flex-direction: column; overflow: hidden; }
.zone-agenda { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.page-pleine { overflow-y: auto; overflow-x: hidden; padding: 20px 16px 100px; }
.page-pleine > .bloc { margin-left: auto; margin-right: auto; }

/* ═══════════════════════  Agenda — mois  ═════════════════════ */

.mois-jours {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border-bottom: .5px solid var(--separateur);
    position: sticky; top: 0; background: var(--fond); z-index: 5;
}
.mois-jours span {
    padding: 8px 0; text-align: center;
    font-size: 11px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--texte-3);
}

.mois {
    display: grid; grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(104px, 1fr);
}
.case {
    border-right: .5px solid var(--separateur);
    border-bottom: .5px solid var(--separateur);
    padding: 5px 6px; min-width: 0; cursor: pointer;
    display: flex; flex-direction: column; gap: 3px;
    transition: background .15s ease;
}
.case:nth-child(7n) { border-right: 0; }
.case:hover { background: var(--surface-2); }
.case.hors { background: color-mix(in srgb, var(--fond) 60%, var(--surface-2)); }
.case.hors .case-num { color: var(--texte-3); }
.case.weekend { background: color-mix(in srgb, var(--fond) 88%, var(--surface-2)); }

.case-num {
    font-size: 13px; font-weight: 560; color: var(--texte-2);
    width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%;
}
.case.actuel .case-num { background: var(--accent); color: #fff; font-weight: 680; }

.puce-evt {
    font-size: 11.5px; line-height: 1.3; padding: 2px 6px;
    border-radius: 5px; background: var(--surface-2); color: var(--texte);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border-left: 2.5px solid var(--u4);
}
.puce-evt.k-intervention { border-left-color: var(--u3); background: var(--u3-doux); }
.puce-evt.k-bureau       { border-left-color: var(--bureau); background: var(--bureau-doux); }
.puce-evt.k-rdv          { border-left-color: var(--rdv); background: var(--rdv-doux); }
.puce-evt.k-relance      { border-left-color: var(--u1); background: var(--u1-doux); }
.puce-evt.k-repere       { border-left-color: var(--u4); opacity: .72; }
.puce-evt.propose        { border-left-style: dashed; opacity: .8; }
.plus { font-size: 11px; color: var(--texte-3); padding-left: 6px; }

/* ═════════════════  Agenda — semaine et jour  ════════════════ */

.grille-temps { display: grid; grid-template-columns: 56px 1fr; }

.entete-jours {
    display: grid; position: sticky; top: 0; z-index: 5;
    background: color-mix(in srgb, var(--fond) 92%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-bottom: .5px solid var(--separateur);
}
.entete-jour { padding: 7px 0 9px; text-align: center; }
.entete-jour .nom {
    display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--texte-3);
}
.entete-jour .num {
    display: inline-grid; place-items: center; margin-top: 3px;
    width: 30px; height: 30px; border-radius: 50%;
    font-size: 17px; font-weight: 570; letter-spacing: -.02em;
}
.entete-jour.actuel .num { background: var(--accent); color: #fff; font-weight: 680; }

.heures { border-right: .5px solid var(--separateur); }
.heure-lbl {
    height: var(--heure-h); position: relative;
    font-size: 10.5px; color: var(--texte-3); text-align: right;
    padding-right: 8px; font-variant-numeric: tabular-nums;
}
.heure-lbl span { position: relative; top: -6px; }

.colonnes { display: grid; position: relative; }
.colonne { position: relative; border-right: .5px solid var(--separateur); }
.colonne:last-child { border-right: 0; }
.colonne.weekend { background: color-mix(in srgb, var(--fond) 88%, var(--surface-2)); }
.ligne-heure {
    height: var(--heure-h);
    border-bottom: .5px solid var(--separateur);
    cursor: pointer; transition: background .12s ease;
}
.ligne-heure:hover { background: var(--accent-doux); }

.bloc-evt {
    position: absolute; left: 3px; right: 3px;
    border-radius: 7px; padding: 4px 7px; overflow: hidden;
    background: var(--u3-doux); border-left: 3px solid var(--u3);
    font-size: 12px; line-height: 1.32; cursor: pointer;
    box-shadow: var(--ombre-1);
}
.bloc-evt .t { font-weight: 570; display: block; }
.bloc-evt .h { font-size: 10.5px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.bloc-evt.k-bureau  { background: var(--bureau-doux); border-left-color: var(--bureau); }
.bloc-evt.k-rdv     { background: var(--rdv-doux);    border-left-color: var(--rdv); }
.bloc-evt.k-relance { background: var(--u1-doux);     border-left-color: var(--u1); }
.bloc-evt.k-repere  { background: var(--u4-doux);     border-left-color: var(--u4); opacity: .78; }

/* Proposition de l'assistant : présente mais visiblement pas encore acquise */
.bloc-evt.propose {
    background: repeating-linear-gradient(45deg,
        var(--accent-doux), var(--accent-doux) 6px,
        transparent 6px, transparent 12px);
    border: 1.5px dashed var(--accent); border-left-width: 3px;
}
.bloc-evt .rang {
    position: absolute; top: 3px; right: 4px;
    width: 17px; height: 17px; border-radius: 50%;
    background: var(--accent); color: #fff;
    font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
}

/* Bandeau des 7 jours (mobile) — comme le calendrier iOS : on tape un jour,
   la grille en dessous le montre. */
.bande-jours {
    display: grid; grid-template-columns: repeat(7, 1fr);
    padding: 6px 8px 8px; gap: 2px;
    position: sticky; top: 0; z-index: 5;
    background: color-mix(in srgb, var(--fond) 92%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-bottom: .5px solid var(--separateur);
}
.bande-jour {
    border: 0; background: transparent; padding: 3px 0 4px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    cursor: pointer; border-radius: 10px;
}
.bande-jour .nom {
    font-size: 10px; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--texte-3);
}
.bande-jour .num {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
    font-size: 16px; font-weight: 570; letter-spacing: -.02em;
}
.bande-jour.actuel .num { color: var(--accent); font-weight: 700; }
.bande-jour.choisi .num { background: var(--texte); color: var(--fond); }
.bande-jour.actuel.choisi .num { background: var(--accent); color: #fff; }
.bande-jour .marque-evt {
    width: 4px; height: 4px; border-radius: 50%; background: var(--texte-3);
}
.bande-jour .marque-evt.vide { visibility: hidden; }

/* Petite note d'un événement entier dans une case de mois (mobile) */
.puce-evt.mini { font-size: 9.5px; padding: 1px 3px; border-left-width: 2px; border-radius: 3px; }

/* Points colorés en vue mois sur mobile (le texte n'y tient pas) */
.points { display: flex; gap: 3px; flex-wrap: wrap; padding: 2px 0 0 4px; }
.pt { width: 6px; height: 6px; border-radius: 50%; background: var(--u4); }
.pt.k-intervention { background: var(--u3); }
.pt.k-bureau { background: var(--bureau); }
.pt.k-rdv { background: var(--rdv); }
.pt.k-relance { background: var(--u1); }
.pt.propose { background: transparent; border: 1.5px solid var(--accent); }

/* Bandeau des journées entières / multi-jours, au-dessus de la grille */
.entiers {
    display: grid; gap: 0; padding: 4px 0;
    border-bottom: .5px solid var(--separateur);
    background: var(--fond);
}
.entiers-cell {
    min-width: 0; padding: 0 2px; display: flex; flex-direction: column; gap: 2px;
    border-right: .5px solid var(--separateur);
}
.entiers-cell:last-child { border-right: 0; }
.entiers .puce-evt { border-radius: 5px; }
.entiers .puce-evt.suite    { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -2px; border-left-width: 0; padding-left: 8px; }
.entiers .puce-evt.continue { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -2px; }

/* Semaine compacte (mobile) : 7 colonnes, couleurs et titres courts */
.grille-temps.compact { grid-template-columns: 30px 1fr; }
.grille-temps.compact .heure-lbl { font-size: 9px; padding-right: 3px; }
.grille-temps.compact .entete-jour { padding: 5px 0 6px; }
.grille-temps.compact .entete-jour .nom { font-size: 9px; }
.grille-temps.compact .entete-jour .num { width: 24px; height: 24px; font-size: 13px; margin-top: 1px; }
.grille-temps.compact .bloc-evt {
    left: 1px; right: 1px; padding: 2px 3px; border-radius: 4px; border-left-width: 2px;
    font-size: 9.5px; line-height: 1.2; box-shadow: none;
}
.grille-temps.compact .bloc-evt .h { display: none; }
.grille-temps.compact .bloc-evt .t { font-weight: 560; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.grille-temps.compact .bloc-evt .rang { width: 13px; height: 13px; font-size: 9px; top: 2px; right: 2px; }
.grille-temps.compact .entiers .puce-evt { font-size: 9px; padding: 1px 3px; }

/* Feuille d'actions (appui long) — liste de boutons, le destructif en rouge */
.feuille-actions { padding: 14px 12px; }
.feuille-actions h2 {
    font-size: 13px; font-weight: 520; color: var(--texte-2); text-align: center;
    margin: 4px 0 12px; letter-spacing: 0;
}
.feuille-actions .action {
    display: block; width: 100%; padding: 14px; margin-bottom: 6px;
    border: 0; border-radius: var(--r-m); cursor: pointer;
    background: var(--surface-2); color: var(--accent); font-size: 16px; font-weight: 520;
    transition: background .12s ease;
}
.feuille-actions .action:active { background: var(--surface-3); }
.feuille-actions .action.danger { color: var(--u1); }
.feuille-actions .action.annuler { color: var(--texte); font-weight: 600; margin-top: 8px; }

/* Retour visuel pendant l'appui long : l'élément se tasse un peu */
.appui { transform: scale(.985); filter: brightness(.96); transition: transform .35s ease, filter .35s ease; }
.bloc-evt, .puce-evt, .tache, .bulle { -webkit-touch-callout: none; }
.bulle, .tache { -webkit-user-select: none; user-select: none; }

/* Case à cocher dans une feuille */
.case-a-cocher { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.case-a-cocher input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; }
.case-a-cocher span { font-size: 15px; }

.trait-maintenant {
    position: absolute; left: 0; right: 0; height: 1.5px;
    background: var(--u1); z-index: 3; pointer-events: none;
}
.trait-maintenant::before {
    content: ''; position: absolute; left: -4px; top: -3.5px;
    width: 8.5px; height: 8.5px; border-radius: 50%; background: var(--u1);
}

/* ═══════════════════  Bandeau des propositions  ══════════════ */

.propositions { padding: 12px 16px 0; }
.proposition {
    background: var(--surface); border: .5px solid var(--separateur);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-m); padding: 13px 15px; margin-bottom: 9px;
    box-shadow: var(--ombre-1);
}
.proposition .chapeau {
    display: flex; align-items: center; gap: 9px; margin-bottom: 4px;
}
.proposition .titre { font-weight: 570; flex: 1; }
.proposition .sous { font-size: 13px; color: var(--texte-2); margin: 0 0 11px; }
.creneaux-choix { display: flex; gap: 7px; flex-wrap: wrap; }
.creneau {
    flex: 1 1 auto; min-width: 132px;
    border: .5px solid var(--separateur-fort); background: var(--surface);
    border-radius: var(--r-s); padding: 8px 11px; cursor: pointer; text-align: left;
    transition: border-color .16s ease, background .16s ease, transform .1s ease;
}
.creneau:hover { border-color: var(--accent); background: var(--accent-doux); }
.creneau:active { transform: scale(.985); }
.creneau .r { font-size: 10.5px; font-weight: 700; color: var(--accent); }
.creneau .l { display: block; font-size: 13px; font-weight: 510; margin-top: 1px; }
.creneau .p { display: block; font-size: 11.5px; color: var(--texte-2); margin-top: 2px; }
.refuser {
    border: 0; background: transparent; color: var(--texte-2);
    font-size: 13px; cursor: pointer; padding: 8px 12px; border-radius: var(--r-s);
}
.refuser:hover { color: var(--u1); background: var(--u1-doux); }

/* ═══════════════════════════  Tâches  ════════════════════════ */

.bloc { margin-bottom: 26px; max-width: 880px; }
.bloc h2 {
    margin: 0 0 11px; font-size: 11px; font-weight: 640;
    letter-spacing: .06em; text-transform: uppercase; color: var(--texte-3);
}
.bloc-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.vide { color: var(--texte-3); font-size: 14px; margin: 0; padding: 4px 0; }

.filtres { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 11px; }
.filtre {
    border: .5px solid var(--separateur-fort); background: transparent;
    color: var(--texte-2); padding: 4px 12px; border-radius: 999px;
    font-size: 12.5px; cursor: pointer; transition: all .16s ease;
}
.filtre.actif { background: var(--texte); color: var(--fond); border-color: var(--texte); }

.tache {
    background: var(--surface); border: .5px solid var(--separateur);
    border-radius: var(--r-m); padding: 12px 14px; margin-bottom: 8px;
    box-shadow: var(--ombre-1); transition: box-shadow .18s ease, transform .12s ease;
}
.tache:hover { box-shadow: var(--ombre-2); }
.tache.prio-p1 { border-left: 3px solid var(--u1); }
.tache.prio-p2 { border-left: 3px solid var(--u2); }
.tache.prio-p3 { border-left: 3px solid var(--separateur-fort); }

.tache-tete { display: flex; align-items: center; gap: 9px; }
.tache-titre { flex: 1; font-weight: 545; }
.puce { width: 7px; height: 7px; border-radius: 50%; background: var(--u4); flex: none; }
.puce.urgence-U1 { background: var(--u1); box-shadow: 0 0 0 3px var(--u1-doux); }
.puce.urgence-U2 { background: var(--u2); box-shadow: 0 0 0 3px var(--u2-doux); }
.puce.urgence-U3 { background: var(--u3); }
.puce.urgence-U4 { background: var(--u4); }
.ref { font-size: 11px; color: var(--texte-3); font-variant-numeric: tabular-nums; }
.tache-desc { margin: 8px 0 0; font-size: 13.5px; color: var(--texte-2); white-space: pre-line; }
.tache-pied {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 10px; font-size: 12px; color: var(--texte-2);
}
.etiquette {
    padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
    background: var(--surface-2); font-weight: 500;
}
.etiquette.dest-terrain { background: var(--u3-doux); color: var(--u3); }
.etiquette.dest-bureau  { background: var(--bureau-doux); color: var(--bureau); }
.etiquette.dest-emilie  { background: rgba(29,122,53,.11); color: var(--ok); }
.lien-action {
    margin-left: auto; border: 0; background: transparent; color: var(--texte-2);
    cursor: pointer; padding: 3px 9px; border-radius: var(--r-s); font-size: 12.5px;
    text-decoration: none;
}
.lien-action:hover { background: rgba(29,122,53,.11); color: var(--ok); }
.lien-action.lien-chat { margin-left: auto; color: var(--accent); }
.lien-action.lien-chat + .lien-action { margin-left: 0; }
.lien-action.lien-chat:hover { background: var(--accent-doux); color: var(--accent); }
.etiquette.manque { background: var(--u2-doux); color: var(--u2); }

/* Page Tâches : barre de filtre + sections */
.outils-taches { position: static; height: auto; padding: 10px 0 14px; border: 0; background: transparent; }
.outils-taches .compteur { margin-left: auto; font-size: 13px; color: var(--texte-3); }
.bloc h2 .nb {
    display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
    margin-left: 6px; border-radius: 9px; background: var(--surface-2);
    font-size: 10.5px; letter-spacing: 0; color: var(--texte-2); vertical-align: 1px;
}
.sous-section { margin: -6px 0 10px; font-size: 12.5px; color: var(--texte-3); }
.bloc.emilie { padding-top: 14px; border-top: .5px solid var(--separateur); }
.tache-tete .badge-u { margin-left: 2px; }

/* ════════════════════════════  Chat  ═════════════════════════ */

.page-chat { display: flex; flex-direction: column; overflow: hidden; }

/* Ce qui attend une réponse, remonté en haut et trié par urgence */
.urgent {
    padding: 11px 16px; border-bottom: .5px solid var(--separateur);
    background: var(--surface); flex: none;
}
.urgent h3 {
    margin: 0 0 8px; font-size: 10.5px; font-weight: 640;
    letter-spacing: .06em; text-transform: uppercase; color: var(--texte-3);
}
.urgent-item {
    display: flex; align-items: center; gap: 9px; padding: 7px 10px;
    border-radius: var(--r-s); background: var(--surface-2);
    margin-bottom: 5px; cursor: pointer; font-size: 13.5px;
}
.urgent-item:hover { background: var(--surface-3); }
/* Badge d'urgence — partagé par le chat et les propositions de l'agenda */
.badge-u {
    font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
    background: var(--u4-doux); color: var(--u4); flex: none; letter-spacing: .02em;
}
.badge-u.U1 { background: var(--u1-doux); color: var(--u1); }
.badge-u.U2 { background: var(--u2-doux); color: var(--u2); }
.badge-u.U3 { background: var(--u3-doux); color: var(--u3); }
.urgent-item .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fil {
    flex: 1; overflow-y: auto; padding: 18px 16px 10px;
    display: flex; flex-direction: column; gap: 9px;
    max-width: 880px; width: 100%; margin: 0 auto;
}

.bulle {
    max-width: 76%; padding: 9px 14px; border-radius: 19px;
    font-size: 14.5px; line-height: 1.42; word-wrap: break-word;
}
.bulle-assistant {
    align-self: flex-start; background: var(--surface);
    border: .5px solid var(--separateur); border-bottom-left-radius: 6px;
    box-shadow: var(--ombre-1);
}
.bulle-louis {
    align-self: flex-end; background: var(--accent); color: #fff;
    border-bottom-right-radius: 6px;
}
.bulle .meta { display: block; margin-top: 5px; font-size: 10.5px; opacity: .55; }
.bulle-creneaux { border-left: 3px solid var(--accent); }

.bulle-reflexion {
    align-self: flex-start; display: flex; gap: 5px; align-items: center;
    padding: 13px 16px; background: var(--surface);
    border: .5px solid var(--separateur); border-radius: 19px;
    border-bottom-left-radius: 6px; box-shadow: var(--ombre-1);
}
.bulle-reflexion span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--texte-3);
    animation: respire 1.3s ease-in-out infinite;
}
.bulle-reflexion span:nth-child(2) { animation-delay: .18s; }
.bulle-reflexion span:nth-child(3) { animation-delay: .36s; }
@keyframes respire {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30%           { opacity: 1;  transform: translateY(-3px); }
}

.choix { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.choix button {
    border: .5px solid var(--separateur-fort); background: var(--surface-2);
    padding: 5px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.choix button:hover { border-color: var(--accent); color: var(--accent); }

.a-coller {
    margin-top: 10px; padding: 10px 12px; background: var(--surface-2);
    border-radius: var(--r-s); font-size: 13px; white-space: pre-wrap;
}
.a-coller .copier {
    display: block; margin: 8px 0 0 auto; border: 0; background: transparent;
    color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 3px 7px;
}

.saisie {
    display: flex; gap: 9px; padding: 11px 16px;
    padding-bottom: calc(11px + env(safe-area-inset-bottom));
    border-top: .5px solid var(--separateur); background: var(--surface);
    justify-content: center;
}
.saisie input {
    flex: 1; max-width: 800px; border: .5px solid var(--separateur-fort);
    background: var(--fond); border-radius: 999px; padding: 10px 17px; outline: none;
    transition: border-color .16s ease;
}
.saisie input:focus { border-color: var(--accent); }
.envoyer {
    width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 17px; cursor: pointer;
    transition: transform .12s ease, opacity .16s ease;
}
.envoyer:active { transform: scale(.92); }
.envoyer:disabled { opacity: .4; }

/* ═══════════════════════  Feuille modale  ════════════════════ */

.voile {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(0,0,0,.32);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    display: grid; place-items: center; padding: 20px;
    animation: paraitre .18s ease;
}
@keyframes paraitre { from { opacity: 0; } }

.feuille {
    width: 100%; max-width: 430px; background: var(--surface);
    border-radius: var(--r-xl); box-shadow: var(--ombre-3);
    padding: 22px; animation: monter .24s cubic-bezier(.32,.72,0,1);
}
@keyframes monter { from { transform: translateY(14px) scale(.98); opacity: 0; } }

.feuille h2 {
    margin: 0 0 18px; font-size: 19px; font-weight: 640;
    letter-spacing: -.02em; text-transform: none; color: var(--texte);
}
.champ { margin-bottom: 14px; }
.champ label {
    display: block; font-size: 12.5px; color: var(--texte-2); margin-bottom: 5px;
}
.champ input, .champ select {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: .5px solid var(--separateur-fort);
    border-radius: var(--r-s); background: var(--fond); outline: none;
    -webkit-appearance: none; appearance: none;
}
.champ select { -webkit-appearance: none; appearance: none; }
.champ input:focus, .champ select:focus { border-color: var(--accent); }
/* minmax(0,1fr) : un champ date iOS ne peut plus élargir sa colonne au-delà du cadre. */
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.duo > div { min-width: 0; }

.feuille-pied { display: flex; gap: 9px; margin-top: 20px; }
.btn {
    flex: 1; padding: 11px; border: 0; border-radius: var(--r-s);
    cursor: pointer; font-weight: 570; font-size: 14.5px;
}
.btn-primaire { background: var(--accent); color: #fff; }
.btn-neutre   { background: var(--surface-2); color: var(--texte); }

/* ═════════════════════════  Divers  ══════════════════════════ */

.fab {
    position: absolute; right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    width: 52px; height: 52px; border: 0; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 25px; line-height: 1;
    cursor: pointer; box-shadow: var(--ombre-2); z-index: 20;
    transition: transform .14s cubic-bezier(.32,.72,0,1);
}
.fab:active { transform: scale(.9); }

.toast {
    /* Centré par les marges, pas par un transform : l'animation d'entrée
       (qui anime transform) ne le fait plus sauter sur le côté. */
    position: fixed; left: 16px; right: 16px; margin: 0 auto;
    width: max-content; max-width: calc(100% - 32px);
    bottom: calc(24px + var(--tab-total));
    background: var(--texte); color: var(--fond);
    padding: 10px 20px; border-radius: 999px; font-size: 13.5px;
    z-index: 100; box-shadow: var(--ombre-2); text-align: center;
    animation: monter .2s cubic-bezier(.32,.72,0,1);
}

/* ═══════════════  Connexion / installation / réglages  ═══════ */

.centre { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.carte {
    width: 100%; max-width: 400px; background: var(--surface);
    border: .5px solid var(--separateur); border-radius: var(--r-l);
    padding: 30px; box-shadow: var(--ombre-2);
}
.carte h1 { margin: 0 0 5px; font-size: 21px; font-weight: 660; letter-spacing: -.022em; }
.carte .sous { margin: 0 0 22px; color: var(--texte-2); font-size: 13.5px; }
.carte label { display: block; margin: 15px 0 5px; font-size: 12.5px; color: var(--texte-2); }
.carte input {
    width: 100%; padding: 11px 13px; border: .5px solid var(--separateur-fort);
    border-radius: var(--r-s); background: var(--fond); outline: none;
}
.carte input:focus { border-color: var(--accent); }
.carte button.principal, .carte a.principal {
    display: block; width: 100%; margin-top: 20px; padding: 12px;
    border: 0; border-radius: var(--r-s); cursor: pointer;
    background: var(--accent); color: #fff; font-weight: 590;
    text-align: center; text-decoration: none;
}
.carte .ligne-case { display: flex; align-items: center; gap: 9px; margin-top: 16px; }
.carte .ligne-case input { width: auto; }
.carte .erreur {
    margin: 15px 0 0; padding: 10px 13px; border-radius: var(--r-s);
    background: var(--u1-doux); color: var(--u1); font-size: 13.5px;
}
.carte .note { margin-top: 18px; font-size: 12.5px; color: var(--texte-2); line-height: 1.62; }
.carte .note-serree { margin-top: 10px; }
.carte.centre-texte { text-align: center; }
.carte .secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 15px; letter-spacing: .05em; word-break: break-all;
    background: var(--surface-2); padding: 12px; border-radius: var(--r-s); margin-top: 6px;
}
.carte .code-champ { letter-spacing: .35em; text-align: center; font-size: 19px; }

.page { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.page h1 { font-size: 23px; font-weight: 660; margin: 0 0 5px; letter-spacing: -.022em; }
.page .sous { color: var(--texte-2); font-size: 13.5px; margin: 0 0 26px; }
.section {
    background: var(--surface); border: .5px solid var(--separateur);
    border-radius: var(--r-m); padding: 20px; margin-bottom: 14px;
    box-shadow: var(--ombre-1);
}
.section h2 {
    margin: 0 0 13px; font-size: 11px; font-weight: 640;
    letter-spacing: .06em; text-transform: uppercase; color: var(--texte-3);
}
.section p { margin: 0 0 12px; font-size: 13.5px; color: var(--texte-2); line-height: 1.62; }
.section label { display: block; margin: 13px 0 5px; font-size: 12.5px; color: var(--texte-2); }
.section input[type="text"] {
    width: 100%; padding: 10px 12px; border: .5px solid var(--separateur-fort);
    border-radius: var(--r-s); background: var(--fond); outline: none;
}
.bouton {
    border: 0; border-radius: var(--r-s); padding: 9px 17px; cursor: pointer;
    background: var(--accent); color: #fff; font-weight: 560; font-size: 13.5px;
}
.bouton.secondaire { background: var(--surface-2); color: var(--texte); }
.bouton.danger { background: transparent; color: var(--u1); padding: 4px 9px; font-size: 12px; }
.rang { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 15px; }

.tableau { width: 100%; border-collapse: collapse; font-size: 13px; }
.tableau th {
    text-align: left; font-weight: 620; font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--texte-3);
    padding: 7px 8px; border-bottom: .5px solid var(--separateur);
}
.tableau td { padding: 9px 8px; border-bottom: .5px solid var(--separateur); }
.tableau tr:last-child td { border-bottom: 0; }
.tableau .revoque { opacity: .45; text-decoration: line-through; }

.encadre {
    background: var(--accent-doux); border: .5px solid var(--accent);
    border-radius: var(--r-m); padding: 15px; margin-bottom: 15px;
}
.encadre strong { color: var(--accent); }
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px; word-break: break-all; background: var(--surface-2);
    padding: 11px 13px; border-radius: var(--r-s); margin: 8px 0 0; white-space: pre-wrap;
}
.retour {
    display: inline-block; margin-bottom: 16px;
    color: var(--texte-2); text-decoration: none; font-size: 13.5px;
}
.retour:hover { color: var(--accent); }
.etat { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; padding: 6px 0; }
.etat .cle { color: var(--texte-2); min-width: 200px; }
.etat .oui { color: var(--ok); font-weight: 590; }
.etat .non { color: var(--u1); font-weight: 590; }

/* ═══════════════  Administration : règles, journal, clients  ═══ */

.page-large { max-width: 1040px; }
.deux-colonnes { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; align-items: start; }
.liste-regles { padding: 12px; }
.regle-lien {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 9px 11px; border-radius: var(--r-s); color: var(--texte); text-decoration: none;
    font-size: 13.5px;
}
.regle-lien:hover { background: var(--surface-2); }
.regle-lien.actif { background: var(--accent-doux); color: var(--accent); font-weight: 580; }
.editeur textarea {
    width: 100%; min-height: 420px; resize: vertical;
    font: 13.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: 12px 14px; border: .5px solid var(--separateur-fort); border-radius: var(--r-s);
    background: var(--fond); color: var(--texte); outline: none;
}
.editeur textarea:focus { border-color: var(--accent); }
.petit { width: 150px !important; } .tres-petit { width: 64px !important; }
.compteur { margin-left: auto; font-size: 12.5px; color: var(--texte-3); }
.liens-admin a { text-decoration: none; }
.recherche {
    width: 100%; max-width: 480px; padding: 9px 14px; border-radius: 999px;
    border: .5px solid var(--separateur-fort); background: var(--surface); outline: none;
    -webkit-appearance: none; appearance: none;
}
.recherche:focus { border-color: var(--accent); }
.tache.client { cursor: pointer; }
.tableau-scroll { overflow-x: auto; }
.tableau .note-cell { max-width: 320px; font-size: 12px; color: var(--texte-2); }
.segments a.segment { text-decoration: none; }
.ligne-journal {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px;
    padding: 8px 0; border-bottom: .5px solid var(--separateur); font-size: 13px;
}
.ligne-journal:last-child { border-bottom: 0; }
.ligne-journal .quand { color: var(--texte-3); font-variant-numeric: tabular-nums; min-width: 92px; }
.ligne-journal .detail { flex: 1 1 260px; }
.ligne-journal .preuve { color: var(--texte-2); font-size: 12px; }
.ligne-journal.auto { background: color-mix(in srgb, var(--u3-doux) 50%, transparent); margin: 0 -8px; padding: 8px; border-radius: 6px; }

@media (max-width: 720px) {
    .deux-colonnes { grid-template-columns: 1fr; }
    .editeur textarea { min-height: 300px; }
}

/* ══════════════════════════  Mobile  ═════════════════════════ */

@media (max-width: 720px) {
    :root { --tab-h: 50px; --tab-total: calc(50px + env(safe-area-inset-bottom)); }

    /* La navigation descend dans la barre d'onglets ; en haut ne restent
       que la marque et les actions. */
    .nav { display: none; }
    .barre-onglets { display: flex; }
    .barre { gap: 10px; padding-left: 14px; padding-right: 8px; }

    /* Barre d'outils sur deux lignes : titre + flèches, puis le segment. */
    .outils {
        height: auto; flex-wrap: wrap; row-gap: 8px;
        padding: 9px 12px 10px; position: static;
    }
    .outils .segments { order: 3; width: 100%; justify-content: center; display: flex; }
    .outils .segment  { flex: 1; text-align: center; padding: 6px 8px; }
    .outils .fleches  { order: 1; }
    .outils .periode  { order: 2; font-size: 17px; }
    .outils .bouton-fin { order: 2; margin-left: 0; }

    /* iOS zoome sur tout champ dont la police est < 16 px : on l'évite. */
    input, select, textarea { font-size: 16px; }

    /* Le bouton flottant et la saisie du chat s'écartent de la barre d'onglets */
    .fab { bottom: 18px; }
    .saisie { padding-bottom: 11px; }

    .mois { grid-auto-rows: minmax(64px, 1fr); }
    .case { padding: 4px 4px 3px; gap: 1px; }
    .case-num { width: 24px; height: 24px; font-size: 13px; }
    .plus { display: none; }
    .grille-temps { grid-template-columns: 46px 1fr; }
    .heure-lbl { font-size: 10px; padding-right: 6px; }
    .bloc-evt { font-size: 12.5px; padding: 5px 8px; }
    .bulle { max-width: 86%; }
    .propositions { padding: 10px 12px 0; }
    .creneau { min-width: 100%; }
    .page-pleine { padding: 16px 12px 90px; }
    .marque strong { display: inline; }

    /* La feuille modale devient un tiroir qui monte du bas, comme sur iOS. */
    .voile { align-items: end; padding: 0; }
    .feuille {
        max-width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0;
        padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
        animation: glisser .28s cubic-bezier(.32,.72,0,1);
    }
    .feuille::before {
        content: ''; display: block; width: 36px; height: 5px; border-radius: 3px;
        background: var(--separateur-fort); margin: -4px auto 14px;
    }
    .toast { bottom: calc(16px + var(--tab-total)); }
}

@keyframes glisser { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Page Courrier (diagnostic) ── */
.courrier summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; list-style: none; font-size: 14px; }
.courrier summary::-webkit-details-marker { display: none; }
.courrier summary strong { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.courrier .quand { color: var(--texte-3); font-size: 12.5px; }
.courrier .apercu { margin: 12px 0 0; padding: 12px; background: var(--surface-2); border-radius: 10px; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
.courrier .etat { margin-top: 8px; }
.page .info { background: var(--accent-doux); color: var(--accent); padding: 10px 14px; border-radius: 10px; font-size: 13.5px; margin: 0 0 16px; }
.bloc-lecture { white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; color: var(--texte-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; max-height: 40vh; overflow: auto; }
.feuille textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: .5px solid var(--separateur-fort); border-radius: 10px; background: var(--surface); color: var(--texte); resize: vertical; }
