/* YumiPlan — home-planner UI. Light, friendly, mobile-first.
   Top tabs on desktop become a bottom nav on phones; the editor opens as a
   bottom sheet. Design tokens first, then components. */
:root {
  /* Palette: warm "washi" paper, sumi-ink text, muted natural pigments, with a
     restrained indigo (藍 ai-iro) accent — calm, warm, Japanese-minimal. */
  --bg: #f1ebdf;          /* warm washi-paper canvas (solid fallback) */
  /* gentle.guide's pastel mesh: soft colour blobs (sage, gold, coral, lilac,
     sky) over a near-white ground, painted full-viewport behind the shell.
     Base made opaque (#fafdff = their rgba(237,248,255,.29) over white) so the
     same value can also cover the login screen without bleed-through. */
  --bg-gradient:
    radial-gradient(rgba(207,216,152,.53) 23%, rgba(255,203,87,0) 67% 100%) 385px -24px,
    radial-gradient(rgba(255,226,120,.72) 0, rgba(255,51,61,0) 60% 100%) -640px 290px,
    radial-gradient(rgba(254,141,121,.23) 10%, rgba(144,224,255,0) 60% 100%) -120px 250px,
    radial-gradient(rgba(255,226,120,.72) 30%, rgba(255,51,61,0) 57% 100%) 605px -70px,
    radial-gradient(rgba(237,248,255,.29) 30%, rgba(169,96,238,0) 67% 100%) 122px -120px,
    radial-gradient(rgba(237,248,255,.29) 10%, rgba(169,96,238,0) 60% 100%) -420px 120px,
    radial-gradient(rgba(254,141,121,.23) 15%, rgba(144,224,255,0) 50% 100%) -620px 0,
    radial-gradient(rgba(254,141,121,.23) 25%, rgba(144,224,255,0) 50% 100%) 520px -250px,
    #fafdff;
  --surface: #fbf8f1;     /* fine paper — lifts gently above the canvas */
  --surface-2: #ece4d4;   /* segmented tracks, chips, swatches */
  --surface-3: #f5efe4;   /* row hover */
  --ink: #2e2a23;         /* warm sumi ink */
  --ink-soft: #5a5347;    /* secondary text */
  --muted: #948b79;       /* muted taupe — captions, sub-lines */
  --line: #e6ddcc;        /* hairline */
  --line-strong: #d6cbb5; /* stronger divider / control border */

  --brand: #4e6175;       /* indigo — primary actions, active nav */
  --brand-strong: #3d4e60;
  --brand-soft: #e3e6ea;  /* tinted active background */
  --accent: #c98a5e;      /* warm clay highlight */
  --focus: #4e6175;

  --maison: #6a7d94;      /* muted steel-indigo */
  --laundry: #5f9189;     /* celadon (青磁) */
  --chore: #8c80a2;       /* wisteria (藤) */
  --repas: #c0954e;       /* ochre */
  --recettes: #6f8a55;    /* matcha / moss */
  --courses: #c0766b;     /* persimmon clay (柿) */
  --green: #5f8a5f;       /* moss — success */
  --red: #b35546;         /* muted vermilion — danger */

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(60,50,36,.06);
  --shadow: 0 2px 4px rgba(60,50,36,.05), 0 14px 30px rgba(60,50,36,.09);
  --shadow-lg: 0 -10px 44px rgba(46,42,35,.20);
  --sheet-max: 560px;
  --content-max: 1040px;

  --nav-h: 64px;          /* mobile bottom-nav height (excl. safe area) */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Pastel gradient backdrop: fixed to the viewport (never scrolls or stretches),
   behind the app shell. Opaque panels sit on top; the gradient peeks through the
   gutters, the gaps between stacked cards, and the translucent top/bottom bars. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-gradient);
  animation: rotate-hue 40s linear infinite; /* slow, ambient pastel-hue cycle */
}
/* Slowly cycle the backdrop's hue. Filter lives on the background layer only, so
   panels, text and the login card are never tinted. Disabled under
   prefers-reduced-motion by the universal guard below. */
