/* Planning des permanences — feuille de style unique, sans dépendance. */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --ink: #1d2626;
  --ink-2: #4b5757;
  --ink-3: #7a8585;
  --line: #e2ddd2;
  --line-strong: #cfc8b9;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe5;
  --danger: #b3412f;
  --danger-soft: #f7e0db;
  --warn: #8a5a00;
  --warn-soft: #fbefd2;
  /* Disponibilités : vert = sans problème, jaune = possible, orange = pour dépanner */
  --l1: #146c3a;   --l1-bg: #cdeed8;   --l1-line: #3fae6a;
  --l2: #6e5300;   --l2-bg: #fcef9c;   --l2-line: #e2c21c;
  --l3: #9a3b06;   --l3-bg: #fed2ad;   --l3-line: #f08a2c;
  --closed-bg: repeating-linear-gradient(135deg, #ebe7de 0 6px, #e2ddd2 6px 12px);
  --assigned: #22303a;
  --assigned-ink: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Thème sombre : automatique (réglage du système) sauf si l'utilisateur a choisi « clair »,
   ou forcé par le choix « sombre » (attribut data-theme posé par js/theme.js).
   Réservé à l'écran : l'impression reste toujours claire. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151a1a;
    --surface: #1d2424;
    --surface-2: #242c2c;
    --ink: #e8ecea;
    --ink-2: #b4bfbc;
    --ink-3: #8a9693;
    --line: #313b3a;
    --line-strong: #435150;
    --accent: #6cc4a6;
    --accent-ink: #0f1a17;
    --accent-soft: #1f3a32;
    --danger: #f08b77;
    --danger-soft: #3d2420;
    --warn: #f0c36b;
    --warn-soft: #3a2f17;
    --l1: #8fe3ad;   --l1-bg: #173a24;   --l1-line: #3fae6a;
    --l2: #f5dc6b;   --l2-bg: #3a3310;   --l2-line: #c9a915;
    --l3: #f9ac6f;   --l3-bg: #43260f;   --l3-line: #e07a1f;
    --closed-bg: repeating-linear-gradient(135deg, #222a2a 0 6px, #1b2121 6px 12px);
    --assigned: #e8ecea;
    --assigned-ink: #151a1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --bg: #151a1a;
    --surface: #1d2424;
    --surface-2: #242c2c;
    --ink: #e8ecea;
    --ink-2: #b4bfbc;
    --ink-3: #8a9693;
    --line: #313b3a;
    --line-strong: #435150;
    --accent: #6cc4a6;
    --accent-ink: #0f1a17;
    --accent-soft: #1f3a32;
    --danger: #f08b77;
    --danger-soft: #3d2420;
    --warn: #f0c36b;
    --warn-soft: #3a2f17;
    --l1: #8fe3ad;   --l1-bg: #173a24;   --l1-line: #3fae6a;
    --l2: #f5dc6b;   --l2-bg: #3a3310;   --l2-line: #c9a915;
    --l3: #f9ac6f;   --l3-bg: #43260f;   --l3-line: #e07a1f;
    --closed-bg: repeating-linear-gradient(135deg, #222a2a 0 6px, #1b2121 6px 12px);
    --assigned: #e8ecea;
    --assigned-ink: #151a1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
small, .muted { color: var(--ink-3); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* --- Structure ------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-static { position: static; }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 15px;
}
.page { max-width: 1280px; margin: 0 auto; padding: 20px 16px 96px; }
.page-narrow { max-width: 880px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge-demo { background: var(--warn-soft); color: var(--warn); }
.status-brouillon { background: var(--surface-2); color: var(--ink-2); }
.status-saisie { background: var(--warn-soft); color: var(--warn); }
.status-publie { background: var(--accent-soft); color: var(--accent); }
.status-cloture { background: var(--line); color: var(--ink-2); }

.notice {
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px;
  background: var(--accent-soft); color: var(--ink);
}
.notice-warn { background: var(--warn-soft); }
.notice-danger { background: var(--danger-soft); }

/* --- Formulaires ------------------------------------------------------------ */

.btn {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap; min-height: 36px;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 3px 9px; font-size: 13px; min-height: 28px; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 600; cursor: pointer; font: inherit; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; min-height: 36px;
  max-width: 100%;
}
textarea { width: 100%; min-height: 90px; resize: vertical; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field input:not([type=checkbox]), .field select { width: 100%; }
.hint { font-size: 13px; color: var(--ink-3); margin: 4px 0 0; }
.form-error { color: var(--danger); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400 !important; }

/* --- Modales et notifications ------------------------------------------------ */

.modal {
  border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .25);
}
.modal-wide { width: min(760px, calc(100vw - 24px)); }
.modal::backdrop { background: rgb(20 25 25 / .45); }
.modal-form { padding: 20px; }
.modal-body { max-height: 65vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); transition: opacity .4s; }
.toast-error { background: var(--danger); color: #fff; }
.toast-success { background: var(--accent); color: var(--accent-ink); }
.toast.out { opacity: 0; }

/* --- Tableaux ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
.pos { color: var(--l1); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }

/* --- Niveaux de disponibilité --------------------------------------------------- */

.lvl { font-weight: 700; border-radius: 6px; padding: 0 6px; font-size: 13px; display: inline-grid; place-items: center; min-width: 26px; line-height: 22px; background: var(--surface-2); }
.lvl-1 { background: var(--l1-bg); color: var(--l1); box-shadow: inset 0 0 0 1px var(--l1-line); }
.lvl-2 { background: var(--l2-bg); color: var(--l2); box-shadow: inset 0 0 0 1px var(--l2-line); }
.lvl-3 { background: var(--l3-bg); color: var(--l3); box-shadow: inset 0 0 0 1px var(--l3-line); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

/* --- Tabs ------------------------------------------------------------------------ */

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  font: inherit; font-weight: 600; font-size: 14px; border: 0; background: none; color: var(--ink-2);
  padding: 7px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: var(--surface-2); }
.tab[aria-selected=true] { background: var(--accent-soft); color: var(--accent); }

/* Page famille : une section par onglet. Sur téléphone, libellés courts sous l'icône. */
.main-tabs {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.main-tabs .tab { flex: 1 1 auto; padding: 7px 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; position: relative; }
.tab-short { display: none; }
.tab-count {
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700;
  min-width: 18px; padding: 0 5px; line-height: 18px; text-align: center;
}
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.month-tabs { margin-bottom: 12px; }
/* Libellés courts jusqu'à la tablette : les libellés complets ne tiennent sur une ligne qu'au-delà. */
@media (max-width: 920px) {
  .main-tabs { gap: 2px; }
  .main-tabs .tab { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 0; font-size: 11px; letter-spacing: -.01em; }
  .main-tabs .tab i { font-size: 16px; }
  .tab-long { display: none; }
  .tab-short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .main-tabs .tab-count, .main-tabs .tab-dot { position: absolute; top: 3px; right: calc(50% - 22px); }
  .main-tabs .tab-count { font-size: 10px; min-width: 16px; line-height: 16px; padding: 0 4px; }
}

/* Mes permanences */
.duties { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.duty {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.duty-when { flex: 1 1 220px; min-width: 0; }
.duty-when .chores { margin-top: 4px; }
.duty-today { border: 2px solid var(--accent); background: var(--accent-soft); padding: 9px 11px; }
.duty-replaced .duty-when strong { text-decoration: line-through; color: var(--ink-3); }
.duties-past .duty { background: var(--surface-2); }
.past-toggle { margin-top: 14px; }
.open-swaps h2 i { color: var(--accent); }

/* Choix de l'agenda */
.agenda-options { display: grid; gap: 8px; }
.agenda-option {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; text-decoration: none;
}
.agenda-option:hover { background: var(--surface-2); }
.agenda-option i { font-size: 20px; color: var(--accent); margin-top: 2px; width: 24px; text-align: center; flex: none; }
.agenda-option strong, .agenda-option small { display: block; }

.print-only { display: none; }

/* --- Page famille : calendrier de saisie ---------------------------------------- */

.cal-head, .cal-week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; margin-bottom: 6px; text-align: center; }
.cal-block + .cal-block { margin-top: 6px; }
/* Titre de semaine : seulement sur téléphone, où les jours s'empilent (sur ordinateur, une ligne = une semaine). */
.cal-week-title { display: none; }
/* Infobulle (dom.js : withTip) */
.has-tip { cursor: help; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.tip {
  position: fixed; z-index: 1000; max-width: min(280px, calc(100vw - 16px)); pointer-events: none;
  background: var(--ink); color: var(--surface); font-size: 13px; line-height: 1.4; font-weight: 500;
  padding: 7px 10px; border-radius: 8px; box-shadow: 0 4px 16px rgb(0 0 0 / .2);
  opacity: 0; visibility: hidden; transition: opacity .12s;
}
.tip.tip-on { opacity: 1; visibility: visible; }
.day {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.day-empty { visibility: hidden; }
.day-label { font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; gap: 4px; }
.day-label .wd { display: none; }
.day-holiday { font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.half {
  /* Hauteur fixe quel que soit l'état : une ligne pour « Matin / Après-midi », une ligne pour la disponibilité. */
  --half-h: 48px;
  container-type: inline-size;
  font: inherit; font-size: 12px; cursor: pointer; border-radius: 6px; padding: 0 6px; min-width: 0; text-align: left;
  height: var(--half-h); display: grid; grid-template-rows: 16px 18px; align-content: center; row-gap: 2px;
  border: 1px dashed var(--line-strong); background: var(--surface); color: var(--ink-3);
}
.half .h-name, .half .h-level { min-width: 0; overflow: hidden; white-space: nowrap; }
.half .h-name { font-size: 12px; line-height: 16px; text-overflow: ellipsis; }
.half[class*=' l'] .h-name { opacity: .85; }
.half .h-level { display: flex; align-items: center; gap: 4px; font-weight: 700; line-height: 18px; }
.half .h-level i { flex: none; }
.half .h-level-text { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.half .h-level-tiny { display: none; font-size: 11px; }
/* Cases étroites : on retire l'icône, puis on passe au libellé court (la couleur reste). */
@container (max-width: 110px) { .half .h-level i { display: none; } .half .h-level-text { font-size: 11px; } }
@container (max-width: 80px) { .half .h-level-text { display: none; } .half .h-level-tiny { display: inline; } }
.half.l1 { background: var(--l1-bg); color: var(--l1); border: 1px solid var(--l1-line); }
.half.l2 { background: var(--l2-bg); color: var(--l2); border: 1px solid var(--l2-line); }
.half.l3 { background: var(--l3-bg); color: var(--l3); border: 1px solid var(--l3-line); }
.half.closed { background: var(--closed-bg); border: 1px solid transparent; cursor: default; color: var(--ink-3); }
.half.absent { background: var(--closed-bg); border: 1px dashed var(--line); cursor: default; color: var(--ink-3); }
.half:disabled:not(.closed) { cursor: default; }
.half.mine { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.half.replaced { text-decoration: line-through; }
.half.empty { font-style: italic; }
.half.readonly { border-style: solid; cursor: default; }

/* Choix de la disponibilité d'une demi-journée */
.picker {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0; position: fixed;
  width: 300px; background: var(--surface); color: var(--ink); box-shadow: 0 12px 40px rgb(0 0 0 / .22);
}
.picker::backdrop { background: rgb(20 25 25 / .18); }
.picker-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.picker-title { font-weight: 700; }
.choices { display: grid; gap: 6px; }
.choice {
  font: inherit; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 48px; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
}
.choice i:first-child { font-size: 20px; }
.choice-1 { background: var(--l1-bg); color: var(--l1); border-color: var(--l1-line); }
.choice-2 { background: var(--l2-bg); color: var(--l2); border-color: var(--l2-line); }
.choice-3 { background: var(--l3-bg); color: var(--l3); border-color: var(--l3-line); }
.choice-0 { color: var(--ink-2); }
.choice[aria-pressed=true] { box-shadow: 0 0 0 3px var(--ink); border-color: var(--ink); }
.choice-current { margin-left: auto; }
.picker-repeat { margin-top: 12px; font-size: 14px; align-items: flex-start !important; }
.picker-repeat input { margin-top: 2px; flex: none; }
.chip-level-1 i { color: var(--l1-line); } .chip-level-2 i { color: var(--l2-line); } .chip-level-3 i { color: var(--l3-line); }

@media (max-width: 640px) {
  .picker {
    inset: auto 0 0 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .picker::backdrop { background: rgb(20 25 25 / .35); }
  .choice { min-height: 54px; font-size: 16px; }
}

/* Bouton de thème */
.theme-toggle { gap: 6px; }
.theme-toggle i { width: 1em; text-align: center; }
@media (max-width: 640px) { .theme-toggle .theme-label { display: none; } }

/* Planning publié : cases de hauteur fixe (lignes réservées), pour une grille régulière */
.plan-half {
  --plan-h: 88px;
  container-type: inline-size;
  height: var(--plan-h); overflow: hidden; min-width: 0;
  display: grid; grid-template-rows: 15px 19px 15px 1fr; row-gap: 2px;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--surface);
}
.plan-half > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-when { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; font-size: 11px; line-height: 15px; color: var(--ink-3); font-weight: 600; }
.plan-slot { text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.plan-when small { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-swap { color: var(--danger); font-weight: 600 !important; }
@container (max-width: 150px) { .plan-time { display: none; } }
.plan-family { font-weight: 700; font-size: 14px; line-height: 19px; }
.plan-child { font-size: 12px; line-height: 15px; color: var(--ink-2); }
.plan-chores { display: flex; align-items: center; }
.plan-chores .chores { margin: 0; flex-wrap: nowrap; overflow: hidden; }
.plan-none { color: var(--danger); font-weight: 600; font-style: italic; }
.plan-closed { grid-row: 2 / 4; font-size: 12px; line-height: 15px; color: var(--ink-3); white-space: normal !important; }
.plan-half.closed { background: var(--closed-bg); border-color: transparent; }
.plan-half.mine { background: var(--accent-soft); border: 2px solid var(--accent); padding: 3px 5px; }
.plan-half.mine .plan-family::before { content: '★ '; color: var(--accent); }
.calendar.planning .cal-head, .calendar.planning .cal-week { grid-template-columns: repeat(5, minmax(120px, 1fr)); }
.calendar.planning .day { padding: 5px; }
.planning-card .legend { margin: 4px 0 12px; }
.plan-times { font-size: 13px; color: var(--ink-2); margin: 0 0 8px; }

.chores { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chore {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border-radius: 999px; padding: 1px 7px 1px 5px; white-space: nowrap;
}
.chore-bin { font-size: 13px; -webkit-text-stroke: .6px rgb(0 0 0 / .55); paint-order: stroke fill; }
.chore-arrow { font-size: 10px; color: var(--ink-3); }
.upcoming li { margin-bottom: 4px; }
.upcoming .chores { display: inline-flex; margin: 0; vertical-align: middle; }

@media (max-width: 640px) {
  .calendar.planning .cal-week { grid-template-columns: 1fr; }
  .calendar.planning .day { grid-template-columns: 58px 1fr 1fr; align-items: stretch; }
  .calendar.planning .day-label { justify-content: flex-start; }
  .plan-when small { display: none; }
  .cal-head { display: none; }
  .cal-week { grid-template-columns: 1fr; gap: 6px; }
  .day { display: grid; grid-template-columns: 62px 1fr 1fr; align-items: center; gap: 6px; }
  .day-label { flex-direction: column; gap: 0; }
  .day-label .wd { display: inline; font-weight: 400; color: var(--ink-3); font-size: 12px; }
  .day-holiday { grid-column: 2 / 4; white-space: normal; }
  .half { --half-h: 52px; }
  .day.day-empty { display: none; }
  .cal-block + .cal-block { margin-top: 22px; }
  .cal-week-title {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
    margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--line-strong);
    font-size: 14px; font-weight: 700; color: var(--ink-2);
  }
  .cal-week-title .week-chip { font-size: 11px; padding: 1px 7px; }
  .savebar-inner { font-size: 14px; }
}

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .06);
}
.savebar-inner { max-width: 880px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; }
.savebar-inner { font-size: 14px; min-height: 48px; padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.savebar-error { background: var(--danger-soft); }
.save-ok { color: var(--l1); font-weight: 600; }
.save-error { color: var(--danger); font-weight: 600; }

.quickfill { margin: 8px 0 12px; }
.quickfill summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; font-size: 14px; cursor: pointer; background: var(--surface); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }

.big-number { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.kpi .label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }

/* --- Admin : grille d'attribution ------------------------------------------------ */

.matrix-wrap { overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
table.matrix thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); vertical-align: bottom; }
table.matrix .sticky-col { position: sticky; left: 0; z-index: 2; background: var(--surface); }
table.matrix thead .sticky-col { z-index: 4; background: var(--surface-2); }
.m-fam { width: 84px; min-width: 84px; padding: 6px 4px !important; text-align: center; font-weight: 600; }
.m-fam .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 76px; margin: 0 auto; }
.m-fam .meta { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); white-space: nowrap; }
.m-fam .need { display: block; font-size: 11px; font-weight: 700; white-space: nowrap; }
.m-fam .noresp { color: var(--danger); }
.m-slot { min-width: 210px; padding: 4px 8px !important; white-space: nowrap; }
.m-slot .d { font-weight: 600; }
.m-slot .s { color: var(--ink-3); }
.m-slot .who { display: block; font-size: 12px; color: var(--accent); font-weight: 700; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.m-slot .who.none { color: var(--danger); }
tr.day-start td, tr.day-start th { border-top: 2px solid var(--line-strong); }
.cell {
  width: 84px; height: 34px; border: 0; background: transparent; font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; display: grid; place-items: center; color: var(--ink-3); position: relative;
}
.cell:hover { background: var(--surface-2); }
.cell i { font-size: 15px; }
.cell.l1 { color: var(--l1); background: var(--l1-bg); }
.cell.l2 { color: var(--l2); background: var(--l2-bg); }
.cell.l3 { color: var(--l3); background: var(--l3-bg); }
.cell.absent { color: var(--ink-3); opacity: .75; }
.cell.assigned { background: var(--assigned); color: var(--assigned-ink); gap: 0; }
.cell.assigned.l1 { box-shadow: inset 0 -4px 0 var(--l1-line); }
.cell.assigned.l2 { box-shadow: inset 0 -4px 0 var(--l2-line); }
.cell.assigned.l3 { box-shadow: inset 0 -4px 0 var(--l3-line); }
.m-fam .child { display: block; font-size: 11px; font-weight: 400; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 76px; margin: 0 auto; }
.cell.planned { box-shadow: inset 0 0 0 2px var(--danger); }
.cell.planned::after { content: 'prévu'; position: absolute; bottom: 1px; font-size: 9px; font-weight: 600; color: var(--danger); }
.cell.closed { background: var(--closed-bg); cursor: default; }
.cell:disabled { cursor: default; }
tr.closed-row .m-slot { color: var(--ink-3); }
tr.unfilled .m-slot { box-shadow: inset 3px 0 0 var(--danger); }

.notes-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.note-item { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-item b { display: block; white-space: normal; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.steps li { counter-increment: step; display: flex; gap: 10px; align-items: baseline; }
.steps li::before {
  content: counter(step); flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; display: grid; place-items: center;
}

.mail-item { border-bottom: 1px solid var(--line); padding: 8px 0; }
.mail-item pre { white-space: pre-wrap; font: 13px/1.5 var(--font); background: var(--surface-2); padding: 10px; border-radius: 8px; margin: 6px 0 0; overflow-wrap: anywhere; }

.login { max-width: 380px; margin: 12vh auto; }
.center { text-align: center; }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }

.explain { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.explain strong { color: var(--ink); }
.coeff-preview { font-size: 15px; margin-top: 8px; padding: 10px 12px; border-radius: 8px; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.coeff-preview.less { border-color: var(--l2-line); background: var(--l2-bg); }
.coeff-preview.more { border-color: var(--l3-line); background: var(--l3-bg); }

@media print {
  @page { size: A4 landscape; margin: 6mm; }
  .topbar, .savebar, .btn, .no-print, #toasts { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body.printing #app > *:not(.print-target):not(:has(.print-target)),
  body.printing #app > :has(.print-target) > *:not(.print-target) { display: none !important; }
  .plan-half { --plan-h: 50px; grid-template-rows: 10px 13px 11px 1fr; row-gap: 0; break-inside: avoid; padding: 2px 4px; }
  .plan-half.mine { padding: 1px 3px; }
  .plan-when small, .plan-half .chore-label { display: none; }
  .plan-family { font-size: 11px; line-height: 13px; } .plan-child { font-size: 9px; line-height: 11px; }
  .plan-when { line-height: 10px; }
  .cal-block + .cal-block { margin-top: 3px !important; }
  .cal-week-title, .tip { display: none !important; }
  .calendar.planning .day { padding: 3px; gap: 2px; }
  .planning-card .muted, .planning-card .hint { display: none; }
  .plan-when { font-size: 8px; }
  .day-label { font-size: 10px; line-height: 1.1; }
  .chores { margin-top: 0; gap: 2px; }
  .chore { padding: 0 4px; font-size: 9px; }
  .chore-bin { font-size: 10px; }
  .planning-card h2 { font-size: 15px; margin: 0; }
  .planning-card .legend { margin: 2px 0 4px; font-size: 10px; }
  .plan-times { margin: 0; font-size: 10px; }
  .cal-head { margin-bottom: 2px !important; font-size: 9px !important; }
  .calendar.planning .cal-head, .calendar.planning .cal-week { grid-template-columns: repeat(5, 1fr) !important; }
  .calendar.planning .day { display: flex !important; }
  .chore-bin { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block !important; }
  .print-stamp { margin: 4px 0 0; font-size: 9px; color: #4b5757; }
}

/* Absences déclarées par la famille (vacances, congés) */
.absence-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.absence-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.absence-list li > span:first-child { flex: 1; min-width: 0; }

/* Suivi des semaines : ce qui est donné par rapport au minimum demandé */
.week-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); }
.week-chip.week-ok { color: var(--l1); background: var(--l1-bg); border-color: var(--l1-line); }
.week-chip.week-low { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.week-chip.week-absent { color: var(--ink-3); background: var(--closed-bg); }

/* Cumul très en retard : au-delà du seuil d'alerte, il devient difficile à rattraper */
.late { color: var(--danger); font-weight: 700; }
