:root {
  --bg: #fbf7f2;
  --card: #ffffff;
  --ink: #2a2433;
  --muted: #847b8f;
  --line: #ece5dc;
  --primary: #6c4fd6;
  --primary-soft: #efeafd;
  --bad: #c9372c;
  --radius: 18px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* 16 px : Safari ne zoome pas au toucher */
a { color: var(--primary); }
[hidden] { display: none !important; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 26px 4px 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.splash { min-height: 100vh; display: grid; place-items: center; font-size: 64px; }

/* ---------- En-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(var(--top) + 8px) 12px 8px; min-height: 56px;
  background: rgba(251,247,242,.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 19px; font-weight: 750; white-space: nowrap; }
.top .side.right { justify-self: end; }
.back { text-decoration: none; font-size: 17px; font-weight: 600; padding: 6px 2px; }
.icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--muted); }
.icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon:active { background: var(--primary-soft); }

main { padding: 12px 14px calc(40px + var(--bottom)); max-width: 560px; margin: 0 auto; }

.monthnav { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; text-align: center; margin: 4px 0 14px; font-size: 20px; }
.arrow {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%;
  font-size: 32px; line-height: 1; text-decoration: none; color: var(--primary); background: var(--card); border: 1px solid var(--line);
}
.arrow:active { background: var(--primary-soft); }

/* ---------- Cartes ---------- */
.card {
  display: block; width: 100%; text-align: left; color: inherit; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0 0 12px; box-shadow: 0 1px 2px rgba(60,40,20,.04);
}
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

/* ---------- Accueil : boutons enfants ---------- */
.kids { display: grid; gap: 12px; margin-bottom: 16px; }
.kid-btn {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 22px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-left: 8px solid var(--c); box-shadow: 0 2px 6px rgba(60,40,20,.05);
}
.kid-btn:active { transform: scale(.98); }
.avatar {
  width: 54px; height: 54px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #fff; font-size: 26px; font-weight: 800;
}
.avatar.sm { width: 40px; height: 40px; font-size: 19px; }
.kid-txt { flex: 1; display: grid; gap: 2px; min-width: 0; }
.kid-txt b { font-size: 21px; }
.kid-txt small { color: var(--muted); font-size: 14.5px; }
.chev { font-size: 28px; color: var(--muted); }
.total { text-align: center; background: var(--primary); color: #fff; border: 0; }
.total span, .total small { display: block; opacity: .88; font-size: 14px; }
.total b { display: block; font-size: 32px; margin: 2px 0; font-variant-numeric: tabular-nums; }

/* ---------- Calendrier ---------- */
.cal { padding: 12px 10px; }
.dow, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow span { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); padding-bottom: 6px; }
.cell {
  position: relative; aspect-ratio: 1; border-radius: 14px; border: 1.5px solid var(--line); background: #fff;
  display: grid; place-items: center; padding: 0; cursor: pointer; font-variant-numeric: tabular-nums;
}
.cell.empty { border: 0; background: none; cursor: default; }
.cell .n { font-size: 17px; font-weight: 650; }
.cell.usual { border: 2px dashed color-mix(in srgb, var(--c) 55%, white); }
.cell.today .n { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cell.on { background: var(--c); border: 2px solid var(--c); color: #fff; }
.cell .tick { position: absolute; top: 2px; right: 5px; font-size: 13px; font-weight: 800; }
.cell .hl { position: absolute; bottom: 2px; font-size: 9.5px; font-weight: 700; color: var(--bad); }
.cell.on .hl { color: #fff; }
.cell:active { transform: scale(.94); }
.cal p { margin: 12px 4px 2px; }

/* ---------- Récap ---------- */
.sum .big { text-align: center; font-size: 17px; margin-bottom: 8px; }
.sum .big b { display: block; font-size: 44px; line-height: 1.1; color: var(--c); }
.row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; color: inherit; font-size: 15.5px; }
.row:last-child { border-bottom: 0; }
.row span { flex: 1; }
.row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.strong { font-size: 17px; border-top: 2px solid var(--ink); }
.row.copy { cursor: pointer; }
.row.copy i { font-style: normal; color: var(--primary); }
.row.copy:active { background: var(--primary-soft); }
details { margin-top: 12px; }
summary { cursor: pointer; font-weight: 650; color: var(--primary); padding: 4px 0; }
.paje { background: var(--primary-soft); border-radius: 14px; padding: 8px 12px; }
.paje .row { border-bottom-color: #ddd3f7; }

/* ---------- Réglages ---------- */
.kid-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.kid-row .kid-txt b { font-size: 18px; }
.kid-row.archived { opacity: .55; }
.tag { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: #eee; color: var(--muted); vertical-align: middle; }
.btn {
  display: block; width: 100%; text-align: center; padding: 13px; margin: 8px 0 0; border-radius: 14px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 650; color: var(--ink); text-decoration: none; cursor: pointer;
}
label.btn { color: var(--ink); font-size: 16px; display: block; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.big { padding: 15px; font-size: 17px; }
label { display: grid; gap: 4px; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
input:not([type=checkbox]):not([type=radio]) {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); min-height: 46px;
}
input:focus { outline: none; border-color: var(--primary); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; position: sticky; bottom: 0; background: #fff; padding: 8px 0 calc(var(--bottom) + 8px); }
.actions .btn { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15.5px; font-weight: 600; margin: 12px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.daypick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.daypick label { margin: 0; }
.daypick input { position: absolute; opacity: 0; pointer-events: none; }
.daypick span { display: block; text-align: center; padding: 10px 0; border-radius: 10px; border: 1.5px solid var(--line); color: var(--ink); font-size: 13px; cursor: pointer; }
.daypick input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.colors { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.colors label { margin: 0; }
.colors input { position: absolute; opacity: 0; pointer-events: none; }
.colors i { display: block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; }
.colors input:checked + i { box-shadow: 0 0 0 3px var(--ink); }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; align-content: center; text-align: center; padding-top: var(--top); }
.login .hello { font-size: 64px; }
.login h1 { margin: 6px 0 2px; }
.login form { text-align: left; margin-top: 22px; }

/* ---------- Feuille du bas et messages ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; background: rgba(30,20,40,.4); display: flex; align-items: flex-end; }
.sheet .panel {
  width: 100%; max-width: 560px; margin: 0 auto; max-height: calc(100vh - var(--top) - 24px); overflow-y: auto;
  background: #fff; border-radius: 22px 22px 0 0; padding: 18px 16px 0; animation: up .2s ease-out;
}
.sheet h2 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 20px; margin: 0 0 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast {
  position: fixed; left: 50%; top: calc(var(--top) + 10px); z-index: 200; transform: translate(-50%, -150%);
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 600; font-size: 15px;
  transition: transform .25s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }
