/* ==========================================================================
   Calendrier — feuille de style unique (2026-09-04)
   Remplace style.css + header.css + calendrier_papier.css + event_popup.css.
   Palette alignée sur la couleur de l'app dans le hub (#5856d6).
   ========================================================================== */

:root {
  --cal-accent: #5b5bd6;
  --cal-accent-strong: #4a49c4;
  --cal-accent-soft: rgba(91, 91, 214, 0.12);
  --cal-danger: #e5484d;

  --cal-bg: #f4f5fa;
  --cal-surface: #ffffff;
  --cal-surface-2: #fafaff;
  --cal-line: rgba(17, 17, 26, 0.09);
  --cal-line-soft: rgba(17, 17, 26, 0.045);
  --cal-text: #1b1b23;
  --cal-text-soft: #6b6b7b;
  --cal-shadow: 0 1px 2px rgba(17, 17, 26, 0.04), 0 8px 24px rgba(17, 17, 26, 0.06);
  --cal-shadow-lift: 0 6px 16px rgba(17, 17, 26, 0.12), 0 20px 40px rgba(17, 17, 26, 0.14);

  --cal-hour: 52px;          /* hauteur d'une heure dans les vues jour/semaine */
  --cal-gutter: 62px;        /* largeur de la colonne des heures */
  --cal-radius: 16px;
}

html[data-theme="dark"] {
  --cal-accent: #7d7cf0;
  --cal-accent-strong: #9391ff;
  --cal-accent-soft: rgba(125, 124, 240, 0.18);
  --cal-danger: #ff6369;

  --cal-bg: #121218;
  --cal-surface: #1c1c25;
  --cal-surface-2: #21212c;
  --cal-line: rgba(255, 255, 255, 0.1);
  --cal-line-soft: rgba(255, 255, 255, 0.05);
  --cal-text: #f2f2f7;
  --cal-text-soft: #a0a0b2;
  --cal-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --cal-shadow-lift: 0 6px 16px rgba(0, 0, 0, 0.5), 0 20px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--cal-bg);
  color: var(--cal-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.cal-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

/* ------------------------------------------------------------------ boutons */
.cal-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.cal-btn:active { transform: translateY(1px); }

.cal-btn-primary {
  background: var(--cal-accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 91, 214, 0.28);
}
.cal-btn-primary:hover { background: var(--cal-accent-strong); }

.cal-btn-soft {
  background: var(--cal-surface);
  border-color: var(--cal-line);
  color: var(--cal-text);
}
.cal-btn-soft:hover { border-color: var(--cal-accent); color: var(--cal-accent); }

.cal-btn-ghost {
  background: var(--cal-surface);
  border-color: var(--cal-line);
  color: var(--cal-text-soft);
}
.cal-btn-ghost:hover { color: var(--cal-text); border-color: var(--cal-accent); }

.cal-btn-ghost.is-connected { color: var(--cal-accent); border-color: var(--cal-accent); }

.cal-btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--cal-danger);
}
.cal-btn-danger:hover { background: rgba(229, 72, 77, 0.12); }

.cal-btn[disabled] { opacity: 0.55; cursor: default; }

/* [hidden] doit gagner contre le display:inline-flex des boutons */
[hidden] { display: none !important; }

.cal-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--cal-line);
  border-radius: 11px;
  background: var(--cal-surface);
  color: var(--cal-text-soft);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.cal-icon-btn:hover { color: var(--cal-accent); border-color: var(--cal-accent); }

/* ------------------------------------------------------------------- header */
.cal-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  /* la marge de droite laisse la place au bouton flottant de settings.js */
  padding: 14px 62px 14px 20px;
  background: var(--cal-surface);
  border-bottom: 1px solid var(--cal-line);
  flex: 0 0 auto;
}

.cal-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.cal-brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--cal-accent), #8f7bf5);
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(91, 91, 214, 0.35);
}

.cal-brand-copy { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.cal-brand-copy strong { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.cal-brand-copy small { font-size: 0.75rem; color: var(--cal-text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cal-auth-slot { display: flex; align-items: center; }

/* ------------------------------------------------------------------ toolbar */
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--cal-bg);
  border-bottom: 1px solid var(--cal-line);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.cal-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }

.cal-period {
  margin: 0 0 0 6px;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-period .cal-period-year { color: var(--cal-text-soft); font-weight: 600; }

.cal-views {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--cal-surface);
  border: 1px solid var(--cal-line);
  margin-inline: auto;
}

.cal-view-btn {
  border: 0;
  background: transparent;
  color: var(--cal-text-soft);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.cal-view-btn:hover { color: var(--cal-text); }
.cal-view-btn.is-active {
  background: var(--cal-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 91, 214, 0.3);
}

/* --------------------------------------------------------------- surface */
.cal-main {
  flex: 1 1 auto;
  min-height: 0;
  /* Le calendrier doit occuper toute la page (Alexandre, 2026-09-21) : juste
     assez de marge pour distinguer la carte du bord de la fenetre, plus le
     cadre de 16-20px d'avant. */
  padding: 8px;
  display: flex;
}

.cal-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--cal-surface);
  border: 1px solid var(--cal-line);
  border-radius: var(--cal-radius);
  box-shadow: var(--cal-shadow);
  overflow: hidden;
}

/* ============================ vues jour / semaine ======================== */
.cal-timegrid { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.cal-tg-head {
  display: grid;
  grid-template-columns: var(--cal-gutter) 1fr;
  border-bottom: 1px solid var(--cal-line);
  background: var(--cal-surface);
  flex: 0 0 auto;
}

.cal-tg-head-gutter { border-right: 1px solid var(--cal-line-soft); }

.cal-tg-head-days { display: grid; }

.cal-dayhead {
  padding: 10px 6px;
  text-align: center;
  border-left: 1px solid var(--cal-line-soft);
  min-width: 0;
}
.cal-dayhead:first-child { border-left: 0; }
.cal-dayhead-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cal-text-soft);
}
.cal-dayhead-num {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  margin-top: 4px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
}
.cal-dayhead.is-today .cal-dayhead-name { color: var(--cal-accent); }
.cal-dayhead.is-today .cal-dayhead-num { background: var(--cal-accent); color: #fff; }
.cal-dayhead.is-weekend .cal-dayhead-name,
.cal-dayhead.is-weekend .cal-dayhead-num { color: var(--cal-text-soft); }
.cal-dayhead.is-weekend.is-today .cal-dayhead-num { color: #fff; }

/* bandeau « journée entière » */
.cal-allday {
  display: grid;
  grid-template-columns: var(--cal-gutter) 1fr;
  border-bottom: 1px solid var(--cal-line);
  background: var(--cal-surface-2);
  flex: 0 0 auto;
  max-height: 108px;
  overflow-y: auto;
}
.cal-allday-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cal-text-soft);
  padding: 8px 8px 0 0;
  text-align: right;
  border-right: 1px solid var(--cal-line-soft);
}
.cal-allday-days { display: grid; }
.cal-allday-col {
  padding: 6px 5px;
  border-left: 1px solid var(--cal-line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.cal-allday-col:first-child { border-left: 0; }

.cal-tg-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: var(--cal-gutter) 1fr;
}

.cal-tg-gutter {
  position: relative;
  border-right: 1px solid var(--cal-line-soft);
  background: var(--cal-surface);
  z-index: 2;
}
.cal-hourlabel {
  position: absolute;
  right: 8px;
  /* Flush avec le haut de sa tranche, EXACTEMENT comme le trait (meme `top`
     pose par le JS) : avec des tranches de hauteurs differentes c'est le
     seul placement qui reste lisible, et le « 0:00 » n'est plus coupe par le
     bord de la grille. Un `margin-top` ici decalerait le texte SOUS le
     trait qu'il est cense annoncer — signale par Alexandre le 2026-09-22
     (« les heures ne sont pas correctement alignees sur les lignes »). */
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--cal-text-soft);
  font-variant-numeric: tabular-nums;
  transition: font-size 0.15s ease, color 0.15s ease;
}
/* Une heure qui contient quelque chose est plus haute ET s'annonce plus
   grand : c'est ce qui donne la sensation de zoom sur les moments charges
   (Alexandre, 2026-09-21 : « l'heure doit etre plus grosse que les autres »). */
.cal-hourlabel.is-zoomed {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--cal-text);
}

.cal-tg-cols { position: relative; display: grid; }

.cal-daycol {
  position: relative;
  border-left: 1px solid var(--cal-line-soft);
  min-width: 0;
}
.cal-daycol:first-child { border-left: 0; }
.cal-daycol.is-today { background: var(--cal-accent-soft); }
.cal-daycol.is-drop-target { background: var(--cal-accent-soft); }

