/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-orange: #FF7043;
  --c-orange-light: #FFF3EE;
  --c-orange-dark: #BF360C;
  --c-blue: #42A5F5;
  --c-blue-light: #E3F2FD;
  --c-green: #66BB6A;
  --c-green-light: #E8F5E9;
  --c-purple: #AB47BC;
  --c-purple-light: #F3E5F5;
  --c-yellow: #FFCA28;
  --c-yellow-light: #FFFDE7;
  --c-bg: #FFF8F5;
  --c-surface: #FFFFFF;
  --c-text: #2D1B0E;
  --c-text-muted: #8D6E63;
  --c-border: #F0D9D0;
  --c-today: #FF7043;
  --c-school-bg: #EBF5FF;
  --c-noschool-bg: #FFF0E8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 2px 12px rgba(255,112,67,0.10);
  --shadow-modal: 0 -4px 32px rgba(45,27,14,0.15);
  --font-main: 'Nunito', 'Baloo 2', sans-serif;
  --font-display: 'Baloo 2', 'Nunito', sans-serif;
  --header-h: 64px;
  --bottom-h: 50px;
  --monthbar-h: 42px;
  --legend-h: 38px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-orange: #FF8259;
    --c-orange-light: #3A2A22;
    --c-orange-dark: #FFB08C;
    --c-blue: #6FB6F7;
    --c-blue-light: #182430;
    --c-green: #81C995;
    --c-green-light: #182619;
    --c-purple: #CE93D8;
    --c-purple-light: #241a29;
    --c-yellow: #FFD54F;
    --c-yellow-light: #2b2411;
    --c-bg: #17110D;
    --c-surface: #211913;
    --c-text: #F5E9E0;
    --c-text-muted: #B4A092;
    --c-border: #3B2C22;
    --c-today: #FF8259;
    --c-school-bg: #172531;
    --c-noschool-bg: #2B2015;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
}

/* Couleur de l'application (Réglages › Cet appareil) : data-theme est
   posé par js/child.js. Orange = :root ci-dessus. Les noms --c-orange*
   sont gardés : ce sont les couleurs d'accent. --c-noschool-bg reprend
   l'accent, --c-school-bg une teinte qui s'en distingue. */
:root[data-theme="rose"] {
  --c-orange: #EC407A;
  --c-orange-light: #FDEDF3;
  --c-orange-dark: #AD1457;
  --c-bg: #FFF7FA;
  --c-text: #2D0E1A;
  --c-text-muted: #8F6575;
  --c-border: #F3D6E1;
  --c-today: #EC407A;
  --c-school-bg: #EBF5FF;
  --c-noschool-bg: #FCE9F0;
  --shadow-card: 0 2px 12px rgba(236,64,122,0.10);
  --shadow-modal: 0 -4px 32px rgba(14,27,45,0.15);
}
:root[data-theme="violet"] {
  --c-orange: #7E57C2;
  --c-orange-light: #F3EEFB;
  --c-orange-dark: #4527A0;
  --c-bg: #FAF7FE;
  --c-text: #1E1430;
  --c-text-muted: #7A6B91;
  --c-border: #E3DAF2;
  --c-today: #7E57C2;
  --c-school-bg: #E6F4F1;
  --c-noschool-bg: #EFE8FA;
  --shadow-card: 0 2px 12px rgba(126,87,194,0.10);
  --shadow-modal: 0 -4px 32px rgba(14,27,45,0.15);
}
:root[data-theme="bleu"] {
  --c-orange: #1E88E5;
  --c-orange-light: #EAF3FD;
  --c-orange-dark: #0D47A1;
  --c-bg: #F5F9FF;
  --c-text: #0E1B2D;
  --c-text-muted: #5F7590;
  --c-border: #D3E1F2;
  --c-today: #1E88E5;
  --c-school-bg: #E8F7F2;
  --c-noschool-bg: #E6EFFC;
  --shadow-card: 0 2px 12px rgba(30,136,229,0.10);
  --shadow-modal: 0 -4px 32px rgba(14,27,45,0.15);
}
:root[data-theme="turquoise"] {
  --c-orange: #00897B;
  --c-orange-light: #E6F4F2;
  --c-orange-dark: #004D40;
  --c-bg: #F4FBFA;
  --c-text: #0B2522;
  --c-text-muted: #5B7B77;
  --c-border: #CFE6E3;
  --c-today: #00897B;
  --c-school-bg: #FFF4E5;
  --c-noschool-bg: #E3F3F1;
  --shadow-card: 0 2px 12px rgba(0,137,123,0.10);
  --shadow-modal: 0 -4px 32px rgba(14,27,45,0.15);
}
:root[data-theme="vert"] {
  --c-orange: #43A047;
  --c-orange-light: #EDF7EE;
  --c-orange-dark: #1B5E20;
  --c-bg: #F6FBF6;
  --c-text: #0F2412;
  --c-text-muted: #5E7A62;
  --c-border: #D5E8D6;
  --c-today: #43A047;
  --c-school-bg: #E8F1FC;
  --c-noschool-bg: #E6F4E7;
  --shadow-card: 0 2px 12px rgba(67,160,71,0.10);
  --shadow-modal: 0 -4px 32px rgba(14,27,45,0.15);
}
:root[data-theme="ardoise"] {
  --c-orange: #546E7A;
  --c-orange-light: #EEF2F4;
  --c-orange-dark: #263238;
  --c-bg: #F7F9FA;
  --c-text: #1A2328;
  --c-text-muted: #6B7C85;
  --c-border: #DCE3E7;
  --c-today: #546E7A;
  --c-school-bg: #FFF4E6;
  --c-noschool-bg: #E9EEF1;
  --shadow-card: 0 2px 12px rgba(84,110,122,0.10);
  --shadow-modal: 0 -4px 32px rgba(14,27,45,0.15);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="rose"] {
    --c-orange: #F06292;
    --c-orange-light: #3A2029;
    --c-orange-dark: #F8BBD0;
    --c-bg: #1A0F13;
    --c-surface: #24161B;
    --c-text: #F7E6EC;
    --c-text-muted: #B997A4;
    --c-border: #3E2731;
    --c-today: #F06292;
    --c-school-bg: #172531;
    --c-noschool-bg: #2D1A21;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
  :root[data-theme="violet"] {
    --c-orange: #B39DDB;
    --c-orange-light: #2A2238;
    --c-orange-dark: #D1C4E9;
    --c-bg: #14101C;
    --c-surface: #1C1726;
    --c-text: #EEE8F7;
    --c-text-muted: #A89BBE;
    --c-border: #332A44;
    --c-today: #B39DDB;
    --c-school-bg: #142621;
    --c-noschool-bg: #241D31;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
  :root[data-theme="bleu"] {
    --c-orange: #64B5F6;
    --c-orange-light: #1C2B3B;
    --c-orange-dark: #90CAF9;
    --c-bg: #0D131A;
    --c-surface: #131C26;
    --c-text: #E6EEF7;
    --c-text-muted: #92A6BC;
    --c-border: #233244;
    --c-today: #64B5F6;
    --c-school-bg: #14261F;
    --c-noschool-bg: #172333;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
  :root[data-theme="turquoise"] {
    --c-orange: #4DB6AC;
    --c-orange-light: #17302D;
    --c-orange-dark: #80CBC4;
    --c-bg: #0C1514;
    --c-surface: #121E1C;
    --c-text: #E3F2F0;
    --c-text-muted: #8FB0AB;
    --c-border: #213936;
    --c-today: #4DB6AC;
    --c-school-bg: #2B2416;
    --c-noschool-bg: #142826;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
  :root[data-theme="vert"] {
    --c-orange: #66BB6A;
    --c-orange-light: #1C2B1D;
    --c-orange-dark: #A5D6A7;
    --c-bg: #0F1610;
    --c-surface: #152017;
    --c-text: #E7F2E8;
    --c-text-muted: #93AE96;
    --c-border: #243A26;
    --c-today: #66BB6A;
    --c-school-bg: #172531;
    --c-noschool-bg: #18291A;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
  :root[data-theme="ardoise"] {
    --c-orange: #78909C;
    --c-orange-light: #222B30;
    --c-orange-dark: #CFD8DC;
    --c-bg: #101417;
    --c-surface: #171D21;
    --c-text: #E6ECEF;
    --c-text-muted: #98A7AF;
    --c-border: #2A343A;
    --c-today: #78909C;
    --c-school-bg: #2B2416;
    --c-noschool-bg: #1E272C;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-modal: 0 -4px 32px rgba(0,0,0,0.55);
  }
}

html, body { height: 100%; overflow: hidden; background: var(--c-bg); }
body { font-family: var(--font-main); color: var(--c-text); -webkit-tap-highlight-color: transparent; }

/* viewport-fit=cover : l'appli occupe tout l'écran, coins arrondis et
   barre d'accueil compris. Les env(safe-area-inset-*) repoussent le
   contenu hors de ces zones (0 sur un écran sans encoche). */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ===== HEADER ===== */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1.5px solid var(--c-border);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.app-logo { font-size: 28px; }
.app-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--c-orange); line-height: 1.1; }
.app-subtitle { font-size: 12px; color: var(--c-text-muted); font-weight: 600; }
.header-right { display: flex; gap: 8px; }
.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; padding: 6px; border-radius: 50%; transition: background 0.15s; }
.icon-btn:hover { background: var(--c-orange-light); }

/* ===== MONTH NAV ===== */
#month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Premier bandeau de l'écran : il passe sous l'encoche / Dynamic Island */
  padding: env(safe-area-inset-top) 4px 0;
  height: calc(var(--monthbar-h) + env(safe-area-inset-top));
  background: var(--c-surface);
  flex-shrink: 0;
}
#month-label { font-family: var(--font-display); font-size: 16px; font-weight: 800; color: var(--c-text); text-align: center; flex: 1; text-transform: capitalize; }
.nav-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--c-orange); padding: 2px 8px; border-radius: var(--radius-sm); transition: background 0.15s; line-height: 1; }
.nav-btn:hover { background: var(--c-orange-light); }

