/* ===========================================================
   UPEC_EmploiDuTemps - design tokens
   Palette pensée "carnet d'agenda universitaire" : fond papier
   très clair, encre profonde, un seul accent (bleu encre-carbone).
   Les couleurs des séances (barres, blocs) reprennent directement
   celles de Formadep360 (une couleur par cours/type, transmise par
   l'API) plutôt qu'une palette recréée ici - voir readableTextColor()
   dans scripts.js pour le choix du texte (noir/blanc) sur ces couleurs.
   =========================================================== */
:root {
  --paper: #F6F4EF;
  --paper-raised: #FFFFFF;
  --ink: #20242B;
  --ink-soft: #5B6472;
  --line: #E4DFD3;
  --accent: #2B4C5C;
  --accent-soft: #E7EEF0;
  --accent-contrast: #FFFFFF;
  --block-outline: rgba(0, 0, 0, 0.08);
  --grid-line-soft: #EFEBE2;

  --status-error-bg: #FBE9E7;
  --status-error-fg: #8A2E20;
  --status-error-border: #F0C4BC;
  --status-info-bg: var(--accent-soft);
  --status-info-fg: var(--accent);
  --status-info-border: #CFE0E3;
  --status-good-fg: #2E7D46;

  --radius: 10px;
  --ctl-h: 38px; /* hauteur commune des contrôles de la barre du haut */
  /* Même pile de polices que le site Miller Development : polices système,
     aucune police web chargée. --font-display est conservé comme alias
     (titres) mais pointe désormais sur la même pile. */
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  color-scheme: light;
}

/* Thème sombre : suit la préférence système par défaut (data-theme absent),
   ou le choix explicite de la personne (bouton dans la barre du haut,
   mémorisé dans localStorage - voir scripts.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #14171C;
    --paper-raised: #1C2028;
    --ink: #ECEDEF;
    --ink-soft: #9AA3AF;
    --line: #2B313B;
    --accent: #7FB3CC;
    --accent-soft: #22313A;
    --accent-contrast: #14171C;
    --block-outline: rgba(255, 255, 255, 0.18);
    --grid-line-soft: #20252D;

    --status-error-bg: #3A2220;
    --status-error-fg: #F3B3A6;
    --status-error-border: #5A342F;
    --status-info-border: #2E4650;
    --status-good-fg: #6FCF97;
  }
}

:root[data-theme="dark"] {
  --paper: #14171C;
  --paper-raised: #1C2028;
  --ink: #ECEDEF;
  --ink-soft: #9AA3AF;
  --line: #2B313B;
  --accent: #7FB3CC;
  --accent-soft: #22313A;
  --accent-contrast: #14171C;
  --block-outline: rgba(255, 255, 255, 0.18);
  --grid-line-soft: #20252D;

  --status-error-bg: #3A2220;
  --status-error-fg: #F3B3A6;
  --status-error-border: #5A342F;
  --status-info-border: #2E4650;
  --status-good-fg: #6FCF97;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--accent); }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  justify-content: space-between;
  align-items: center;
  padding: 12px clamp(16px, 4vw, 48px);
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .topbar {
    background: color-mix(in srgb, var(--paper-raised) 90%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
  }
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Logo UPEC : deux fichiers (texte noir / texte blanc) permutés selon le
   thème, avec la même logique à trois états que les tokens de couleur -
   choix explicite (data-theme), sinon préférence système. */
.topbar__logo {
  display: block;
  height: 40px;
  width: auto;
  flex: none;
}

.topbar__logo--dark { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar__logo--light { display: none; }
  :root:not([data-theme="light"]) .topbar__logo--dark { display: block; }
}

:root[data-theme="dark"] .topbar__logo--light { display: none; }
:root[data-theme="dark"] .topbar__logo--dark { display: block; }

.topbar__titles { min-width: 0; }

.topbar__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0;
  line-height: 1.15;
}

.topbar__subtitle {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.promo-badge {
  flex: none;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--status-info-border);
  border-radius: 999px;
  padding: 3px 10px;
}

.topbar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  padding-left: 2px;
}

/* ---------- Listes déroulantes ---------- */
.field__select-wrap {
  position: relative;
  display: block;
}

/* Chevron dessiné en CSS (deux bords) -> suit le thème, pas d'image. */
.field__select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
  transition: border-color 0.12s ease;
}
.field__select-wrap:hover::after { border-color: var(--ink); }