.cal-hourline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--cal-line);
  pointer-events: none;
}
.cal-hourline.is-zoomed { border-top-color: var(--cal-line); }
/* Les demi-heures n'ont plus de sens : une tranche ne represente plus une
   duree constante. Le style reste pour la vue mois/agenda. */
.cal-halfline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--cal-line-soft);
  pointer-events: none;
}

/* trait « maintenant » */
.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--cal-danger);
  z-index: 6;
  pointer-events: none;
}
.cal-now::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cal-danger);
}

/* ----------------------------------------------------------- carte d'event */
.cal-event {
  position: absolute;
  display: flex;
  overflow: hidden;
  /* Pas de plancher ici : la hauteur vient du JS et vaut la duree reelle.
     Un `min-height` donnerait la meme taille a 3 min et a 15 min. */
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: var(--ev);
  background: color-mix(in srgb, var(--ev) 16%, var(--cal-surface));
  color: var(--cal-text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ev) 30%, transparent);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  z-index: 3;
}
html[data-theme="dark"] .cal-event {
  background: color-mix(in srgb, var(--ev) 30%, var(--cal-surface));
}
.cal-event:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ev) 55%, transparent), var(--cal-shadow); z-index: 5; }

.cal-event-bar {
  flex: 0 0 4px;
  background: var(--ev);
  border-radius: 8px 0 0 8px;
}

.cal-event-body {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3px 7px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
  overflow: hidden;
}

.cal-event-title {
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event-time,
.cal-event-place {
  font-size: 0.7rem;
  color: var(--cal-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Le redimensionnement a la souris a ete retire le 2026-09-21 : la hauteur
   d'un bloc ne dit plus sa duree, tirer son bord bas ne voudrait rien dire.
   Debut et fin se reglent dans la fiche. */

.cal-event.is-dragging {
  z-index: 40;
  box-shadow: var(--cal-shadow-lift);
  opacity: 0.94;
  cursor: grabbing;
}
.cal-event.is-ghost { opacity: 0.28; }

/* pastille « journée entière » et mois */
.cal-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--ev);
  background: color-mix(in srgb, var(--ev) 16%, var(--cal-surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ev) 28%, transparent);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme="dark"] .cal-chip { background: color-mix(in srgb, var(--ev) 30%, var(--cal-surface)); }
.cal-chip:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ev) 55%, transparent); }
.cal-chip-dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--ev); }
.cal-chip-hour { color: var(--cal-text-soft); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-chip-name { overflow: hidden; text-overflow: ellipsis; }
.cal-chip.is-dragging { box-shadow: var(--cal-shadow-lift); opacity: 0.95; }

/* sélection en cours de création */
.cal-selection {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 8px;
  background: var(--cal-accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--cal-accent);
  color: var(--cal-accent);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 30;
}

/* ================================ vue mois =============================== */
.cal-month { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.cal-month-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--cal-line);
  flex: 0 0 auto;
}
.cal-month-head span {
  padding: 9px 0;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cal-text-soft);
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
}

.cal-mday {
  border-top: 1px solid var(--cal-line-soft);
  border-left: 1px solid var(--cal-line-soft);
  padding: 5px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
}
.cal-mday:nth-child(7n + 1) { border-left: 0; }
.cal-mday:nth-child(-n + 7) { border-top: 0; }
.cal-mday.is-other { background: var(--cal-surface-2); }
.cal-mday.is-other .cal-mday-num { color: var(--cal-text-soft); opacity: 0.6; }
.cal-mday.is-drop-target { background: var(--cal-accent-soft); }