/* ===== LÉGENDE ===== */
#legend {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: var(--legend-h);
  background: var(--c-surface);
  border-bottom: 1.5px solid var(--c-border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#legend::-webkit-scrollbar { display: none; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, opacity 0.15s;
  user-select: none;
}
.legend-item:hover { opacity: 0.75; }
.legend-pct { font-weight: 400; opacity: 0.75; }

/* Filtre actif */
.cal-day.filtered-out { opacity: 0.15; }

/* ===== CALENDRIER ===== */
#calendar-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* La barre d'onglets flotte par-dessus : on laisse de quoi faire
     remonter la dernière ligne au-dessus en défilant. */
  padding-bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 6px);
  background: var(--c-bg);
  scrollbar-width: thin;
}

.cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: sticky;
  top: 0;
  background: var(--c-surface);
  border-bottom: 1.5px solid var(--c-border);
  z-index: 2;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--c-text-muted);
  padding: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#cal-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 4px 2px;
}

.cal-day {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  min-height: 72px;
  padding: 4px 3px 3px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow: hidden;
}
.cal-day:active { transform: scale(0.96); }
.cal-day.other-month { opacity: 0.35; }
.cal-day.past { opacity: 0.45; }
.cal-day.today { border-color: var(--c-orange); }
.cal-day.today .day-num { background: var(--c-orange); color: #fff; }
.cal-day.is-school  { background: var(--c-school-bg); }
.cal-day.no-school  { background: var(--c-noschool-bg); }

.day-num {
  font-size: 12px;
  font-weight: 800;
  color: var(--c-text);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
  flex-shrink: 0;
}

.day-tasks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.day-task-dot {
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 5px;
  flex-shrink: 0;
}
.day-task-dot .task-icon    { font-size: 15px; line-height: 1; flex-shrink: 0; }
.day-task-dot .task-initial { font-size: 11px; font-weight: 800; color: #fff; line-height: 1; }

/* Périscolaire décidé, mais personne pour récupérer l'enfant */
.day-task-dot-neutral {
  background: var(--c-border);
}
.day-task-dot-neutral .task-initial { color: var(--c-text-muted); }

.day-note-icon {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 11px;
  line-height: 1;
}

/* ===== BOTTOM BAR ===== */
/* ===== BARRE D'ONGLETS (façon iOS 26 « Liquid Glass ») =====
   Pilule de verre flottante : le calendrier défile dessous et se devine
   à travers le flou. Elle occupe la même hauteur que l'ancienne barre ;
   ses extrémités arrondies épousent les coins de l'écran. */
:root {
  --tabbar-h: 54px;
  /* Flotte nettement au-dessus du bas, comme les barres d'onglets
     d'iOS 26 : 18 px minimum (l'iPhone ne fournit pas toujours la zone
     du trait d'accueil), un peu plus quand il la fournit. */
  --tabbar-bottom: max(22px, calc(env(safe-area-inset-bottom) / 2 + 11px));
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-highlight: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 8px 28px rgba(45, 27, 14, 0.16), 0 1px 3px rgba(45, 27, 14, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass-bg: rgba(40, 32, 26, 0.58);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-highlight: rgba(255, 255, 255, 0.16);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}
#bottom-bar {
  position: fixed;
  z-index: 50;
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  bottom: var(--tabbar-bottom);
  max-width: 440px;
  margin: 0 auto;
  height: var(--tabbar-h);
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-border);
  /* Reflet en haut du verre + ombre portée douce */
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}
.tab-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--c-text-muted);
  font-family: -apple-system, BlinkMacSystemFont, var(--font-main);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s, transform 0.12s;
}
.tab-item:active { transform: scale(0.92); }
.tab-icon { width: 24px; height: 24px; flex-shrink: 0; }
.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1px;
  line-height: 1;
  white-space: nowrap;
}
/* Onglet actif : couleur d'accent + lentille claire derrière. La lentille
   est un seul élément qui glisse d'un onglet à l'autre (js : moveTabIndicator) */
.tab-item { position: relative; z-index: 1; }
.tab-item.active { color: var(--c-orange); }
.tab-item.active .tab-label { font-weight: 700; }
.tab-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-orange) 14%, transparent);
  pointer-events: none;
  opacity: 0;
  transform: translateX(0);
  /* Léger dépassement à l'arrivée, façon ressort */
  transition: transform 0.42s cubic-bezier(0.34, 1.32, 0.5, 1),
              width 0.42s cubic-bezier(0.34, 1.32, 0.5, 1),
              opacity 0.2s;
}
.tab-indicator.ready { opacity: 1; }
.tab-indicator.no-anim { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .tab-indicator { transition: opacity 0.2s; }
}

/* ===== MODALS ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45,27,14,0.45);
  backdrop-filter: blur(2px);
}

.modal-sheet {
  position: relative;
  background: var(--c-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  padding-bottom: env(safe-area-inset-bottom);
  max-height: calc(90vh - env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: slide-up 0.3s cubic-bezier(.32,1.25,.6,1);
}
.modal-sheet-full { max-height: calc(95vh - env(safe-area-inset-top)); }

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes modal-appear {
  from { transform: scale(0.97) translateY(6px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);   opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--c-border);
  border-radius: 2px;
  margin: 10px auto 6px;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 12px;
  flex-shrink: 0;
}
.modal-title, #modal-day-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--c-text);
}

.modal-close {
  background: var(--c-bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: var(--c-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px 20px;
  border-top: 1.5px solid var(--c-border);
  flex-shrink: 0;
}

/* ===== NOTE DU JOUR ===== */
.day-note-section {
  background: var(--c-yellow-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.day-note-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--c-text);
  margin-bottom: 6px;
}
.day-note-input {
  width: 100%;
  resize: none;
  overflow: hidden;
  min-height: 72px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
}
.day-note-input:focus {
  outline: none;
  border-color: var(--c-orange);
}