@keyframes rotate-hue { to { filter: hue-rotate(360deg); } }
body.sheet-open { overflow: hidden; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- Buttons & inputs ---- */
.btn {
  font: 600 14px 'Inter', sans-serif;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .04s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(78,97,117,.22);
}
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { color: var(--red); border-color: var(--line-strong); background: var(--surface); }
.btn-danger:hover { background: #f5e6e0; border-color: #e3c3b8; }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

input[type=text], input[type=search], input[type=password], input[type=time], input[type=date], select, textarea {
  width: 100%;
  font: 15px 'Inter', sans-serif;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #b3a994; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
/* Drop the native search chrome (WebKit clear "✕" + pill) so search fields match
   every other input; we provide our own clear affordances (Échap / "Effacer"). */
input[type=search] { appearance: none; -webkit-appearance: none; }
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
/* Custom select chevron (native one is inconsistent across platforms). */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818aa3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 13px;
}
textarea { resize: vertical; min-height: 64px; }
label.field-label { display:block; font-size:12px; font-weight:700; letter-spacing:.01em; color:var(--ink-soft); margin: 0 0 6px; }
.field { margin-bottom: 16px; }

/* ---- Login ---- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 100; }
/* Same animated pastel mesh behind the login card (filter on the ::before only,
   so the card and its text stay crisp). */
.login::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--bg-gradient); animation: rotate-hue 40s linear infinite; }
.login-card { background: var(--surface); border-radius: var(--radius-lg); padding: 30px 26px; width: 100%; max-width: 360px; box-shadow: 0 24px 60px rgba(46,42,35,.26); display: flex; flex-direction: column; gap: 13px; }
.login-brand { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 30px; letter-spacing: -.02em; color: var(--ink); }
.login-sub { margin: -8px 0 8px; color: var(--muted); font-size: 14px; }
.login-err { color: var(--red); font-size: 13px; font-weight: 600; }
.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 13px; }
.seg-btn { flex: 1; border: none; background: transparent; border-radius: 10px; padding: 10px; font: 700 14px 'Inter'; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg-btn.is-active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 4px rgba(60,50,36,.14); }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(250,247,240,.82); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 14px; padding: 11px 18px; max-width: var(--content-max); margin: 0 auto; padding-top: max(11px, env(safe-area-inset-top)); }
.brand { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 21px; letter-spacing: -.02em; color: var(--ink); }
.brand span { color: var(--brand); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 11px; white-space: nowrap; transition: background .15s, color .15s; }
.tab:hover { background: var(--surface-2); color: var(--ink-soft); }
.tab.is-active { background: var(--brand); color: #fff; }
.tab-ico { display: inline-flex; }
.tab-ico svg { width: 18px; height: 18px; display: block; }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 17px; display: grid; place-items: center; color: var(--ink-soft); transition: background .15s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.who { font-family: 'Space Grotesk'; font-weight: 700; font-size: 15px; background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.offline-banner { background: #f4ead2; color: #8a6a30; font-size: 12px; font-weight: 700; text-align: center; padding: 7px; }

/* ---- View layout ---- */
.view { max-width: var(--content-max); margin: 0 auto; padding: 20px 18px 64px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 26px; letter-spacing: -.01em; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-pad { padding: 16px; }
.panel-head { padding: 15px 18px; border-bottom: 1px solid var(--line); font-family: 'Space Grotesk'; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 26px 18px; text-align: center; }
.spinner { color: var(--muted); font-size: 14px; padding: 28px; text-align: center; }

/* ---- Pills / tags ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 11px; }
.pill-green { background: #e9efe0; color: var(--green); }
.pill-red { background: #f4e2db; color: var(--red); }
.pill-toggle { cursor: pointer; border: none; }
.tag { display:inline-flex; align-items:center; gap:7px; font-size:12px; font-weight:700; color:var(--ink-soft); background:var(--surface-2); border-radius:999px; padding:5px 11px; }
.tag .dot { width:9px; height:9px; border-radius:50%; }

/* ---- Filter chips ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fchip { font-size: 13px; font-weight: 600; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s, border-color .15s; }
.fchip:hover { background: var(--surface-2); }
.fchip[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.fchip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---- List rows ---- */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 13px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-3); }
.row:active { background: var(--surface-2); }
.row.is-done .row-title { text-decoration: line-through; color: var(--muted); }
.row-accent { width: 4px; align-self: stretch; min-height: 34px; border-radius: 3px; background: var(--muted); flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-strong); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 15px; flex: none; transition: background .12s, border-color .12s; }
.check.on { background: var(--green); border-color: var(--green); }

/* ---- Courses: shopping progress + store-group headers ---- */
.course-progress { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.course-progress-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.course-progress-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .3s ease; }
.course-progress-label { font-size: 12.5px; font-weight: 600; margin-top: 8px; }
.group-count { font-size: 12px; font-weight: 700; color: var(--muted); }
.keep-divider { padding: 12px 4px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---- Courses page: roomier sections, smaller controls, cleaner add bar ---- */
.courses-view { gap: 18px; }
.input-sm { padding: 8px 11px; font-size: 13px; }
select.input-sm { padding-right: 30px; background-position: right 10px center; }
.addbar { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.addbar-row { display: flex; gap: 8px; align-items: center; }
.addbar-row > input, .addbar-row > select { flex: 1; min-width: 0; }
.courses-view .row { padding: 10px 14px; gap: 11px; }
.courses-view .row-title { font-size: 14px; }
.courses-view .panel-head { padding: 11px 14px; font-size: 14px; }
.courses-view .course-progress { padding: 12px 14px; }
.courses-view .fchip { padding: 6px 11px; font-size: 12px; }
.courses-view .check { width: 23px; height: 23px; }

/* ---- Bottom sheet (was right drawer) ---- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(40,34,26,.46); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: overlay-in .22s ease; }
.drawer-overlay.is-closing { animation: overlay-out .22s ease forwards; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlay-out { from { opacity: 1; } to { opacity: 0; } }

.drawer { background: var(--surface); width: 100%; max-width: var(--sheet-max); max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: sheet-up .28s cubic-bezier(.22,1,.36,1); will-change: transform; }
.drawer.is-closing { animation: sheet-down .24s ease forwards; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-down { from { transform: translateY(0); } to { transform: translateY(100%); } }
.drawer.is-dragging { animation: none; transition: none; }

.drawer-grabber { display: flex; justify-content: center; padding: 11px 0 5px; cursor: grab; touch-action: none; flex: none; }
.drawer-grabber:active { cursor: grabbing; }
.drawer-grabber::before { content: ""; width: 42px; height: 5px; border-radius: 999px; background: var(--line-strong); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 20px 14px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-title { font-family: 'Space Grotesk'; font-weight: 600; font-size: 19px; margin: 0; }
.drawer-body { padding: 18px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; flex: 1; }
.drawer-foot { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--surface); flex: none; }
.drawer-foot .btn { flex: 1; }

/* ---- Segmented / pickers (inside the sheet) ---- */
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 11px; padding: 9px 13px; font: 600 13px 'Inter'; color: var(--ink-soft); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.choice:hover { background: var(--surface-2); }
.choice[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.wd { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); font: 700 12px 'Inter'; color: var(--ink-soft); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.wd[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.inline { display: flex; gap: 10px; align-items: center; }
.inline > * { flex: 1; }

/* Structured ingredient row: [grip] [amount] [unit ▾] [name] [✕] */
.ing-row { display: flex; align-items: center; gap: 7px; }
.ing-row > .drag-handle, .ing-row > button { flex: 0 0 auto; }
.ing-row .ing-amount { width: 56px; flex: 0 0 auto; text-align: center; padding-left: 6px; padding-right: 6px; }
.ing-row .ing-unit { width: 92px; flex: 0 0 auto; padding-right: 4px; }
.ing-row .ing-name { flex: 1; min-width: 0; }
.drag-handle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; align-self: stretch;
  color: var(--muted); cursor: grab; touch-action: none;
  border-radius: 8px;
}
.drag-handle:hover { background: var(--surface-2); color: var(--ink-soft); }
.drag-handle:active { cursor: grabbing; }
.row.reorder-item { cursor: pointer; }
.row .drag-handle { flex: 0 0 auto; }
/* Bought items sit in their own sub-list under the active ones. */
.rows-bought { border-top: 1px dashed var(--line); }
/* The grabbed row lifts off the list and tracks the finger (transform set in JS). */
.dragging { background: var(--surface); border-radius: 12px; box-shadow: 0 10px 28px rgba(60,50,36,.20); cursor: grabbing; }
.dragging .drag-handle { cursor: grabbing; }

/* ---- Toasts ---- */
.toasts { position: fixed; left: 0; right: 0; bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast { background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; padding: 11px 17px; border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.24); animation: pop .16s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Mobile: bottom navigation ---- */
@media (max-width: 720px) {
  .topbar-inner { padding: 9px 14px; gap: 10px; }
  .section-title { font-size: 22px; }
  .view { padding: 14px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }

  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    flex: none; gap: 2px; overflow: visible;
    background: rgba(250,247,240,.92); backdrop-filter: saturate(1.4) blur(10px);
    border-top: 1px solid var(--line);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    box-shadow: 0 -3px 18px rgba(60,50,36,.08);
  }
  .tab { flex: 1; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; font-size: 11px; font-weight: 600; border-radius: 12px; color: var(--muted); }
  .tab:hover { background: transparent; }
  .tab.is-active { background: transparent; color: var(--brand); }
  .tab-ico { padding: 4px 12px; border-radius: 999px; transition: background .16s; }
  .tab.is-active .tab-ico { background: var(--brand-soft); }
  .tab-ico svg { width: 22px; height: 22px; }
  .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

  .toasts { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
}

@media (max-width: 380px) {
  .brand { display: none; }
  /* Five bottom-nav tabs: shrink labels/padding so the longest French word fits. */
  .tab { padding: 4px 1px; font-size: 10px; }
  .tab-ico { padding: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- Recipe form (Recettes editor + meal drawer) ---- */
.stack-tight { display: flex; flex-direction: column; gap: 8px; }
.inline-lbl { display: flex; align-items: center; gap: 6px; flex: 1; }
.inline-lbl > span { white-space: nowrap; }
.disclosure { text-align: left; }
.recipe-picker { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; max-height: 40vh; overflow-y: auto; overscroll-behavior: contain; }
.recipe-picker .row { padding: 11px 14px; }
/* Sticky search + tag-filter header so the list scrolls under it */
.picker-head { position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.filters-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filters-scroll::-webkit-scrollbar { display: none; }
.filters-scroll .fchip { flex: 0 0 auto; }
/* Brand the picker chips to the Recettes section colour */
.recipe-picker .fchip[aria-pressed="true"] { background: var(--recettes); border-color: var(--recettes); }
/* Keyboard/active row — distinct from the green accent bar and from :hover */
.recipe-picker .row.is-active { background: var(--brand-soft); box-shadow: inset -3px 0 0 var(--brand); }
.recipe-picker .row-title mark { background: transparent; color: var(--brand-strong); font-weight: 700; }
.picker-hint { font-size: 12.5px; padding: 0 16px 16px; text-align: center; }
.recipe-picker .empty + .btn { display: block; margin: 0 auto 16px; }

/* Numbered, reorderable preparation steps */
.steps { counter-reset: step; }
.step-row { display: flex; align-items: flex-start; gap: 7px; counter-increment: step; }
.step-row > .drag-handle { align-self: center; }
.step-row .step-num { flex: 0 0 auto; width: 22px; height: 22px; margin-top: 7px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-soft); font: 700 11px 'Inter'; display: grid; place-items: center; }
.step-row .step-num::before { content: counter(step); }
.step-row .step-text { flex: 1; min-width: 0; resize: vertical; }

/* Recipe book rows */
.recipe-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.recipe-tag { font-size: 11px; font-weight: 600; color: var(--ink-soft); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }

/* ---- Cook mode (full-screen read view) ---- */
body.cook-open { overflow: hidden; }
.cookmode { position: fixed; inset: 0; z-index: 120; background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; overflow-y: auto; animation: cook-in .2s ease; }
.cookmode.is-closing { animation: cook-out .18s ease forwards; }
@keyframes cook-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cook-out { to { opacity: 0; transform: translateY(8px); } }
.cook-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 18px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.cook-close { font-size: 20px; }
.cook-titles { flex: 1; min-width: 0; }
.cook-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: clamp(22px, 4vw, 30px); margin: 0; letter-spacing: -.01em; }
.cook-meta { color: var(--muted); font-size: 14px; margin-top: 3px; }
.cook-body { width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 18px calc(40px + env(safe-area-inset-bottom)); }
.cook-section { margin-bottom: 30px; }
.cook-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cook-h2 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 20px; margin: 0 0 12px; }
.cook-section-head .cook-h2 { margin: 0; }
.cook-stepper { display: flex; align-items: center; gap: 12px; }
.cook-step-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 22px; font-weight: 600; color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; }
.cook-step-btn:hover { background: var(--surface-2); }
.cook-serv { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 46px; }
.cook-serv-n { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 24px; }
.cook-serv-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cook-ings { display: flex; flex-direction: column; }
.cook-ing { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  background: none; border: none; border-bottom: 1px solid var(--line); padding: 14px 4px; font-size: 18px; color: var(--ink); }
.cook-ing:last-child { border-bottom: none; }
.cook-tick { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-strong); display: grid; place-items: center; }
.cook-ing.checked .cook-tick { background: var(--green); border-color: var(--green); }
.cook-ing.checked .cook-tick::after { content: '✓'; color: #fff; font-size: 15px; }
.cook-ing.checked .cook-ing-text { text-decoration: line-through; color: var(--muted); }
.cook-empty { color: var(--muted); padding: 12px 4px; }
.cook-steps { list-style: none; counter-reset: cstep; margin: 0; padding: 0; }
.cook-step { counter-increment: cstep; position: relative; padding: 14px 4px 14px 44px; border-bottom: 1px solid var(--line);
  font-size: 18px; line-height: 1.5; cursor: pointer; }
.cook-step:last-child { border-bottom: none; }
.cook-step::before { content: counter(cstep); position: absolute; left: 0; top: 13px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--recettes); color: #fff; font: 700 14px 'Inter'; display: grid; place-items: center; }
.cook-step.done { color: var(--muted); }
.cook-step.done .cook-step-text { text-decoration: line-through; }
.cook-step.done::before { background: var(--muted); }
.cook-notes { font-size: 16px; line-height: 1.6; color: var(--ink-soft); white-space: pre-wrap; }
.cook-section .btn-block { margin-top: 16px; }

/* ============================================================================
   Mobile UX pass — clean category iconography, bigger touch targets, calmer
   density. Audited per section at 360–414px; desktop (>720px) is intentionally
   left as-is. Rules here are appended last so they layer over the base styles.
   ========================================================================== */

/* ---- Category identity: a tinted icon badge before each section title ---- */
.section-title-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.section-title-wrap .section-title { min-width: 0; }
.section-ico {
  flex: none; width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); /* default = accueil */
}
.section-ico svg { width: 19px; height: 19px; display: block; }
.section-ico.is-accueil  { background: var(--brand-soft); color: var(--brand);    }
.section-ico.is-maison   { background: #e7ebf0;           color: var(--maison);   }
.section-ico.is-repas    { background: #f4ead4;           color: var(--repas);    }
.section-ico.is-recettes { background: #e8eedd;           color: var(--recettes); }
.section-ico.is-courses  { background: #f4e3dd;           color: var(--courses);  }

/* ---- Touch feedback & small polish (all widths) ---- */
* { -webkit-tap-highlight-color: transparent; } /* kill the platform tap flash; we have our own :active states */
.fchip:active { background: var(--surface-2); transform: translateY(1px); }
/* Disclosure toggles read as real expandable controls (left-aligned label). */
.disclosure { display: flex; align-items: center; min-height: 44px; }
.disclosure[aria-expanded="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
/* Full-width small buttons (e.g. "Ajouter dernières courses") get a comfortable
   height and room to breathe; the disclosure toggles keep their own sizing. */
.btn-sm.btn-block:not(.disclosure) { min-height: 44px; padding-top: 10px; padding-bottom: 10px; line-height: 1.3; }

/* Animated loading spinner (replaces the static "Chargement…" word). */
.spinner::before {
  content: ""; display: block; width: 18px; height: 18px; margin: 0 auto 10px;
  border: 2px solid var(--line-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Richer empty state: a soft icon above the message, with an optional CTA. */
.empty-ico { color: var(--line-strong); margin-bottom: 10px; display: grid; place-items: center; }
.empty .btn { margin-top: 14px; }

/* Search field with a leading magnifier (native search chrome is stripped). */
input[type=search].has-ico {
  padding-left: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818aa3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 13px center; background-size: 16px;
}

/* The base `* { animation:none }` reduced-motion rule doesn't match pseudo-
   elements, so guard the spinner (and any future ::before/::after) explicitly. */
@media (prefers-reduced-motion: reduce) {
  *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Phones (≤720px): touch targets & per-section layout ---- */
@media (max-width: 720px) {
  /* Buttons: floor at a comfortable tap height (small buttons a touch smaller). */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 9px 14px; }
  .choice { min-height: 44px; padding: 11px 14px; }
  .pill-toggle { min-height: 40px; padding: 8px 14px; font-size: 13px; }

  /* The primary per-row action / toggle gets the full 44px. */
  .row-actions .btn-sm,
  .row-actions .pill-toggle { min-height: 44px; }
  .recipe-row .row-actions .btn { min-height: 40px; padding: 9px 14px; font-size: 13px; }

  /* Icon-only buttons: square, centered hit area (course-sheet ✕, courses
     delete, ingredient/step ✕). */
  .drawer .row-actions .btn-sm,
  .courses-view .row-actions .btn-sm,
  .ing-row > button.btn-sm,
  .step-row > button.btn-sm {
    min-width: 44px; min-height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
  }

  /* Horizontally-scrolling filter chips: easier one-handed taps. */
  .filters-scroll .fchip { min-height: 40px; }

  /* Wider, genuinely grabbable drag handles. */
  .drag-handle { width: 40px; min-height: 44px; }

  /* Weekday picker: 7 equal columns on one line, full-height targets. */
  .weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
  .wd { width: auto; height: 44px; }

  /* "À acheter" quick-add: article field takes the first line; store select +
     "Ajouter" share the next, instead of all three fighting for ~1/3 each. */
  .panel-pad > .inline { flex-wrap: wrap; }
  .panel-pad > .inline > input[type=text] { flex: 1 0 100%; }
  .panel-pad > .inline > select { flex: 1 1 auto; min-width: 0; }
  .panel-pad > .inline > .btn { flex: 0 0 auto; }

  /* Section-head action button shouldn't get squeezed or wrap oddly. */
  .section-head .btn { flex: 0 0 auto; }

  /* Ingredient row (recipe editor + meal sheet): the name takes its own full
     line so it never collapses to ~90px; the controls reach 44px. */
  .ing-row { flex-wrap: wrap; row-gap: 8px; }
  .ing-row .ing-amount { width: 64px; min-height: 44px; }
  .ing-row .ing-unit { width: 110px; min-height: 44px; }
  .ing-row .ing-name { flex: 1 0 100%; order: 5; min-height: 44px; }

  /* Meal drawer footer: let the destructive "Supprimer" size to its label so it
     doesn't carry equal weight to the primary action. */
  .drawer-foot { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .drawer-foot .btn { padding-left: 12px; padding-right: 12px; }
  .drawer-foot .btn-danger { flex: 0 1 auto; }

  /* Recipe picker inside the sheet: show more than a keyhole. */
  .recipe-picker { max-height: 56vh; }

  /* Courses add-bar: stack the store + date selects so neither truncates. */
  .addbar .addbar-row:nth-child(2) { flex-direction: column; align-items: stretch; }

  /* Courses checkbox: restore a legible 26px tick on the left of each row. */
  .courses-view .check { width: 26px; height: 26px; }

  /* Cook mode: 44px steppers; let the section head wrap if it must. */
  .cook-step-btn { width: 44px; height: 44px; }
  .cook-section-head { flex-wrap: wrap; }
}

/* ---- Accueil · "Aujourd'hui" day agenda (richer than one calendar cell) ---- */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 15px 18px 13px; border-bottom: 1px solid var(--line); }
.today-eyebrow { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--brand); }
.today-date { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 19px; letter-spacing: -.01em; margin-top: 3px; }
.today-count { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.today-list { display: flex; flex-direction: column; }
.today-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.today-row:last-child { border-bottom: none; }
.today-row:hover { background: var(--surface-3); }
.today-row:active { background: var(--surface-2); }
.today-row.is-done .row-title { text-decoration: line-through; color: var(--muted); }
.today-time { flex: none; width: 48px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.today-allday { color: var(--line-strong); }
.today-ico { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; }
.today-ico svg { width: 18px; height: 18px; display: block; }
.today-check { flex: none; width: 24px; height: 24px; border-radius: 999px; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 13px; }
.today-empty { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 30px 18px; color: var(--muted); font-size: 14px; text-align: center; }
.today-empty-ico { color: var(--repas); opacity: .7; }
