:root {
  /* Valeurs par défaut (thème "Clair mat"): remplacées dynamiquement par
     applyTheme() dans app.js selon le réglage choisi — voir la section Réglages.
     --glass-rgb pilote les petits éléments interactifs (boutons, champs, menus) et reste
     lié à la lisibilité du texte (sombre sur clair / clair sur sombre). --panel-rgb ne
     pilote QUE les 3 grands panneaux (gauche/droite/modales): pour les thèmes plats
     "mat", ce fond doit rester un voile blanc très translucide même en mode sombre (juste
     assez pour suggérer le verre), indépendamment de la couleur du texte — d'où la
     variable séparée plutôt que de réutiliser --glass-rgb partout. */
  --bg-1: oklch(0.86 0.05 250);
  --bg-2: oklch(0.88 0.05 340);
  --bg-3: oklch(0.9 0.04 90);
  --accent-color: #5b7fff;
  --accent-color-2: #ff7ab8;
  --glass-rgb: 255, 255, 255;
  --panel-rgb: 255, 255, 255;
  --panel-alpha-left: 0.16;
  --panel-alpha-right: 0.15;
  --panel-alpha-modal: 0.2;
  --panel-border: none;
  --blob-opacity: 0.7;
  /* Calibrées pour les fonds dégradés colorés (où un liseré blanc/gris ressort déjà
     naturellement): les thèmes plats "mat" les redéfinissent pour garder la même
     hiérarchie visuelle (colonnes, blocs, boutons détachés du fond) sur un fond uni. */
  --col-separator: rgba(120, 100, 140, 0.14);
  --hour-line-color: rgba(120, 100, 140, 0.10);
  --event-border: none;
  --event-shadow: 0 12px 24px -8px rgba(30, 20, 50, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  --control-ring: rgba(255, 255, 255, 0.4);
  --text-dark: oklch(0.27 0.015 60);
  --text-mid: oklch(0.42 0.02 60);
  /* Épaisseur des lignes de grille (heures + séparateurs de colonnes/cellules). Un trait
     de "1px CSS" ne correspond à un pixel PHYSIQUE net que si devicePixelRatio est un
     entier propre; sur beaucoup d'écrans 2K/4K le ratio effectif (zoom OS + panneau) est
     fractionnaire, et le rendu du trait est anti-aliasé sur plusieurs pixels physiques à
     intensité réduite jusqu'à devenir quasi invisible — indépendamment de l'opacité de la
     couleur. On compense en épaississant le trait CSS selon la densité réelle de l'écran
     (voir les media queries plus bas), pour qu'il reste net à toute résolution.
     Utilisée à la fois dans le background-image des lignes d'heure et dans les box-shadow
     des séparateurs de colonnes/cellules, pour ne définir la logique qu'une seule fois. */
  --line-width: 1px;
}

@media (min-resolution: 1.5dppx) {
  :root { --line-width: 1.5px; }
}
@media (min-resolution: 2dppx) {
  :root { --line-width: 1.75px; }
}
@media (min-resolution: 2.5dppx) {
  :root { --line-width: 2px; }
}
@media (min-resolution: 3dppx) {
  :root { --line-width: 2.25px; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(60, 50, 70, 0.18); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes flashGlow {
  0% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 8px 24px rgba(0, 0, 0, .12); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0), 0 4px 14px rgba(0, 0, 0, .08); }
}

/* ---------- Page & fond ---------- */

.page {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
  color: var(--text-dark);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
}

/* Pas de vraie photo d'arrière-plan disponible (le fichier de référence utilise un
   image-slot vide, sans image réelle) — on reproduit le rendu par un dégradé de
   couleurs flouté équivalent, cf. rapport final. */
.bg-color-layer {
  position: absolute;
  inset: -10%;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 22%, var(--accent-color) 0%, transparent 42%),
    radial-gradient(circle at 82% 15%, var(--accent-color-2) 0%, transparent 45%),
    radial-gradient(circle at 30% 85%, var(--accent-color-2) 0%, transparent 40%),
    radial-gradient(circle at 88% 78%, var(--accent-color) 0%, transparent 45%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  filter: blur(60px) saturate(1.4);
  transform: scale(1.15);
  opacity: var(--blob-opacity);
}

.bg-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(150deg, rgba(255, 255, 255, .28), rgba(240, 235, 255, .12) 45%, rgba(255, 255, 255, .24));
}

