/* h0me — la pièce est l'interface.
   Palette « Pêche & Eucalyptus » : lin, encre brun doux, corail, eucalyptus, abricot, bois.
   Vocabulaire : angles droits, bordures 2 px, ombres portées dures, meubles en CSS et en canvas. */

@font-face {
  font-family: "Pixelify Sans";
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/pixelify-sans.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/plex-mono-500.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/plex-mono-600.woff2") format("woff2");
}

:root {
  --bg: #fbf2e4;
  --dot: rgb(120 80 40 / 7%);
  --surface: #fffcf6;
  --sunken: #f3e6d2;
  --fg: #4a3a30;
  --muted: #876b58;
  --line: #e8dcc8;
  --edge: #c9b39a;
  --ink: #4a3a30;
  --on-ink: #fffcf6;
  --shadow-c: #e3cfb3;
  --late: #cf4f2f;
  --late-soft: #fbe0d6;
  --on-late: #fff;
  --honey: #f5b25a;
  --honey-soft: #fde8c4;
  --on-honey: #4a3a30;
  --p1: #e8775c;
  --p1-soft: #fde0d6;
  --p2: #3f9f88;
  --p2-soft: #d4efe6;
  --on-p: #fffcf6;
  --scrim: rgb(74 58 48 / 40%);
  /* Bois, liège, sol : les matières de la pièce */
  --wood: #c98f5a;
  --wood-dark: #a9733f;
  --wood-light: #dcae7c;
  --cork: #eedcbd;
  --cork-dot: rgb(120 80 40 / 12%);
  --sc-wall: #fbf2e4;
  --sc-floor: #ecd3b0;
  --sc-floor-dark: #dcbf98;
  --sc-fur: #7a6354;
  --sc-rug: var(--p2-soft);
  --sc-rug-stripe: var(--p1-soft);
  /* Le ciel de la fenêtre : la journée par défaut, les autres moments plus bas */
  --sky-top: #bfe3ef;
  --sky-mid: #d4edf5;
  --sky-bottom: #e3f4f9;
  --sky-ink: #4a3a30;
  --sky-star: transparent;
  --cloud: #ffffff;
  --display: "Pixelify Sans", "Courier New", monospace;
  --mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bw: 2px;
  --drop: 4px 4px 0 var(--shadow-c);
  --drop-sm: 3px 3px 0 var(--shadow-c);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --snap: steps(3, end);
  color-scheme: light;
}
:root[data-sky="dawn"] { --sky-top: #f3c2a4; --sky-mid: #f8d6b8; --sky-bottom: #fde8c4; }
:root[data-sky="dusk"] { --sky-top: #d9825f; --sky-mid: #eaa060; --sky-bottom: #f5c478; }
:root[data-sky="night"] { --sky-top: #2f3d5c; --sky-mid: #3b4c70; --sky-bottom: #4b5d82; --sky-ink: #f3e9dd; --sky-star: #fffcf6; --cloud: #6f7f9e; }

/* La nuit (20 h à 6 h, heure de Paris) : la pièce passe en mode sombre, décidé par l'horloge et non par le système */
:root[data-theme="dark"] {
  --bg: #26201c;
  --dot: rgb(255 220 180 / 5%);
  --surface: #312a25;
  --sunken: #3c332d;
  --fg: #f3e9dd;
  --muted: #ab9686;
  --line: #4a403a;
  --edge: #5c4f46;
  --ink: #f3e9dd;
  --on-ink: #26201c;
  --shadow-c: #1a1512;
  --late: #f07a5c;
  --late-soft: #4a2820;
  --on-late: #26201c;
  --honey: #f6bd6b;
  --honey-soft: #4a371d;
  --on-honey: #26201c;
  --p1: #f08c74;
  --p1-soft: #4d2e27;
  --p2: #5fbba5;
  --p2-soft: #1f3f37;
  --on-p: #26201c;
  --scrim: rgb(0 0 0 / 60%);
  --wood: #8a6240;
  --wood-dark: #6a4a30;
  --wood-light: #a67a52;
  --cork: #3a2e25;
  --cork-dot: rgb(255 220 180 / 7%);
  --sc-wall: #26201c;
  --sc-floor: #3d3027;
  --sc-floor-dark: #33281f;
  --sc-fur: #c9b3a2;
  --sc-rug: #2f5e4f;
  --sc-rug-stripe: #7c4b3e;
  --sky-top: #5f98b3;
  --sky-mid: #7fb3c9;
  --sky-bottom: #a3cddd;
  --sky-ink: #26201c;
  --cloud: #e6f0f4;
  color-scheme: dark;
}
:root[data-theme="dark"][data-sky="dawn"] { --sky-top: #c98d72; --sky-mid: #dba98a; --sky-bottom: #e7c3a3; }
:root[data-theme="dark"][data-sky="dusk"] { --sky-top: #b5644a; --sky-mid: #c8824e; --sky-bottom: #d9a85e; }
:root[data-theme="dark"][data-sky="night"] { --sky-top: #1b2438; --sky-mid: #243049; --sky-bottom: #2c3a56; --sky-ink: #f3e9dd; --sky-star: #f3e9dd; --cloud: #4a5a78; }

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }
body {
  margin: 0;
  color: var(--fg);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  /* Le papier peint : une trame de points sur tout le mur */
  background:
    radial-gradient(var(--dot) 1px, transparent 1.5px) 0 0 / 8px 8px,
    var(--bg);
}

[hidden] { display: none !important; }

.screen {
  --top-inset: env(safe-area-inset-top, 0px);
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, var(--top-inset)) 20px 24px;
  min-height: 100dvh;
}
#offline:not([hidden]) ~ .screen { --top-inset: 0px; }
::selection { background: var(--honey-soft); color: var(--fg); }
input::selection { background: var(--honey); color: var(--on-honey); }

h1, h2, .today, .brand, .avatar, .empty h3 {
  font-family: var(--display);
  letter-spacing: 0;
  font-variant-ligatures: none;
}
.count, .here, .when, .card-meta .late, .toast #toast-action, .jar-time { font-family: var(--mono); }
h1 { font-size: 34px; line-height: 1.05; font-weight: 700; margin: 0 0 10px; }
h2 { font-size: 24px; font-weight: 700; margin: 0; }
.lead { color: var(--muted); margin: 0 0 28px; }
.lead strong { color: var(--fg); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--late); font-size: 14px; margin: 0; font-family: var(--mono); font-weight: 500; padding-left: 12px; border-left: 4px solid var(--late); }
.sheet .error { margin-top: -8px; }

/* ---------- le mur : logo-enseigne, portrait, fenêtre ---------- */

/* Logo : le 0 est une case de tâche vide, partagée entre les deux couleurs du foyer */
.brand { font-weight: 700; font-size: 26px; margin-bottom: 36px; display: flex; align-items: center; gap: 1px; }
.brand span {
  display: inline-block; width: .52em; height: .68em; margin: 0 .06em;
  border: .12em solid;
  border-color: var(--p1) var(--p2) var(--p2) var(--p1);
  color: transparent; overflow: hidden; line-height: 0;
  background: var(--surface);
}
/* Sur l'écran principal, le logo est une enseigne clouée au mur */
.brand.small {
  font-size: 18px; margin: 0; padding: 5px 10px 3px;
  background: var(--surface); border: var(--bw) solid var(--wood); box-shadow: 0 0 0 2px var(--wood-dark), 3px 3px 0 2px var(--shadow-c);
  position: relative;
}
.brand.small::before, .brand.small::after { content: ""; position: absolute; top: 4px; width: 4px; height: 4px; background: var(--wood-dark); }
.brand.small::before { left: 4px; }
.brand.small::after { right: 4px; }
/* L'escalier de pixels à côté du logo : signature des écrans d'accueil */
.onboard .brand::after {
  content: ""; margin-left: auto; width: 56px; height: 16px;
  background: linear-gradient(90deg, var(--p1) 0 25%, var(--honey) 0 50%, var(--p2) 0 75%, var(--ink) 0 100%);
  clip-path: polygon(0 100%, 0 75%, 25% 75%, 25% 50%, 50% 50%, 50% 25%, 75% 25%, 75% 0, 100% 0, 100% 100%);
}

/* Portrait : l'initiale dans un cadre de bois, accroché à un clou */
.avatar {
  width: 44px; height: 44px; position: relative;
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px; line-height: 1;
  background: var(--pc-soft); color: var(--pc);
  border: 3px solid var(--wood);
  box-shadow: 0 0 0 2px var(--wood-dark), 3px 3px 0 2px var(--shadow-c);
}
.p1 { --pc: var(--p1); --pc-soft: var(--p1-soft); }
.p2 { --pc: var(--p2); --pc-soft: var(--p2-soft); }
.me { padding: 12px 4px 4px; position: relative; transition: transform .08s var(--snap); }
.me::before { content: ""; position: absolute; top: 2px; left: 50%; width: 4px; height: 4px; margin-left: -2px; background: var(--wood-dark); }
.me::after { content: ""; position: absolute; top: 6px; left: 50%; width: 2px; height: 8px; margin-left: -1px; background: var(--wood-dark); }
.me:active { transform: translate(2px, 2px); }
.me:active .avatar { box-shadow: 0 0 0 2px var(--wood-dark); }

.top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }

/* La fenêtre : le ciel suit l'heure, la date est gravée sur une plaque sous l'appui */
.window { position: relative; margin: 0 14px 24px; padding-top: 10px; }
.rod { position: absolute; top: 0; left: -14px; right: -14px; height: 4px; background: var(--wood-dark); }
.rod::before, .rod::after { content: ""; position: absolute; top: -3px; width: 8px; height: 10px; background: var(--wood-dark); }
.rod::before { left: -4px; }
.rod::after { right: -4px; }
.curtain {
  position: absolute; top: 6px; bottom: 14px; width: 18px; z-index: 2;
  background: repeating-linear-gradient(90deg, var(--pc-soft) 0 4px, var(--pc) 4px 6px);
  border-bottom: 3px solid var(--pc);
}
.curtain.p1 { left: -10px; }
.curtain.p2 { right: -10px; }
.pane {
  position: relative; height: 78px; overflow: hidden;
  border: 6px solid var(--wood); outline: 2px solid var(--wood-dark);
  background: linear-gradient(180deg, var(--sky-top) 0 38%, var(--sky-mid) 38% 70%, var(--sky-bottom) 70%);
  transition: background .4s;
}
/* Étoiles la nuit, invisibles le jour */
.pane::before { content: ""; position: absolute; inset: 0; background: radial-gradient(var(--sky-star) 1px, transparent 1.5px) 7px 9px / 26px 22px; }
/* Croisillons */
.pane::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(var(--wood) 0 0) 50% 0 / 6px 100% no-repeat, linear-gradient(var(--wood) 0 0) 0 46% / 100% 6px no-repeat;
}
.sun { position: absolute; top: 12px; right: 22px; width: 14px; height: 14px; background: var(--honey); box-shadow: 0 0 0 3px rgb(255 255 255 / 25%); }
/* La lune : un croissant, le ciel mordant un carré clair */
:root[data-sky="night"] .sun { background: #f3e9dd; box-shadow: -5px -4px 0 0 var(--sky-top); }
.cloud { position: absolute; top: 22px; left: 20px; width: 26px; height: 8px; background: var(--cloud); animation: drift 40s linear infinite; }
.cloud::before { content: ""; position: absolute; top: -6px; left: 8px; width: 12px; height: 6px; background: var(--cloud); }
.cloud.far { top: 44px; left: 60%; width: 18px; height: 6px; animation-duration: 55s; animation-delay: -20s; }
.cloud.far::before { top: -4px; left: 4px; width: 8px; height: 4px; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(120px); } }
.sill { height: 8px; margin: 2px -14px 0; background: var(--wood); border-top: 2px solid var(--wood-light); box-shadow: 0 3px 0 var(--wood-dark), 4px 6px 0 var(--shadow-c); }
.plate {
  position: relative; z-index: 3; margin: -2px auto 0; width: max-content; max-width: calc(100% - 8px);
  padding: 4px 14px 2px; background: var(--surface); border: var(--bw) solid var(--edge); box-shadow: var(--drop-sm);
}
.plate::before, .plate::after { content: ""; position: absolute; top: -6px; width: 2px; height: 6px; background: var(--wood-dark); }
.plate::before { left: 12px; }
.plate::after { right: 12px; }
.today { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.1; text-align: center; }
.today::first-letter { text-transform: uppercase; }

/* ---------- contrôles ---------- */

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, input:focus-visible, summary:focus-visible, .card:focus-visible {
  outline: var(--bw) dashed var(--fg); outline-offset: 3px;
}
.card .check:focus-visible, .card .card-body:focus-visible { outline-offset: -5px; }

/* Bouton pixel : il s'enfonce, l'ombre se replie */
.primary, .secondary {
  min-height: 48px; padding: 0 20px;
  border: var(--bw) solid var(--edge);
  box-shadow: var(--drop-sm);
  font-family: var(--mono); font-weight: 600; font-size: 15px;
  transition: transform .08s var(--snap), box-shadow .08s var(--snap), opacity .12s;
}
.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.secondary { background: var(--surface); color: var(--fg); }
.primary:active, .secondary:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--shadow-c); }
.primary:disabled { opacity: .35; cursor: default; transform: none; box-shadow: var(--drop-sm); }
.big { width: 100%; min-height: 56px; font-size: 16px; }
.link { padding: 12px; font-weight: 500; font-family: var(--mono); font-size: 14px; }
.danger { color: var(--late); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.field input, .title-input {
  width: 100%; min-height: 52px; padding: 0 14px;
  background: var(--surface); border: var(--bw) solid var(--edge);
  font-size: 17px; transition: box-shadow .1s var(--snap);
}
.field input:focus, .title-input:focus { outline: none; box-shadow: inset 3px 3px 0 var(--sunken); }
.field input[aria-invalid="true"], .title-input[aria-invalid="true"], .inline-field input[aria-invalid="true"],
.seg-input:has(input[aria-invalid="true"]) { border-color: var(--late); box-shadow: inset 3px 3px 0 var(--late-soft); }
.title-input::placeholder, .field input::placeholder { color: var(--muted); opacity: .8; }

form { display: flex; flex-direction: column; gap: 18px; margin: 0; }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--fg); }
svg { shape-rendering: crispEdges; }
.icon-btn svg, .fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: square; stroke-linejoin: miter; }
.back { margin: -6px 0 0 -10px; position: absolute; }
.onboard {
  position: relative; display: flex; flex-direction: column;
  padding-top: max(28px, var(--top-inset)); padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.onboard > * { flex-shrink: 0; }
.onboard .back:not([hidden]) + .brand { margin-top: 44px; }

/* ---------- accueil : la porte, les portraits ---------- */

/* La porte d'entrée : on y entre avec le jeton, qui est la clé */
.door { width: 88px; height: 124px; margin: 0 0 22px; position: relative; background: var(--wood); border: 4px solid var(--wood-dark); box-shadow: var(--drop); }
.door::before { content: ""; position: absolute; inset: 10px 10px 54px; border: 3px solid var(--wood-dark); }
.door::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 10px; height: 36px; border: 3px solid var(--wood-dark); }
.door i { position: absolute; right: 12px; top: 58px; width: 8px; height: 8px; background: var(--honey); box-shadow: 0 12px 0 var(--ink); z-index: 1; }
.door i::after { content: ""; position: absolute; top: 14px; left: 2px; width: 4px; height: 6px; background: var(--ink); }