/* ===== TÂCHES DANS MODAL JOUR ===== */
/* Chaque moment est un bloc séparé (et ses parties matin / après-midi aussi) */
#day-task-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#day-task-container > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-group {
  background: var(--c-bg);
  border-radius: var(--radius-md);
  padding: 12px;
}
.task-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.task-group-icon { font-size: 20px; }
.task-group-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--c-text);
}
.task-group-sub {
  font-size: 11px;
  color: var(--c-text-muted);
  font-weight: 600;
  margin-left: auto;
}
.hidden-task { display: none; }

.guardian-choice-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.guardian-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 2px solid transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--c-surface);
  color: var(--c-text);
}
.guardian-chip.selected {
  border-color: currentColor;
  opacity: 1;
}
.guardian-chip:not(.selected) { opacity: 0.5; }
.guardian-chip .g-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}
.nobody-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 2px solid var(--c-border);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--c-surface);
  color: var(--c-text-muted);
}
.nobody-chip.selected {
  border-color: var(--c-text-muted);
  background: var(--c-bg);
}

/* ===== TOGGLE ÉCOLE ===== */
.school-toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.school-toggle-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-muted);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.school-toggle-btn.active {
  border-color: var(--c-orange);
  background: var(--c-orange-light);
  color: var(--c-orange);
}

/* ===== BOUTONS ===== */
.btn-primary {
  flex: 1;
  background: var(--c-orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--c-orange-dark); }
.btn-primary.full-width { width: 100%; }
.btn-secondary {
  flex: 1;
  background: var(--c-bg);
  color: var(--c-text-muted);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* ===== PARAMÈTRES ===== */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--c-orange);
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--c-border);
}
.settings-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-muted);
}
.settings-hint {
  font-size: 12px;
  color: var(--c-text-muted);
}
.settings-input {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
  background: var(--c-bg);
  width: 100%;
}
.settings-input:focus { outline: 2px solid var(--c-orange); border-color: transparent; }

.guardian-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.guardian-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--c-bg);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}
.guardian-name-input {
  flex: 1;
  min-width: 0; /* peut rétrécir : la ligne tient sur les petits écrans */
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
}
.guardian-name-input:focus { outline: none; }
.guardian-emoji-input {
  width: 36px;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 18px;
  padding: 2px;
}
.guardian-del-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--c-text-muted);
  padding: 2px;
  flex-shrink: 0;
}
.btn-add-guardian {
  background: var(--c-orange-light);
  color: var(--c-orange-dark);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

/* Jours école */
.school-days-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.school-day-btn {
  flex: 1;
  min-width: 36px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.school-day-btn.active {
  background: var(--c-orange);
  border-color: var(--c-orange);
  color: #fff;
}

/* Activités récurrentes */
#recurring-activities-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recurring-activity-icon { font-size: 20px; flex-shrink: 0; }
.recurring-activity-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recurring-activity-name { font-size: 15px; font-weight: 700; color: var(--c-text); }
.recurring-activity-sub  { font-size: 12px; color: var(--c-text-muted); }
.recurring-activity-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--c-bg);
  border-radius: var(--radius-md);
  margin-top: 4px;
}
.recurring-icon-input { text-align: center; font-size: 18px; }
.recurring-end-date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--c-text-muted);
}
.recurring-end-date-row input[type="date"] { flex: 1; }

/* ===== SEMAINE TYPE ===== */
.wt-day {
  background: var(--c-bg);
  border-radius: var(--radius-md);
  padding: 12px;
}
.wt-day-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--c-text);
  margin-bottom: 10px;
  text-transform: capitalize;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 700;
  z-index: 200;
  white-space: nowrap;
  animation: fade-in-up 0.3s ease;
}
.toast.hidden { display: none; }
@keyframes fade-in-up {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 2px; }

/* ===== COLOR PICKER PALETTE ===== */
.color-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--c-border);
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: var(--c-text); }

/* Mon compte et invitations (Réglages) */
.account-form, .invite-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.account-form .settings-input, .invite-form .settings-input { margin: 0; }
.account-email { font-size: 14px; font-weight: 700; color: var(--c-text); word-break: break-all; }
.account-sep { border: none; border-top: 1px solid var(--c-border); margin: 14px 0 6px; }
.invite-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
  background: var(--c-bg);
  border: 1.5px dashed var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}
.btn-danger-outline { color: #D84315; }
.guardian-account-badge {
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  font-size: 16px;
}

/* Couleur de l'application (Réglages › Cet appareil) */
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 2px 10px;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
}
.theme-swatch-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 2px transparent;
  transition: transform 0.12s, box-shadow 0.12s;
}
.theme-swatch.selected { color: var(--c-text); }
.theme-swatch.selected .theme-swatch-dot { box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--swatch); }
.theme-swatch:active .theme-swatch-dot { transform: scale(0.92); }

/* Onboarding */
.onboarding-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 20px;
  text-align: center;
}
.onboarding-emoji { font-size: 64px; }
.onboarding-title { font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--c-orange); }
.onboarding-text { font-size: 15px; color: var(--c-text-muted); line-height: 1.6; }

/* ===================================================
   RESPONSIVE — TABLETTE (≥ 600px)
   =================================================== */
@media (min-width: 600px) {
  :root {
    --header-h:   60px;
    --monthbar-h: 46px;
    --legend-h:   42px;
    --bottom-h:   54px;
  }
  .app-title   { font-size: 22px; }
  .icon-btn    { font-size: 24px; }
  #month-label { font-size: 18px; }
  .nav-btn     { font-size: 26px; padding: 2px 14px; }
  .legend-item { font-size: 12px; padding: 3px 12px; }
  .cal-dow     { font-size: 12px; padding: 6px 0; }
  #cal-body    { gap: 3px; padding: 4px; }
  .cal-day     { min-height: 90px; padding: 5px 4px 4px; }
  .day-num     { font-size: 13px; width: 22px; height: 22px; }
  .day-task-dot { height: 24px; }
  .day-task-dot .task-icon { font-size: 17px; }
  .day-task-dot .task-initial { font-size: 12px; }
  .modal-sheet      { max-width: 520px; }
  .modal-sheet-full { max-width: 640px; max-height: 90vh; }
}


/* ===================================================
   RESPONSIVE — BUREAU (≥ 1024px)
   =================================================== */