.cal-mday-num {
  align-self: flex-start;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.cal-mday.is-today .cal-mday-num { background: var(--cal-accent); color: #fff; }

.cal-mday-events { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow: hidden; }
.cal-mday-more { font-size: 0.7rem; font-weight: 600; color: var(--cal-text-soft); padding-left: 4px; }

/* =============================== vue agenda ============================== */
.cal-agenda { flex: 1; min-height: 0; overflow: auto; padding: 4px 0 20px; }

.cal-agenda-day {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--cal-line-soft);
}
.cal-agenda-day:first-child { border-top: 0; }
.cal-agenda-day.is-today { background: var(--cal-accent-soft); }

.cal-agenda-date { text-align: right; line-height: 1.2; padding-top: 2px; }
.cal-agenda-date strong { display: block; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.cal-agenda-date span { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--cal-text-soft); }
.cal-agenda-day.is-today .cal-agenda-date strong,
.cal-agenda-day.is-today .cal-agenda-date span { color: var(--cal-accent); }

.cal-agenda-list { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.cal-agenda-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--cal-surface-2);
  box-shadow: inset 0 0 0 1px var(--cal-line);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.cal-agenda-event:hover { transform: translateX(2px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ev) 45%, transparent), var(--cal-shadow); }
.cal-agenda-event-bar { flex: 0 0 4px; align-self: stretch; border-radius: 4px; background: var(--ev); }
.cal-agenda-event-hour { flex: 0 0 auto; font-size: 0.78rem; font-weight: 700; color: var(--cal-text-soft); font-variant-numeric: tabular-nums; min-width: 92px; }
.cal-agenda-event-copy { min-width: 0; }
.cal-agenda-event-copy strong { display: block; font-size: 0.92rem; font-weight: 650; }
.cal-agenda-event-copy small { display: block; font-size: 0.76rem; color: var(--cal-text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================ vide ================================== */
.cal-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--cal-text-soft);
  padding: 40px 20px;
  text-align: center;
}
.cal-empty i { font-size: 2rem; opacity: 0.35; }
.cal-empty p { margin: 0; font-size: 0.9rem; }

/* ================================ modale ================================ */
.cal-modal-backdrop {
  position: fixed;
  inset: 0;
  /* Pas de flou (retire le 2026-09-26, Alexandre : « quand on clique sur un
     evenement, le reste de l'ecran devient flou ») : le calendrier doit
     rester lisible derriere la fiche. Un leger voile suffit a detacher la
     boite. */
  background: rgba(12, 12, 20, 0.28);
  z-index: 900;
  animation: cal-fade 0.16s ease;
}

.cal-modal {
  position: fixed;
  z-index: 901;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: min(86dvh, 780px);
  background: var(--cal-surface);
  border-radius: 20px;
  box-shadow: var(--cal-shadow-lift);
  overflow: hidden;
  animation: cal-pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes cal-fade { from { opacity: 0; } }
@keyframes cal-pop { from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(0.97); } }

.cal-modal-form { display: flex; flex-direction: column; max-height: inherit; }

.cal-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--cal-line);
}
.cal-modal-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--cal-accent); flex: 0 0 auto; }
.cal-modal-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; flex: 1; }
.cal-modal-close { width: 32px; height: 32px; border-radius: 9px; }

/* Une boite longue (Importer) doit garder son pied visible et faire defiler
   SON CORPS, pas la page : la fiche d'evenement y arrivait grace au <form>
   (`.cal-modal-form`), les boites sans formulaire ont besoin de la meme chose.
   Le `:not([hidden])` est indispensable : un `display: flex` inconditionnel
   annulerait l'attribut `hidden` et afficherait toutes les boites. */
.cal-modal:not([hidden]) { display: flex; flex-direction: column; }
.cal-modal-form { flex: 1 1 auto; min-height: 0; }

.cal-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  flex: 1 1 auto;
  min-height: 0;
}

.cal-modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--cal-line);
  background: var(--cal-surface-2);
}
.cal-modal-spacer { flex: 1; }

.cal-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* Seuls les intitules de champ sont en petites capitales : un choix de radio
   ou une case a cocher est une phrase, pas une etiquette. */
.cal-field > label:not(.cal-radio):not(.cal-check):not(.cal-switch),
.cal-field-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cal-text-soft);
}
.cal-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.cal-field-row--2 { grid-template-columns: 1fr 1fr; }
.cal-field-row:has(.cal-field:only-child) { grid-template-columns: 1fr; }
.cal-field-inline { flex-direction: row; align-items: center; justify-content: space-between; }