.field__select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 150px;
  height: var(--ctl-h);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 34px 0 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field__select:hover { border-color: var(--ink-soft); }
.field__select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field__select option {
  background: var(--paper-raised);
  color: var(--ink);
  font-weight: 500;
}

/* ---------- Bascule Jour / Semaine ---------- */
.view-toggle {
  display: inline-flex;
  height: var(--ctl-h);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.view-toggle__btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  padding: 0 14px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.view-toggle__btn:hover:not(.is-active) { color: var(--ink); }
.view-toggle__btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}
.view-toggle__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Libellés de la bascule : "Par jour / Par semaine" sur bureau,
   "Liste / Grille" sur mobile (même seuil que MOBILE_WEEK_QUERY dans
   scripts.js). */
.view-toggle__label--narrow { display: none; }
@media (max-width: 640px) {
  .view-toggle__label--wide { display: none; }
  .view-toggle__label--narrow { display: inline; }
}

/* ---------- Boutons d'action ---------- */
.topbar__actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--ctl-h);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 0 15px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn--ghost {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn--ghost:hover { background: var(--accent-soft); border-color: var(--ink-soft); }
.btn--ghost:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn--icon {
  padding: 0;
  width: var(--ctl-h);
  justify-content: center;
  line-height: 1;
}

/* Icônes SVG : tout le site utilise des icônes tracées (currentColor),
   jamais d'émoji. */
.icon {
  display: inline-flex;
  align-items: center;
  flex: none;
}
.icon svg,
.btn svg,
.site-footer__link svg {
  display: block;
}

/* ---------- Page layout ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 60px;
}

.status {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 18px;
}
.status--error { background: var(--status-error-bg); color: var(--status-error-fg); border: 1px solid var(--status-error-border); }
.status--info  { background: var(--status-info-bg); color: var(--status-info-fg); border: 1px solid var(--status-info-border); }

/* Pendant une synchro manuelle (bouton "Actualiser"), un voile flouté
   couvre toute la page avec un message + une roue qui tourne au premier
   plan : impossible d'interagir avec quoi que ce soit derrière, le voile
   n'est retiré qu'une fois les données rechargées (hideSyncOverlay() dans
   scripts.js, appelé après le rafraîchissement réel). */
.sync-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 23, 28, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
/* Même spécificité que ".sync-overlay" : sans ce sélecteur combiné, cette
   règle "display: flex" l'emporterait sur le "display: none" par défaut
   du navigateur pour [hidden], et le voile resterait affiché à l'écran
   même une fois l'attribut "hidden" reposé par hideSyncOverlay(). */
.sync-overlay[hidden] {
  display: none;
}

.sync-overlay__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 320px;
  padding: 28px 32px;
  border-radius: var(--radius);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.sync-overlay__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sync-overlay-spin 0.8s linear infinite;
}

.sync-overlay__text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

@keyframes sync-overlay-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Navigation de semaine ---------- */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}

.week-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--ink);
  line-height: 1;
  cursor: pointer;
}
.week-nav__btn svg { display: block; }
.week-nav__btn:hover:not(:disabled) { background: var(--accent-soft); }
.week-nav__btn:disabled { opacity: 0.35; cursor: default; }

/* Libellé de semaine : bouton qui ouvre la liste des semaines. */
.week-nav__picker {
  position: relative;
  display: flex;
}

.week-nav__label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  text-align: center;
}
.week-nav__label:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--status-info-border);
}
.week-nav__label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.week-nav__label:disabled {
  cursor: default;
}
/* petit chevron bas, dessiné en CSS */
.week-nav__label::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.55;
}
.week-nav__label:disabled::after {
  display: none;
}

.week-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  min-width: 220px;
  max-width: calc(100vw - 24px);
  padding: 4px;
  display: flex;
  flex-direction: column;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}
.week-menu[hidden] {
  display: none;
}

.week-menu__item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 3px);
  padding: 9px 12px;
  cursor: pointer;
}
.week-menu__item:hover {
  background: var(--accent-soft);
}
.week-menu__item.is-selected {
  color: var(--accent);
}
.week-menu__arrow {
  flex: 0 0 auto;
  display: none;
  color: var(--status-good-fg);
}
.week-menu__item.is-current-week .week-menu__arrow {
  display: inline-flex;
}