@media (min-width: 1024px) {
  :root {
    --header-h:   60px;
    --monthbar-h: 50px;
    --legend-h:   44px;
    --bottom-h:   56px;
  }

  /* Header */
  .app-title { font-size: 24px; }
  .icon-btn  { font-size: 22px; padding: 6px; }

  /* Nav mois */
  #month-label { font-size: 20px; }
  .nav-btn     { font-size: 28px; padding: 2px 20px; }

  /* Légende */
  .legend-item { font-size: 13px; padding: 4px 14px; }

  /* Calendrier mensuel */
  .cal-dow { font-size: 13px; padding: 8px 0; letter-spacing: 0.05em; }
  #cal-body { gap: 6px; padding: 8px; }
  .cal-day {
    min-height: 120px;
    padding: 6px 5px 5px;
    gap: 3px;
    border-radius: 10px;
  }
  .cal-day:not(.other-month):hover {
    background: var(--c-orange-light);
    border-color: var(--c-border);
  }
  .day-num      { font-size: 14px; width: 24px; height: 24px; }
  .day-task-dot { height: 26px; }
  .day-task-dot .task-icon { font-size: 18px; }
  .day-task-dot .task-initial { font-size: 13px; }

  /* Modals centrées (pas en bas) */
  .modal { align-items: center; }
  .modal-sheet {
    border-radius: var(--radius-lg);
    max-width: 540px;
    animation: modal-appear 0.22s cubic-bezier(.32,1.25,.6,1);
  }
  .modal-sheet-full {
    border-radius: var(--radius-lg);
    max-width: 720px;
    max-height: 85vh;
    animation: modal-appear 0.22s cubic-bezier(.32,1.25,.6,1);
  }
  .modal-handle { display: none; }

  /* Chips gardiens */
  .guardian-chip { padding: 8px 16px; font-size: 14px; }
  .g-avatar      { width: 28px; height: 28px; font-size: 14px; }
  .nobody-chip   { padding: 8px 14px; font-size: 13px; }

  /* Toggle école & boutons */
  .school-toggle-btn { font-size: 15px; padding: 10px 14px; }
  .btn-primary   { font-size: 16px; }
  .btn-secondary { font-size: 16px; }
}

/* ===================================================
   RESPONSIVE — GRAND BUREAU (≥ 1440px)
   =================================================== */
@media (min-width: 1440px) {
  :root {
    --header-h:   60px;
    --monthbar-h: 54px;
    --bottom-h:   60px;
  }
  .app-title   { font-size: 26px; }
  #month-label { font-size: 22px; }
  #cal-body    { gap: 6px; padding: 10px 8px; }
  .cal-day     { min-height: 140px; padding: 8px 7px 5px; }
  .day-num     { font-size: 15px; width: 27px; height: 27px; }
  .day-task-dot { height: 30px; }
  .day-task-dot .task-icon { font-size: 20px; }
  .day-task-dot .task-initial { font-size: 14px; }
  .cal-dow     { font-size: 13px; padding: 10px 0; }
  .modal-sheet      { max-width: 580px; }
  .modal-sheet-full { max-width: 800px; }
}

/* ===== INIT SEMAINE ===== */
.week-init-hint {
  font-size: 14px;
  color: var(--c-text-muted);
  text-align: center;
  line-height: 1.6;
}
.btn-init-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  font-family: var(--font-main);
}
.btn-init-option:hover { border-color: var(--c-orange); background: var(--c-orange-light); }
.btn-init-icon { font-size: 24px; flex-shrink: 0; }
.btn-init-text { display: flex; flex-direction: column; gap: 3px; }
.btn-init-text strong { font-size: 14px; font-weight: 800; color: var(--c-text); }
.btn-init-text small { font-size: 12px; color: var(--c-text-muted); font-weight: 600; }

/* ===== ACTIVITÉS PERSONNALISÉES ===== */
.activities-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1.5px solid var(--c-border);
}
.activities-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.activity-item {
  background: var(--c-bg);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.activity-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.activity-name {
  font-weight: 800;
  font-size: 14px;
  color: var(--c-text);
}
.activity-delete-btn {
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 50%;
  transition: background 0.15s;
}
.activity-delete-btn:hover { background: var(--c-border); }
.btn-add-activity {
  width: 100%;
  padding: 9px;
  border: 1.5px dashed var(--c-border);
  background: transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 2px;
}
.btn-add-activity:hover {
  border-color: var(--c-orange);
  color: var(--c-orange);
  background: var(--c-orange-light);
}
.btn-split-activity {
  width: 100%;
  padding: 7px;
  border: 1.5px solid var(--c-border);
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.15s;
}
.btn-split-activity:hover {
  border-color: var(--c-orange);
  color: var(--c-orange);
  background: var(--c-orange-light);
}

/* ===== UTILITAIRE ===== */
.hidden { display: none !important; }

/* ===== MODE INVITÉ (LECTURE SEULE) ===== */
/* Tout ce qui écrit disparaît pour un invité : les Réglages restent
   accessibles, mais réduits à la seule déconnexion. */
body.read-only #view-settings .settings-section:not(#settings-logout),
body.read-only #view-settings .view-footer,
body.read-only #modal-day .modal-footer,
body.read-only #view-template .view-footer,
body.read-only #btn-liaison,
body.read-only #btn-requests,
body.read-only .btn-add-activity,
body.read-only .btn-split-activity,
body.read-only .activity-delete-btn {
  display: none !important;
}

/* …et ce qui reste visible n'est plus cliquable */
body.read-only .guardian-choice-grid,
body.read-only .school-toggle-row,
body.read-only .day-note-input {
  pointer-events: none;
}
body.read-only .guardian-chip:not(.selected),
body.read-only .nobody-chip:not(.selected) {
  opacity: 0.45;
}

/* ===== DÉCONNEXION ===== */
.btn-logout {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--c-border);
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 800;
  color: #D84315;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover {
  border-color: #D84315;
  background: rgba(216, 67, 21, 0.08);
}
@media (prefers-color-scheme: dark) {
  .btn-logout { color: #FF8A65; }
  .btn-logout:hover { border-color: #FF8A65; background: rgba(255, 138, 101, 0.12); }
}

/* ===== MOMENTS DE LA JOURNÉE (RÉGLAGES) ===== */
.moment-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--c-bg);
  border-radius: var(--radius-md);
}
.moment-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.moment-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.moment-icon-input {
  width: 42px;
  flex-shrink: 0;
  text-align: center;
  font-size: 18px;
  padding: 8px 2px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font-main);
}
.moment-name-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
}
.moment-applies-select {
  flex: 1;
  min-width: 140px;
  padding: 6px 8px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
}
.moment-split-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
}
.moment-points-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
}
.activity-points-label { margin-bottom: 4px; font-size: 13px; }
.points-input {
  width: 52px;
  padding: 6px 4px;
  text-align: center;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
}
.points-input.invalid { border-color: #E53935; outline: 2px solid #E53935; }
.moment-move-btn {
  flex-shrink: 0;
  width: 28px;
  height: 32px;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  font-size: 14px;
  cursor: pointer;
}
.moment-move-btn:disabled { opacity: 0.3; cursor: default; }

/* ===================================================================
   LIQUID GLASS (façon iOS 26)
   Les commandes flottent en verre au-dessus du contenu : haut d'écran
   (mois, légende, jours), barre d'onglets, feuilles, boutons, toasts.
   Bloc placé en dernier : il prend le pas sur les règles précédentes.
   =================================================================== */
:root {
  /* Hauteur du haut d'écran flottant (mise à jour par app.js) */
  --chrome-h: calc(env(safe-area-inset-top) + 120px);
  --glass-tint: rgba(255, 255, 255, 0.55);
  --glass-tint-strong: rgba(255, 255, 255, 0.78);
  --glass-press: rgba(255, 255, 255, 0.35);
  --glass-blur: blur(20px) saturate(180%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass-tint: rgba(60, 50, 42, 0.5);
    --glass-tint-strong: rgba(36, 28, 22, 0.78);
    --glass-press: rgba(255, 255, 255, 0.08);
  }
}

/* Recette commune : verre clair, flou, reflet en haut, ombre douce */
.glass-btn,
.glass-capsule,
.modal-close {
  background: var(--glass-tint);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}

/* ── Haut d'écran flottant ───────────────────────────── */
#app { position: relative; }
#top-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  pointer-events: none; /* seuls les boutons captent les touchers */
}
/* « Scroll edge effect » : le calendrier qui passe dessous est flouté,
   et le flou s'estompe vers le bas au lieu de finir par une ligne nette. */