.cal-field input[type="text"],
.cal-field input[type="date"],
.cal-field input[type="time"],
.cal-field select,
.cal-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cal-line);
  border-radius: 11px;
  background: var(--cal-surface-2);
  color: var(--cal-text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cal-field textarea { resize: vertical; min-height: 68px; }
.cal-field input:focus,
.cal-field select:focus,
.cal-field textarea:focus {
  outline: none;
  border-color: var(--cal-accent);
  box-shadow: 0 0 0 3px var(--cal-accent-soft);
}
.cal-field input[disabled] { opacity: 0.5; }

.cal-hint { margin: -4px 0 0; font-size: 0.78rem; color: var(--cal-text-soft); min-height: 1em; }

.cal-notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--cal-accent-soft);
  color: var(--cal-text);
  font-size: 0.8rem;
  line-height: 1.45;
}
.cal-notice a { color: var(--cal-accent); font-weight: 600; }

.cal-switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: 0 0 auto; }
.cal-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.cal-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--cal-line);
  transition: background 0.18s ease;
}
.cal-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease;
}
.cal-switch input:checked + span { background: var(--cal-accent); }
.cal-switch input:checked + span::after { transform: translateX(19px); }

.cal-palette { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--sw);
  box-shadow: 0 0 0 2px var(--cal-surface), 0 0 0 2px transparent;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.cal-swatch:hover { transform: scale(1.08); }
.cal-swatch.is-active { box-shadow: 0 0 0 2px var(--cal-surface), 0 0 0 4px var(--sw); }

/* ================================ toasts ================================ */
.cal-toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.cal-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: 12px;
  background: var(--cal-surface);
  box-shadow: var(--cal-shadow-lift);
  border-left: 3px solid var(--cal-accent);
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 340px;
  animation: cal-toast-in 0.2s ease;
}
.cal-toast.is-error { border-left-color: var(--cal-danger); }
.cal-toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s ease, transform 0.25s ease; }
@keyframes cal-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* =============================== responsive ============================= */
@media (max-width: 1080px) {
  .cal-brand-copy small { display: none; }
}

@media (max-width: 860px) {
  :root { --cal-gutter: 48px; }
  .cal-topbar { padding: 10px 56px 10px 12px; flex-wrap: wrap; }
  .cal-topbar-actions .cal-btn span { display: none; }
  .cal-topbar-actions .cal-btn { padding: 9px 11px; }
  .cal-toolbar { padding: 10px 12px; gap: 10px; }
  .cal-views { order: 3; width: 100%; margin: 0; justify-content: space-between; }
  .cal-view-btn { flex: 1; padding: 7px 6px; }
  .cal-period { font-size: 1rem; }
  .cal-main { padding: 10px 10px 12px; }
  .cal-agenda-day { grid-template-columns: 64px 1fr; gap: 10px; padding: 12px 12px; }
  .cal-agenda-event-hour { min-width: 0; }
  #cal-new-event span { display: none; }
}

/* ---------------------------------------------------- pendant un glissement */
body.cal-noselect,
body.cal-noselect * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* La pastille tiree ne doit pas se retrouver sous le curseur lors du
   hit-test de la case de destination (elementFromPoint). */
.cal-chip.is-dragging { pointer-events: none; position: relative; z-index: 40; }

.cal-btn-danger.is-armed {
  background: var(--cal-danger);
  color: #fff;
}

/* ------------------------------------------- confirmation de reinitialisation */
.cal-modal--sm { width: min(470px, calc(100vw - 32px)); }

.cal-modal-dot--danger { background: var(--cal-danger); }

.cal-btn-danger-solid {
  background: var(--cal-danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(229, 72, 77, 0.3);
}
.cal-btn-danger-solid:hover { filter: brightness(1.08); }

.cal-confirm-lead {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.cal-confirm-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cal-confirm-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--cal-text-soft);
}
.cal-confirm-list li strong { color: var(--cal-text); }
.cal-confirm-list i { margin-top: 2px; flex: 0 0 auto; }
.cal-confirm-list .is-removed i { color: var(--cal-danger); }
.cal-confirm-list .is-kept i { color: #22c55e; }

.cal-notice--danger {
  background: rgba(229, 72, 77, 0.12);
  font-weight: 600;
}

/* ==========================================================================
   Options Google Calendar (2026-09-06)
   ========================================================================== */

.cal-modal--lg { width: min(620px, calc(100vw - 32px)); }

/* ------------------------------------------------------ lignes a cocher */
/* Venaient du panneau des agendas Google (retire le 2026-09-21), reprises
   telles quelles par la liste des calendriers d'un fichier importe. */
.cal-panel-list { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }

.cal-panel-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 9px;
  font-size: 0.86rem;
  cursor: pointer;
}
.cal-panel-row:hover { background: var(--cal-surface-2); }
.cal-panel-row input { accent-color: var(--cal-accent); flex: 0 0 auto; }