/* Deux cadres vides sur le mur, à remplir */
.frames { display: flex; gap: 24px; margin: 4px 0 26px; }
.frames .avatar { width: 56px; height: 56px; font-size: 26px; }
.frames .avatar:empty::before { content: "?"; color: var(--muted); }
.frames .avatar.blank { background: var(--sunken); color: var(--muted); }

#picker-buttons { display: flex; flex-direction: column; gap: 16px; }
.pick {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: var(--bw) solid var(--edge); box-shadow: var(--drop);
  padding: 14px 8px 14px 16px;
  transition: transform .08s var(--snap), box-shadow .08s var(--snap);
}
.pick-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; min-height: 52px; text-align: left; font-size: 18px; font-weight: 600; }
.pick-main .avatar { width: 52px; height: 52px; font-size: 26px; flex-shrink: 0; }
.pick-name { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; max-width: 100%; }
.pick-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-main .here { white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--fg); background: var(--pc-soft); border: var(--bw) solid var(--pc); padding: 1px 6px; }
.pick-rename {
  flex-shrink: 0; color: var(--fg); font-size: 13px; min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; font-family: var(--mono); font-weight: 500;
  text-decoration: underline; text-decoration-style: dotted; text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.pick-rename:active { background: var(--sunken); text-decoration-style: solid; }
.pick:has(.pick-main:active) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow-c); }
.invite { margin-top: 40px; padding-top: 24px; border-top: var(--bw) dashed var(--line); }
.invite p { margin: 0 0 12px; }
.invite .secondary { width: 100%; }