#top-chrome::before {
  content: '';
  position: absolute;
  /* Démarre au-dessus de l'écran : le bord d'un backdrop-filter dessine
     une fine ligne, elle reste ainsi hors de vue. */
  inset: -40px 0 -14px 0;
  z-index: -1;
  /* Au bord de l'écran, le flou va chercher du vide et fonce les premiers
     pixels : un fond uni les recouvre, puis s'estompe (40 px = hors écran). */
  background: linear-gradient(to bottom,
    var(--c-bg) 44px,
    color-mix(in srgb, var(--c-bg) 72%, transparent) 62px);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
}
#top-chrome > * { pointer-events: auto; }
/* Ombre des boutons du haut uniquement vers le bas : une ombre large
   débordait vers le haut et dessinait un trait sous la barre de l'heure. */
#month-nav .glass-btn,
#month-nav .glass-capsule {
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 6px 14px -6px rgba(45, 27, 14, 0.28);
}

#month-nav {
  background: transparent;
  padding: calc(env(safe-area-inset-top) + 2px) 12px 2px;
  height: auto;
  gap: 10px;
}
.nav-btn.glass-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-orange);
  flex-shrink: 0;
  transition: transform 0.12s, background 0.2s;
}
.nav-btn.glass-btn svg { width: 22px; height: 22px; }
.nav-btn.glass-btn:hover { background: var(--glass-tint-strong); }
.glass-btn:active,
.modal-close:active { transform: scale(0.9); }
#month-label.glass-capsule {
  flex: none;
  height: 38px;
  line-height: 36px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 16px;
}

#legend {
  background: transparent;
  border-bottom: none;
  padding: 2px 12px;
  height: auto;
  min-height: var(--legend-h);
  flex-wrap: wrap;
  justify-content: center;
  overflow: visible;
}
/* Pastilles de verre teintées de la couleur de chaque personne */
.legend-item {
  background: color-mix(in srgb, var(--chip) 80%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(170%);
  backdrop-filter: blur(12px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 2px 8px rgba(0, 0, 0, 0.10);
  padding: 4px 11px;
  transition: transform 0.12s, box-shadow 0.15s;
}
.legend-item:active { transform: scale(0.94); }
/* Filtre actif : anneau de la couleur du texte */
.legend-item.active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 0 2px currentColor, 0 2px 8px rgba(0, 0, 0, 0.12);
}

.cal-header-row {
  position: static;
  background: transparent;
  border-bottom: none;
}

/* Le calendrier occupe tout l'écran et défile sous le haut et la barre */
#calendar-grid {
  padding-top: var(--chrome-h);
  scroll-padding-top: var(--chrome-h);
}

/* ── Feuilles (Réglages, jour, modèle…) ──────────────── */
.modal-backdrop {
  background: rgba(20, 12, 6, 0.28);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.modal-sheet {
  background: var(--glass-tint-strong);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 12px 48px rgba(0, 0, 0, 0.22);
  /* Feuille flottante, décollée des bords, coins très arrondis */
  width: calc(100% - 16px);
  margin: 0 8px var(--tabbar-bottom);
  border-radius: 34px;
  padding-bottom: 0;
}
/* Comme sur iOS, la feuille laisse voir le haut de l'écran assombri.
   dvh = hauteur réellement visible (vh, sur iPhone, compte aussi la zone
   de l'heure et faisait déborder la feuille en haut). */
.modal-sheet,
.modal-sheet-full {
  max-height: calc(100vh - 40px - var(--tabbar-bottom) - env(safe-area-inset-top));
  max-height: calc(100dvh - 40px - var(--tabbar-bottom) - env(safe-area-inset-top));
}
.modal-handle { background: color-mix(in srgb, var(--c-text) 22%, transparent); }
.modal-footer { border-top: none; }
.modal-close {
  width: 34px;
  height: 34px;
  color: var(--c-text);
  transition: transform 0.12s;
}

/* ── Boutons ─────────────────────────────────────────── */
/* Bouton principal : verre teinté de la couleur d'accent */
.btn-primary {
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%),
    var(--c-orange);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              0 6px 18px color-mix(in srgb, var(--c-orange) 35%, transparent);
  transition: transform 0.12s, filter 0.15s;
}
.btn-primary:hover { background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%),
    var(--c-orange); filter: brightness(1.05); }
.btn-primary:active { transform: scale(0.97); }
/* Boutons secondaires : verre neutre */
.btn-secondary,
.btn-logout {
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-text) 6%, transparent);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition: transform 0.12s;
}
.btn-secondary:active,
.btn-logout:active { transform: scale(0.97); }
.btn-add-guardian {
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-orange) 13%, transparent);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition: transform 0.12s;
}
.btn-add-guardian:active { transform: scale(0.97); }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  background: color-mix(in srgb, var(--c-text) 72%, transparent);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 24px rgba(0, 0, 0, 0.2);
  bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 14px);
}

/* ── Écrans larges : feuilles centrées ───────────────── */
@media (min-width: 600px) {
  #month-label.glass-capsule { font-size: 18px; }
  .legend-item { padding: 4px 13px; }
}
@media (min-width: 1024px) {
  .modal-sheet,
  .modal-sheet-full {
    width: 100%;
    margin: 0;
    border-radius: 30px;
  }
  #month-label.glass-capsule { font-size: 20px; height: 44px; line-height: 42px; }
  .nav-btn.glass-btn { width: 44px; height: 44px; }
}

/* ── Écrans Modèle et Réglages (onglets) ─────────────────
   Écrans entiers façon iOS : grand titre, contenu qui défile sous la
   barre d'onglets, bouton d'enregistrement flottant au-dessus. */
.app-view {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: var(--c-bg);
}
.view-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(16px + env(safe-area-inset-right))
    calc(var(--tabbar-h) + var(--tabbar-bottom) + 84px)
    calc(16px + env(safe-area-inset-left));
}
/* Flou dégradé sous l'heure et l'encoche quand le contenu remonte */
.app-view::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 0;
  right: 0;
  height: calc(env(safe-area-inset-top) + 54px);
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to bottom,
    var(--c-bg) 44px,
    color-mix(in srgb, var(--c-bg) 72%, transparent) 62px);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
/* Grand titre iOS */
.view-title {
  font-family: -apple-system, BlinkMacSystemFont, var(--font-display);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--c-text);
  margin: 6px 4px 4px;
}
.view-subtitle {
  font-size: 14px;
  color: var(--c-text-muted);
  margin: 0 4px 14px;
  line-height: 1.4;
}
.view-title + .view-body { margin-top: 12px; }
.view-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Sections en cartes de verre, comme les groupes des Réglages iOS */
#view-settings .settings-section,
#view-template .wt-day {
  background: var(--glass-tint-strong);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 22px;
  padding: 14px;
}
.view-footer {
  position: absolute;
  z-index: 3;
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 10px);
  max-width: 440px;
  margin: 0 auto;
}
.view-footer .btn-primary { padding: 14px; }

@media (min-width: 900px) {
  .view-scroll > * { max-width: 720px; margin-left: auto; margin-right: auto; }
  .view-title { margin-top: 18px; }
}
/* Sur les écrans à bouton flottant, le toast passe au-dessus du bouton */
body[data-view="template"] .toast,
body[data-view="settings"] .toast,
body[data-view="liaison"] .toast,
body[data-view="requests"] .toast {
  bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 78px);
}

/* ===================================================================
   LIAISON — messages, documents et conversations
   =================================================================== */
/* Pastille « nouveau » sur l'onglet */
.tab-icon-wrap { position: relative; display: inline-flex; }
.tab-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FF3B30;
  border: 2px solid var(--c-surface);
}