.cal-panel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* --------------------------------------------------- sections du formulaire */
.cal-section-title {
  margin: 6px 0 -4px;
  padding-top: 10px;
  border-top: 1px solid var(--cal-line);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cal-text-soft);
}

/* portée : cet événement / toute la série */
.cal-scope {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--cal-accent-soft);
}
.cal-scope-label { font-size: 0.8rem; font-weight: 600; }

.cal-segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--cal-surface);
  border: 1px solid var(--cal-line);
  align-self: flex-start;
}
.cal-seg-btn {
  border: 0;
  background: transparent;
  color: var(--cal-text-soft);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.cal-seg-btn.is-active { background: var(--cal-accent); color: #fff; }

/* ------------------------------------------------------------ répétition */
.cal-subpanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px;
  border-radius: 12px;
  background: var(--cal-surface-2);
  border: 1px solid var(--cal-line);
}
.cal-subpanel.is-locked { opacity: 0.7; }

.cal-inline-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.87rem; }
.cal-inline-row input[type="email"] { flex: 1; min-width: 180px; }
.cal-inline-col { display: flex; flex-direction: column; gap: 8px; }

.cal-mini-input {
  width: 84px;
  padding: 7px 9px;
  border: 1px solid var(--cal-line);
  border-radius: 9px;
  background: var(--cal-surface);
  color: var(--cal-text);
  font: inherit;
  font-size: 0.86rem;
}
input.cal-mini-input[type="date"] { width: 150px; }

.cal-weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-weekday {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--cal-line);
  background: var(--cal-surface);
  color: var(--cal-text-soft);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cal-weekday:hover { border-color: var(--cal-accent); color: var(--cal-accent); }
.cal-weekday.is-active { background: var(--cal-accent); border-color: var(--cal-accent); color: #fff; }

/* ------------------------------------------------------- cases et radios */
.cal-radio,
.cal-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.87rem;
  cursor: pointer;
  line-height: 1.35;
}
.cal-radio input,
.cal-check input { accent-color: var(--cal-accent); flex: 0 0 auto; }
.cal-checks { display: flex; flex-direction: column; gap: 9px; }
.cal-check--danger { font-weight: 600; }
.cal-check--danger input { accent-color: var(--cal-danger); }

