/* ===== 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);
  }
}

/* Instance de Louis : thème bleu (data-child posé par js/child.js).
   Les noms --c-orange* sont gardés : ce sont les couleurs d'accent. */
:root[data-child="louis"] {
  --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);
}

@media (prefers-color-scheme: dark) {
  :root[data-child="louis"] {
    --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);
  }
}

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; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ===== 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;
  padding: 0 4px;
  height: var(--monthbar-h);
  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; }
.week-day-card.filtered-out { opacity: 0.15; }

/* ===== CALENDRIER ===== */
#calendar-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  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; cursor: default; }
.cal-day.past:active { transform: none; }
.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; }

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

/* ===== BOTTOM BAR ===== */
#bottom-bar {
  display: flex;
  height: var(--bottom-h);
  background: var(--c-surface);
  border-top: 1.5px solid var(--c-border);
  flex-shrink: 0;
  padding: 4px 8px;
  gap: 6px;
  position: relative;
}
#bottom-bar .icon-btn {
  flex-shrink: 0;
  align-self: center;
  font-size: 22px;
  padding: 6px 8px;
}
.bottom-btn {
  flex: 1;
  border: 1.5px solid var(--c-border);
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.bottom-btn.active {
  background: var(--c-orange);
  border-color: var(--c-orange);
  color: #fff;
}

/* ===== VUE SEMAINE ===== */
#calendar-grid.week-mode .cal-header-row { display: none; }

#cal-body.week-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
.week-day-card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--c-border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.week-day-card.is-school { background: var(--c-school-bg); }
.week-day-card.no-school { background: var(--c-noschool-bg); }
.week-day-card:active { transform: scale(0.99); }
.week-day-card.past { opacity: 0.45; cursor: default; }
.week-day-card.past:active { transform: none; }
.week-day-card.today { border-color: var(--c-orange); }
.week-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--c-border);
}
.week-day-name {
  font-weight: 800;
  font-size: 14px;
  text-transform: capitalize;
  color: var(--c-text);
}
.week-day-card.today .week-day-name { color: var(--c-orange); }
.week-day-type {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
}
.week-task-list {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.week-task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.week-task-icon { font-size: 15px; width: 20px; text-align: center; }
.week-task-label { flex: 1; color: var(--c-text-muted); font-size: 12px; }
.week-task-guardian { font-weight: 700; font-size: 13px; }
.week-task-empty { color: var(--c-text-muted); font-size: 12px; padding: 2px 0; }

/* ===== 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;
  max-height: 90vh;
  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: 95vh; }

@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: vertical;
  min-height: 44px;
  max-height: 160px;
  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 ===== */
.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;
  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); }

/* 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 — VUE SEMAINE EN GRILLE (≥ 900px)
   =================================================== */
@media (min-width: 900px) {
  #cal-body.week-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    padding: 14px;
    align-items: start;
  }
}

/* ===================================================
   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; }

  /* Vue semaine */
  #cal-body.week-view   { gap: 10px; padding: 12px; }
  .week-day-header      { padding: 10px 14px 8px; }
  .week-day-name        { font-size: 13px; }
  .week-day-type        { font-size: 11px; }
  .week-task-list       { padding: 8px 14px; gap: 7px; }
  .week-task-guardian   { font-size: 13px; font-weight: 800; }

  /* Bottom bar */
  #bottom-bar { padding: 5px 24px; gap: 12px; justify-content: center; }
  .bottom-btn { flex: none; min-width: 140px; font-size: 13px; padding: 0 20px; }
  #bottom-bar .icon-btn { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); }

  /* 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; }
  .bottom-btn  { min-width: 170px; font-size: 14px; }
  .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 #modal-settings .settings-section:not(#settings-logout),
body.read-only #modal-settings .modal-footer,
body.read-only #modal-day .modal-footer,
body.read-only #modal-week-template .modal-footer,
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-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; }