.content {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 20px;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;
}
/* [hidden] { display: none } de l'UA perd contre le display: flex ci-dessus à
   spécificité égale (les styles d'auteur gagnent les ex-aequo) — override explicite,
   même pattern que .modal-overlay[hidden] plus bas dans ce fichier. */
.content[hidden] { display: none; }

/* ---------- Écran de connexion (Clerk, voir public/app.js) ---------- */

.auth-screen {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;
}
.auth-screen[hidden] { display: none; } /* voir commentaire sur .content[hidden] plus haut */

.auth-screen-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.auth-screen-header .chat-avatar { width: 44px; height: 44px; font-size: 19px; }
.auth-screen-title { font-size: 22px; font-weight: 700; color: var(--text-dark); }
.auth-screen-subtitle { font-size: 13px; color: var(--text-mid); }

#clerk-sign-in {
  background: rgba(var(--panel-rgb), var(--panel-alpha-modal));
  border: var(--panel-border);
  backdrop-filter: blur(32px) saturate(1.7);
  -webkit-backdrop-filter: blur(32px) saturate(1.7);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(50, 30, 80, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 1.5px 0 rgba(255, 255, 255, 0.75);
  padding: 4px;
}

/* Bannière "Connecter Google Calendar" (voir #gcal-connect-banner dans index.html): un
   compte Google non connecté devient le cas normal au premier accès d'un nouvel
   utilisateur Nimbra, pas juste un cas rare comme avant l'authentification Clerk. */
.gcal-connect-banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(var(--glass-rgb), 0.22);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--control-ring);
}
.gcal-connect-banner[hidden] { display: none; } /* voir commentaire sur .content[hidden] plus haut */
.gcal-connect-title { font-size: 12.5px; font-weight: 700; color: var(--text-dark); }
.gcal-connect-body { font-size: 11.5px; color: var(--text-mid); }
.gcal-connect-btn {
  flex: none;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-2));
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(91, 127, 255, 0.27);
}

/* Écran de blocage "Connecter Google Calendar" (#gcal-gate-screen dans index.html):
   réutilise .auth-screen/.gcal-connect-btn (voir plus haut) mais le bouton principal, seule
   action possible sur un écran plein page, doit être plus proéminent que sa version dans la
   petite bannière .gcal-connect-banner — d'où ce sélecteur plus spécifique plutôt qu'un
   nouveau bouton dupliqué. */
#gcal-gate-screen .gcal-connect-btn {
  padding: 13px 26px;
  border-radius: 14px;
  font-size: 14px;
}

.gcal-gate-error {
  max-width: 360px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(229, 72, 77, 0.16);
  box-shadow: inset 0 0 0 1px rgba(229, 72, 77, 0.4);
  color: var(--text-dark);
  font-size: 12.5px;
  line-height: 1.4;
}
.gcal-gate-error[hidden] { display: none; } /* voir commentaire sur .content[hidden] plus haut */

.gcal-gate-signout-btn {
  border: none;
  background: none;
  color: var(--text-mid);
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}
.gcal-gate-signout-btn:hover { color: var(--text-dark); }

/* Point de montage Clerk.mountUserButton() dans .chat-header — taille alignée sur
   .new-conv-btn juste à côté pour ne pas casser le rythme visuel de la rangée de boutons. */
#user-button {
  flex: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Panneaux (glassmorphism) ---------- */

