/* « On roule quand ? » (agenda.html, agenda.js) — pack design v2, écran 02 « Agenda partagé ».
   Réutilise les composants partagés td2-* (site.css) et le tableau entre potes (potes.css) ; préfixe ag-. */

/* ---------- En-tête, périmètre, « Qui afficher » ---------- */
.ag .pt-onglets { position: relative; }   /* le texte .sr-only du compteur « Mes potes » reste dans la barre qui défile (sinon la page s'élargit à 320 px) */
.ag-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 18px 0 20px; }
.ag-tete h1 { margin: 0; font: 800 clamp(30px, 3.4vw, 40px)/1.1 var(--f-display); letter-spacing: -.025em; color: var(--td2-ink); }
.ag-tete .lede { margin: 8px 0 0; font-size: 17px; color: var(--ink-2); }
.ag-tete-a { display: flex; flex-wrap: wrap; gap: 10px; }
.ag-tete-a .ico { width: 18px; height: 18px; }
.ag-perim { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 16px; }
.ag-seg-perim { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ag-seg-perim button { white-space: nowrap; }
.ag-choix-g select { min-height: 44px; padding: 0 34px 0 12px; border: 1px solid var(--td2-border); border-radius: 10px; background-color: #fff; font: 600 14px var(--f-text); color: var(--td2-ink); }
.ag-qui-b { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 8px; border: 1px solid transparent; border-radius: 99px; background: none;
  color: var(--td2-ink); font: 600 14px var(--f-text); text-decoration: none; cursor: pointer; }
.ag-qui-b:hover, .ag-qui-b[aria-expanded=true] { border-color: var(--td2-border); background: #fff; }
.ag-qui-b > .ico { width: 17px; height: 17px; color: var(--td2-muted); }
.ag-qui-b .td2-avatars + .td2-txt { margin-left: 4px; }
.ag-qui-b .tb-av { font-size: 12px; }
.ag-plus { display: inline-grid; place-items: center; background: var(--td2-neutral-bg); color: var(--td2-ink); font: 700 11px var(--f-text); }
.ag-qui .tb-barre { gap: 12px; }
.ag-qui-l { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.ag-qui-l .tb-coche { margin-left: 0; }
.ag-qui .td2-puce { padding-left: 5px; }
.ag-qui .td2-puce .tb-av { width: 30px; height: 30px; font-size: 13px; }
.ag-qui .td2-puce[aria-pressed=false] { background: #fff; color: var(--td2-muted); border-style: dashed; }
.ag-qui .td2-puce[aria-pressed=false] .tb-av { background: #a9b0b7; }
.ag-qui .td2-puce[aria-pressed=true] .tb-dot { box-shadow: 0 0 0 2px var(--td2-ink); }

/* ---------- Mise en page : vue + panneau de détail (300 px) ---------- */
.ag-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.ag-layout.is-seul { grid-template-columns: minmax(0, 1fr); }
.ag-main { padding: 18px; }
.ag-barre { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.ag-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ag-nav .td2-icone { border: 1px solid var(--td2-border); }
.ag-nav .td2-icone:disabled { opacity: .35; cursor: default; background: none; }
.ag-nav .td2-icone[hidden] { display: none; }
.ag-g { transform: scaleX(-1); }
.ag-periode { margin: 0 6px; font: 800 22px/1.2 var(--f-display); letter-spacing: -.02em; color: var(--td2-ink); }
.ag-vues button[aria-pressed=true] { background: var(--td2-action); color: #fff; }
.td2-seg button:focus-visible, .ag-qui-b:focus-visible, .ag-puce:focus-visible, .ag-puce-plus:focus-visible, .ag-item:focus-visible, .td2-ruban button:focus-visible,
.ag-detail:focus-visible, .ag-choix-g select:focus-visible { outline: 2px solid var(--td2-action); outline-offset: 2px; }

/* ---------- Mois : grille lundi-dimanche ---------- */
.ag-cal { width: 100%; table-layout: fixed; border-collapse: collapse; }
.ag-cal th { height: 30px; font: 600 11px var(--f-text); letter-spacing: .06em; text-transform: uppercase; color: var(--td2-muted); }
.ag-cal td { height: 98px; padding: 0; border: 1px solid #e8ecef; vertical-align: top; }
.ag-case { display: flex; flex-direction: column; align-items: stretch; gap: 5px; height: 100%; min-height: 96px; padding: 7px 6px; border: 1.5px solid transparent; border-radius: 7px; }
.ag-num { align-self: flex-start; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 99px; font: 600 13px var(--f-text); color: var(--td2-ink); }
.ag-cal td.is-hors { background: #fafbfc; }
.ag-cal td.is-hors .ag-num { color: #9aa2ad; font-weight: 500; }
.ag-cal td.is-passe:not(.is-hors) .ag-num { color: var(--td2-muted); }
.ag-cal td.is-auj .ag-num { box-shadow: inset 0 0 0 1.5px var(--td2-ink); }
.ag-cal td.is-sel .ag-case { border-color: var(--td2-action); background: #fff6f5; }
.ag-cal td.is-sel .ag-num { background: var(--td2-action); color: #fff; box-shadow: none; }
.ag-puce { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 28px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px;
  background: var(--td2-neutral-bg); color: var(--td2-ink); font: 600 12px/1.25 var(--f-text); text-align: left; cursor: pointer; }
.ag-puce-t { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-puce small { font: 500 11px/1.2 var(--f-text); opacity: .85; }
.ag-puce.st-inscrit { background: var(--td2-success-bg); color: var(--td2-success); }
.ag-puce.st-prevu { background: #e9edf2; color: #344054; }
.ag-puce.st-peutetre { background: var(--td2-warning-bg); color: var(--td2-warning); }
.ag-puce.st-amis { background: #fff; border: 1px dashed #c4cbd3; color: var(--ink-2); }
.ag-puce:hover { filter: brightness(.97); border-color: currentColor; }
.ag-puce[aria-pressed=true] { box-shadow: 0 0 0 2px var(--td2-action); }
.ag-puce-plus { align-self: flex-start; padding: 2px 4px; border: 0; background: none; color: var(--ink-2); font: 600 11.5px var(--f-text); text-decoration: underline; cursor: pointer; }
.ag-vide-mois { margin: 14px 0 0; color: var(--td2-muted); font-size: 14px; }

/* Légende sous le mois (bureau) */
.ag-legende { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 26px; margin-top: 16px; padding: 14px 16px; border: 1px solid var(--td2-border); border-radius: 10px; }
.ag-legende[hidden] { display: none; }
.ag-leg-i { display: inline-flex; align-items: center; gap: 9px; }
.ag-leg-i b { display: block; font: 600 13px var(--f-text); color: var(--td2-ink); }
.ag-leg-i small { display: block; font-size: 12px; color: var(--td2-muted); }
.ag-leg-pt { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ag-leg-pt.st-inscrit { background: var(--td2-success); }
.ag-leg-pt.st-prevu { background: #344054; }
.ag-leg-pt.st-peutetre { background: #e3a008; }
.ag-leg-pt.st-amis { background: #fff; border: 1.5px dashed #9aa2ad; }
.ag-leg-trajet { flex: 1 1 280px; }
.ag-leg-trajet .ico { width: 16px; height: 16px; flex: none; color: var(--td2-muted); }

/* ---------- Agenda : liste chronologique ---------- */
.ag-mois-t { margin: 18px 0 6px; font: 800 15px var(--f-display); color: var(--td2-ink); }
.ag-mois-t:first-of-type { margin-top: 0; }
.ag-liste { list-style: none; margin: 0; padding: 0; border: 1px solid var(--td2-border); border-radius: 10px; overflow: hidden; }
.ag-liste li + li { border-top: 1px solid var(--td2-border); }
.ag-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 16px; width: 100%; padding: 14px 16px; border: 0; border-left: 3px solid transparent;
  background: #fff; color: var(--td2-ink); font: inherit; text-align: left; cursor: pointer; }
.ag-item:hover { background: #fbfbfc; }
.ag-item[aria-pressed=true] { background: #fff6f5; border-left-color: var(--td2-action); }
.ag-date { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.ag-date b { font: 800 26px/1 var(--f-display); letter-spacing: -.03em; }
.ag-date small { font: 600 11px var(--f-text); text-transform: uppercase; letter-spacing: .05em; color: var(--td2-muted); }
.ag-item-c { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ag-item-t { display: flex; align-items: center; gap: 8px; font: 800 17px/1.2 var(--f-display); letter-spacing: -.015em; overflow-wrap: anywhere; }
.ag-item-t .flag { margin-top: 0; }
.ag-item-s { font-size: 13.5px; color: var(--ink-2); }
.ag-item-s small { font-size: 12px; }
.ag-item-p { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.ag-p { display: inline-flex; align-items: center; gap: 6px; font: 600 13px var(--f-text); color: var(--td2-ink); }
.ag-p .tb-av { width: 24px; height: 24px; font-size: 11px; }
.ag-p .td2-badge, .ag-item-st .td2-badge { padding: 2px 8px; font-size: 12px; }
.ag-pas { background: #fff; border: 1px dashed #c4cbd3; color: var(--td2-muted); }
.ag-proch, .ag-ruban, .ag-fiche-m { display: none; }

/* ---------- Comparer : le tableau entre potes ---------- */
.ag-v-comparer .tb-wrap { position: relative; border-color: var(--td2-border); }  /* garde les textes .sr-only des cases dans le cadre qui défile */
.ag-leg-tb { margin: 14px 0 0; }

.ag a.btn, .ag a.btn:hover { text-decoration: none; }

/* ---------- Panneau de détail ---------- */
.ag-detail { position: sticky; top: 16px; padding: 16px; outline: none; }
.ag-d-bandeau { display: grid; place-items: center; height: 150px; margin-bottom: 14px; border-radius: 10px; background: var(--td2-bg); border: 1px solid var(--paper-2); }
.ag-trace { display: block; width: 120px; height: 120px; }
.ag-trace path, .ag-f-trace path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ag-trace .tr-loop { stroke: var(--td2-ink); stroke-width: 3; }
.ag-d-sans .ico { width: 34px; height: 34px; color: var(--td2-muted); }
.ag-d-date { margin: 0; font: 600 14px var(--f-text); color: var(--ink-2); }
.ag-d-titre { display: flex; align-items: center; gap: 8px; margin: 4px 0; font: 800 24px/1.15 var(--f-display); letter-spacing: -.02em; overflow-wrap: anywhere; }
.ag-d-titre .flag { margin-top: 0; }
.ag-d-titre a { color: inherit; text-decoration: none; }
.ag-d-titre a:hover { text-decoration: underline; text-decoration-color: var(--td2-action); text-underline-offset: 3px; }
.ag-d-orga { margin: 0; font-size: 15px; color: var(--ink-2); }
.ag-d-orga b { color: var(--td2-ink); }
.ag-d-type { margin: 4px 0 0; font-size: 13px; color: var(--td2-muted); }
.ag-d-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ag-d-badges .td2-badge { white-space: normal; }
.ag-b-groupe { background: var(--td2-warning-bg); color: var(--td2-warning); }
.ag-b-ens { background: var(--td2-active-bg); color: var(--td2-action); }
.ag-d-moi { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--td2-bg); }
.ag-d-moi-t { flex: 1 0 100%; font: 600 12px var(--f-text); letter-spacing: .04em; text-transform: uppercase; color: var(--td2-muted); }
.ag-d-moi .btn { margin-left: auto; height: 36px; padding: 0 12px; }
.ag-d-h { margin: 18px 0 4px; font: 700 16px var(--f-display); color: var(--td2-ink); }
.ag-gens { list-style: none; margin: 0; padding: 0; }
.td2-person { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.td2-person + .td2-person { border-top: 1px solid #eef0f2; }
.td2-person > div { flex: 1; min-width: 0; }
.td2-person b { display: block; font: 600 14px var(--f-text); overflow-wrap: anywhere; }
.td2-person b a { color: var(--td2-ink); text-decoration: none; }
.td2-person b a:hover { text-decoration: underline; }
.td2-caption { display: block; overflow: hidden; font-size: 12px; color: var(--td2-muted); text-overflow: ellipsis; white-space: nowrap; }
.td2-person .td2-badge { flex: none; max-width: 130px; padding: 3px 9px; font-size: 12px; }
.ag-d-act { display: grid; gap: 8px; margin-top: 16px; }
.ag-d-btn { width: 100%; }
.ag-d-btn .ico { width: 18px; height: 18px; }
.ag-d-btn .ds-nl { background: #fff; color: var(--td2-action); }
.ag-d-btn.ghost .ds-nl { background: var(--td2-action); color: #fff; }
.ag-d-aide { margin: 0; padding: 10px 12px; border: 1px dashed var(--td2-border); border-radius: 10px; font-size: 13px; color: var(--ink-2); }
.ag-mini { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.ag-mini-c { display: flex; gap: 8px; min-width: 0; padding: 12px 10px; border: 1px solid var(--td2-border); border-radius: 9px; font-size: 12.5px; }
.ag-mini-c > .ico { width: 18px; height: 18px; flex: none; color: var(--ink-2); }
.ag-mini-c > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.ag-mini-c b { font: 600 13px var(--f-text); color: var(--td2-ink); }
.ag-mini-c small, .ag-mini-c li { color: var(--td2-muted); font-size: 12px; overflow-wrap: anywhere; }
.ag-mini-c ul { list-style: none; margin: 0; padding: 0; }
.ag-mini-c .pt-lienb { font-size: 12.5px; text-align: left; }
.ag-cv { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ag-cv .cv-chip { white-space: normal; }
.ag-d-notes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ag-d-notes li { display: flex; gap: 8px; font-size: 13.5px; color: var(--td2-ink); }
.ag-d-notes .ico { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--td2-muted); }
.ag-d-fiche { display: inline-flex; align-items: center; gap: 4px; margin-top: 16px; font: 600 14px var(--f-text); color: var(--td2-action); }
.ag-d-fiche .ico { width: 15px; height: 15px; }
.ag-d-info { display: flex; gap: 8px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--td2-border); font-size: 12.5px; color: var(--td2-muted); }
.ag-d-info .ico { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.ag-d-retour { margin: -4px 0 12px; }
.ag-d-retour .ico { width: 16px; height: 16px; }

/* ---------- Fiche courte de la journée (téléphone) ---------- */
.ag-fiche { padding: 14px; }
.ag-f-h { display: flex; align-items: center; gap: 12px; }
.ag-f-trace { display: grid; place-items: center; flex: none; width: 64px; height: 64px; border-radius: 10px; background: var(--td2-bg); }
.ag-f-trace .ag-trace { width: 50px; height: 50px; }
.ag-f-trace .ag-trace .tr-loop { stroke-width: 2.4; }
.ag-f-trace .ico { width: 24px; height: 24px; color: var(--td2-muted); }
.ag-f-h h3 { margin: 0; font: 800 19px/1.2 var(--f-display); letter-spacing: -.015em; overflow-wrap: anywhere; }
.ag-f-h p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.ag-f-l { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13.5px; color: var(--ink-2); }
.ag-f-l .ico { width: 16px; height: 16px; flex: none; }
.ag-fiche .ag-gens { margin-top: 8px; }
.ag-fiche .td2-person { padding: 6px 0; }
.ag-f-ouvrir { width: 100%; margin-top: 10px; }
.ag-f-ouvrir .ico { width: 16px; height: 16px; }

.ag-outils { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.ag-outils .btn .ico { width: 17px; height: 17px; }

/* ---------- Tablette et petit bureau ---------- */
@media (max-width: 1099px) {
  .ag-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
  .ag-main { padding: 14px; }
  .ag-cal td { height: 88px; }
  .ag-case { min-height: 86px; padding: 5px 4px; }
  .ag-puce { font-size: 11px; padding: 3px 4px; }
  .ag-puce small { font-size: 10px; }
}
@media (max-width: 899px) and (min-width: 768px) {
  .ag-layout { grid-template-columns: minmax(0, 1fr); }
  .ag-detail { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
  .ag-detail[hidden] { display: none; }
  .ag-detail > * { grid-column: 2; }
  .ag-detail > .ag-d-bandeau { grid-column: 1; grid-row: 1 / span 6; height: 220px; }
  .ag-detail .ag-mini { grid-template-columns: 1fr 1fr; }
}

/* ---------- Téléphone ---------- */
@media (max-width: 767px) {
  /* En-tête compact du socle : à 320 px, la 1re colonne (190-270 px) + l'écart poussaient le menu hors de l'écran */
  body.td-espace .hd { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .ag-tete { margin: 10px 0 14px; }
  .ag-tete .lede { font-size: 15px; }
  .ag-tete-a { width: 100%; }
  .ag-tete-a { gap: 8px; }
  .ag-tete-a .btn { flex: 1 1 auto; height: 42px; padding: 0 12px; font-size: 14px; }
  .ag-perim { gap: 8px; }
  .ag-seg-perim { width: 100%; }
  .ag-seg-perim button { padding: 0 12px; font-size: 13.5px; }
  .ag-layout { display: block; }
  .ag-main { padding: 0; border: 0; background: none; box-shadow: none; }
  .ag-barre { margin-bottom: 12px; }
  .ag-periode { font-size: 18px; margin: 0 2px; }
  .ag-vues { width: 100%; }
  .ag-vues button { flex: 1; justify-content: center; padding: 0 8px; }
  .ag-v-mois { padding: 8px; background: #fff; border: 1px solid var(--td2-border); border-radius: var(--td2-radius); }
  .ag-cal th { font-size: 10px; letter-spacing: .02em; }
  .ag-cal td { height: 60px; }
  .ag-case { min-height: 58px; padding: 3px 2px; gap: 3px; }
  .ag-num { min-width: 22px; height: 22px; font-size: 12px; }
  .ag-puce { min-height: 24px; padding: 2px 3px; font-size: 9.5px; }
  .ag-puce small { display: none; }
  .ag-puce-plus { font-size: 10px; padding: 0 2px; }
  .ag-legende { display: none; }
  .ag-ruban { display: flex; margin: 0 -16px 14px; padding: 3px 16px; }
  .ag-ruban button { flex-basis: 54px; min-height: 66px; }
  .ag-ruban .ag-r-m { font-size: 10px; text-transform: none; letter-spacing: 0; }
  .ag-fiche-m { display: block; margin: 14px 0 0; }
  .ag-v-agenda .ag-fiche-m { margin: 0 0 18px; }
  .ag-proch { display: block; margin: 0 0 8px; font: 800 18px var(--f-display); color: var(--td2-ink); }
  .ag-mois-t { font-size: 14px; color: var(--ink-2); }
  .ag-item { grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .ag-item-st { grid-column: 2; }
  .ag-date b { font-size: 22px; }
  .ag-item-t { font-size: 16px; }
  .ag-item-p { gap: 6px 10px; }
  /* Détail : panneau plein écran au-dessus de la page, retour en haut */
  .ag-detail:not(.is-plein) { display: none; }
  .ag-detail.is-plein { position: fixed; inset: 0; z-index: 80; overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 0; box-shadow: none;
    padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
  html.ag-plein, html.ag-plein body { overflow: hidden; }
  .ag-d-bandeau { height: 130px; }
  .ag-d-moi .btn { min-height: 44px; }
  /* Comparer : le tableau défile dans son cadre, la 1re colonne (journée) reste lisible */
  .ag-v-comparer .tb-wrap { display: block; max-width: 100%; }
  .ag-v-comparer .tb-cartes { display: none; }
  .ag-v-comparer .tb .tb-j-h { width: 150px; padding: 12px 10px; }
  .ag-v-comparer .tb-j { min-width: 150px; max-width: 150px; padding: 12px 10px; box-shadow: 1px 0 0 var(--td2-border); }
  .ag-v-comparer .tb-j .tb-tuile { display: none; }
  .ag-v-comparer .tb-circ { font-size: 15px; }
  .ag-v-comparer .tb-quand, .ag-v-comparer .tb-type { font-size: 12px; }
  .ag-v-comparer .tb .tb-p { min-width: 92px; }
  .ag-v-comparer .tb-logi, .ag-v-comparer .tb .tb-logi-h { min-width: 180px; }
  .ag-v-comparer .tb-mois-in { left: 10px; }
}
@media (max-width: 359px) {
  .ag-seg-perim button { padding: 0 9px; font-size: 13px; }
  .ag-vues button { font-size: 13px; padding: 0 4px; }
  .ag-mini { grid-template-columns: 1fr; }
  .ag-cal th { font-size: 9px; }
  .ag-puce { font-size: 8.5px; }
  .ag-v-comparer .tb .tb-j-h, .ag-v-comparer .tb-j { min-width: 128px; max-width: 128px; width: 128px; }
}
@media (prefers-reduced-motion: reduce) { .ag-item, .ag-puce { transition: none; } }

/* Lien « Partager … en image » sous mon statut (partager.html) */
.ag-d-partager { display: inline-flex; align-items: center; gap: 7px; margin: 10px 0 4px; font-size: 14px; }
.ag-d-partager .ico { width: 16px; height: 16px; }