/* ---------- Day tabs ---------- */
.day-tabs[hidden] {
  display: none;
}

.day-tabs {
  display: flex;
  gap: 8px;
  /* Centré à l'écran ; "safe" évite de rogner le premier onglet quand la
     rangée déborde sur petit écran (elle repasse alors à gauche). */
  justify-content: center;
  justify-content: safe center;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.day-tab {
  flex: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-align: center;
}

.day-tab .day-tab__date {
  display: block;
  font-weight: 400;
  font-size: 12px;
  margin-top: 2px;
}

.day-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---------- Date de dernière synchronisation ---------- */
.last-update {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 16px;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--status-info-border);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
.last-update svg {
  display: block;
  flex: none;
}

.last-update--stale {
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
  color: var(--status-error-fg);
}

/* ---------- Agenda / cards ---------- */
.agenda {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Vue semaine (grille quadrillée) ---------- */
/* Sur petit écran, la grille défile horizontalement plutôt que d'écraser
   les colonnes (largeur minimale fixée en JS, voir renderWeek()) ; la
   colonne des heures reste fixe pendant le défilement. */
.week-grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

.week-grid {
  position: relative;
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}

.week-grid__corner,
.week-grid__day-header {
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
}

.week-grid__time {
  position: sticky;
  left: 0;
  z-index: 3;
}

.week-grid__day-header {
  padding: 10px 8px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  border-left: 1px solid var(--line);
  /* Collé en haut de la grille pendant le défilement vertical de celle-ci
     (la grille est son propre conteneur de défilement à cause de
     overflow-x sur .week-grid-scroll). */
  position: sticky;
  top: 0;
  z-index: 2;
}

.week-grid__corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
}

.week-grid__day-header .week-grid__date {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* Cases de fond du quadrillage : une par quart d'heure et par colonne,
   avec un trait plus marqué toutes les heures pleines. */
.week-grid__cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--grid-line-soft);
}
.week-grid__cell--hour {
  border-bottom: 1px solid var(--line);
}

/* La case reste pleine hauteur (align-self stretch par défaut) pour que
   son fond opaque continue de couvrir toute la colonne "figée" (sticky)
   pendant le défilement horizontal - seul le TEXTE à l'intérieur est
   recentré sur le trait du haut, via .week-grid__time-text ci-dessous.
   (Une version précédente réduisait la case elle-même : le fond ne
   couvrait plus tout le créneau, laissant apparaître le quadrillage.) */
.week-grid__time {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-soft);
  opacity: 0.6;
  background: var(--paper-raised);
}

.week-grid__time-text {
  line-height: 1;
  transform: translateY(-50%);
}

/* Le tout premier repère (8h) n'a pas de trait au-dessus de lui dans
   lequel se centrer : pas de décalage, pour ne pas passer derrière le
   coin en haut à gauche (case vide au-dessus de la colonne des heures). */
.week-grid__time--first .week-grid__time-text {
  transform: none;
  margin-top: 2px;
}

.week-grid__time--hour {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  opacity: 1;
}

.week-grid__block {
  margin: 1px;
  border-radius: 5px;
  padding: 5px 7px 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 0 0 0 1px var(--block-outline);
}

.week-grid__block-head,
.week-grid__block-subject,
.week-grid__block-info {
  color: inherit;
}

/* En-tête du bloc : pastille de type à gauche, horaire à droite. */
.week-grid__block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.week-grid__block-type {
  flex: none;
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 5px;
  border: 1px solid currentColor;
  border-radius: 999px;
  white-space: nowrap;
}

.week-grid__block-time {
  flex: none;
  font-size: 9.5px;
  font-weight: 700;
  opacity: 0.8;
  white-space: nowrap;
}