.left-panel {
  flex: 1 1 72%;
  display: flex;
  flex-direction: column;
  padding: 18px 22px;
  box-sizing: border-box;
  min-width: 0;
  gap: 14px;
  background: rgba(var(--panel-rgb), var(--panel-alpha-left));
  border: var(--panel-border);
  backdrop-filter: blur(30px) saturate(1.7);
  -webkit-backdrop-filter: blur(30px) saturate(1.7);
  border-radius: 28px;
  box-shadow: 0 18px 46px rgba(60, 30, 90, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 1.5px 0 rgba(255, 255, 255, 0.7);
}

.right-panel {
  flex: 0 1 340px;
  min-width: 250px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(var(--panel-rgb), var(--panel-alpha-right));
  border: var(--panel-border);
  backdrop-filter: blur(32px) saturate(1.7);
  -webkit-backdrop-filter: blur(32px) saturate(1.7);
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(50, 30, 80, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 1.5px 0 rgba(255, 255, 255, 0.75);
}

/* ---------- Barre d'outils ---------- */

.toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.today-btn {
  flex: none;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 10px;
  border: none;
  background: rgba(var(--glass-rgb), 0.3);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--control-ring);
  color: var(--text-dark);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 10px;
  border: none;
  background: rgba(var(--glass-rgb), 0.3);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--control-ring);
  color: var(--text-dark);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.segment-group {
  flex: none;
  display: flex;
  background: rgba(var(--glass-rgb), 0.25);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--control-ring);
  border-radius: 14px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  flex: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: transparent;
  color: var(--text-mid);
}

/* Couleur d'accent plutôt qu'un simple blanc plus opaque: sur un thème clair, un fond
   quasi blanc (85% blanc) sur une piste elle-même quasi blanche ne se distinguait pas
   assez de l'état inactif ("blanc sur blanc", signalé après coup). L'accent contraste
   nettement quel que soit le thème (clair ou sombre). */
.seg-btn.active {
  background: var(--accent-color);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.new-event-btn {
  flex: none;
  white-space: nowrap;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-2));
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(91, 127, 255, 0.27);
}

/* ---------- Grille calendrier ---------- */
/* Grille à 4 zones (coin vide / bande de dates / gouttière d'heures / grille maître) pour
   que la bande de dates et la gouttière restent visibles pendant le scroll: seule
   .week-columns-row (ou .day-columns-row) défile réellement dans les deux sens (scrollbars
   natives, donc toujours ancrées en bas/à droite de la zone visible); les deux autres bandes
   ont leur scroll piloté en JS (voir app.js) en miroir de ce scroll maître. */

.week-grid-wrap, .day-grid-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 58px 1fr;
  grid-template-rows: 52px 1fr;
}

.week-grid-wrap[hidden], .day-grid-wrap[hidden] { display: none; }

.grid-corner { grid-column: 1; grid-row: 1; }

.week-header-row, .day-header-row {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  min-width: 0;
  overflow: hidden;
  justify-self: start;
}