/* ---------- écran principal ---------- */

#screen-main { display: flex; flex-direction: column; padding-bottom: 0; }
#screen-main > * { flex-shrink: 0; }
/* Le sol : la page se termine dessus. Il reste en bas quand il y a peu de fiches, sinon on le rejoint en défilant */
#scene {
  display: block; margin: 28px 0 0 calc(50% - 50vw); margin-top: auto; padding-top: 28px;
  width: 100vw; height: calc(156px + env(safe-area-inset-bottom)); box-sizing: content-box;
  image-rendering: pixelated; pointer-events: none;
}

/* L'étagère : une potion par personne, son niveau est sa part du temps de la semaine */
.shelf { position: relative; margin: 0 6px 30px; }
.shelf-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px; }
.label {
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.label::before { content: ""; width: 8px; height: 8px; background: var(--honey); flex-shrink: 0; }
#counter-note { margin: 0 0 8px; font-size: 12px; }
.jars { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 0 14px; }
.jar { display: flex; align-items: flex-end; gap: 10px; min-width: 0; }
.jar:last-child { flex-direction: row-reverse; }
.jar-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-bottom: 6px; }
.jar:last-child .jar-text { align-items: flex-end; text-align: right; }
/* La fiole : un col étroit bouché de liège, un corps de verre, le liquide à la couleur de la personne */
.jar-glass {
  position: relative; flex-shrink: 0; width: 48px; height: 50px; margin-top: 26px;
  background: var(--surface); border: var(--bw) solid var(--edge);
  box-shadow: inset 5px 0 0 rgb(255 255 255 / 55%), inset -4px 0 0 var(--sunken);
}
.jar-glass::before {
  content: ""; position: absolute; left: 50%; top: -16px; width: 20px; height: 16px; margin-left: -10px;
  background: var(--surface); border: var(--bw) solid var(--edge); border-bottom: 0;
  box-shadow: inset 3px 0 0 rgb(255 255 255 / 55%);
}
.jar-glass::after {
  content: ""; position: absolute; left: 50%; top: -26px; width: 16px; height: 12px; margin-left: -8px;
  background: var(--wood); border: var(--bw) solid var(--wood-dark);
}
.jar-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--h, 0%);
  background: repeating-linear-gradient(90deg, transparent 0 6px, rgb(255 255 255 / 28%) 6px 8px), var(--pc);
  transition: height .6s var(--snap);
}
.jar-fill::before { content: ""; position: absolute; top: -4px; left: 0; right: 0; height: 4px; background: repeating-linear-gradient(90deg, var(--pc) 0 4px, transparent 4px 8px); }
/* Deux bulles qui montent dans la potion */
.jar-fill::after {
  content: ""; position: absolute; left: 12px; bottom: 6px; width: 4px; height: 4px;
  background: rgb(255 255 255 / 70%); box-shadow: 14px -10px 0 rgb(255 255 255 / 55%);
  animation: bubble 2.4s var(--snap) infinite;
}
.jar.is-zero .jar-fill::before, .jar.is-zero .jar-fill::after { display: none; }
@keyframes bubble { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }
.jar-name { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.jar-name::before { content: ""; width: 8px; height: 8px; background: var(--pc); flex-shrink: 0; }
.jar-time { font-size: 20px; font-weight: 600; line-height: 1; color: var(--pc); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plank { height: 12px; margin: 0 -6px; background: var(--wood); border-top: 2px solid var(--wood-light); box-shadow: 0 3px 0 var(--wood-dark), 4px 7px 0 var(--shadow-c); position: relative; }
.plank::before, .plank::after { content: ""; position: absolute; top: 11px; width: 10px; height: 10px; background: var(--wood-dark); }
.plank::before { left: 14px; }
.plank::after { right: 14px; }

/* Le tableau de liège : les tâches y sont punaisées */
.board {
  display: block; position: relative;
  padding: 14px 8px 4px; margin: 0;
  background: radial-gradient(var(--cork-dot) 1px, transparent 1.5px) 0 0 / 6px 6px, var(--cork);
  border: 4px solid var(--wood); outline: 2px solid var(--wood-dark); box-shadow: var(--drop);
}
.section + .section { margin-top: 18px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 13px; }
/* L'étiquette de section : une bande de papier collée sur le liège */
.section-head .label { background: var(--surface); border: var(--bw) solid var(--edge); padding: 4px 8px; box-shadow: 2px 2px 0 var(--shadow-c); }
.section-head.late .label { color: var(--late); background: var(--late-soft); }
.section-head.late .label::before { background: var(--late); }
.count {
  font-size: 11px; font-weight: 600; line-height: 18px; min-width: 20px; padding: 0 6px; text-align: center;
  color: var(--fg); background: var(--sunken); border: var(--bw) solid var(--line); font-variant-numeric: tabular-nums;
}
.count:empty { display: none; }
.section-head.late .count { background: var(--late-soft); color: var(--late); border-color: var(--late); }

/* Fiche tâche : une feuille punaisée, la punaise de la couleur de la personne */
.card {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: var(--bw) solid var(--edge); box-shadow: var(--drop-sm);
  margin: 0 0 16px; min-height: 68px;
  transition: transform .25s var(--ease), opacity .25s var(--ease), max-height .3s var(--ease), margin .3s var(--ease), box-shadow .08s var(--snap);
  max-height: 240px;
}
.board .card::before {
  content: ""; position: absolute; top: -7px; left: 50%; width: 10px; height: 10px; margin-left: -5px; z-index: 2;
  background: var(--pc); box-shadow: inset -2px -2px 0 rgb(0 0 0 / 18%), 2px 2px 0 var(--shadow-c);
}
.card-body { flex: 1; min-width: 0; text-align: left; padding: 12px 34px 12px 4px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.card-body:active { background: var(--sunken); }
.more { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); }
.more svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: square; stroke-linejoin: miter; }
.more svg rect { fill: currentColor; stroke: none; }
.card.future .more svg { width: 16px; height: 16px; stroke-width: 2.4; }
.card-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; overflow: hidden; font-size: 13px; color: var(--muted); margin-top: 4px; font-family: var(--mono); font-weight: 500; }
.card-meta > * { position: relative; }
.card-meta > * + :not(.late)::before { content: ""; position: absolute; left: -8px; top: 50%; width: 3px; height: 3px; margin-top: -2px; background: var(--muted); opacity: .6; }
.card-meta .who { color: var(--fg); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.card-meta .who .mini { width: 8px; height: 8px; background: var(--pc); flex-shrink: 0; }
.card-meta .late { color: var(--on-late); background: var(--late); font-size: 12px; font-weight: 600; padding: 1px 7px; margin: 1px 0; }
.card.is-done .card-meta .late { background: var(--line); color: var(--muted); }
/* Demain : déjà sur le tableau, mais en retrait */
.section-head.soon .label::before { background: var(--edge); }
.card.soon { background: var(--sunken); border-color: var(--line); box-shadow: 2px 2px 0 var(--shadow-c); }
.card.soon .card-name { color: var(--muted); font-weight: 500; }
.card.soon .card-meta { opacity: .8; }
.card.soon .check .ring { border-color: var(--edge); background: var(--surface); box-shadow: 2px 2px 0 var(--line); }
.card.soon .check:active .ring, .card.soon.is-done .ring { border-color: var(--pc); }
.board .card.soon::before { background: var(--pc-soft); box-shadow: inset 0 0 0 2px var(--pc), 2px 2px 0 var(--shadow-c); }

/* La case à cocher */
.check { flex-shrink: 0; width: 54px; align-self: stretch; display: grid; place-items: center; border-right: var(--bw) dashed var(--line); }
.check .ring {
  width: 28px; height: 28px;
  border: var(--bw) solid var(--pc); background: var(--surface);
  box-shadow: 2px 2px 0 var(--pc-soft);
  display: grid; place-items: center;
  transition: background .12s var(--snap), transform .12s var(--snap), box-shadow .12s var(--snap);
}
.check svg { width: 18px; height: 18px; fill: none; stroke: var(--on-p); stroke-width: 3.2; stroke-linecap: square; stroke-linejoin: miter; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .25s .05s var(--snap); }
.check:active .ring { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--pc-soft); background: var(--pc-soft); }
.card.is-done .ring { background: var(--pc); animation: pop .3s var(--snap); }
.card.is-done svg { stroke-dashoffset: 0; }
.card.is-done .card-name { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.card.leaving { opacity: 0; transform: translateX(24px); max-height: 0; margin-bottom: 0; min-height: 0; overflow: hidden; }
.card.is-done[data-min]::after {
  content: "+" attr(data-min);
  position: absolute; right: 12px; top: -10px; z-index: 2;
  font-family: var(--mono); font-weight: 600; font-size: 13px; line-height: 1;
  color: var(--on-honey); background: var(--honey); padding: 3px 6px; border: var(--bw) solid var(--edge);
  animation: fly .9s var(--snap) forwards;
}
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes fly { 0% { opacity: 0; transform: translateY(8px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-28px); } }

/* Carte à venir, dans le tiroir : en pointillés, encore en attente */
.card.future { box-shadow: none; background: transparent; border: var(--bw) dashed var(--edge); min-height: 56px; margin-bottom: 10px; }
.card.future .card-body { padding-left: 14px; padding-right: 36px; }
.card.future .more { right: 8px; }
.card.future .card-name { font-weight: 500; }
.when { font-weight: 700; color: var(--fg); font-size: 14px; }

/* État vide : un mot punaisé, et le chat qui dort */
.empty { text-align: center; padding: 4px 12px 10px; }
.empty-mark { width: 96px; height: 48px; margin: 0 auto 6px; display: block; image-rendering: pixelated; }
.empty h3 { margin: 0 0 4px; font-size: 20px; font-weight: 700; font-family: var(--display); }
.empty p { margin: 0; color: var(--muted); font-size: 14px; }

/* La commode : « À venir » et « Fait cette semaine » sont ses tiroirs */
.dresser {
  margin: 22px 0 12px; padding: 6px;
  background: var(--wood); border: var(--bw) solid var(--wood-dark); outline: 2px solid var(--wood-dark); outline-offset: 2px;
  box-shadow: var(--drop); position: relative;
}
.dresser::before, .dresser::after { content: ""; position: absolute; bottom: -12px; width: 12px; height: 8px; background: var(--wood-dark); }
.dresser::before { left: 8px; }
.dresser::after { right: 8px; }
.drawer + .drawer { margin-top: 6px; }
.drawer summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 54px;
  padding: 6px 12px 6px 10px; background: var(--wood-light); border: var(--bw) solid var(--wood-dark);
  box-shadow: inset 0 -4px 0 var(--wood), inset 2px 2px 0 rgb(255 255 255 / 25%);
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg);
}
.drawer summary::-webkit-details-marker { display: none; }
/* L'étiquette du tiroir, et sa poignée */
.drawer summary > span:first-child { background: var(--surface); border: var(--bw) solid var(--edge); padding: 3px 8px; box-shadow: 2px 2px 0 var(--wood-dark); }
.drawer summary::after {
  content: ""; width: 40px; height: 10px; margin-left: auto;
  background: var(--wood-dark); box-shadow: inset 0 0 0 2px var(--surface), 2px 2px 0 var(--wood-dark);
  transition: transform .15s var(--snap);
}
.drawer[open] summary { box-shadow: inset 0 -4px 0 var(--wood), 0 4px 0 var(--wood-dark); }
.drawer[open] summary::after { transform: translateY(2px); }
.drawer > div { margin-top: 6px; padding: 12px 10px 6px; background: var(--sunken); border: var(--bw) solid var(--wood-dark); box-shadow: inset 0 4px 0 var(--shadow-c); }

