/* ==========================================================================
   Polices auto-hébergées (section 8 — pas de dépendance CDN, cohérent avec
   Alpine.js déjà vendorisé localement dans static/js/vendor/).
   Inter et JetBrains Mono sont des fichiers variables (une seule ressource
   couvre toute la plage de graisses) ; Kalam est fournie en 2 graisses
   statiques. Sous-ensemble "latin" uniquement (U+0000-00FF, couvre les
   accents français à/é/è/ê/ç/ô/û). Licence SIL Open Font License.
   ========================================================================== */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-variable-latin.woff2') format('woff2-variations'),
       url('../fonts/inter-variable-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrains-mono-variable-latin.woff2') format('woff2-variations'),
       url('../fonts/jetbrains-mono-variable-latin.woff2') format('woff2');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kalam';
  src: url('../fonts/kalam-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kalam';
  src: url('../fonts/kalam-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   Palette "Carnet de planning" (section 8) + alias sémantiques.
   Les couleurs d'activité (choisies par l'utilisateur) restent inchangées
   et continuent d'être appliquées au cas par cas (swatches, fond des
   créneaux, teinte des post-it) — elles s'intègrent par-dessus cette base.
   ========================================================================== */
:root {
  /* Jetons primitifs (noms imposés par la spec section 8) */
  --color-paper: #FAF8F3;
  --color-ink: #2B2D42;
  --color-nav: #2D3250;
  --color-accent: #D4A24C;
  --color-border-soft: #EDEAE0;

  /* Anneau de focus : mélange accent/encre plutôt que l'accent pur, dont le
     contraste sur papier n'est que de 2.2:1 (insuffisant). Ce mélange tient
     6:1 sur papier en clair et reste cohérent en sombre (voir media query
     plus bas — se recalcule automatiquement via --color-ink). */
  --color-focus: color-mix(in srgb, var(--color-accent) 60%, var(--color-ink) 40%);

  /* Alias déjà utilisés dans tout ce fichier — les redéfinir ici applique
     la nouvelle identité sans réécrire chaque règle individuellement. */
  --color-bg: var(--color-paper);
  --color-surface: #FFFFFF;
  --color-text: var(--color-ink);
  --color-muted: #666877; /* encre éclaircie à 72% — 5.2:1 sur papier, 5.5:1 sur blanc */
  --color-border: var(--color-border-soft);
  --color-primary: var(--color-accent);
  /* Toujours sombre, jamais dérivé de --color-ink : le bouton primaire reste
     sur fond accent quel que soit le thème (clair/sombre) — du texte blanc
     sur l'accent ne tient que 2.3:1, du texte sombre tient 5.8:1. */
  --color-primary-text: #2B2D42;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --color-info: #0891b2;

  /* Muted spécifique aux zones sur fond --color-nav (topbar) : l'encre
     éclaircie standard (--color-muted) n'y tient que 2.3:1. */
  --color-muted-on-nav: #A8A9B2; /* 5.3:1 sur --color-nav */

  /* Texte des liens sur fond --color-nav (nav complète ET menu hamburger
     déplié, section 5.9). Volontairement un jeton dédié plutôt qu'un alias
     de --color-paper : --color-nav ne change jamais entre clair/sombre
     (chrome toujours sombre), donc son texte non plus — --color-paper, lui,
     devient quasi noir en mode sombre (voir media query plus bas) puisqu'il
     sert de fond de page là-bas. Le réutiliser pour le texte de nav créait
     1.38:1 de contraste en mode sombre (texte quasi invisible, bug corrigé
     ici) au lieu des 11.75:1 voulus — quasi identique en clair et sombre
     désormais (jamais redéfini dans la media query sombre plus bas, pour
     rester constant dans les deux thèmes comme --color-nav lui-même). */
  --color-nav-text: #FAF8F3;

  /* Typographie (section 8) */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-hand: 'Kalam', 'Segoe Print', 'Comic Sans MS', cursive;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow-soft: 0 2px 10px rgba(43, 45, 66, 0.08);
  --shadow-soft-lg: 0 8px 22px rgba(43, 45, 66, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
}

a {
  color: inherit;
}

/* Focus clavier visible partout (section 8) — :focus-visible n'affiche
   l'anneau qu'au clavier, pas au clic souris. Aucun outline:none ailleurs
   dans ce fichier ne vient le supprimer. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* prefers-reduced-motion (section 8) : neutralise transitions/animations
   sans avoir à toucher chaque règle qui en déclare une. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--color-nav);
  border-bottom: 1px solid color-mix(in srgb, var(--color-nav) 60%, black);
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-accent);
  text-decoration: none;
}

/* Bouton hamburger (section 5.9) : masqué au-dessus de 768px (nav complète
   affichée en ligne, comportement historique) ; affiché en dessous, où il
   pilote #topbar-nav/.user-menu via .nav-open (voir js/nav_toggle.js). */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-nav-text);
}