.gutter-body {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.week-columns-row, .day-columns-row {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scroll-snap-type: x mandatory;
}

.hour-label {
  position: absolute;
  right: 6px;
  width: 50px;
  text-align: right;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
}

.day-col {
  flex: 0 0 calc(100% / 7);
  min-width: 0;
  position: relative;
  scroll-snap-align: start;
}
/* box-shadow inset plutôt que border: une bordure de 1px CSS sur une colonne de largeur
   fractionnaire (100%/7) peut se retrouver rendue sur une fraction de pixel physique sur
   écran haute densité et devenir quasi invisible (anti-aliasing), même avec une opacité
   correcte. Le box-shadow est peint à l'intérieur de la boîte de l'élément et ne dépend
   pas d'un partage de bord avec la colonne voisine, donc rendu net à toute résolution. */
.day-col:not(:last-child) { box-shadow: inset calc(-1 * var(--line-width)) 0 0 0 var(--col-separator); }

.day-col-header {
  flex: 0 0 calc(100% / 7);
  min-width: 0;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}
.day-col-header.today { color: var(--accent-color); }

.day-col-name { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.day-col-num { font-size: 15px; font-weight: 700; }
.day-col-num.today {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Lignes horaires: un empilement de vraies sous-boîtes (une par heure) avec un box-shadow
   sur leur propre bord bas, plutôt qu'un repeating-linear-gradient. Mesuré objectivement
   (Playwright + pngjs, luminance pixel par pixel): le gradient répété perd presque toute
   sa netteté à certains devicePixelRatio fractionnaires (1.25, 1.5, ~2), alors que le
   box-shadow ancré sur un vrai bord d'élément (même technique que .day-col ci-dessus)
   reste net à tous les DPR testés (1 à 3). */
.hour-lines-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hour-line-row {
  position: absolute;
  left: 0;
  right: 0;
  box-shadow: inset 0 calc(-1 * var(--line-width)) 0 0 var(--hour-line-color);
}

.day-header {
  flex: 0 0 100%;
  min-width: 0;
  height: 52px;
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
}

.day-body {
  flex: 0 0 100%;
  min-width: 0;
  position: relative;
  border-radius: 10px;
  scroll-snap-align: start;
}

/* Bloc d'événement */

.event-block {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 16px;
  padding: 5px 9px;
  box-sizing: border-box;
  overflow: hidden;
  isolation: isolate;
  background: rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: var(--event-shadow);
  cursor: pointer;
  border: var(--event-border);
  text-align: left;
  font: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

/* L'effet de survol (agrandissement + halo) ne s'applique PAS ici sur l'élément réel: ses
   ancêtres (.day-columns-row/.week-columns-row pour le scroll, .month-cell/.month-events-list
   pour le troncage "+X de plus") ont besoin de leur overflow (auto/hidden) pour fonctionner,
   et ce même overflow coupe systématiquement le halo dès qu'il dépasse l'élément — un
   z-index seul ne suffit pas à s'en échapper puisque overflow clippe indépendamment de
   l'ordre d'empilement. Solution: au survol (voir buildEventBlock dans app.js), un clone
   visuel est positionné en position: fixed dans #event-hover-portal, hors de toute
   grille/ancêtre à overflow — lui seul reçoit l'agrandissement et le halo ci-dessous. */
#event-hover-portal {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}


.event-hover-clone {
  position: fixed !important;
  margin: 0;
  pointer-events: none;
  transform: scale(1.035);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 18px 2px var(--dot-color-glow, rgba(91, 127, 255, 0.35)), 0 8px 24px rgba(0, 0, 0, 0.12);
}

.event-block.day-variant { left: 8px; right: 8px; }
.event-block.flash { animation: flashGlow 1.6s ease-out; }

.event-block::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent-color));
  box-shadow: 0 0 5px var(--dot-color, var(--accent-color));
  pointer-events: none;
}

.event-title-week { font-size: 10px; font-weight: 700; line-height: 1.15; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 9px; }
.event-time-week { font-size: 9px; color: var(--text-mid); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 9px; }
.event-title-day { font-size: 14px; font-weight: 700; color: var(--text-dark); padding-left: 12px; }
.event-time-day { font-size: 12px; color: var(--text-mid); margin-top: 3px; padding-left: 12px; }

/* Bloc d'événement compact de la vue Mois: pas de positionnement absolu par heure (pas
   d'axe horaire en vue mois), juste un chip empilé dans le flux de la cellule. Le point de
   catégorie du ::before partagé est désactivé au profit d'un vrai span (plus simple à aligner
   dans ce layout en ligne compacte). */
.event-block.month-variant {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  height: auto;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
}
.event-block.month-variant::before { display: none; }

.month-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent-color));
  box-shadow: 0 0 4px var(--dot-color, var(--accent-color));
  margin-right: 5px;
}