.event-row { display: flex; align-items: center; gap: 12px; padding: 8px 2px 10px; border-bottom: 1px dashed var(--edge); font-size: 15px; }
.event-row:last-child { border-bottom: 0; }
.event-row .dot { width: 10px; height: 10px; background: var(--pc); flex-shrink: 0; }
.ev-main { flex: 1; min-width: 0; }
.ev-name { font-weight: 500; overflow-wrap: anywhere; }
.ev-meta.card-meta { font-size: 12px; margin-top: 0; }
.event-row button { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--fg); min-height: 44px; padding: 0 12px; background: var(--surface); border: var(--bw) solid var(--edge); box-shadow: 2px 2px 0 var(--shadow-c); white-space: nowrap; transition: transform .08s var(--snap), box-shadow .08s var(--snap); }
.event-row button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shadow-c); }
.event-row.undone .ev-name { text-decoration: line-through; color: var(--muted); }
.event-row.undone .dot { background: var(--line); }
.drawer .empty-line { color: var(--muted); font-size: 14px; padding: 2px 2px 10px; margin: 0; }

/* La petite boîte dans le coin : le bouton d'ajout, avec sa poignée */
.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid; place-items: center;
  width: 56px; height: 52px; padding: 0;
  background: var(--honey); color: var(--on-honey); border: var(--bw) solid var(--edge);
  box-shadow: inset 0 -5px 0 rgb(0 0 0 / 12%), 4px 4px 0 var(--shadow-c); z-index: 5;
  transition: transform .08s var(--snap), box-shadow .08s var(--snap);
}
.fab::before { content: ""; position: absolute; top: -10px; left: 50%; width: 28px; height: 10px; margin-left: -14px; border: var(--bw) solid var(--edge); border-bottom: 0; background: var(--honey); }
.fab svg { width: 26px; height: 26px; stroke-width: 3; }
.fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fab:active { transform: translate(3px, 3px); box-shadow: inset 0 -5px 0 rgb(0 0 0 / 12%), 1px 1px 0 var(--shadow-c); }