.week-grid__block-subject {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* Infos alignées en deux colonnes (libellé / valeur). */
.week-grid__block-info {
  margin: 1px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 7px;
  font-size: 9.5px;
  line-height: 1.5;
}

.week-grid__block-info dt {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.55;
}

.week-grid__block-info dd {
  margin: 0;
  font-weight: 600;
  opacity: 0.95;
  overflow-wrap: anywhere;
}

/* Pauses (trous entre séances) : neutres et discrètes, hachurées pour se
   distinguer clairement des vraies séances colorées. */
.week-grid__break {
  margin: 1px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
  background: repeating-linear-gradient(
    135deg,
    var(--paper) 0px,
    var(--paper) 6px,
    var(--accent-soft) 6px,
    var(--accent-soft) 12px
  );
  border: 1px dashed var(--line);
}

.week-grid__break--lunch {
  font-weight: 700;
  color: var(--ink);
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 60px 20px;
  font-size: 15px;
}

.session-card {
  display: grid;
  grid-template-columns: 92px 4px 1fr auto;
  gap: 0 16px;
  align-items: center;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.session-card__time {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}
.session-card__time small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-soft);
}

.session-card__bar {
  align-self: stretch;
  border-radius: 4px;
}

.session-card__main {
  min-width: 0;
}

.session-card__subject {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 3px;
  overflow-wrap: anywhere;
}

.session-card__meta {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.session-card__meta span + span::before {
  content: "·";
  margin: 0 6px;
}

.session-card__group {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Pauses (trous entre séances) en vue "Par jour" : discrètes, sans la
   mise en page en carte des vraies séances. */
.break-card {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--ink-soft);
}

.break-card::before {
  content: "";
  flex: none;
  width: 92px;
}

.break-card__time {
  font-weight: 600;
  min-width: 70px;
}

.break-card--lunch {
  font-weight: 700;
  color: var(--ink);
}

.footnote {
  margin-top: 34px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* ---------- Pied de page ----------
   Mise en page reprise du site Miller Development (titres capitales 16px,
   textes 14px/1.8, liens en bloc qui glissent de 4px au survol, rythme
   60/48/24px) mais avec les couleurs d'origine de ce site : fond papier
   surélevé, encre, filet clair — le tout suit le thème clair / sombre. */
.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--ink-soft);
  padding: 60px 0 24px;
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
}

.site-footer__cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px;
  margin-bottom: 48px;
}

.site-footer__col h4 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink);
}

.site-footer__col p,
.site-footer__col a {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.site-footer__col p strong {
  color: var(--ink);
}

/* Liens du pied de page : mis en évidence (couleur d'accent + souligné). */
.site-footer__col a:not(.site-footer__link) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}
.site-footer__col a:not(.site-footer__link):hover {
  color: var(--ink);
}
/* Lien seul (ex. "Mentions légales") : sur sa propre ligne.
   Lien dans une phrase (ex. "Source : Formadep360") : reste en ligne. */
.site-footer__col > a:not(.site-footer__link) {
  display: block;
}
.site-footer__col p a {
  display: inline;
}

.site-footer__bottom {
  padding-top: 24px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.site-footer__bottom p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.site-footer__bottom a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}
.site-footer__bottom a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Bouton "Revoir le tutoriel" : vrai aspect de bouton (cadre + fond). */
.site-footer__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.site-footer__link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.site-footer__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .site-footer__cols {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 40px;
  }
  .site-footer__col {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

/* =========================================================
   Tutoriel de première visite
   Superposition : un fond qui capte les clics + un halo qui
   met en valeur la commande décrite, et une bulle explicative.
   Le halo assombrit le reste de la page via un box-shadow très
   étalé (pas d'image, suit donc le thème).
   ========================================================= */
.tuto[hidden] {
  display: none;
}

.tuto {
  position: fixed;
  inset: 0;
  z-index: 200;
}

/* Capte les clics pour empêcher de manipuler la page pendant le tuto.
   Transparent par défaut ; assombri seulement sur les étapes sans cible.
   Teinte foncée fixe (et non un token) pour rester un vrai voile
   assombrissant dans les deux thèmes. */
.tuto__backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: transparent;
}
.tuto__backdrop--solid {
  background: rgba(10, 12, 16, 0.6);
}