.event-title-month {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Vue Mois ---------- */

.month-grid-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.month-grid-wrap[hidden] { display: none; }

/* Défile latéralement en miroir de .month-body (même principe que .day-header-row pour
   .day-columns-row): une cellule pleine largeur par mois tamponné, scrollLeft recopié en
   direct au fil du geste plutôt qu'un texte qui ne changerait qu'à l'arrêt du scroll. */
.month-title-row {
  flex: none;
  display: flex;
  overflow: hidden;
}
.month-title-cell {
  flex: 0 0 100%;
  min-width: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-dark);
  padding: 2px 4px 14px;
}

.month-header-row { flex: none; display: flex; }
.month-header-cell {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-mid);
  opacity: .7;
}

/* La bande de noms de jours (.month-header-row) ne bouge jamais: elle est statique (les 7
   noms sont les mêmes quel que soit le mois affiché). Seul .month-body défile latéralement,
   un mois entier (.month-page) à la fois, avec un tampon de mois de chaque côté — même
   principe que le scroll latéral des vues Semaine/Jour (voir renderMonthGrid dans app.js). */
.month-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
}

.month-page {
  flex: 0 0 100%;
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  scroll-snap-align: start;
}

.month-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  min-height: 0;
  overflow: hidden;
  /* box-shadow plutôt que border, même raison que .day-col ci-dessus (netteté sur
     colonnes/lignes de largeur fractionnaire, écrans haute densité). */
  box-shadow: inset calc(-1 * var(--line-width)) 0 0 0 var(--col-separator), inset 0 calc(-1 * var(--line-width)) 0 0 var(--col-separator);
  cursor: pointer;
}
.month-cell.other-month { opacity: 0.4; }

.month-day-num {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
}
.month-day-num.today { background: var(--accent-color); color: #fff; }

.month-events-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}

.month-more-link {
  flex: none;
  align-self: flex-start;
  background: none;
  border: none;
  padding: 1px 4px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-mid);
  cursor: pointer;
}
.month-more-link:hover { text-decoration: underline; }

/* ---------- Panneau assistant ---------- */

.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

.chat-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.chat-header-text { flex: 1 1 auto; min-width: 0; }
.chat-title { font-size: 14px; font-weight: 700; color: var(--text-dark); }
.chat-subtitle { font-size: 11.5px; color: var(--text-mid); }

.new-conv-btn {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 10px;
  border: none;
  background: rgba(var(--glass-rgb), 0.3);
  box-shadow: inset 0 0 0 1px var(--control-ring);
  color: var(--text-dark);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.new-conv-btn:hover { background: rgba(var(--glass-rgb), 0.5); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.msg-row { display: flex; }
.msg-row.user { justify-content: flex-end; }
.msg-row.bot { justify-content: flex-start; }

.bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}

.bubble.user {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 127, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.bubble.bot {
  background: rgba(var(--glass-rgb), 0.28);
  color: var(--text-dark);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 2px 4px; }
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-mid);
  opacity: 0.5;
  animation: typingBounce 1.1s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.proposal-card { margin-top: 9px; padding: 10px 11px; border-radius: 11px; }
.proposal-title { font-size: 13px; font-weight: 700; color: var(--text-dark); }
.proposal-meta { font-size: 11.5px; color: var(--text-mid); margin-top: 2px; }
.proposal-actions { display: flex; gap: 8px; margin-top: 9px; }

.proposal-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 9px;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.proposal-btn.confirm {
  color: #fff;
  /* Fallback pour les boutons "tout confirmer" de l'extraction (buildExtractionCard),
     qui n'ont pas de couleur de catégorie unique à appliquer en inline comme le fait
     buildProposalCard pour une seule proposition (voir confirmBtn.style.background). */
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-2));
}
.proposal-btn.cancel {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(var(--glass-rgb), 0.5);
  color: var(--text-mid);
  font-weight: 600;
}

.proposal-status { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--text-mid); }