/* ---------- feuilles : des tiroirs qui montent du bas ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s var(--ease);
}
.sheet {
  background: var(--bg); width: 100%; max-width: 520px;
  max-height: 92dvh; overflow-y: auto;
  border-top: 8px solid var(--wood);
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 0 var(--wood-dark), 0 -4px 0 var(--wood-dark);
  animation: rise .28s var(--ease);
  display: flex; flex-direction: column; gap: 18px;
}
@media (min-width: 560px) { .sheet { border-left: var(--bw) solid var(--wood-dark); border-right: var(--bw) solid var(--wood-dark); } }
/* La poignée du tiroir */
.grabber { width: 48px; height: 10px; margin: -2px auto 0; flex-shrink: 0; background: var(--wood-dark); box-shadow: inset 0 0 0 2px var(--surface); }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.group { display: flex; flex-direction: column; gap: 8px; }
.group-label { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.group-label em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg > * {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 10px;
  background: var(--surface); border: var(--bw) solid var(--edge); box-shadow: 2px 2px 0 var(--shadow-c);
  font-family: var(--mono); font-size: 13px; font-weight: 500; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .1s var(--snap), color .1s var(--snap), transform .08s var(--snap), box-shadow .08s var(--snap);
}
.seg.wrap > * { flex-basis: calc(50% - 4px); }
.seg > *:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shadow-c); }
.seg > [aria-checked="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); font-weight: 600; transform: none; box-shadow: none; }
.seg > .person-opt[aria-checked="true"] { background: var(--pc-soft); color: var(--fg); border-color: var(--pc); box-shadow: inset 0 0 0 2px var(--pc); }
.seg > .person-opt .mini { width: 8px; height: 8px; background: var(--pc); flex-shrink: 0; }
.seg > .person-opt > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.seg-input { position: relative; cursor: text; }
.seg-input input {
  width: 100%; border: 0; background: none; text-align: right; padding: 0; font: inherit; color: inherit;
  -moz-appearance: textfield; appearance: textfield;
}
.seg-input input::-webkit-inner-spin-button, .seg-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.seg-input input::placeholder { color: var(--muted); text-align: center; }
.seg-input input:placeholder-shown { text-align: center; }
.seg-input input:placeholder-shown + span { display: none; }
.seg-input input:not(:placeholder-shown) { width: 3.2ch; text-align: right; }
.seg-input input:focus { outline: none; }
.seg-input:focus-within { background: var(--honey-soft); color: var(--fg); }
.seg-input.date { cursor: pointer; padding: 0 6px; }
.seg-input.date input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.seg-input.date input + span { display: inline !important; overflow: hidden; text-overflow: ellipsis; }

.inline-field { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.inline-field input::-webkit-inner-spin-button, .inline-field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.inline-field input {
  -moz-appearance: textfield; appearance: textfield;
  width: 64px; min-height: 40px; text-align: center;
  background: var(--surface); border: var(--bw) solid var(--edge); font-family: var(--mono); font-weight: 600;
}
.inline-field input:focus { outline: none; background: var(--honey-soft); }

.summary { margin: 0; padding: 12px 14px; background: var(--sunken); border-left: 4px solid var(--honey); font-size: 14px; color: var(--muted); }
.summary b { color: var(--fg); font-weight: 600; }

.actions { display: flex; gap: 12px; }
.actions > * { flex: 1; }
.actions .primary { flex: 2; }
#btn-delete { align-self: center; margin-top: -6px; }
#btn-delete.confirm { background: var(--late); color: var(--on-late); padding: 12px 18px; border: var(--bw) solid var(--edge); box-shadow: var(--drop-sm); }

#actions-title {
  margin-bottom: -12px; overflow-wrap: anywhere; font-size: 22px; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#actions-meta { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack button {
  min-height: 52px; text-align: left; padding: 0 16px; display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 15px; font-weight: 500;
  background: var(--surface); border: var(--bw) solid var(--edge); box-shadow: var(--drop-sm);
  transition: transform .08s var(--snap), box-shadow .08s var(--snap);
}
.stack button.primary { background: var(--ink); color: var(--on-ink); font-weight: 600; }
.stack button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; stroke-linejoin: miter; flex-shrink: 0; }
.stack button .avatar { width: 26px; height: 26px; font-size: 13px; border-width: 2px; box-shadow: 0 0 0 1px var(--wood-dark); }
.stack button.danger { color: var(--late); }
.stack button.danger.confirm { background: var(--late); color: var(--on-late); }
.stack button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--shadow-c); }
.stack hr { border: 0; height: var(--bw); background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 10px); margin: 4px 0; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; z-index: 30;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 14px;
  padding: 4px 4px 4px 16px; min-height: 52px;
  background: var(--ink); color: var(--on-ink); border: var(--bw) solid var(--edge);
  box-shadow: 4px 4px 0 var(--honey); font-size: 14px;
  animation: toast-in .2s var(--snap);
}
.toast.error { background: var(--late); color: var(--on-late); box-shadow: 4px 4px 0 var(--shadow-c); }
.toast #toast-text { padding: 6px 0; }
.toast #toast-action { color: var(--on-honey); font-size: 13px; font-weight: 600; min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; background: var(--honey); }
.toast:not(:has(#toast-action:not([hidden]))) { padding-right: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

#offline {
  position: sticky; top: 0; z-index: 40;
  background: var(--honey); color: var(--on-honey); border-bottom: var(--bw) solid var(--edge);
  text-align: center; padding: calc(6px + env(safe-area-inset-top)) 16px 6px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em;
}

/* Petits téléphones : fenêtre et bocaux plus bas, pour garder les fiches du jour visibles */
@media (max-height: 700px) {
  .screen { padding-top: max(16px, var(--top-inset)); }
  .top { margin-bottom: 10px; }
  .pane { height: 64px; }
  .window { margin-bottom: 24px; }
  .jar-glass { height: 42px; width: 42px; }
  .shelf { margin-bottom: 20px; }
  .section + .section { margin-top: 14px; }
  .card { margin-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}