/* Cartes du fil, en verre comme les sections des Réglages */
.liaison-card {
  background: var(--glass-tint-strong);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 22px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.12s;
}
.liaison-card:active { transform: scale(0.985); }
.liaison-card-main { cursor: default; }
.liaison-card-main:active { transform: none; }
.liaison-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.liaison-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}
.liaison-author { font-weight: 800; font-size: 14px; color: var(--c-text); }
.liaison-date { margin-left: auto; font-size: 12px; color: var(--c-text-muted); white-space: nowrap; }
.liaison-text {
  font-size: 15px;
  line-height: 1.45;
  color: var(--c-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.liaison-card-foot {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-orange);
}
.liaison-empty {
  text-align: center;
  color: var(--c-text-muted);
  font-size: 15px;
  line-height: 1.6;
  padding: 40px 20px;
}

/* Document joint : aperçu pour les photos, sinon une pastille fichier */
.liaison-image img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c-text) 6%, transparent);
}
.liaison-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c-orange) 10%, transparent);
  border: 1px solid var(--glass-border);
  text-decoration: none;
  color: var(--c-text);
}
.liaison-file-icon { font-size: 22px; }
.liaison-file-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.liaison-file-size { font-size: 12px; color: var(--c-text-muted); white-space: nowrap; }

/* Écrire un message */
.liaison-textarea {
  width: 100%;
  border: 1.5px solid var(--c-border);
  border-radius: 18px;
  padding: 12px 14px;
  font-family: var(--font-main);
  font-size: 16px; /* 16 px : iOS ne zoome pas sur le champ */
  color: var(--c-text);
  background: var(--c-surface);
  resize: none;
}
.liaison-textarea:focus { outline: 2px solid var(--c-orange); border-color: transparent; }
.liaison-file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-orange) 12%, transparent);
  font-size: 14px;
  font-weight: 700;
  color: var(--c-text);
}
.liaison-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liaison-file-remove {
  border: none;
  background: color-mix(in srgb, var(--c-text) 10%, transparent);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--c-text);
  flex-shrink: 0;
}

/* Conversation */
.liaison-replies { display: flex; flex-direction: column; gap: 10px; }
.liaison-reply {
  background: color-mix(in srgb, var(--c-text) 5%, transparent);
  border-radius: 18px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-right: 28px;
}
.liaison-reply.mine {
  background: color-mix(in srgb, var(--c-orange) 12%, transparent);
  margin-right: 0;
  margin-left: 28px;
}
.liaison-no-reply { text-align: center; color: var(--c-text-muted); font-size: 14px; padding: 8px 0; }
.liaison-delete {
  align-self: flex-start;
  border: none;
  background: none;
  color: #D84315;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 0;
  cursor: pointer;
}
.liaison-reply-bar { align-items: flex-end; }
.liaison-reply-input { flex: 1; min-height: 44px; max-height: 140px; border-radius: 22px; padding: 10px 14px; }
.liaison-reply-send {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
  border-radius: 50%;
}

/* Interrupteur façon iOS (Réglages) */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-text);
  padding: 4px 2px;
  cursor: pointer;
}
.ios-switch {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-text) 16%, transparent);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.ios-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.ios-switch:checked { background: #34C759; }
.ios-switch:checked::after { transform: translateX(20px); }
.ios-switch:disabled { opacity: 0.4; }

/* ── Réglages : ligne qui ouvre un sous-écran (façon iOS) ── */
.settings-nav-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: none;
  padding: 2px 0;
  text-align: left;
  font-family: var(--font-main);
  color: var(--c-text);
  cursor: pointer;
}
.settings-nav-icon { font-size: 22px; }
.settings-nav-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-text strong { font-size: 16px; font-weight: 800; }
.settings-nav-text small { font-size: 12px; color: var(--c-text-muted); }
.settings-nav-chevron { font-size: 26px; color: var(--c-text-muted); line-height: 1; }
.settings-nav-row:active { opacity: 0.6; }

/* Bouton retour d'un sous-écran : « ‹ Réglages » en verre */
.view-back {
  align-self: flex-start;
  margin: 2px 0 2px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-tint);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 4px 12px -6px rgba(45, 27, 14, 0.25);
  color: var(--c-orange);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s;
}
.view-back:active { transform: scale(0.94); }

/* « Vu par » sous un message de la Liaison */
.liaison-seen {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
}

