/* Tension Famille
   Mise en page : une colonne pour téléphone, barre d'onglets en bas, la couleur du profil actif colore l'action principale.
   L'écran de saisie reprend l'affichage d'un tensiomètre (SYS, DIA, pouls) pour recopier sans se tromper. */

@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Mono"; src: url("fonts/atkinson-hyperlegible-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Atkinson Mono"; src: url("fonts/atkinson-hyperlegible-mono-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  /* Couleurs de base */
  --paper: #F4F6FA;
  --surface: #FFFFFF;
  --ink: #18202F;
  --muted: #566074;
  --line: #DCE1EA;
  --screen: #E9EEF3;      /* fond de l'afficheur du tensiomètre */
  /* États de tension */
  --ok: #23824C;
  --warn: #B26A00;
  --bad: #C42F37;
  --crit: #8C1820;
  /* Couleur du profil actif (remplacée par le script) */
  --p: #2F6FDB;
  --p-soft: color-mix(in oklab, var(--p) 13%, var(--surface));
  --p-text: color-mix(in oklab, var(--p) 82%, #000);
  --on-p: #FFFFFF;
  --focus: color-mix(in oklab, var(--p) 70%, #000);
  --shadow: 0 1px 2px rgb(24 32 47 / 8%), 0 8px 24px rgb(24 32 47 / 8%);
  --scrim: rgb(14 19 30 / 46%);

  /* Typographie */
  --font-ui: "Atkinson Next", "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: "Atkinson Mono", "Atkinson Hyperlegible Mono", ui-monospace, "Roboto Mono", "Cascadia Mono", monospace;
  --t-xs: 0.875rem;  /* 14 */
  --t-sm: 1rem;      /* 16 */
  --t-md: 1.125rem;  /* 18 */
  --t-lg: 1.375rem;  /* 22 */
  --t-xl: 1.75rem;   /* 28 */
  --t-2xl: 2.5rem;   /* 40 */
  --t-num: 3.25rem;  /* 52 */

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --tab-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10141C; --surface: #1A202B; --ink: #E9EDF4; --muted: #A2ABBC; --line: #2B3343; --screen: #222B37;
    --ok: #4CC183; --warn: #F0A93B; --bad: #F2686E; --crit: #FF8C92;
    --p-soft: color-mix(in oklab, var(--p) 24%, var(--surface));
    --p-text: color-mix(in oklab, var(--p) 55%, #fff);
    --focus: color-mix(in oklab, var(--p) 55%, #fff);
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
    --scrim: rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10141C; --surface: #1A202B; --ink: #E9EDF4; --muted: #A2ABBC; --line: #2B3343; --screen: #222B37;
  --ok: #4CC183; --warn: #F0A93B; --bad: #F2686E; --crit: #FF8C92;
  --p-soft: color-mix(in oklab, var(--p) 24%, var(--surface));
  --p-text: color-mix(in oklab, var(--p) 55%, #fff);
  --focus: color-mix(in oklab, var(--p) 55%, #fff);
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
  --scrim: rgb(0 0 0 / 60%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-md);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); }
[hidden] { display: none !important; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.2; }
p { margin: 0; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: var(--t-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Structure ---------- */
.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in oklab, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  padding-block: 10px 8px;
}
.topbar-row { display: flex; align-items: center; gap: 12px; }
.who { display: flex; gap: 6px; flex: 1; min-width: 0; }
.who-btn {
  display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; padding: 4px 10px 4px 4px; border-radius: 999px;
  min-height: 48px; color: var(--muted); font-size: var(--t-sm);
}
.who-btn .avatar { width: 36px; height: 36px; transition: transform .2s ease; }
.who-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--pc); }
.who-btn[aria-pressed="true"] .avatar { transform: scale(1.12); }
.who-btn .who-name { white-space: nowrap; }
@media (max-width: 420px) {
  .who-btn { padding-right: 4px; }
  .who-btn:not([aria-pressed="true"]) .who-name { display: none; }
}

.avatar { display: inline-block; flex: none; border-radius: 50%; overflow: hidden; background: var(--p-soft); position: relative; }
.avatar svg, .avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }

main.view { padding-block: 8px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom, 0px)); }
.view-title { font-size: var(--t-xl); font-weight: 700; margin-block: 6px 14px; }
.section-gap { display: grid; gap: 18px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tabbar ul { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; }
.tabbar a {
  display: grid; justify-items: center; gap: 2px; padding: 9px 4px 8px; min-height: var(--tab-h);
  color: var(--muted); text-decoration: none; font-size: var(--t-xs);
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--p-text); font-weight: 700; }
.tabbar a[aria-current="page"] svg { stroke-width: 2.4; }
body.focus-mode .tabbar { display: none; }
body.focus-mode main.view { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: var(--t-md); text-decoration: none;
}
.btn svg { width: 22px; height: 22px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--p); border-color: transparent; color: var(--on-p); }
.btn-soft { background: var(--p-soft); border-color: transparent; color: var(--p-text); }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
.btn-hero { min-height: 68px; font-size: var(--t-lg); border-radius: 20px; box-shadow: 0 6px 18px color-mix(in oklab, var(--p) 35%, transparent); }
.btn-hero svg { width: 28px; height: 28px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }
.link-btn { background: none; border: 0; padding: 8px 4px; color: var(--p-text); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 12px; color: var(--muted); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- Pastilles de niveau ---------- */
.lvl { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: var(--t-xs); font-weight: 700; white-space: nowrap; }
.lvl::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.lvl-ok { color: var(--ok); background: color-mix(in oklab, var(--ok) 13%, var(--surface)); }
.lvl-warn { color: var(--warn); background: color-mix(in oklab, var(--warn) 15%, var(--surface)); }
.lvl-bad { color: var(--bad); background: color-mix(in oklab, var(--bad) 13%, var(--surface)); }
.lvl-crit { color: #fff; background: var(--crit); }
.lvl-crit::before { background: #fff; }

/* ---------- Accueil ---------- */
.slides {
  position: relative; aspect-ratio: 16 / 10; max-height: 236px; width: 100%; max-width: 100%;
  border-radius: var(--r-lg); overflow: hidden; background: var(--p-soft);
}
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity .9s ease; display: grid; place-items: center; }
.slide.on { opacity: 1; }
.slide img { width: 100%; height: 100%; object-fit: cover; }
.slide-avatar { background: color-mix(in oklab, var(--sc) 16%, var(--surface)); }
.slide-avatar .avatar { width: min(52%, 168px); aspect-ratio: 1; height: auto; box-shadow: 0 0 0 8px color-mix(in oklab, var(--sc) 30%, var(--surface)); }
.slide-caption { position: absolute; left: 16px; bottom: 12px; right: 16px; font-weight: 700; color: color-mix(in oklab, var(--sc) 75%, var(--ink)); font-size: var(--t-sm); }
.slide-family { background: linear-gradient(120deg, color-mix(in oklab, var(--c1) 18%, var(--surface)), color-mix(in oklab, var(--c3) 18%, var(--surface))); }
.family-row { display: flex; align-items: flex-end; justify-content: center; }
.family-row .avatar { width: min(28%, 104px); aspect-ratio: 1; height: auto; box-shadow: 0 0 0 6px var(--surface); }
.family-row .avatar:nth-child(2) { width: min(33%, 122px); margin: 0 -14px; z-index: 1; }
.slides-dots { position: absolute; right: 14px; top: 12px; display: flex; gap: 6px; }
.slides-dots span { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in oklab, var(--ink) 25%, transparent); }
.slides-dots span.on { background: var(--ink); }

.greet { font-size: var(--t-xl); font-weight: 700; margin-top: 6px; }
.cta { display: grid; gap: 8px; }
.due { display: flex; align-items: center; gap: 8px; color: var(--p-text); font-weight: 700; }
.due svg { width: 22px; height: 22px; flex: none; }
.greet-sub { color: var(--muted); margin-top: 2px; }

.week { padding-block: 4px; }
.week h2 { font-size: var(--t-md); color: var(--muted); font-weight: 400; }
.week-bp { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 2px; }
.week-bp .num { font-size: var(--t-2xl); font-weight: 700; line-height: 1.05; }
.week-bp .unit { font-size: var(--t-sm); color: var(--muted); font-family: var(--font-ui); font-weight: 400; margin-left: 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 8px; color: var(--muted); }
.facts b { color: var(--ink); font-family: var(--font-num); }
.last-line { border-top: 1px solid var(--line); padding-top: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 14px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.banner svg { width: 24px; height: 24px; flex: none; margin-top: 2px; color: var(--p-text); }
.banner-body { flex: 1; min-width: 0; }
.banner-body strong { display: block; }
.banner-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.banner-actions .btn { min-height: 44px; padding: 0 14px; font-size: var(--t-sm); }
.banner.warn svg { color: var(--warn); }
.banner-close { margin: -8px -6px 0 0; }

/* ---------- Saisie : l'afficheur ---------- */
/* L'écran de saisie tient dans la hauteur du téléphone : les valeurs en haut, le clavier dessous.
   Les tailles suivent la hauteur de l'écran (dvh), pour ne pas avoir à faire défiler. */
body.focus-mode .topbar { padding-block: 6px 4px; }
body.focus-mode .shell { display: flex; flex-direction: column; }
body.focus-mode main.view { flex: 1; display: flex; flex-direction: column; padding-top: 4px; }
.entry {
  flex: 1; display: flex; flex-direction: column;
  --ro-h: clamp(46px, calc(14dvh - 42px), 72px);
  --key-h: clamp(42px, calc(11dvh - 30px), 62px);
  --save-h: clamp(48px, calc(8dvh - 3px), 64px);
}
.entry-head { display: flex; align-items: center; gap: 10px; margin-block: 0 6px; }
.entry-head .avatar { width: 40px; height: 40px; }
.entry-head h1 { font-size: var(--t-lg); }
.entry-head .icon-btn { margin-left: auto; }

.monitor {
  background: var(--screen); border-radius: var(--r-lg); padding: 8px;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / 30%), inset 0 0 0 1px color-mix(in oklab, var(--ink) 8%, transparent);
  display: grid; gap: 6px;
}
.readout {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  width: 100%; text-align: left; border: 2px solid transparent; background: transparent;
  border-radius: 16px; padding: 2px 14px; min-height: var(--ro-h);
}
.readout[aria-pressed="true"] { background: var(--surface); border-color: var(--p); box-shadow: var(--shadow); }
.readout-name { display: grid; line-height: 1.15; }
.readout-name b { font-size: var(--t-md); }
.readout-name span { font-size: var(--t-xs); color: var(--muted); }
.readout-value { font-family: var(--font-num); font-weight: 700; font-size: min(var(--t-num), calc(var(--ro-h) - 10px)); line-height: 1; min-width: 3ch; text-align: right; color: var(--ink); white-space: nowrap; }
.readout-value.is-empty { color: color-mix(in oklab, var(--muted) 45%, transparent); }
.readout[aria-pressed="true"] .readout-value::after { content: ""; display: inline-block; width: 3px; height: .8em; margin-left: 3px; background: var(--p); vertical-align: -0.05em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.readout-live { min-height: 1.4em; padding: 0 6px 2px; display: flex; justify-content: flex-end; }

.entry-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.entry-meta .chip { min-height: 44px; font-weight: 700; color: var(--p-text); }
.entry-meta .chip[aria-expanded="true"] { background: var(--p-soft); border-color: transparent; }
.entry-note { margin-top: 8px; }
.entry-pad { margin-top: auto; padding-top: 12px; display: grid; gap: 10px; }
.entry-pad .btn-hero { min-height: var(--save-h); }
.entry-del { margin-top: 10px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: var(--t-sm); color: var(--muted); }
.input {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: var(--t-md);
}
.input:focus { outline: 3px solid color-mix(in oklab, var(--p) 45%, transparent); outline-offset: 0; border-color: var(--p); }
textarea.input { min-height: 80px; resize: vertical; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  min-height: var(--key-h); border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  font-family: var(--font-num); font-size: 1.75rem; font-weight: 700; color: var(--ink);
  display: grid; place-items: center; user-select: none; touch-action: manipulation;
}
.key:active { background: var(--p-soft); }
.key-fn { font-family: var(--font-ui); font-size: var(--t-md); color: var(--muted); }
.key-fn svg { width: 26px; height: 26px; }
.key-next { background: var(--p-soft); color: var(--p-text); border-color: transparent; }

/* ---------- Historique ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-block: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: var(--t-sm); white-space: nowrap;
}
.chip svg { width: 18px; height: 18px; }
.chip-main { background: var(--p-soft); color: var(--p-text); border-color: transparent; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--p); color: var(--on-p); border-color: transparent; font-weight: 700; }
.chip-x { color: var(--muted); font-size: 1.1em; line-height: 1; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-block: 8px 14px; }
.summary div { display: grid; }
.summary span { font-size: var(--t-xs); color: var(--muted); }
.summary b { font-family: var(--font-num); font-size: var(--t-lg); }

.day { margin-top: 6px; }
.day-title {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 66px); z-index: 5;
  background: var(--paper); padding-block: 8px 6px; font-size: var(--t-sm); color: var(--muted); font-weight: 700;
}
.rows { background: var(--surface); border-radius: var(--r-md); border: 1px solid var(--line); overflow: hidden; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center;
  width: 100%; padding: 12px 14px; background: transparent; border: 0; text-align: left;
  border-bottom: 1px solid var(--line); position: relative;
}
.rows .row:last-child { border-bottom: 0; }
.row-time { font-family: var(--font-num); color: var(--muted); font-size: var(--t-sm); }
.row-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.row-bp { font-family: var(--font-num); font-weight: 700; font-size: 1.6rem; line-height: 1.1; }
.row-pulse { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-num); color: var(--muted); }
.row-pulse svg { width: 16px; height: 16px; color: var(--bad); }
.row-note { grid-column: 2 / -1; font-size: var(--t-sm); color: var(--muted); overflow-wrap: anywhere; }
.row-who { position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--rc); }
.row .avatar { width: 30px; height: 30px; }
.more { margin-top: 14px; }

.empty {
  text-align: center; padding: 40px 16px; display: grid; gap: 12px; justify-items: center; color: var(--muted);
}
.empty svg { width: 56px; height: 56px; color: color-mix(in oklab, var(--p) 55%, var(--muted)); }
.empty strong { color: var(--ink); font-size: var(--t-lg); }

/* ---------- Graphique ---------- */
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; border-radius: 9px; min-height: 40px; padding: 0 12px; font-size: var(--t-sm); color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--p-soft); color: var(--p-text); font-weight: 700; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 10px 10px; }
.chart-card h2 { font-size: var(--t-sm); color: var(--muted); font-weight: 700; padding-inline: 6px; margin-bottom: 6px; }
.chart-box { position: relative; height: 270px; }
.chart-box.small { height: 150px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 6px 0; font-size: var(--t-sm); color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px) !important; height: 2px; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.tools .seg { width: 100%; grid-auto-columns: 1fr; }
.tools .seg button { padding: 0 6px; }