.tuto__halo {
  position: fixed;
  z-index: 201;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(10, 12, 16, 0.6);
  pointer-events: none;
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.tuto__halo[hidden] {
  display: none;
}

.tuto__pop {
  position: fixed;
  z-index: 202;
  width: min(320px, calc(100vw - 32px));
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  padding: 16px 18px 14px;
}
.tuto__pop:focus {
  outline: none;
}

.tuto__step {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.tuto__title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
}

.tuto__body {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.tuto__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tuto__spacer {
  flex: 1;
}

.tuto__btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border-radius: calc(var(--radius) - 3px);
  padding: 7px 12px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tuto__btn--skip {
  background: transparent;
  color: var(--ink-soft);
  padding: 7px 4px;
}
.tuto__btn--skip:hover { color: var(--ink); }
.tuto__btn--prev {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}
.tuto__btn--prev:hover { background: var(--accent-soft); }
.tuto__btn--next {
  background: var(--accent);
  color: var(--accent-contrast);
}
.tuto__btn--next:hover { filter: brightness(1.06); }
.tuto__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.tuto__btn--prev[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .tuto__halo { transition: none; }
  .sync-overlay__spinner { animation-duration: 2s; }
}

/* =========================================================
   Responsive
   - >900px  : mise en page complète (bureau)
   - 640-900 : tablette - barre du haut plus compacte
   - <640    : mobile - en-tête empilé, listes/cartes resserrées
   - <420    : très petits écrans
   ========================================================= */

@media (max-width: 900px) {
  .page {
    padding: 22px clamp(14px, 4vw, 32px) 48px;
  }

  .topbar__subtitle {
    display: none;
  }

  .week-nav {
    gap: 10px;
  }
}

@media (max-width: 640px) {
  /* En-tête empilé : trop haut pour rester "sticky" sur un téléphone. */
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 16px;
  }

  .topbar__brand {
    justify-content: center;
  }
  .topbar__title {
    justify-content: center;
    font-size: 20px;
  }
  /* Rétabli sur mobile (en-tête empilé et centré) : il porte la mention
     "Réalisé par David Gomes". */
  .topbar__subtitle {
    display: block;
    white-space: normal;
    text-align: center;
    font-size: 11.5px;
  }

  .topbar__controls {
    width: 100%;
    gap: 10px;
  }

  /* Affichage sur toute la largeur, Classe + Groupe côte à côte, actions dessous. */
  .field {
    min-width: 0;
    flex: 1 1 100%;
  }
  .field:nth-child(2),
  .field:nth-child(3) {
    flex: 1 1 calc(50% - 5px);
  }
  .view-toggle {
    width: 100%;
  }
  .view-toggle__btn {
    flex: 1;
  }
  .field__select {
    min-width: 0;
    max-width: 100%;
  }

  /* Actions (Actualiser + thème) : barre d'outils pleine largeur placée
     en tête des contrôles plutôt que perdue en bas à droite. "Actualiser"
     s'étire, le bouton de thème reste carré au bout. */
  .topbar__actions {
    order: -1;
    flex: 1 0 100%;
    gap: 8px;
  }
  .topbar__actions .btn:not(.btn--icon) {
    flex: 1;
  }

  .page {
    padding: 18px 14px 40px;
  }

  /* weekNav + dayTabs restent figés en haut pendant le défilement
     (la barre du haut est en position: static sur mobile). Fond opaque
     et marges négatives pour couvrir toute la largeur de la page. */
  .week-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--paper);
    margin: 0 -14px 14px;
    padding: 8px 14px;
  }

  .day-tabs {
    position: sticky;
    top: 48px;
    z-index: 19;
    background: var(--paper);
    margin: 0 -14px 16px;
    padding: 0 14px 6px;
  }

  .week-nav__label {
    max-width: none;
    font-size: 13px;
  }

  .day-tab {
    padding: 9px 11px;
    font-size: 13px;
  }

  .session-card {
    grid-template-columns: 74px 3px 1fr;
    padding: 12px;
    gap: 0 12px;
  }
  .session-card__group {
    grid-column: 1 / -1;
    justify-self: start;
    margin-top: 8px;
  }

  .break-card::before {
    width: 74px;
  }

  .footnote {
    font-size: 11px;
    text-align: justify;
  }
}

@media (max-width: 420px) {
  .topbar__title {
    font-size: 19px;
  }

  .view-toggle__btn {
    padding: 0 8px;
    font-size: 12px;
  }

  .week-nav__btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  /* Boutons plus petits -> weekNav moins haute, on ajuste le décalage. */
  .day-tabs {
    top: 44px;
  }

  .session-card {
    grid-template-columns: 62px 3px 1fr;
  }
  .session-card__time {
    font-size: 13px;
  }

  .break-card {
    padding: 6px 12px;
    font-size: 11px;
  }
  .break-card::before {
    width: 62px;
  }
}