/* ------------------------------------------------------------- invités */
.cal-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.cal-guest {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px 5px 11px;
  border-radius: 999px;
  background: var(--cal-surface-2);
  box-shadow: inset 0 0 0 1px var(--cal-line);
  font-size: 0.8rem;
  max-width: 100%;
}
.cal-guest-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-guest-state { font-size: 0.7rem; color: var(--cal-text-soft); }
.cal-guest.is-accepted { box-shadow: inset 0 0 0 1px #22c55e; }
.cal-guest.is-declined { box-shadow: inset 0 0 0 1px var(--cal-danger); }
.cal-guest.is-accepted .cal-guest-state { color: #16a34a; }
.cal-guest.is-declined .cal-guest-state { color: var(--cal-danger); }
.cal-guest-remove {
  border: 0;
  background: transparent;
  color: var(--cal-text-soft);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 50%;
  font-size: 0.75rem;
}
.cal-guest-remove:hover { color: var(--cal-danger); }

/* -------------------------------------------------------- notifications */
.cal-reminders { display: flex; flex-direction: column; gap: 8px; }
.cal-reminder { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 0.85rem; }
.cal-reminder select {
  padding: 7px 9px;
  border: 1px solid var(--cal-line);
  border-radius: 9px;
  background: var(--cal-surface-2);
  color: var(--cal-text);
  font: inherit;
  font-size: 0.85rem;
}
.cal-btn-inline { align-self: flex-start; }

.cal-icon-btn-sm { width: 28px; height: 28px; border-radius: 8px; font-size: 0.75rem; }

/* ---------------------------------------------------------------- visio */

/* --------------------------------------------------------- couleur auto */
.cal-swatch--auto {
  position: relative;
  box-shadow: 0 0 0 2px var(--cal-surface), 0 0 0 3px var(--cal-line);
}
.cal-swatch--auto::after {
  content: "A";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------- toast warn */
.cal-toast.is-warn { border-left-color: #f59e0b; }

@media (max-width: 860px) {
  .cal-field-row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Coche « fait » et décalage global (2026-09-07)
   ========================================================================== */

/* La coche occupe toute la hauteur de la barre de l'événement, sur son bord
   droit : c'est une cible qu'on doit attraper sans viser. */
.cal-done-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 28px;
  padding: 0;
  border: 0;
  border-left: 1px solid color-mix(in srgb, var(--ev, var(--cal-accent)) 30%, transparent);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--ev, var(--cal-accent)) 12%, transparent);
  color: color-mix(in srgb, var(--ev, var(--cal-accent)) 75%, var(--cal-text));
  font-size: 0.82rem;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cal-event:hover .cal-done-btn,
.cal-chip:hover .cal-done-btn,
.cal-agenda-event:hover .cal-done-btn,
.cal-done-btn:hover,
.cal-done-btn:focus-visible { opacity: 1; }

.cal-done-btn:hover { background: color-mix(in srgb, var(--ev, var(--cal-accent)) 28%, transparent); }

.cal-done-btn.is-done {
  opacity: 1;
  background: var(--ev, var(--cal-accent));
  border-left-color: transparent;
  color: #fff;
}
.cal-done-btn.is-done:hover { filter: brightness(1.1); }

/* Réserver la place à droite pour que le titre ne passe pas dessous. */
.cal-event .cal-event-body { padding-right: 34px; }


.cal-chip { position: relative; padding-right: 32px; overflow: hidden; }
.cal-chip .cal-done-btn { width: 26px; border-radius: 0 7px 7px 0; font-size: 0.75rem; }

/* Les pastilles du mois font ~110 px de large : la coche y reste pleine
   hauteur, mais plus etroite, sinon elle mange le titre. */
.cal-mday-events .cal-chip { padding-right: 25px; }
.cal-mday-events .cal-chip .cal-done-btn { width: 20px; font-size: 0.68rem; }

.cal-agenda-event { position: relative; padding-right: 56px; overflow: hidden; }
.cal-agenda-event .cal-done-btn { width: 44px; border-radius: 0 12px 12px 0; font-size: 1rem; }

/* Fait : l'événement s'efface sans disparaître. */
.cal-event.is-done,
.cal-chip.is-done { opacity: 0.55; }
.cal-event.is-done .cal-event-title,
.cal-chip.is-done .cal-chip-name,
.cal-agenda-event.is-done .cal-agenda-event-copy strong {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.cal-agenda-event.is-done { opacity: 0.6; }

/* ------------------------------------------------------ boîte de décalage */
#shift-popup .cal-inline-row select,
#shift-popup .cal-inline-row input {
  /* .cal-field impose width:100% aux selects : ici les trois contrôles
     doivent tenir sur une seule ligne. */
  width: auto;
  padding: 8px 10px;
  border: 1px solid var(--cal-line);
  border-radius: 10px;
  background: var(--cal-surface-2);
  color: var(--cal-text);
  font: inherit;
  font-size: 0.88rem;
}
#shift-preview { line-height: 1.5; font-weight: 500; }
#shift-preview strong { font-weight: 700; }
#shift-undo { margin-right: auto; }

/* ==========================================================================
   Événement à cheval sur minuit (2026-09-07)
   Le bloc est coupé au changement de jour : le côté qui continue perd son
   arrondi et gagne un liseré, pour qu'on voie que ça n'est pas la fin.
   ========================================================================== */
.cal-event.is-continues-before {
  border-radius: 0 0 8px 8px;
  border-top: 2px dashed color-mix(in srgb, var(--ev) 55%, transparent);
}
.cal-event.is-continues-before .cal-event-bar { border-radius: 0 0 0 8px; }
.cal-event.is-continues-before .cal-done-btn { border-radius: 0 0 8px 0; }

.cal-event.is-continues-after {
  border-radius: 8px 8px 0 0;
  border-bottom: 2px dashed color-mix(in srgb, var(--ev) 55%, transparent);
}
.cal-event.is-continues-after .cal-event-bar { border-radius: 8px 0 0 0; }
.cal-event.is-continues-after .cal-done-btn { border-radius: 0 8px 0 0; }

/* Un morceau du milieu (journée entièrement couverte) : aucun arrondi. */
.cal-event.is-continues-before.is-continues-after,
.cal-event.is-continues-before.is-continues-after .cal-event-bar,
.cal-event.is-continues-before.is-continues-after .cal-done-btn { border-radius: 0; }


/* ==========================================================================
   Importer / exporter un fichier de calendrier (2026-09-21)
   Remplace la connexion Google Calendar : un fichier entre, un fichier sort.
   ========================================================================== */
.cal-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 18px;
  border: 2px dashed var(--cal-line);
  border-radius: var(--cal-radius);
  background: var(--cal-surface-2);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.cal-drop.is-over { border-color: var(--cal-accent); background: var(--cal-accent-soft); }
.cal-drop > i { font-size: 1.6rem; color: var(--cal-accent); }
.cal-drop p { margin: 0; font-size: 0.87rem; color: var(--cal-text-soft); }
.cal-drop code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--cal-accent-soft);
  color: var(--cal-accent);
  font-size: 0.82rem;
}

/* Les périodes et les choix de doublons : deux colonnes tant que la place
   le permet, une seule sur téléphone. */
.cal-radio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 9px 16px;
}