.topbar nav {
  display: flex;
  gap: 16px;
  flex: 1;
}

.topbar nav a,
.user-menu a {
  color: var(--color-nav-text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.topbar nav a:hover,
.user-menu a:hover {
  color: var(--color-accent);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-muted-on-nav);
  font-size: 0.9rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

h1 {
  font-size: 1.5rem;
  margin: 0;
}

.btn,
button[type="submit"] {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-block;
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn:hover,
button[type="submit"]:hover {
  filter: brightness(1.06);
  box-shadow: var(--shadow-soft);
}

.btn:active,
button[type="submit"]:active {
  transform: translateY(1px);
}

.link-btn {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  text-decoration: underline;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-accent);
}

.quarter-hour-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.quarter-hour-field .time-select {
  width: auto;
  font-family: var(--font-mono);
}

.quarter-hour-field .time-sep {
  font-weight: 600;
  color: var(--color-muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.table th {
  background: var(--color-bg);
  color: var(--color-muted);
  font-weight: 600;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.flash-success { background: #dcfce7; color: var(--color-success); }
.flash-danger { background: #fee2e2; color: var(--color-danger); }
.flash-warning { background: #fef3c7; color: var(--color-warning); }
.flash-info { background: #e0f2fe; color: var(--color-info); }

.error {
  color: var(--color-danger);
  font-size: 0.8rem;
  margin: 4px 0 0;
}

.hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin: 4px 0 0;
}

[x-cloak] {
  display: none !important;
}

.planning-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  align-items: start;
}

.grid-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 12px;
  position: sticky;
  top: 12px;
}

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  margin-bottom: 8px;
  font-size: 0.85rem;
  cursor: grab;
  user-select: none;
}

.sidebar-item:active {
  cursor: grabbing;
}

.sidebar-item-name {
  flex: 1;
}

.sidebar-item-todo-link {
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.sidebar-item-blocking {
  border-style: dashed;
}

.swatch-blocking {
  background-image: repeating-linear-gradient(45deg, #9ca3af, #9ca3af 3px, #d1d5db 3px, #d1d5db 6px);
}

/* Résumé du jour/de la semaine (section 9) — encart en haut de l'onglet
   Calendrier, lecture du cache au chargement, génération/régénération
   uniquement au clic (voir ai_summary_panel.js). */
.ai-summary-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.ai-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-summary-tabs {
  display: flex;
  gap: 4px;
}

.ai-summary-tab {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--color-muted);
  cursor: pointer;
}

.ai-summary-tab.is-active {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text);
  font-weight: 600;
}

.ai-summary-content {
  margin: 10px 0 0;
  line-height: 1.5;
}

.ai-summary-content.is-stale {
  opacity: 0.6;
  font-style: italic;
}

/* ==========================================================================
   Grille de planning (onglets Créneaux / Calendrier) — structure et
   interactions inchangées (section 8 : "cette identité visuelle habille le
   chrome autour, pas la logique déjà en place"). Seul ajout : la police
   mono sur les horaires/dates de la grille (.grid-hour-label,
   .grid-header-cell, .grid-slot-time), pour la lisibilité chronométrée.
   ========================================================================== */
.grid-wrapper {
  display: grid;
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.grid-cell {
  background: var(--color-surface);
  min-height: 46px;
  /* Sans ce min-width:0, un item de grille CSS ne peut pas rétrécir
     en dessous de la taille intrinsèque de son contenu (texte non
     coupé) : une case avec un libellé long élargirait sa colonne au
     lieu de garder toutes les colonnes à largeur égale (1fr). */
  min-width: 0;
}

.grid-corner {
  background: var(--color-bg);
}

.grid-header-cell {
  background: var(--color-bg);
  padding: 8px 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  text-transform: capitalize;
  font-family: var(--font-mono);
}

.grid-hour-label {
  background: var(--color-bg);
  padding: 6px;
  font-size: 0.75rem;
  color: var(--color-muted);
  text-align: right;
  font-family: var(--font-mono);
}

.grid-slot-cell {
  position: relative;
  padding: 3px;
  display: flex;
  flex-direction: row;
  /* Pas de gap : plusieurs créneaux empilés sur la même heure (section 5.2)
     se touchent pour garder chacun le maximum de largeur disponible — la
     séparation se fait par un liseré (voir .grid-slot-cell > .grid-slot +
     .grid-slot ci-dessous), pas par un espace. */
  gap: 0;
  align-items: stretch;
}

.grid-slot-cell.is-drag-hover {
  background: color-mix(in srgb, var(--color-primary) 15%, var(--color-surface));
}

/* Fin liseré entre créneaux/tâches adjacents partageant la même heure —
   même règle appliquée sur les 2 onglets (Créneaux : .grid-slot-cell ;
   Calendrier : .availability-bg et .calendar-cell-tasks juste après) pour
   rester cohérent. rgba noir plutôt que --color-border-soft : reste visible
   quelle que soit la couleur (saturée) du bloc, toujours "légèrement plus
   foncé que le fond", sans dépendre de la couleur d'activité.

   Le sélecteur cible explicitement .grid-slot (pas "> * + *") : sur
   l'onglet Calendrier, .grid-slot-cell contient toujours exactement 2
   enfants structurels (.availability-bg puis .calendar-cell-tasks), qu'il
   y ait ou non un créneau/une tâche dedans — un sélecteur générique "* + *"
   posait donc un liseré parasite entre ces deux couches même sur une case
   entièrement vide. En ciblant uniquement .grid-slot (jamais le nom de
   classe de ces deux wrappers), le liseré n'apparaît que là où il y a
   réellement un 2e créneau/bloc de contenu visible, sur les deux onglets. */
.grid-slot-cell > .grid-slot + .grid-slot {
  border-left: 1.5px solid rgba(0, 0, 0, 0.18);
}

/* Fond de disponibilité de l'onglet Calendrier (section 5.3, décision 24) :
   même codage couleur que l'onglet Créneaux (coloration de fond, sans
   texte). Purement décoratif, en arrière-plan des tâches placées
   (.calendar-cell-tasks), qui restent affichées par-dessus, inchangées. */
.availability-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  flex-direction: row;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
}

.availability-bg-slot {
  flex: 1;
  background: #9ca3af;
}

.availability-bg-slot.is-blocking {
  background-image: repeating-linear-gradient(45deg, #9ca3af, #9ca3af 6px, #d1d5db 6px, #d1d5db 12px);
}

.availability-bg > .availability-bg-slot + .availability-bg-slot {
  border-left: 1.5px solid rgba(0, 0, 0, 0.18);
}

.calendar-cell-tasks {
  position: relative;
  z-index: 1;
  flex: 1;
  /* Comme .grid-cell (voir plus haut) : sans min-width:0, cet item flex
     imbriqué ne peut pas rétrécir sous la taille intrinsèque de son
     contenu — un long libellé de tâche déborderait alors sur la colonne
     du jour suivant au lieu d'être contenu et tronqué (ellipsis) dans sa
     propre colonne. C'était la régression introduite avec .availability-bg
     : ce wrapper n'existait pas avant et n'avait pas hérité du correctif. */
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  /* Pas de gap ici non plus : le liseré (.calendar-cell-tasks > .grid-slot
     + .grid-slot) sépare les tâches adjacentes sans leur retirer de largeur. */
  gap: 0;
  align-items: stretch;
}

.calendar-cell-tasks > .grid-slot + .grid-slot {
  border-left: 1.5px solid rgba(0, 0, 0, 0.18);
}

.grid-slot {
  position: relative;
  flex: 1;
  border-radius: 4px;
  padding: 4px 16px 4px 6px;
  font-size: 0.7rem;
  line-height: 1.2;
  cursor: grab;
  min-width: 0;
  overflow: hidden;
}

.grid-slot:active {
  cursor: grabbing;
}

/* Onglet Calendrier / agenda partagé : blocs statiques (non draggable),
   simples liens ou div, pas de sémantique "glisser" ici. */
.grid-slot.is-static {
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.grid-slot.is-static.is-readonly {
  cursor: default;
}

.agenda-block-occupied {
  background: #9ca3af;
  color: #1f2430;
}

.agenda-block-free {
  background: transparent;
  border: 1px dashed var(--color-border);
  color: var(--color-muted);
}

/* Créneau issu d'un gabarit récurrent (AvailabilityTemplate) plutôt que d'un
   override ponctuel : le clic n'ouvre pas le menu "Rendre récurrent" (déjà
   récurrent), donc ce style le signale visuellement au lieu de laisser un
   clic sans effet ni explication. */
.grid-slot.is-template-slot {
  border: 1px dashed rgba(255, 255, 255, 0.75);
}

.grid-slot-recurring-icon {
  margin-right: 2px;
  opacity: 0.9;
}

.grid-slot-label {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-slot-time {
  display: block;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.grid-slot-remove {
  position: absolute;
  top: 1px;
  right: 1px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 14px;
  height: 14px;
  line-height: 14px;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0;
}

.context-menu {
  position: fixed;
  z-index: 50;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 220px;
}

.context-menu button {
  background: none;
  border: none;
  text-align: left;
  padding: 8px 10px;
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.context-menu button:hover {
  background: var(--color-bg);
}

/* Réordonnancement tactile ◀/▶ (section 5.9, alternative au glisser d'un
   créneau sur son voisin) : 2 boutons côte à côte plutôt qu'empilés comme
   le reste du menu. */
.context-menu-row {
  display: flex;
  gap: 4px;
}

.context-menu-row button {
  flex: 1;
  text-align: center;
}

.context-menu-danger {
  color: var(--color-danger);
}

/* Bandeau de sélection tactile (section 5.9, alternative au glisser-déposer
   natif) : visible tant qu'une activité de la barre latérale est armée
   pour dépôt. */
.tap-place-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1 / -1;
  background: color-mix(in srgb, var(--color-accent) 18%, var(--color-surface));
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.sidebar-item.is-selected {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 40%, transparent);
}

.grid-slot-cell.is-tap-target {
  cursor: pointer;
}

@media (max-width: 768px) {
  /* --- Navigation compacte (section 5.9, point 1) --- */
  .nav-toggle {
    display: flex;
  }

  .topbar {
    flex-wrap: wrap;
  }

  #topbar-nav,
  .user-menu {
    display: none;
    flex-basis: 100%;
  }

  .topbar.nav-open #topbar-nav,
  .topbar.nav-open .user-menu {
    display: flex;
  }

  #topbar-nav {
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
  }

  .topbar nav a {
    padding: 12px 4px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .user-menu {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid color-mix(in srgb, var(--color-nav) 60%, white);
  }

  .user-menu a {
    padding: 10px 4px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* --- Grille de planning (point 2) : sidebar en ligne plutôt que colonne
     fixe ; la bascule automatique en vue "Jour" est gérée côté JS
     (responsive_view.js), pas ici — cette règle ne fait qu'adapter la mise
     en page si l'utilisateur revient manuellement en vue "Semaine" (scroll
     horizontal alors acceptable, voir .grid-wrapper ci-dessous). --- */
  .planning-layout {
    grid-template-columns: 1fr;
  }

  .grid-sidebar {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sidebar-item {
    margin-bottom: 0;
  }

  .tap-place-hint {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  /* Vue "Semaine" revenue manuellement sur petit écran (point 2 : "scroll
     horizontal acceptable dans ce cas, pas une obligation de tout
     interdire") — le nombre de colonnes ne change pas ici, seul le
     conteneur devient scrollable plutôt que d'écraser les cases. */
  .grid-wrapper {
    overflow-x: auto;
  }

  /* --- Zones tactiles (point 4, ~44px) --- */
  .btn,
  button[type="submit"] {
    min-height: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .link-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 4px 0;
  }

  .field input[type="text"],
  .field input[type="email"],
  .field input[type="password"],
  .field input[type="number"],
  .field input[type="date"],
  .field select,
  .field textarea {
    min-height: 44px;
  }

  .checkbox-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
  }

  .context-menu button {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* .grid-slot-remove reste en-deçà de 44px par nécessité : la grille reste
     dense (une case peut faire ~46px de haut, un bouton de 44px la
     dominerait entièrement). Élargi sensiblement (14px -> 22px) comme
     compromis pragmatique ; la suppression fiable au tactile passe surtout
     par le menu tap (bouton "Supprimer" de 44px, voir .context-menu button
     ci-dessus) plutôt que cette croix, qui reste une raccourci secondaire. */
  .grid-slot-remove {
    width: 22px;
    height: 22px;
    line-height: 22px;
    font-size: 0.85rem;
  }
}

.filters {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.activity-todo-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.activity-todo-filter a {
  color: var(--color-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.filters .field {
  margin-bottom: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.board-column {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 12px;
}

.board-column h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  color: var(--color-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-column .count {
  background: var(--color-bg);
  border-radius: 10px;
  padding: 0 8px;
  font-size: 0.8rem;
}

.board-column .empty {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.task-card {
  display: block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.task-card:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.task-card-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.task-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-basse { background: #e5e7eb; color: #374151; }
.priority-normale { background: #dbeafe; color: #1d4ed8; }
.priority-haute { background: #fef3c7; color: #b45309; }
.priority-urgente { background: #fee2e2; color: #b91c1c; }

.progress-bar {
  background: var(--color-border);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.progress-bar.large {
  height: 10px;
  margin: 12px 0 4px;
}

.progress-bar-fill {
  background: var(--color-primary);
  height: 100%;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0 0 16px;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.item-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.item-list li.done .item-label {
  text-decoration: line-through;
  color: var(--color-muted);
}

.checkbox-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.1s ease;
}

.checkbox-btn:active {
  transform: scale(0.85);
}

.item-label {
  flex: 1;
}

.item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
}

.item-actions input[type="text"] {
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
}

/* ==========================================================================
   Todos en post-it (section 8, signature visuelle) — panneau flottant
   (.postit-compact) et onglet global /todo/ (.postit pleine taille).
   Rotation légère déterministe (-2°/+2°, cycle sur 6 valeurs via
   nth-child), ombre portée, coin coupé (clip-path), bande "ruban adhésif"
   (::before), teinte dérivée de la couleur d'activité (--activity-color,
   posée en inline-style par l'appelant ; neutre papier par défaut).
   ========================================================================== */
.postit {
  --postit-tint: color-mix(in srgb, var(--activity-color, var(--color-border-soft)) 20%, white);
  --postit-rotate: -1deg;
  position: relative;
  background: var(--postit-tint);
  border-radius: 2px;
  box-shadow: var(--shadow-soft-lg);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
  transform: rotate(var(--postit-rotate));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  list-style: none;
}

.postit::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  width: 50px;
  height: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(43, 45, 66, 0.06);
  box-shadow: 0 1px 2px rgba(43, 45, 66, 0.12);
  transform: translateX(-50%) rotate(-3deg);
  pointer-events: none;
}

.postit:hover {
  transform: rotate(0deg) translateY(-2px);
  box-shadow: 0 12px 24px rgba(43, 45, 66, 0.2), 0 2px 4px rgba(43, 45, 66, 0.1);
}

.postit:nth-child(6n+1) { --postit-rotate: -2deg; }
.postit:nth-child(6n+2) { --postit-rotate: 1.5deg; }
.postit:nth-child(6n+3) { --postit-rotate: -1deg; }
.postit:nth-child(6n+4) { --postit-rotate: 2deg; }
.postit:nth-child(6n+5) { --postit-rotate: -1.5deg; }
.postit:nth-child(6n+6) { --postit-rotate: 1deg; }

.postit-title {
  font-family: var(--font-hand);
  font-weight: 400;
  color: var(--color-ink);
  display: block;
  word-break: break-word;
}

.postit.is-done {
  opacity: 0.6;
}

.postit.is-done .postit-title {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.postit-link {
  color: var(--color-ink);
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.postit-link:hover {
  opacity: 1;
}

/* Onglet global /todo/ : grille de post-it pleine taille. */
.postit-board {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 0 0 28px;
  padding: 6px 4px 16px;
}

.postit-board .postit {
  width: 190px;
  padding: 20px 14px 14px;
}

.postit-board .postit-title {
  font-size: 1.2rem;
  line-height: 1.3;
}

.postit-board .postit-body {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.postit-board .postit-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.78rem;
  font-family: var(--font-sans);
}

/* Panneau flottant (section 5.4) : variante compacte, une ligne par note. */
.postit-compact {
  padding: 9px 10px 7px 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.postit-compact .postit-title {
  font-size: 1rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.postit-compact::before {
  width: 34px;
  height: 12px;
  top: -6px;
}

.postit-compact .postit-link {
  font-family: var(--font-sans);
  text-decoration: none;
  font-weight: 700;
}

/* Todo list rapide (section 5.4) : panneau flottant, toujours accessible
   sans perturber la mise en page des pages existantes. */
.todo-sidebar {
  position: fixed;
  top: 76px;
  right: 16px;
  width: 260px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 0.8rem;
  box-shadow: var(--shadow-soft-lg);
  z-index: 10;
}

.todo-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.todo-sidebar-header strong {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-quick-add {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.todo-quick-add input[type="text"],
.todo-quick-add select,
.todo-quick-add textarea {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.78rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  resize: vertical;
}

.todo-quick-add button[type="submit"] {
  padding: 5px 8px;
  font-size: 0.78rem;
}

.todo-sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.todo-sidebar-list li.empty {
  color: var(--color-muted);
  font-style: italic;
  padding: 5px 0;
}

@media (max-width: 768px) {
  /* --- Board de tâches, todos en post-it (section 5.9, point 3) --- */
  .board {
    grid-template-columns: 1fr;
  }

  .todo-sidebar {
    position: static;
    width: auto;
    margin: 16px auto;
    max-width: 1100px;
  }

  .postit-board {
    flex-direction: column;
    align-items: stretch;
  }

  .postit-board .postit {
    width: auto;
  }

  /* --- Listes de projets/activités/membres (point 3) : les tableaux se
     transforment en cartes empilées (1 par ligne) plutôt que de comprimer
     les colonnes ou forcer un défilement horizontal. Chaque <td> doit
     porter un attribut data-label (voir les templates) pour reproduire
     l'en-tête de colonne devant sa valeur. --- */
  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    margin-bottom: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  .table td {
    border-bottom: 1px solid var(--color-border);
    padding: 10px 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .table td:last-child {
    border-bottom: none;
  }

  .table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-muted);
    flex: 0 0 40%;
  }

  /* Cellule vide ("Aucun projet pour le moment.", colspan) : pas de
     data-label pertinent, l'étiquette générée serait vide et laisserait un
     flex-basis inutile — supprime le pseudo-élément dans ce seul cas. */
  .table td[colspan]::before {
    content: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-paper: #1E1B17;
    --color-ink: #EDEAE0;
    --color-border-soft: #3A342C;
    --color-surface: #29241F;
    --color-muted: #9A9892; /* encre assombrie à 65% côté sombre — 5.9:1 sur papier sombre */
    --color-muted-on-nav: #A8A9B2;
  }
}