/* ---------- Réglages ---------- */
.group { display: grid; gap: 8px; }
.group h2 { font-size: var(--t-sm); color: var(--muted); font-weight: 700; padding-inline: 4px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 10px 14px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink); text-decoration: none;
}
.list > .item:last-child { border-bottom: 0; }
.item .avatar { width: 42px; height: 42px; }
.item-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--p-soft); color: var(--p-text); flex: none; }
.item-ic svg { width: 24px; height: 24px; }
.item-body { flex: 1; min-width: 0; display: grid; }
.item-body span { color: var(--muted); font-size: var(--t-sm); }
.item-chev { color: var(--muted); width: 20px; height: 20px; flex: none; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; vertical-align: middle; }

.switch { position: relative; width: 56px; height: 34px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .2s; }
.switch input:checked + span { background: var(--p); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); background: var(--c); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.avatar-pick { border: 0; padding: 0; background: transparent; border-radius: 50%; aspect-ratio: 1; }
.avatar-pick .avatar { width: 100%; height: 100%; }
.avatar-pick[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--p); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button { position: absolute; border: 0; }
.photo .photo-del { right: 4px; top: 4px; width: 36px; height: 36px; border-radius: 50%; background: rgb(0 0 0 / 55%); color: #fff; display: grid; place-items: center; }
.photo .photo-del svg { width: 18px; height: 18px; }
.photo .photo-show { left: 4px; bottom: 4px; padding: 6px 10px; border-radius: 999px; background: rgb(0 0 0 / 60%); color: #fff; font-size: 13px; white-space: nowrap; min-height: 32px; }
.sheet:focus { outline: none; }
.photo.off img { opacity: .4; }
.photo-add { border: 2px dashed var(--line); background: transparent; color: var(--muted); display: grid; place-content: center; justify-items: center; gap: 4px; font-size: var(--t-xs); text-align: center; padding: 8px; cursor: pointer; }
.photo-add svg { width: 28px; height: 28px; }

.rem { display: grid; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rem:last-child { border-bottom: 0; }
.rem-top { display: flex; align-items: center; gap: 12px; }
.rem-top input[type="time"] { max-width: 200px; font-family: var(--font-num); font-size: var(--t-lg); font-weight: 700; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: var(--t-sm); }
.days button[aria-pressed="true"] { background: var(--p); color: var(--on-p); border-color: transparent; font-weight: 700; }

.prose { display: grid; gap: 12px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; }
.prose a { color: var(--p-text); }
.table-wrap { overflow-x: auto; }
.ref-table { border-collapse: collapse; width: 100%; font-size: var(--t-sm); }
.ref-table th, .ref-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---------- Feuilles (bottom sheets) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: var(--scrim); opacity: 0; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; margin: 0 auto; max-width: 600px;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px);
  background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / 20%);
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.sheet.open { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); }
.sheet-head h2 { font-size: var(--t-lg); flex: 1; }
.sheet-body { overflow-y: auto; padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; overscroll-behavior: contain; }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sheet-section { display: grid; gap: 10px; }
.sheet-section > h3 { font-size: var(--t-sm); color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wrap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: grid; gap: 4px; text-align: left; padding: 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.choice b { font-size: var(--t-md); }
.choice span { color: var(--muted); font-size: var(--t-sm); }
.choice[aria-pressed="true"] { border: 2px solid var(--p); background: var(--p-soft); }
.check { display: flex; gap: 12px; align-items: center; min-height: 48px; }
.check input { width: 24px; height: 24px; accent-color: var(--p); }
.alert-box { border-radius: var(--r-md); padding: 16px; background: color-mix(in oklab, var(--bad) 12%, var(--surface)); border: 1px solid color-mix(in oklab, var(--bad) 35%, var(--surface)); display: grid; gap: 8px; }
.alert-box strong { color: var(--bad); font-size: var(--t-lg); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; transition: opacity .2s, transform .2s;
  width: min(calc(100% - 32px), 520px); background: var(--ink); color: var(--paper);
  border-radius: 14px; padding: 12px 12px 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.toast { pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast p { flex: 1; }
.toast button { background: transparent; border: 0; color: color-mix(in oklab, var(--p) 45%, #fff); font-weight: 700; min-height: 44px; padding: 0 10px; }
body.focus-mode .toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Animations de fête ---------- */
.fx { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none; }
.fx.active { pointer-events: auto; background: color-mix(in oklab, var(--paper) 35%, transparent); }
.fx canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx-card {
  position: relative; background: var(--surface); color: var(--ink); border-radius: 22px; padding: 18px 24px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 18%); text-align: center; display: grid; gap: 4px; justify-items: center;
  max-width: calc(100% - 48px); transform: scale(.9); opacity: 0; transition: transform .3s cubic-bezier(.2,1.4,.4,1), opacity .2s;
}
.fx-card.show { transform: scale(1); opacity: 1; }
.fx-card .avatar { width: 64px; height: 64px; margin-bottom: 6px; }
.fx-card strong { font-size: var(--t-xl); }
.fx-card span { color: var(--muted); }
.fx-heart { width: 120px; height: 120px; color: var(--bad); animation: beat var(--beat, .85s) ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(.98); } 45% { transform: scale(1.1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
  .slide { transition: none; }
}

/* Écrans plus larges */
@media (min-width: 700px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 560px; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