/* Réglages > Personnes : pastille « Parent » activable */
.guardian-parent-btn {
  flex-shrink: 0;
  border: 1.5px solid var(--c-border);
  background: transparent;
  color: var(--c-text-muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.guardian-parent-btn.active {
  background: var(--c-orange);
  border-color: var(--c-orange);
  color: #fff;
}
.guardian-parent-btn:active { transform: scale(0.94); }

/* ===================================================================
   À VALIDER — créneaux proposés en attente de validation
   =================================================================== */
.requests-h2 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-muted);
  margin: 6px 4px -6px;
}
.request-card {
  background: var(--glass-tint-strong);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 22px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.request-card.history { opacity: 0.8; padding: 12px 14px; }
.req-title { font-size: 15px; font-weight: 800; color: var(--c-text); }
.req-line { display: flex; flex-direction: column; gap: 1px; }
.req-line small { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-text-muted); }
.req-slot { font-size: 14px; color: var(--c-text); }
.req-slot b { text-transform: capitalize; }
.req-message { font-size: 14px; color: var(--c-text-muted); font-style: italic; }
.req-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.req-status.pending { color: var(--c-text-muted); }
.req-status.ok { color: #2E7D32; }
.req-status.ko { color: #C62828; }
.req-status.off { color: var(--c-text-muted); }
.request-actions { display: flex; gap: 10px; margin-top: 2px; }
.request-actions button { padding: 10px; font-size: 15px; }

/* Formulaire de demande */
.req-type {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-text) 7%, transparent);
}
.req-type button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 9px 6px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 800;
  color: var(--c-text-muted);
  cursor: pointer;
}
.req-type button.active {
  background: var(--c-surface);
  color: var(--c-orange);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.req-block { display: flex; flex-direction: column; gap: 8px; }
.req-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.req-slot-chip {
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  border-radius: 999px;
  padding: 8px 12px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  color: var(--c-text);
  cursor: pointer;
}
.req-slot-chip small { color: var(--c-text-muted); font-weight: 600; }
.req-slot-chip.selected { border-color: var(--c-orange); background: var(--c-orange-light); color: var(--c-orange-dark); }

/* Liaison : archivage des messages (post-it) */
.liaison-archive-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: -4px -4px -4px 2px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--c-text) 6%, transparent);
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s;
}
.liaison-archive-btn:active { transform: scale(0.9); }
.liaison-archived-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--c-text-muted);
  border-top: 1px solid var(--c-border);
  padding-top: 10px;
}
.liaison-unarchive-btn, .liaison-thread-archive {
  border: none;
  background: color-mix(in srgb, var(--c-orange) 13%, transparent);
  color: var(--c-orange-dark);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.liaison-thread-archive { align-self: flex-start; }
.liaison-archives-link {
  margin-top: 4px;
  background: var(--glass-tint-strong);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 22px;
  padding: 14px;
}

/* Visionneuse de document (PDF, photo) : fenêtre haute, fermeture visible */
.doc-sheet { height: calc(100dvh - 40px - var(--tabbar-bottom) - env(safe-area-inset-top)); }
.doc-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}
.doc-body {
  flex: 1;
  min-height: 0;
  margin: 0 12px;
  border-radius: 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: color-mix(in srgb, var(--c-text) 6%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.doc-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.doc-loading, .doc-other {
  text-align: center;
  color: var(--c-text-muted);
  font-size: 15px;
  line-height: 1.6;
  padding: 24px;
}
.doc-other { word-break: break-word; }
.doc-other-icon { font-size: 44px; }
.doc-other strong { color: var(--c-text); }
.doc-other small { font-size: 13px; }
#doc-close2 { flex: 0 0 auto; padding: 12px 20px; }
#doc-share { white-space: nowrap; }

/* « Valider à sa place » : discret, c'est exceptionnel */
.request-for-other {
  align-self: flex-end;
  border: none;
  background: none;
  padding: 2px 0;
  color: var(--c-text-muted);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* Réglages > Carnet de liaison : une ligne par personne */
.access-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  cursor: pointer;
}
.access-row + .access-row { border-top: 1px solid var(--c-border); }
.access-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.access-text strong { font-size: 15px; font-weight: 800; color: var(--c-text); }
.access-parent {
  font-size: 10px;
  font-weight: 800;
  color: var(--c-orange);
  border: 1px solid var(--c-orange);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}
.access-status { font-size: 12px; font-weight: 600; }
.access-status.on   { color: #2E7D32; }
.access-status.warn { color: #E65100; }
.access-status.off  { color: var(--c-text-muted); }
@media (prefers-color-scheme: dark) {
  .access-status.on   { color: #81C995; }
  .access-status.warn { color: #FFB74D; }
}

/* Demandes : réponse de chacun, discussion */
.req-title small { font-weight: 600; color: var(--c-text-muted); font-size: 12px; }
.req-answers { display: flex; flex-wrap: wrap; gap: 6px; }
.req-answer {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-text) 6%, transparent);
  color: var(--c-text);
}
.req-answer.ko { color: var(--c-text-muted); text-decoration: line-through; }
.req-thread-toggle {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 2px 0;
  color: var(--c-orange);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.req-thread { display: flex; flex-direction: column; gap: 8px; }
.req-reply { display: flex; align-items: flex-end; gap: 8px; }

/* Fiche d'un jour : demander qu'on prenne un créneau */
.day-request-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
}

/* Liaison : messages épinglés */
.liaison-pin-btn { opacity: 0.45; filter: grayscale(1); }
.liaison-pin-btn.on { opacity: 1; filter: none; background: color-mix(in srgb, var(--c-orange) 16%, transparent); }
.liaison-card.pinned { border-color: color-mix(in srgb, var(--c-orange) 45%, transparent); }
.liaison-thread-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Dans le fil, le document fait partie du message (il ouvre la conversation) */
div.liaison-image, div.liaison-file { cursor: pointer; }
/* La visionneuse s'ouvre depuis la conversation : elle passe devant */
#modal-doc { z-index: 110; }


/* ===================================================================
   STATISTIQUES
   =================================================================== */
.stats-period { margin-top: 4px; margin-bottom: 12px; }
.stats-title { margin-top: 0; margin-bottom: 12px; padding: 0 4px; font-size: 20px; font-weight: 700; color: var(--c-text); }
.stats-title:empty { display: none; }
.stats-card {
  background: var(--glass-tint-strong);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 22px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stats-h2 { font-size: 16px; font-weight: 800; color: var(--c-text); }
.stats-sub { font-size: 12px; color: var(--c-text-muted); line-height: 1.5; }
.stats-points { font-size: 11px; margin-top: -6px; }
.stats-row, .stats-month { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; }
.stats-name { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--c-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.stats-track { height: 10px; border-radius: 4px; background: color-mix(in srgb, var(--c-text) 7%, transparent); overflow: hidden; }
.stats-fill { display: block; height: 100%; border-radius: 4px; }
.stats-val { font-size: 13px; color: var(--c-text-muted); white-space: nowrap; text-align: right; }
.stats-val b { color: var(--c-text); font-size: 15px; }
.stats-table-wrap { overflow-x: auto; scrollbar-width: none; }
.stats-table-wrap::-webkit-scrollbar { display: none; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--c-text); }
.stats-table th, .stats-table td { padding: 7px 6px; text-align: right; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.stats-table thead th { font-weight: 800; font-size: 12px; color: var(--c-text-muted); }
.stats-table thead th .stats-dot { margin-right: 4px; vertical-align: middle; }
.stats-table tbody th { text-align: left; font-weight: 700; }
.stats-table tbody tr:last-child th, .stats-table tbody tr:last-child td { border-bottom: none; }
.stats-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; font-weight: 700; color: var(--c-text); }
.stats-legend span { display: inline-flex; align-items: center; gap: 5px; }
.stats-month { grid-template-columns: 44px 1fr 110px; }
.price-input { width: 64px; }
.stats-peri-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; color: var(--c-text); }
.stats-peri-row span:last-child { white-space: nowrap; color: var(--c-text-muted); }
.stats-peri-total { padding-top: 10px; border-top: 1px solid var(--c-border); font-weight: 800; }
.stats-peri-total span:last-child { color: var(--c-text); font-size: 18px; }
.stats-month-label { font-size: 12px; font-weight: 800; color: var(--c-text-muted); text-transform: capitalize; }
.stats-stack { display: flex; gap: 2px; height: 14px; }
.stats-seg { height: 100%; min-width: 2px; }
.stats-seg:first-child { border-radius: 4px 0 0 4px; }
.stats-seg:last-child { border-radius: 0 4px 4px 0; }
.stats-seg:only-child { border-radius: 4px; }
.stats-seg.empty { flex: 1; background: color-mix(in srgb, var(--c-text) 7%, transparent); }
.stats-list { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--c-text); }
.stats-list b { text-transform: capitalize; }

/* 5 onglets : sur les très petits écrans, texte un peu plus petit */
@media (max-width: 380px) {
  .tab-label { font-size: 9px; letter-spacing: 0; }
}

.stats-period button { padding: 9px 2px; font-size: 13px; }

/* ===== ASSISTANT : UNE PHRASE → DES CRÉNEAUX ===== */
/* Bouton rond en verre, en bas à droite, au-dessus de la barre d'onglets */
#btn-assistant {
  position: fixed;
  z-index: 45;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 14px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--c-text-muted);   /* sobre, comme les icônes de la barre d'onglets */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s;
}
#btn-assistant svg { width: 26px; height: 26px; }
/* Liaison et Demandes : le bouton passe au-dessus du grand bouton du bas
   (« Nouveau message / document », « Nouvelle demande ») */
body[data-view="liaison"] #btn-assistant,
body[data-view="requests"] #btn-assistant { bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 76px); }
body.has-assistant[data-view="liaison"] #view-liaison .view-scroll,
body.has-assistant[data-view="requests"] #view-requests .view-scroll { padding-bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 146px); }
/* De quoi faire remonter la dernière ligne au-dessus du bouton */
body.has-assistant #calendar-grid { padding-bottom: calc(var(--tabbar-h) + var(--tabbar-bottom) + 72px); }

.assistant-hint { text-align: left; margin: 0; }
/* Fenêtre haute dès l'ouverture, zone de saisie confortable (le texte
   d'exemple tient en entier) */
#modal-assistant .modal-sheet { min-height: min(78vh, 640px); }
#assistant-text { min-height: 132px; font-size: 16px; line-height: 1.4; }
#assistant-result { display: flex; flex-direction: column; gap: 10px; }
#assistant-result:empty { display: none; }

.ai-summary {
  font-weight: 800;
  color: var(--c-text);
  background: var(--c-orange-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.ai-question {
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-yellow-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.ai-warnings {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-muted);
}
.ai-day {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-day-title { font-weight: 800; color: var(--c-text); text-transform: capitalize; }
.ai-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
  background: var(--c-bg);
  border-radius: 999px;
  padding: 1px 8px;
  text-transform: none;
}
.ai-change {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  font-size: 14px;
}
.ai-slot { font-weight: 700; color: var(--c-text); }
.ai-move { display: inline-flex; align-items: center; gap: 6px; }
.ai-arrow { color: var(--c-text-muted); font-weight: 800; }
.ai-person {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  color: var(--chip, var(--c-text-muted));
}
.ai-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip); }
.ai-person-none { font-weight: 600; font-style: italic; }

/* Attente de la réponse de l'assistant */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--c-text);
  background: var(--c-orange-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.ai-sparkle { display: inline-block; font-size: 20px; animation: ai-sparkle 1.4s ease-in-out infinite; }
.ai-loading-text { animation: ai-fade-in 0.4s ease; }
.ai-dots { display: inline-flex; gap: 3px; margin-left: -2px; padding-top: 6px; }
.ai-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c-orange); animation: ai-dot 1.2s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }

/* Cartes fantômes : la forme de l'aperçu, avec un reflet qui passe */
.ai-skeleton {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ai-skeleton i {
  display: block;
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--c-border) 0%, var(--c-orange-light) 50%, var(--c-border) 100%);
  background-size: 200% 100%;
  animation: ai-shimmer 1.3s linear infinite;
}
.ai-skeleton i:first-child { width: 45%; height: 13px; }
.ai-skeleton i:nth-child(2) { width: 85%; }
.ai-skeleton i:nth-child(3) { width: 70%; }

@keyframes ai-sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50%      { transform: scale(1.25) rotate(18deg); opacity: 0.75; }
}
@keyframes ai-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}
@keyframes ai-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes ai-fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ai-sparkle, .ai-dots i, .ai-skeleton i, .ai-loading-text { animation: none; }
}

/* Aperçu d'une demande faite par l'assistant */
.ai-req-title { font-weight: 800; color: var(--c-text); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ai-req-slot { font-size: 14px; color: var(--c-text); text-align: right; }
.ai-req-message { font-size: 14px; font-style: italic; color: var(--c-text-muted); }

/* Réponse de l'assistant à une question de statistiques */
.ai-stats-headline {
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-orange-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  line-height: 1.4;
}
.ai-stats-headline b { font-size: 18px; font-weight: 900; }
.ai-change.ai-highlight { background: var(--c-bg); border-radius: 8px; margin: 0 -6px; padding: 2px 6px; }

/* ===== LIAISON × ASSISTANT ===== */
.ai-remind {
  margin-top: 8px;
  background: var(--c-yellow-light);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--c-text);
}
.ai-remind.muted { background: var(--c-bg); color: var(--c-text-muted); font-weight: 700; }
.ai-remind-title { font-weight: 800; margin-bottom: 2px; }
.ai-remind-list { margin: 0; padding-left: 18px; }
.ai-remind-list li.past { color: var(--c-text-muted); text-decoration: line-through; }

.ai-doc { display: flex; flex-direction: column; gap: 8px; }
.ai-doc-summary {
  background: var(--c-orange-light);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--c-text);
  line-height: 1.4;
}
.ai-doc .ai-remind { margin-top: 0; }
.ai-doc-ask { display: flex; gap: 8px; }
.ai-doc-ask .settings-input { flex: 1; min-width: 0; margin: 0; }
.ai-doc-ask .btn-primary { flex: none; padding-left: 14px; padding-right: 14px; }
.ai-reread { align-self: flex-start; }

.ai-answer {
  background: var(--c-orange-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.45;
  white-space: pre-line;
}
.ai-sources { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-source {
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* Exemples de l'assistant : on touche, la phrase se met dans la zone de saisie */
.ai-examples { display: flex; flex-direction: column; gap: 6px; }
.ai-examples-title { font-size: 13px; font-weight: 800; color: var(--c-text-muted); }
.ai-example {
  text-align: left;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ai-example:active { background: var(--c-orange-light); }
#modal-assistant.has-result .ai-examples { display: none; }

/* ===== FIL DE LA LIAISON, VERSION COMPACTE ===== */
#liaison-list .liaison-card,
#liaison-archives-list .liaison-card { gap: 6px; padding: 12px 14px; }
/* Sans titre de l'assistant : une ligne de texte dans le fil (en entier
   dans la conversation) */
#liaison-list .liaison-text,
#liaison-archives-list .liaison-text {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Titre donné par l'assistant, à la place du texte */
.liaison-title {
  min-width: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.liaison-title-icon { margin-right: 6px; }
.liaison-file-mini {
  align-self: flex-start;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c-orange) 10%, transparent);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text);
}
.liaison-file-mini-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-remind-mini {
  background: var(--c-yellow-light);
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--c-text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-remind-mini.muted { background: var(--c-bg); color: var(--c-text-muted); font-weight: 700; }
.ai-remind-line {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-remind-line.past { color: var(--c-text-muted); text-decoration: line-through; }
.ai-remind-more { font-size: 12px; font-weight: 700; color: var(--c-text-muted); }
/* Texte puis document juste après, sur la même ligne ; le nom du document
   cède la place au texte */
.liaison-line { display: flex; align-items: center; justify-content: flex-start; gap: 8px; min-width: 0; }
.liaison-line .liaison-text { flex: 0 1 auto; min-width: 0; }
.liaison-line .liaison-file-mini { flex: 0 1 auto; min-width: 0; max-width: 55%; }
.liaison-line .liaison-file-mini:only-child { max-width: 100%; }

/* ===== BOUTON ⏰ « À NE PAS OUBLIER » (haut du planning) ===== */
/* Le bouton ⏰ est posé par-dessus la barre, collé à la flèche de droite :
   il ne prend pas de place dans la rangée, le mois reste centré */
#month-nav { position: relative; }
#btn-todo {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 2px);
  right: calc(12px + 38px + 8px);   /* marge de la barre + flèche + écart */
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--c-text-muted);   /* sobre, comme les icônes de la barre d'onglets */
  cursor: pointer;
  transition: transform 0.12s;
}
#btn-todo svg { width: 20px; height: 20px; }
#btn-todo:active { transform: scale(0.92); }
/* Échéance aujourd'hui ou demain : même icône, en orange */
#btn-todo.urgent { color: var(--c-orange); }

.todo-item {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.todo-item.soon { border-color: var(--c-orange); background: var(--c-orange-light); }
.todo-when { font-size: 12px; font-weight: 800; color: var(--c-orange); text-transform: uppercase; letter-spacing: 0.02em; }
.todo-text { font-size: 15px; font-weight: 700; color: var(--c-text); line-height: 1.4; }
.todo-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.todo-doc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
}
.todo-done {
  flex: none;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--c-orange);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.todo-done:disabled { opacity: 0.5; }

/* Réglages : coûts de l'IA */
.ai-usage-month { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; color: var(--c-text); margin-bottom: 6px; }
.ai-usage-month b { font-size: 22px; font-weight: 900; color: var(--c-orange); }
.ai-usage-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--c-text); padding: 3px 0; }
.ai-usage-row span:last-child { color: var(--c-text-muted); font-weight: 700; white-space: nowrap; }
.ai-usage-sep { border-top: 1.5px solid var(--c-border); margin-top: 6px; padding-top: 8px; }

/* ===== HISTORIQUE (bouton à gauche du mois, symétrique de la cloche) ===== */
#btn-history {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 2px);
  left: calc(12px + 38px + 8px);   /* marge de la barre + flèche + écart */
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: transform 0.12s;
}
#btn-history svg { width: 20px; height: 20px; }
#btn-history:active { transform: scale(0.92); }
body.read-only #btn-history { display: none; }

.history-group {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.history-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.history-meta { font-size: 12px; font-weight: 700; color: var(--c-text-muted); margin-bottom: 2px; }
.history-line { display: flex; gap: 8px; font-size: 14px; color: var(--c-text); line-height: 1.35; }
.history-day { flex: none; width: 82px; font-weight: 800; color: var(--c-text-muted); font-size: 13px; padding-top: 1px; }
.history-what { min-width: 0; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.history-rest { display: flex; flex-direction: column; gap: 5px; }
.history-rest.hidden { display: none; }
.history-more {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 2px 0;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--c-orange);
  cursor: pointer;
}