/* ---------- Cartes de proposition en liste (toute réponse du chat avec 1+ add_event) ---------- */
/* .proposal-item réutilise .proposal-card (même halo de couleur par catégorie posé en
   inline par JS) mais remplace ses boutons Confirmer/Annuler par un unique bouton
   "Retirer" quand il y a plusieurs propositions: la confirmation/annulation se fait en
   bloc, une seule fois, tout en bas via .proposal-actions (réutilisé tel quel pour
   "Confirmer tout"/"Annuler tout" — ou juste "Confirmer"/"Annuler" s'il n'y en a qu'une). */
.proposals-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.proposal-item { margin-top: 0; position: relative; padding-right: 68px; }

.proposal-remove-btn {
  position: absolute;
  top: 10px;
  right: 11px;
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(var(--glass-rgb), 0.55);
  color: var(--text-mid);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.proposal-remove-btn:hover { background: rgba(var(--glass-rgb), 0.75); }

/* ---------- Fichiers en attente (choisis mais pas encore envoyés, voir pendingFiles
   dans app.js) et chips en lecture seule dans une bulle déjà envoyée ---------- */
.pending-files-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}
/* [hidden] { display: none } de l'UA perd contre le display: flex ci-dessus à
   spécificité égale (les styles auteur gagnent toujours) — même correctif que
   .modal-field-group[hidden] plus bas dans ce fichier. */
.pending-files-row[hidden] { display: none; }

/* Compteurs de rate limiting (#chat-usage-row dans index.html) — discrets, alignés avec
   .pending-files-row juste au-dessus. */
.chat-usage-row {
  display: flex;
  justify-content: space-between;
  padding: 0 16px 6px;
  font-size: 11px;
  color: var(--text-mid);
}
.chat-usage-row[hidden] { display: none; } /* voir commentaire sur .pending-files-row[hidden] plus haut */
.chat-usage-item.chat-usage-warn { color: #e5484d; font-weight: 600; }

.pending-file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 10px;
  border-radius: 20px;
  background: rgba(var(--glass-rgb), 0.35);
  box-shadow: inset 0 0 0 1px var(--control-ring);
  font-size: 12px;
  color: var(--text-dark);
  max-width: 220px;
}
.pending-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pending-file-remove {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(var(--glass-rgb), 0.6);
  color: var(--text-mid);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.pending-file-remove:hover { background: rgba(var(--glass-rgb), 0.85); }

/* Chips en lecture seule (pas de bouton retirer) affichées dans la bulle du message
   utilisateur une fois envoyé — voir msg.files dans buildMessageRow. */
.msg-files-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-file-chip {
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 11.5px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-input-row {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.5);
}

.chat-input {
  flex: 1;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: rgba(var(--glass-rgb), 0.25);
  backdrop-filter: blur(10px);
  font: inherit;
  font-size: 13px;
  outline: none;
  color: var(--text-dark);
  resize: none;
  overflow-y: hidden;
  max-height: 160px;
  line-height: 1.4;
}
.chat-input::placeholder { color: var(--text-mid); }

.send-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  border: none;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-2));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.upload-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  border: none;
  background: rgba(var(--glass-rgb), 0.3);
  box-shadow: inset 0 0 0 1px var(--control-ring);
  color: var(--text-dark);
  font-size: 16px;
  cursor: pointer;
}
.upload-btn:hover { background: rgba(var(--glass-rgb), 0.5); }