/* La liste des calendriers trouvés dans le fichier : elle vit DANS la boite,
   pas dans un panneau flottant, d'ou la bordure. */
.cal-panel-list--inline {
  border: 1px solid var(--cal-line);
  border-radius: 12px;
  padding: 4px;
  max-height: 190px;
}
.cal-panel-list--inline .cal-panel-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: normal;
}
.cal-panel-list--inline .cal-panel-name small { color: var(--cal-text-soft); font-size: 0.76rem; }

#import-summary strong,
#export-summary strong { color: var(--cal-accent); }
#import-progress { color: var(--cal-accent); font-weight: 600; }

@media (max-width: 640px) {
  .cal-radio-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Grille condensee (2026-09-21)

   Tous les blocs ont la meme taille — celle d'un titre plus une ligne d'heure
   — et seule une description les allonge. La hauteur ne dit donc plus la
   duree : c'est l'etiquette qui la porte. Voir `buildGridScale()` dans le JS.
   ========================================================================== */

.cal-event .cal-event-body {
  padding: 5px 8px;
  gap: 2px;
  justify-content: center;
}

/* La description, quand il y en a une : deux lignes au plus, le reste se lit
   dans la fiche. C'est la SEULE chose qui fait grandir un bloc. */
.cal-event-desc {
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--cal-text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Deux evenements qui se chevauchent sont EMPILES, plus cote a cote : chacun
   garde donc toute la largeur de la colonne. */
.cal-event { left: 3px; right: 3px; width: auto; }

/* ==========================================================================
   Inserer un evenement dans la chaine en le glissant (2026-09-23)
   ========================================================================== */

/* L'etiquette de la carte tenue annonce ou elle va se glisser, plutot que
   des heures qui, de toute facon, ne seront pas les bonnes. */
.cal-event.is-dragging .cal-event-time { font-weight: 700; }

/* Bord haut / bord bas d'une carte : inserer AVANT ou APRES elle (2026-09-23).
   Un gros trait a l'endroit exact ou l'evenement tenu va se glisser. */
.cal-event.is-insert-before,
.cal-event.is-insert-after { z-index: 20; }
.cal-event.is-insert-before::after,
.cal-event.is-insert-after::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  height: 4px;
  border-radius: 4px;
  background: var(--cal-accent);
  box-shadow: 0 0 0 2px var(--cal-surface), 0 2px 8px color-mix(in srgb, var(--cal-accent) 60%, transparent);
  z-index: 21;
}
.cal-event.is-insert-before::after { top: -3px; }
.cal-event.is-insert-after::after { bottom: -3px; }

/* Notification au debut de l'evenement (2026-09-26) : l'etat de CET appareil,
   dit en clair sous la case — abonne, pas encore, ou bloque. */
#notify-status { margin-top: -2px; }
#notify-status[data-kind="ok"] { color: #16a34a; }
#notify-status[data-kind="warn"] { color: #d97706; }

/* Le corps d'une fiche DEFILE : ses enfants ne doivent jamais retrecir pour
   « tenir ». Sans ca, un texte sur deux lignes dont le `min-height` est fixe
   (`.cal-hint`) etait ecrase sous le bouton qui le suit. */
.cal-modal-body > * { flex-shrink: 0; }