/* ---------- Modale nouvel/modifier événement ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(40, 30, 55, 0.25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay[hidden] { display: none; }

.modal-card {
  width: 340px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: rgba(var(--panel-rgb), var(--panel-alpha-modal));
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border-radius: 24px;
  border: var(--panel-border);
  box-shadow: 0 18px 46px rgba(60, 30, 90, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 1.5px 0 rgba(255, 255, 255, 0.7);
}

.modal-title { font-size: 16px; font-weight: 700; color: var(--text-dark); margin-bottom: 2px; }

.modal-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(var(--glass-rgb), 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 13.5px;
  outline: none;
  color: var(--text-dark);
}

.modal-row { display: flex; gap: 8px; }
.modal-row > .modal-field-group { flex: 1; min-width: 0; }
.modal-field-group { display: flex; flex-direction: column; gap: 4px; }
/* Un display explicite sur .modal-field-group (comme sur .recurrence-details/-weekdays
   plus bas) prime sur la règle UA [hidden] { display: none } à spécificité égale (les
   styles auteur gagnent toujours sur les styles UA) — sans cette règle, poser .hidden =
   true en JS sur #modal-recurrence-group ne masquerait rien. Même correctif déjà en place
   pour .time-wheel/.custom-select-menu plus bas dans ce fichier. */
.modal-field-group[hidden] { display: none; }
.modal-field-label { font-size: 11.5px; font-weight: 600; color: var(--text-mid); }
.modal-actions { display: flex; gap: 8px; margin-top: 6px; }

/* ---------- Sélecteurs de date/heure custom (remplacent les input type=date/time natifs,
   impossibles à styler en liquid glass) ---------- */

.field-popover-wrap { position: relative; }

.field-trigger {
  width: 100%;
  display: block;
  text-align: left;
  font: inherit;
  color: var(--text-dark);
  cursor: pointer;
}

.date-popover, .time-popover {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 20;
  /* Fond teinté sombre (var(--glass-rgb), pas du blanc) et plus opaque + plus flouté que
     la modale derrière: le texte (--text-dark) est clair, pensé pour un fond sombre — un
     fond blanc plus opaque le rendrait illisible (délavé) au lieu d'améliorer la lisibilité. */
  background: rgba(var(--glass-rgb), 0.82);
  backdrop-filter: blur(36px) saturate(1.6);
  -webkit-backdrop-filter: blur(36px) saturate(1.6);
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  padding: 10px;
}

/* Largeur fixe et compacte plutôt que pleine largeur du champ: un mois à 6 lignes reste
   assez court pour ne pas trop déborder sous la modale (qui n'est pas bien haute). */
.date-popover { left: 0; width: 232px; }

.date-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.date-cal-label { font-size: 12px; font-weight: 700; color: var(--text-dark); }

.date-cal-weekdays, .date-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.date-cal-weekdays { margin-bottom: 2px; }
.date-cal-weekday {
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-mid);
  opacity: .7;
}

.date-cal-day {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dark);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  background: none;
}
.date-cal-day:hover { background: rgba(var(--glass-rgb), 0.4); }
.date-cal-day.other-month { opacity: 0.35; }
.date-cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent-color); }
.date-cal-day.selected { background: var(--accent-color); color: #fff; box-shadow: none; }

/* Roulette d'heure façon iOS: chaque colonne défile indépendamment (scroll-snap natif
   pour l'accroche en fin de geste), l'opacité/échelle de chaque item est recalculée en JS
   à chaque scroll (voir buildWheel/applyWheelFade dans app.js) pour l'effet de profondeur. */
.time-popover { width: 220px; }

.time-wheel-row {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 4px;
  height: 180px; /* 5 lignes visibles de 36px, doit rester cohérent avec TIME_ITEM_HEIGHT en JS */
}

.time-wheel-indicator {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 36px;
  transform: translateY(-50%);
  border-top: 1px solid rgba(var(--glass-rgb), 0.6);
  border-bottom: 1px solid rgba(var(--glass-rgb), 0.6);
  background: rgba(var(--glass-rgb), 0.12);
  border-radius: 8px;
  pointer-events: none;
}

.time-wheel {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.time-wheel::-webkit-scrollbar { display: none; }
.time-wheel[hidden] { display: none; }

.time-wheel-track { display: flex; flex-direction: column; }

.time-wheel-item {
  height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  scroll-snap-align: center;
  cursor: pointer;
  will-change: transform, opacity;
}

.time-done-btn { width: 100%; margin-top: 12px; }

/* ---------- Récurrence (modale "Nouvel événement", création uniquement) ---------- */

.recurrence-details { display: flex; flex-direction: column; gap: 11px; }
.recurrence-details[hidden] { display: none; } /* voir commentaire sur .modal-field-group[hidden] plus haut */
.recurrence-unit-label { display: flex; align-items: center; color: var(--text-mid); }

.recurrence-weekdays { display: flex; gap: 6px; }
.recurrence-weekdays[hidden] { display: none; } /* voir commentaire sur .modal-field-group[hidden] plus haut */
.recurrence-weekday-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(var(--glass-rgb), 0.25);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-mid);
  cursor: pointer;
}
.recurrence-weekday-btn.selected {
  background: var(--accent-color);
  border-color: transparent;
  color: #fff;
}

/* Positionné dans .field-popover-wrap (position: relative), par-dessus le bouton
   déclencheur de la date de fin — visible seulement quand une date de fin est choisie
   (voir modalRecurrenceEndClearBtn.hidden dans app.js). */
.recurrence-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(var(--glass-rgb), 0.6);
  color: var(--text-mid);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.recurrence-clear-btn:hover { background: rgba(var(--glass-rgb), 0.85); }

/* Au-dessus de la modale nouvel/modifier événement (z-index 10): la confirmation de
   suppression s'affiche par-dessus, avec son propre overlay flouté. */
.confirm-overlay { z-index: 11; }

.confirm-card {
  width: 300px;
  background: rgba(var(--panel-rgb), var(--panel-alpha-modal));
  border: var(--panel-border);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border-radius: 20px;
  box-shadow: 0 18px 46px rgba(60, 30, 90, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  padding: 24px;
}

.confirm-subtitle { font-size: 13px; color: var(--text-mid); }

/* ---------- Réglages ---------- */

.settings-card {
  width: 380px;
  max-height: 82vh;
  overflow-y: auto;
  background: rgba(var(--panel-rgb), var(--panel-alpha-modal));
  border: var(--panel-border);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border-radius: 24px;
  box-shadow: 0 18px 46px rgba(60, 30, 90, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.settings-section { display: flex; flex-direction: column; gap: 8px; }
.settings-label { font-size: 12.5px; font-weight: 600; color: var(--text-mid); }


.settings-legal-links { display: flex; gap: 16px; }
.settings-legal-links a { font-size: 12.5px; color: var(--accent-color); text-decoration: none; }
.settings-legal-links a:hover { text-decoration: underline; }

.color-picker-row { display: flex; gap: 16px; }
.color-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
}
.color-picker-item input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

/* Dropdown custom (catégorie) — un <select> natif ne peut pas être flouté dans sa
   liste ouverte (rendu OS/navigateur), donc on reproduit le comportement en HTML/CSS/JS
   pur pour garder le liquid glass jusque dans la liste ouverte. */
.custom-select {
  position: relative;
  flex: 1;
  outline: none;
}

.custom-select-trigger {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(var(--glass-rgb), 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--text-dark);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: rgba(var(--glass-rgb), 0.35);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(60, 30, 90, 0.18);
}
.custom-select-menu[hidden] { display: none; }

.custom-select-option {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
}
.custom-select-option:hover { background: rgba(var(--glass-rgb), 0.4); }

.modal-btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-mid);
}
.modal-btn.primary { border: none; background: var(--accent-color); color: #fff; font-weight: 700; }
.modal-btn.danger { border: 1px solid rgba(255, 90, 90, 0.4); background: rgba(255, 90, 90, 0.12); color: #b23a3a; }
.modal-btn.danger-solid { border: none; background: #e5484d; color: #fff; font-weight: 700; box-shadow: 0 4px 14px rgba(229, 72, 77, 0.35); }

@media (max-width: 900px) {
  .content { flex-direction: column; }
  .left-panel, .right-panel { flex: none; max-width: none; }
  .left-panel { height: 55vh; }
  .right-panel { height: 42vh; }
}
