:root {
  --bg: #ecefe9;
  --surface: #ffffff;
  --surface-2: #f7f8f4;
  --ink: #21262b;
  --muted: #737a80;
  --faint: #a2a8ac;
  --line: #e0e3dd;
  --line-strong: #cbcfc8;

  --ben: #2f6f6a;
  --caroline: #b5527a;
  --both: #bf862a;

  --today-bg: #e6efe9;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(28, 33, 30, 0.12);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --num-h: 26px;   /* space reserved for the day number */
  --lane-h: 21px;  /* height of one event bar row (fits stacked person stripes) */
  --chip-fs: 11.5px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "tnum" 1, "cv05" 1;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 100% at 50% 0%, #f3f5ef 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 32px 26px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.login-mark { font-size: 38px; line-height: 1; color: var(--ben); }
.login-card h1 { font-size: 26px; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); margin-bottom: 8px; font-size: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input, .sheet input, .sheet select, .sheet textarea {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
}
.login-card input:focus, .sheet input:focus, .sheet select:focus, .sheet textarea:focus {
  outline: 2px solid var(--ben); outline-offset: 1px; border-color: var(--ben);
}
.login-card button {
  margin-top: 8px; padding: 12px; border: none; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff; font-weight: 600; font-size: 15px;
}
.login-error { color: #b23b3b; font-size: 13px; text-align: center; }

/* ---------- Topbar ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.period-title {
  font-size: 20px; font-weight: 650; letter-spacing: -0.02em; text-transform: capitalize;
  white-space: nowrap;
}
.nav-arrows { display: flex; }
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 14px; font-weight: 550;
}
.btn.ghost { background: transparent; }
.btn.icon { width: 38px; height: 38px; padding: 0; font-size: 19px; display: grid; place-items: center; }
.nav-arrows .btn.icon { border-radius: 0; }
.nav-arrows .btn.icon:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.nav-arrows .btn.icon:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.btn.primary { background: var(--ink); color: #fff; border: none; }
.btn.danger { background: transparent; color: #b23b3b; border-color: #e4c4c4; }
.btn.full { width: 100%; margin-top: 8px; }

.viewswitch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.viewswitch button {
  border: none; background: transparent; color: var(--muted); padding: 6px 12px;
  border-radius: 6px; font-size: 13px; font-weight: 600;
}
.viewswitch button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.legend span { display: inline-flex; align-items: center; }

/* ---------- Calendar shell ---------- */
.calendar { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }

/* ---------- Month ---------- */
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: 1px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.month-head div { text-align: center; padding: 8px 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 650; }
/* The month fills the available height; weeks share it evenly but never squash
   below the space their bars need. */
.month-weeks {
  border-top: 1px solid var(--line); background: var(--line);
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.week { position: relative; display: flex; flex: 1 1 0; min-height: 0; overflow: hidden; }
.week + .week { margin-top: 1px; }
.week-cells {
  flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  column-gap: 1px; background: var(--line);
}
.day-cell { background: var(--surface); min-width: 0; overflow: hidden; padding: 3px 4px; display: flex; flex-direction: column; }
/* Bars sit above the cells and span several columns -> one continuous run.
   Same track sizing + gap as .week-cells so columns line up exactly. */
.week-bars {
  position: absolute; left: 0; right: 0; display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  column-gap: 1px; row-gap: 2px; pointer-events: none;
  overflow: hidden;
}
.week-bars .chip { pointer-events: auto; margin: 0 2px; height: calc(var(--lane-h) - 3px); display: flex; align-items: center; }
/* A bar with free rows beneath it grows downwards and shows the title over
   several lines, clamped to exactly the rows it owns (--lines). */
.week-bars .chip.wrap {
  display: block; white-space: normal; overflow: hidden;
  line-height: 1.18; padding-top: 2px; align-items: flex-start;
}
.week-bars .chip.wrap .txt {
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--lines, 2); line-clamp: var(--lines, 2);
  white-space: normal; overflow: hidden; text-overflow: ellipsis;
  overflow-wrap: anywhere;                 /* long words break instead of vanishing */
}
.day-cell.other { background: var(--surface-2); }
.day-cell .num { font-size: 13px; font-weight: 600; color: var(--muted); align-self: flex-start; padding: 2px 5px; border-radius: 999px; line-height: 1.4; }
.day-cell.other .num { color: var(--faint); }
.day-cell.today .num { background: var(--ben); color: #fff; }
.chip {
  font-size: var(--chip-fs); line-height: 1.25; padding: 2px 6px; border-radius: 5px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  border-left: 3px solid rgba(0,0,0,.18);
  max-width: 100%; min-width: 0; flex: 0 0 auto;
}
/* Multi-day: square off the joined edges so the run reads as one bar */
.chip.cont-l { border-radius: 0 5px 5px 0; border-left: none; margin-left: 0 !important; }
.chip.cont-r { border-radius: 5px 0 0 5px; margin-right: 0 !important; }
.chip.cont-l.cont-r { border-radius: 0; border-left: none; }
.chip .arrow { opacity: .85; margin-right: 3px; font-weight: 700; flex: 0 0 auto; }
.chip .t { flex: 0 0 auto; }
.chip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip .arrow.right { margin: 0 0 0 auto; padding-left: 3px; }
.chip .t { opacity: .85; font-variant-numeric: tabular-nums; margin-right: 4px; }
.chip.allday { border-radius: 5px; }
.more { font-size: 11px; color: var(--muted); padding: 1px 4px; cursor: pointer; font-weight: 600; }

/* ---------- Time grid (week/day) ---------- */
.timegrid { display: grid; grid-template-columns: 52px 1fr; }
.tg-allday { display: grid; grid-template-columns: 52px 1fr; border-bottom: 1px solid var(--line-strong); background: var(--surface); position: sticky; top: 0; z-index: 3; }
.tg-allday .label { font-size: 10px; color: var(--faint); padding: 6px 4px; text-align: right; text-transform: uppercase; letter-spacing: .06em; }
.tg-allday-cells { display: grid; }
.tg-colhead { display: grid; position: sticky; top: 0; z-index: 3; background: var(--bg); }
.tg-colhead .spacer { }
.tg-colhead .dh { text-align: center; padding: 6px 2px; border-left: 1px solid var(--line); }
.tg-colhead .dh .dow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.tg-colhead .dh .dnum { font-size: 17px; font-weight: 650; }
.tg-colhead .dh.today .dnum { color: var(--ben); }
.tg-body { position: relative; }
.tg-hours { position: relative; }
.tg-hour { height: 48px; border-top: 1px solid var(--line); position: relative; }
.tg-hour .h { position: absolute; left: -48px; top: -7px; width: 44px; text-align: right; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tg-cols { position: absolute; inset: 0; display: grid; }
.tg-col { border-left: 1px solid var(--line); position: relative; min-width: 0; }
.tg-event {
  position: absolute; left: 2px; right: 2px; min-width: 0; border-radius: 6px; color: #fff; padding: 3px 6px;
  font-size: 11.5px; overflow: hidden; cursor: pointer; border-left: 3px solid rgba(0,0,0,.2);
}
.tg-event .tt { font-weight: 600; }
.tg-event .tm { opacity: .9; font-variant-numeric: tabular-nums; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #d64545; z-index: 4; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #d64545; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--ink); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: var(--shadow); z-index: 20;
}

/* ---------- Sheets & modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(24,28,25,.42); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow); padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow: auto;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 3px; background: var(--line-strong); margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 18px; letter-spacing: -0.01em; }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
.sheet label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.field-title { font-size: 17px !important; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--ink) !important; font-size: 14px !important; }
.row-check input { width: 18px; height: 18px; }
.who { display: flex; flex-wrap: wrap; gap: 8px; }
.who button {
  flex: 1 1 28%; min-width: 90px; border: 1.5px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm);
  padding: 9px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 7px;
}
.who button .dot { width: 11px; height: 11px; border-radius: 3px; }
.who button.sel { color: var(--ink); border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.who button.sel::after {
  content: "✓"; font-size: 11px; font-weight: 700; margin-left: 2px; opacity: .8;
}
.who-hint { font-size: 11.5px; color: var(--faint); margin-top: -4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .primary { flex: 1; padding: 13px; font-size: 15px; }
.sheet-actions .danger { padding: 13px 16px; }
.account-name { font-size: 15px; margin-bottom: 8px; }
.account-name b { font-weight: 650; }
.account-msg { font-size: 13px; }
.account-msg.ok { color: var(--ben); }
.account-msg.err { color: #b23b3b; }
#password-form h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13.5px; z-index: 60;
  box-shadow: var(--shadow);
}

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
  .day-cell { min-height: 120px; }
  .period-title { font-size: 24px; }
  .fab { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: slideup .22s ease; }
  .chip, .tg-event { transition: filter .12s ease; }
  .chip:active, .tg-event:active { filter: brightness(.92); }
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---------- Offline / sync ---------- */
.netbar {
  padding: 7px 14px; font-size: 12.5px; text-align: center; color: #fff; font-weight: 550;
  letter-spacing: -0.005em;
}
.netbar.off { background: #a8641d; }
.netbar.sync { background: var(--ben); }
/* Pending = created offline, not yet synced. The horizontal hatching itself is
   applied inline (JS) so it layers correctly over multi-person stripes. */
.chip.pending, .tg-event.pending { opacity: .62; }

/* ---------- Password field with eye toggle ---------- */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 42px !important; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; padding: 0; border: none; background: transparent;
  color: var(--faint); display: grid; place-items: center; border-radius: 8px;
}
.pw-eye svg { width: 20px; height: 20px; display: block; }
.pw-eye.on { color: var(--ben); }
.pw-eye:hover { color: var(--muted); }
.pw-eye:focus-visible { outline: 2px solid var(--ben); outline-offset: 1px; }

/* ---------- Date range picker ---------- */
.range { display: flex; flex-direction: column; gap: 10px; }
.range-chips { display: flex; align-items: center; gap: 8px; }
.range-arrow { color: var(--faint); font-size: 15px; }
.date-chip {
  flex: 1; padding: 9px 10px; border: 1.5px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; color: var(--ink);
  text-align: center; position: relative;
}
.date-chip.active { border-color: var(--ben); color: var(--ben); box-shadow: inset 0 0 0 1px var(--ben); }
.date-chip[data-days]:not([data-days=""])::after {
  content: attr(data-days); position: absolute; top: -7px; right: 6px;
  background: var(--ben); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px;
}
.mini-cal { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; background: var(--surface-2); }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-label { font-size: 13.5px; font-weight: 650; text-transform: capitalize; }
.mini-nav {
  width: 30px; height: 30px; border: none; background: transparent; color: var(--muted);
  font-size: 18px; border-radius: 7px; display: grid; place-items: center;
}
.mini-nav:hover { background: var(--surface); color: var(--ink); }
.mini-dows { display: grid; grid-template-columns: repeat(7, 1fr); }
.mini-dows div { text-align: center; font-size: 10px; color: var(--faint); font-weight: 700; padding-bottom: 3px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px 0; }
.mini-day {
  aspect-ratio: 1; border: none; background: transparent; color: var(--ink);
  font-size: 12.5px; font-weight: 550; font-variant-numeric: tabular-nums;
  display: grid; place-items: center; position: relative;
}
.mini-day.other { color: var(--faint); }
.mini-day.today { font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.mini-day.in { background: color-mix(in srgb, var(--ben) 16%, transparent); border-radius: 0; }
.mini-day.edge { background: var(--ben); color: #fff; font-weight: 700; }
.mini-day.edge.start { border-radius: 7px 0 0 7px; }
.mini-day.edge.end { border-radius: 0 7px 7px 0; }
.mini-day.edge.start.end { border-radius: 7px; }
.mini-day:focus-visible { outline: 2px solid var(--ben); outline-offset: -2px; }

/* ---------- Compact metrics on narrow screens ---------- */
@media (max-width: 430px) {
  :root { --num-h: 22px; --lane-h: 19px; --chip-fs: 10.5px; }
  .day-cell .num { font-size: 12px; padding: 1px 4px; }
  .chip { font-size: var(--chip-fs); padding: 1px 5px; }
  .month-head div { font-size: 10px; padding: 6px 0; }
  .legend { gap: 4px 12px; font-size: 11.5px; padding: 6px 12px; }
  .topbar { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .period-title { font-size: 17px; }
  .btn { padding: 7px 10px; font-size: 13px; }
  .btn.icon { width: 34px; height: 34px; font-size: 17px; }
  .viewswitch button { padding: 5px 9px; font-size: 12px; }
}
@media (max-width: 360px) {
  :root { --lane-h: 18px; --chip-fs: 10px; }
  .chip { font-size: var(--chip-fs); }
}

/* ---------- Read-only event (created by someone else) ---------- */
.readonly-note {
  background: #fdf3e3; border: 1px solid #ecd9b5; color: #8a6320;
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 4px;
}
form.readonly input, form.readonly select, form.readonly textarea {
  background: var(--surface-2); color: var(--muted); cursor: default;
}
form.readonly .who button, form.readonly .date-chip, form.readonly .mini-day, form.readonly .mini-nav {
  opacity: .75; cursor: default;
}
form.readonly .who button.sel { opacity: 1; }
form.readonly .mini-day.in, form.readonly .mini-day.edge { opacity: 1; }

/* ---------- Notification preferences ---------- */
.prefs { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.prefs h3 { font-size: 13px; color: var(--muted); font-weight: 600; }
.prefs .row-check { font-size: 13.5px !important; }

.ver { font-size: 11px; color: var(--faint); background: var(--surface-2); border: 1px solid var(--line);
       padding: 1px 6px; border-radius: 999px; margin-left: 6px; font-weight: 600; }

/* ---------- Push notifications ---------- */
.push-row { display: flex; gap: 8px; }
.push-row .btn { flex: 1; }
.push-status { font-size: 12.5px; color: var(--muted); margin-top: -4px; }

/* ---------- Interactive legend ---------- */
.legend .leg, .legend .leg-all {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent;
  font: inherit; font-size: 12.5px; color: var(--muted); padding: 3px 4px; border-radius: 6px; cursor: pointer;
}
.legend .leg .dot { width: 10px; height: 10px; border-radius: 3px; }
.legend .leg.off { opacity: .4; }
.legend .leg.off .dot { box-shadow: inset 0 0 0 2px var(--surface); background: var(--line-strong) !important; }
.legend .leg.off span:last-child { text-decoration: line-through; }
.legend .leg-all { color: var(--ben); font-weight: 600; }

/* ---------- Colour picker ---------- */
.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.swatch { aspect-ratio: 1; border: 2px solid transparent; border-radius: 10px; cursor: pointer; }
.swatch.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
.color-custom-row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.color-custom-row input[type=color] { width: 52px; height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; background: none; }

/* ---------- Shift generator ---------- */
#shift-form { display: flex; flex-direction: column; gap: 12px; }
.series-list { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.series-list h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.series-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; }
.series-row .series-meta { font-size: 12px; color: var(--muted); }
.series-row .btn.danger { padding: 7px 12px; font-size: 13px; white-space: nowrap; }
#btn-shifts { margin-top: 4px; }

/* ---------- To-do list ---------- */
.viewswitch button.has-count { position: relative; }
.viewswitch button.has-count::after {
  content: attr(data-count);
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px;
  font-size: 10px; line-height: 15px; font-weight: 700; color: #fff; background: var(--ben);
  border-radius: 999px; text-align: center;
}
.todos { width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 10px 90px; box-sizing: border-box; }
.todo-quick { display: flex; gap: 8px; margin-bottom: 6px; }
.todo-quick input {
  flex: 1; padding: 13px 14px; font-size: 15px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface);
}
.todo-quick button { width: 48px; font-size: 22px; flex: none; }
.todo-hint { font-size: 11.5px; color: var(--faint); margin: 0 2px 12px; }
.todo-empty { text-align: center; color: var(--muted); padding: 32px 12px; }

.todo-list { display: flex; flex-direction: column; gap: 2px; }
.todo-list.done { opacity: .72; }
.todo-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 8px;
  border-bottom: 1px solid var(--line); border-radius: 8px;
}
.todo-row.pending { opacity: .55; }
.todo-check {
  flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 999px;
  border: 2px solid var(--line-strong); background: var(--surface); color: #fff;
  font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.todo-row.done .todo-check { background: var(--ben); border-color: var(--ben); }
.todo-main { flex: 1; min-width: 0; cursor: pointer; }
.todo-text { font-size: 15px; color: var(--ink); word-break: break-word; }
.todo-row.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 5px; }
.todo-due {
  font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); padding: 1px 8px; border-radius: 999px;
}
.todo-due.today { color: #fff; background: var(--ben); border-color: var(--ben); }
.todo-due.overdue { color: #fff; background: #b23b3b; border-color: #b23b3b; }
.todo-prio { font-size: 12px; font-weight: 800; color: #d4952b; letter-spacing: -1px; }
.todo-prio.p3 { color: #b23b3b; }
.todo-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.todo-done-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: none; border: none; font: inherit; cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 16px 6px 8px; margin-top: 6px;
}
.todo-done-head .todo-clear { color: #b23b3b; font-weight: 600; }
#todo-form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Shopping list ---------- */
.viewswitch { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.viewswitch::-webkit-scrollbar { display: none; }
.viewswitch button { white-space: nowrap; }
.shop-cat {
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; padding: 14px 6px 4px; border-bottom: 1px solid var(--line);
}
.shop-edit {
  flex: none; border: none; background: transparent; color: var(--faint);
  font-size: 16px; padding: 4px 8px; cursor: pointer;
}

/* ---------- Weekly meals ---------- */
.meal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.meal-range { font-weight: 650; color: var(--ink); font-size: 15px; }
.meal-day { display: flex; gap: 10px; align-items: stretch; padding: 7px 0; border-bottom: 1px solid var(--line); }
.meal-day.today .meal-day-label { color: var(--ben); font-weight: 800; }
.meal-day-label { flex: none; width: 58px; font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 10px; }
.meal-cells { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meal-cell {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  border: 1px dashed var(--line-strong); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 10px; cursor: pointer; font: inherit; min-height: 52px;
  position: relative;
}
.meal-cell.filled { border-style: solid; background: var(--surface-2); }
.meal-cell .meal-slot { font-size: 10.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; }
.meal-cell .meal-what { font-size: 13.5px; color: var(--ink); word-break: break-word; }
.meal-cell:not(.filled) .meal-what { color: var(--faint); font-size: 18px; }

/* Meal sheet: three compact actions on one row */
#meal-form .sheet-actions { flex-wrap: wrap; }
#meal-form .sheet-actions .btn { flex: 1; white-space: nowrap; padding: 12px 8px; font-size: 13.5px; }

/* ---------- Recipe picker ---------- */
.field-with-btn { display: flex; gap: 8px; align-items: center; }
.field-with-btn input { flex: 1; }
.field-with-btn .btn.ghost { flex: none; padding: 10px 12px; font-size: 18px; }
.recipes-list { max-height: 55vh; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.recipe-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  border: none; border-bottom: 1px solid var(--line); background: transparent; font: inherit;
  padding: 11px 6px; cursor: pointer; width: 100%;
}
.recipe-item:hover, .recipe-item:active { background: var(--surface-2); }
.recipe-name { font-size: 15px; color: var(--ink); font-weight: 600; }
.recipe-fam { color: var(--ben); }
.recipe-ings { font-size: 12px; color: var(--muted); }

/* ---------- Meals: courses ---------- */
.meal-suggest-week { width: 100%; margin-bottom: 12px; }
.meal-cells.one { grid-template-columns: 1fr; }
.meal-cell { gap: 3px; }
.meal-course { font-size: 13px; color: var(--ink); word-break: break-word; line-height: 1.25; }
.meal-course.entree, .meal-course.dessert { font-size: 11.5px; color: var(--muted); }
.meal-course.plat { font-weight: 650; }
.meal-course.entree::before { content: '· '; color: var(--faint); }
.meal-course.dessert::before { content: '· '; color: var(--faint); }
/* Meal sheet: one scroll area (the form), sized to the *visible* viewport.
   dvh follows the mobile browser bars; vh is the fallback for older engines. */
#meal-sheet {
  display: flex; flex-direction: column;
  max-height: 90vh; max-height: 90dvh;
  overflow: hidden;                       /* the form scrolls, not the sheet */
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
#meal-sheet .sheet-handle, #meal-sheet .sheet-head { flex: none; }
#meal-form {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding-right: 2px;
}
#meal-form .sheet-actions {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--surface); padding: 10px 0 2px; margin-top: 8px;
  box-shadow: 0 -8px 12px -8px rgba(0,0,0,.18);
}
/* Recipe picker: same treatment */
#recipes-sheet { display: flex; flex-direction: column; max-height: 88vh; max-height: 88dvh; overflow: hidden;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
#recipes-sheet .sheet-handle, #recipes-sheet .sheet-head, #recipes-search, #recipes-sheet .who-hint { flex: none; }
.recipes-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Servings control */
.servings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0 2px; border-bottom: 1px solid var(--line); }
.servings-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.servings-ctl { display: flex; align-items: center; gap: 6px; }
.servings-ctl .btn.icon { width: 34px; height: 34px; font-size: 18px; line-height: 1; }
#meal-servings { width: 54px; text-align: center; font-size: 16px; font-weight: 650; padding: 7px 4px; }
.course { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.course:first-of-type { border-top: none; }
.course-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.course textarea { width: 100%; margin-top: 6px; }

/* ---------- Meals: delete crosses & actions ---------- */
.meal-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.meal-actions .btn.primary { flex: 1; }
.btn.ghost.danger { color: #b23b3b; border: 1px solid var(--line-strong); white-space: nowrap; }
.meal-cell { position: relative; }
.meal-x {
  border: none; background: transparent; color: var(--faint); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 6px;
}
.meal-x:hover, .meal-x:active { color: #b23b3b; background: rgba(178,59,59,.1); }
.cell-x { position: absolute; top: 4px; right: 4px; }
.meal-day-label { display: flex; align-items: center; gap: 4px; }
.day-x { font-size: 11px; opacity: .6; }

/* ---------- Meals: emoji & favourites ---------- */
.meal-course { display: flex; align-items: baseline; gap: 4px; }
.mc-emoji { font-size: 13px; flex: none; }
.meal-course.entree .mc-emoji, .meal-course.dessert .mc-emoji { font-size: 12px; }
.meal-course.entree::before, .meal-course.dessert::before { content: none; }

/* Recipe picker rows with emoji + star */
.recipe-item { display: flex; flex-direction: row; align-items: stretch; gap: 4px; border-bottom: 1px solid var(--line); padding: 0; }
.recipe-star {
  flex: none; border: none; background: transparent; cursor: pointer; font-size: 20px;
  color: var(--faint); padding: 0 8px; line-height: 1;
}
.recipe-star.on { color: #e0a400; }
.recipe-main {
  flex: 1; display: flex; align-items: center; gap: 10px; text-align: left;
  border: none; background: transparent; font: inherit; padding: 11px 4px; cursor: pointer; min-width: 0;
}
.recipe-emoji { font-size: 22px; flex: none; }
.recipe-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recipe-item:hover .recipe-main, .recipe-item:active .recipe-main { background: var(--surface-2); }

/* Ingredient boxes auto-grow: no inner scroll (was stealing the sheet's scroll) */
.course textarea { resize: none; overflow: hidden; min-height: 44px; }

/* Narrow screens: let the dish input shrink instead of pushing buttons off-screen */
.field-with-btn { flex-wrap: nowrap; }
.field-with-btn input { min-width: 0; }
.field-with-btn .btn.ghost { padding: 10px; font-size: 16px; }
@media (max-width: 380px) {
  .field-with-btn { gap: 5px; }
  .field-with-btn .btn.ghost { padding: 9px 7px; font-size: 15px; }
  .servings-label { font-size: 11.5px; }
}

/* Shopping: wipe-all control */
.shop-tools { display: flex; justify-content: flex-end; margin: 6px 0 2px; }
.shop-tools .btn.ghost.danger { font-size: 12.5px; padding: 7px 10px; }

/* Menu planner: per-day and per-meal suggestion buttons */
.day-sug { font-size: 12px; opacity: .75; }
.cell-sug { position: absolute; top: 4px; right: 26px; font-size: 12px; opacity: .75; }
.meal-cell:not(.filled) .cell-sug { right: 4px; }
.meal-x.day-sug:hover, .meal-x.cell-sug:hover { color: var(--ben); background: rgba(0,0,0,.06); }

/* ---------------------------------------------- Jours feries & vacances scolaires
   Le fond de la case porte l'information ; les barres d'evenements restent
   lisibles par-dessus, donc les teintes sont volontairement tres pales. */
.day-cell { position: relative; }
.day-cell.ferie { background: #fdf3e3; }
.day-cell.ferie.other { background: #faeedd; }
.day-cell.vac { background: #eef5f4; }
.day-cell.vac.other { background: #e8f0ef; }
.dtag {
  position: absolute; top: 3px; right: 4px; max-width: calc(100% - 26px);
  font-size: 9px; line-height: 1.25; letter-spacing: .01em; font-weight: 650;
  color: var(--faint); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}
.dtag.f { color: #b07a2b; }

.tg-colhead .dh.ferie { background: #fdf3e3; }
.tg-colhead .dh.vac { background: #eef5f4; }
.tg-colhead .dh .dh-tag {
  font-size: 9.5px; color: var(--faint); font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tg-colhead .dh.ferie .dh-tag { color: #b07a2b; }

/* ---------------------------------------------- Anniversaires */
.sheet-sub {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 650; margin: 14px 0 2px;
}
.grid3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; }
.bday-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.bday-list:empty { background: none; }
.bday-list .who-hint { background: var(--surface); padding: 12px; margin: 0; }
.bday-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 12px; border: none; background: var(--surface);
  font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer;
}
.bday-row:active { background: var(--surface-2); }
.bday-row .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.bday-row .bd-name { font-weight: 600; }
.bday-row .bd-when { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* =====================================================================
   v40 — Coquille responsive
   Deux cibles prioritaires : le telephone (barre d'onglets en bas, au
   pouce) et la tablette murale en paysage (barre laterale permanente).
   Le point de bascule est 900px : en dessous on est au pouce, au-dessus
   on a la place d'une colonne de navigation fixe.
   ===================================================================== */

.app { display: flex; flex-direction: column; height: 100dvh; }
.main { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }

/* ---------- Navigation laterale (masquee par defaut) ---------- */
.sidenav { display: none; }
.sidenav .brand {
  display: flex; align-items: center; gap: 9px; padding: 4px 6px 14px;
  font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em;
}
.sidenav .brand-mark { color: var(--ben); font-size: 17px; line-height: 1; }
.navlist { display: flex; flex-direction: column; gap: 2px; }
.navitem {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 11px; border: none; background: transparent; border-radius: 10px;
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--muted);
  text-align: left; cursor: pointer;
}
.navitem .ic { display: flex; width: 20px; height: 20px; flex: 0 0 auto; }
.navitem .ic svg { width: 100%; height: 100%; }
.navitem:hover { background: var(--surface-2); color: var(--ink); }
.navitem.active { background: var(--surface-2); color: var(--ink); }
.navitem.active .ic { color: var(--ben); }
.sidenav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.sidenav-foot .legend { padding: 6px 2px; background: none; border: none; flex-direction: column; gap: 7px; }
.ver { font-size: 11px; color: var(--faint); padding: 8px 2px 0; }

/* ---------- Barre d'onglets telephone ---------- */
.tabbar {
  display: flex; align-items: stretch; background: var(--surface);
  border-top: 1px solid var(--line); flex: 0 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 8px 2px 7px; border: none; background: transparent;
  font: inherit; font-size: 10.5px; font-weight: 600; color: var(--faint); cursor: pointer;
}
.tab .ic { width: 22px; height: 22px; }
.tab .ic svg { width: 100%; height: 100%; }
.tab .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tab.active { color: var(--ben); }
/* Pastille de taches en retard/ouvertes, reprise de l'ancien .has-count */
.tab.has-count .ic, .navitem.has-count .ic { position: relative; }
.tab.has-count .ic::after, .navitem.has-count .ic::after {
  content: attr(data-count);
  position: absolute; top: -4px; right: -7px; min-width: 15px; height: 15px; padding: 0 3px;
  font-size: 10px; line-height: 15px; font-weight: 700; color: #fff; background: var(--ben);
  border-radius: 999px; text-align: center;
}

/* Le bouton + ne doit pas passer sous la barre d'onglets */
.fab { bottom: calc(74px + env(safe-area-inset-bottom)); }

/* ---------- Ecran Reglages ---------- */
.settings { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); }
.settings-inner { max-width: 720px; margin: 0 auto; padding: 14px 14px 40px; display: flex; flex-direction: column; gap: 14px; }
.settings .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px 16px; display: flex; flex-direction: column; gap: 11px; margin: 0;
}
.settings fieldset.card { border: 1px solid var(--line); }
.settings .card legend, .settings .card > h3:first-child {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 700; padding: 0; margin-bottom: 2px;
}
.settings .card h3 { font-size: 13px; color: var(--muted); font-weight: 650; margin-top: 6px; }
.settings .card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.settings .prefs { display: flex; flex-direction: column; gap: 14px; border: none; padding: 0; margin: 0; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-actions .primary { margin-left: auto; }
.card-actions .account-msg { margin: 0; }
.settings .btn.full { width: 100%; }

/* =====================================================================
   Tablette murale en paysage et ordinateur
   ===================================================================== */
@media (min-width: 900px) {
  .app { flex-direction: row; }
  .tabbar { display: none; }
  .sidenav {
    display: flex; flex-direction: column; width: 232px; flex: 0 0 232px;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: max(14px, env(safe-area-inset-top)) 12px 14px; overflow-y: auto;
  }
  /* La legende passe dans la colonne : elle ferait doublon en haut du contenu */
  .main > .legend { display: none; }
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .fab { bottom: 28px; right: 28px; }

  /* Les feuilles cessent de coller au bas de l'ecran : sur grand ecran une
     modale centree est plus lisible qu'un panneau pleine largeur. */
  .sheet {
    left: 50%; top: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    width: min(580px, 92vw); border-radius: 16px;
    max-height: 88dvh; padding: 18px 22px 22px;
  }
  .sheet-handle { display: none; }
  .settings-inner { padding: 22px 22px 48px; }
}

/* Grand ecran : on borne la largeur du calendrier pour eviter des cases
   demesurement etirees, sans jamais deborder. */
@media (min-width: 1500px) {
  .main > .topbar, .calendar { max-width: 1400px; width: 100%; margin-inline: auto; }
}

/* =====================================================================
   Tablette murale en portrait / petite tablette : la barre d'onglets
   reste, mais on profite de la hauteur.
   ===================================================================== */
@media (min-width: 600px) and (max-width: 899px) {
  .tab { flex-direction: row; gap: 8px; font-size: 13px; padding: 11px 4px; }
  .tab .ic { width: 19px; height: 19px; }
  .settings-inner { padding: 18px 20px 40px; }
}

/* Ecran tactile mural : cibles plus grandes, on tape de loin et debout. */
@media (min-width: 900px) and (pointer: coarse) {
  .navitem { padding: 13px 12px; font-size: 15.5px; }
  .viewswitch button { padding: 9px 16px; font-size: 14px; }
  .btn { min-height: 42px; }
}

/* =====================================================================
   v41 — La barre de navigation ne doit JAMAIS disparaitre
   Deux causes possibles auparavant :
   1. `html, body` pouvaient defiler : quelques pixels de scroll du document
      suffisaient a faire sortir la barre du bas de l'ecran.
   2. `100dvh` change de valeur quand la barre d'URL du navigateur se
      retracte, ce qui decalait le bas de l'application.
   On bloque tout defilement du document : seuls les panneaux interieurs
   defilent, et la barre reste ancree.
   ===================================================================== */
html, body { height: 100%; overflow: hidden; }
.app { height: 100%; }
.tabbar { position: relative; z-index: 25; }

/* La barre laterale apparait des la tablette, portrait compris, au lieu
   d'attendre 900px : sur une tablette murale le menu est ainsi toujours
   affiche en entier, sans dependre de l'orientation. */
@media (min-width: 780px) {
  .app { flex-direction: row; }
  .tabbar { display: none; }
  .sidenav {
    display: flex; flex-direction: column; width: 216px; flex: 0 0 216px;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: max(14px, env(safe-area-inset-top)) 11px 14px; overflow-y: auto;
  }
  .main > .legend { display: none; }
  .fab { bottom: 28px; right: 28px; }
}
@media (min-width: 780px) and (max-width: 899px) {
  .sidenav { width: 190px; flex: 0 0 190px; }
  .navitem { font-size: 13.5px; padding: 9px 10px; }
}

/* ---------------------------------------------- Meteo */
.dh-wx { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 11px; line-height: 1.3; }
.dh-wx .ico { font-size: 12.5px; }
.dh-wx b { font-weight: 700; color: var(--ink); }
.dh-wx span { color: var(--faint); }
.weather-now { font-size: 14px; color: var(--ink); }
.weather-now .muted { color: var(--muted); font-size: 12.5px; }
.wx-results { display: flex; flex-direction: column; gap: 1px; }
.wx-results:not(:empty) { background: var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.wx-opt {
  display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 10px 12px;
  border: none; background: var(--surface); font: inherit; font-size: 14px;
  color: var(--ink); text-align: left; cursor: pointer;
}
.wx-opt:active { background: var(--surface-2); }
.wx-opt .det { color: var(--muted); font-size: 12.5px; }

/* =====================================================================
   v42 — Meteo : en-tete non tronque + detail horaire
   En vue Semaine une colonne fait ~50px sur telephone : icone et
   temperatures sur une seule ligne debordaient. On empile.
   ===================================================================== */
.dh-wx {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  line-height: 1.25; cursor: pointer; padding: 1px 0 0;
}
.dh-wx .ico { font-size: 13px; }
.dh-wx .t { display: flex; align-items: baseline; gap: 3px; font-size: 10.5px; white-space: nowrap; }
.dh-wx .t b { font-weight: 700; color: var(--ink); }
.dh-wx .t span { color: var(--faint); }
.dh-wx:active { opacity: .6; }
/* Des qu'il y a de la place (vue Jour, tablette), on remet tout en ligne. */
@media (min-width: 780px) {
  .dh-wx { flex-direction: row; gap: 5px; }
  .dh-wx .ico { font-size: 14px; }
  .dh-wx .t { font-size: 11.5px; }
}

.wx-hours { display: flex; flex-direction: column; gap: 1px; background: var(--line);
  border-radius: var(--radius-sm); overflow: hidden; max-height: 58dvh; overflow-y: auto; }
.wx-h {
  display: grid; grid-template-columns: 46px 26px 1fr 52px; align-items: center;
  gap: 8px; padding: 8px 12px; background: var(--surface); font-size: 13.5px;
}
.wx-h.now { background: #f3f7f6; }
.wx-h .hh { color: var(--muted); font-variant-numeric: tabular-nums; }
.wx-h.now .hh { color: var(--ben); font-weight: 700; }
.wx-h .ic { font-size: 15px; }
.wx-h .tp { font-weight: 650; font-variant-numeric: tabular-nums; }
.wx-h .rn { display: flex; align-items: center; gap: 5px; justify-content: flex-end;
  font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.wx-h .bar { width: 26px; height: 4px; border-radius: 2px; background: var(--line-strong); overflow: hidden; }
.wx-h .bar i { display: block; height: 100%; background: #4a8fd4; }

/* =====================================================================
   v43 — En-tete compact hors agenda
   Taches / Courses / Menus / Reglages n'ont ni fleches de navigation ni
   bouton « Aujourd'hui » : les masquer avec `visibility` reservait leur
   place et donnait une barre aussi haute que celle de l'agenda, remplie
   de vide. On les retire du flux et on reduit les marges.
   ===================================================================== */
.app.noncal .nav-arrows,
.app.noncal #btn-today,
.app.noncal .viewswitch { display: none; }

.app.noncal .topbar {
  padding-top: max(7px, env(safe-area-inset-top));
  padding-bottom: 7px;
  flex-wrap: nowrap;
}
.app.noncal .period-title { font-size: 17px; }

@media (min-width: 780px) {
  .app.noncal .period-title { font-size: 19px; }
}

/* =====================================================================
   v43 — Page Recettes
   ===================================================================== */
.rc-bar { display: flex; flex-direction: column; gap: 10px; }
.rc-courses { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.rc-courses button {
  flex: 1 1 0; padding: 9px 6px; border: none; background: transparent; border-radius: 8px;
  font: inherit; font-size: 13.5px; font-weight: 650; color: var(--muted); cursor: pointer;
}
.rc-courses button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#rc-search {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 14.5px; background: var(--surface); color: var(--ink);
}
#rc-count { margin: 0; }

.rc-list { display: flex; flex-direction: column; gap: 1px; background: var(--line);
  border-radius: var(--radius-sm); overflow: hidden; }
.rc-list:empty { background: none; }
.rc-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 13px;
  border: none; background: var(--surface); font: inherit; font-size: 14.5px;
  color: var(--ink); text-align: left; cursor: pointer;
}
.rc-row:active { background: var(--surface-2); }
.rc-row .em { font-size: 17px; flex: 0 0 auto; }
.rc-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-row .ing { color: var(--faint); font-size: 12px; }
/* Etiquette de provenance : « base » n'est pas modifiable directement, une
   modification cree une copie personnalisee. */
.rc-row .src {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); color: var(--faint);
}
.rc-row .src.fam { background: #e8f0ef; color: #2f6f6a; }
.rc-row .fav { flex: 0 0 auto; font-size: 14px; }
.rc-empty { background: var(--surface); padding: 18px 14px; text-align: center; color: var(--muted); font-size: 14px; }
#rc-form textarea {
  font: inherit; font-size: 14.5px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); resize: vertical;
  line-height: 1.5;
}

/* =====================================================================
   v44 — Plats mis de cote
   Une case a cocher par plat dans le selecteur des menus : decochee, le
   plat n'est plus propose automatiquement ni liste ici.
   ===================================================================== */
.recipe-keep {
  flex: 0 0 auto; width: 22px; height: 22px; margin-right: 2px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); cursor: pointer; padding: 0;
  font-size: 13px; line-height: 1; color: #fff;
}
.recipe-keep.on { background: var(--ben); border-color: var(--ben); }
.recipe-item.is-hidden { opacity: .5; }
.recipe-item.is-hidden .recipe-name { text-decoration: line-through; }
#recipes-showhidden { margin-top: 10px; }

/* Page Recettes : signaler les plats mis de cote */
.rc-row .src.off { background: #f3e4e4; color: #b23b3b; }
.rc-row.is-hidden .nm { opacity: .6; text-decoration: line-through; }

/* Page Recettes : la case a cocher est hors de la ligne cliquable, sinon
   toucher la case ouvrirait aussi la fiche d'edition. */
.rc-line { display: flex; align-items: stretch; background: var(--surface); }
.rc-line .recipe-keep { align-self: center; margin: 0 0 0 11px; }
.rc-line .rc-row { flex: 1; min-width: 0; }

/* =====================================================================
   v47 — Reglages en sections repliables
   <details>/<summary> natifs : aucun JavaScript, fonctionne hors ligne,
   accessible au clavier et aux lecteurs d'ecran.
   ===================================================================== */
.settings details.card { padding: 0; gap: 0; display: block; }
.settings details.card > summary {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 16px; cursor: pointer; list-style: none;
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 700; user-select: none;
}
.settings details.card > summary::-webkit-details-marker { display: none; }
/* Chevron : tourne a l'ouverture */
.settings details.card > summary::before {
  content: ''; flex: 0 0 auto; width: 7px; height: 7px; margin-right: 1px;
  border-right: 2px solid var(--line-strong); border-bottom: 2px solid var(--line-strong);
  transform: rotate(-45deg); transition: transform .18s ease;
}
.settings details.card[open] > summary::before { transform: rotate(45deg); }
.settings details.card[open] > summary { color: var(--ink); border-bottom: 1px solid var(--line); }
.settings details.card > summary:hover { background: var(--surface-2); }
/* Le contenu de la section reprend les marges d'une carte */
.settings details.card > *:not(summary) { margin-left: 16px; margin-right: 16px; }
.settings details.card > *:first-of-type:not(summary) { margin-top: 13px; }
.settings details.card > *:last-child:not(summary) { margin-bottom: 16px; }
.settings details.card > .grid2,
.settings details.card > .grid3 { margin-top: 11px; }
.settings details.card > .card-actions { margin-top: 13px; margin-bottom: 16px; }
.settings form > details.card { margin: 0; }

/* Cible tactile confortable sur tablette murale */
@media (pointer: coarse) {
  .settings details.card > summary { padding: 16px; }
}

/* =====================================================================
   v48 — Stock de la maison
   ===================================================================== */
.stock-actions { display: flex; gap: 9px; }
.stock-actions .btn { flex: 1; }
.stock-urgent {
  background: #fdf3e3; border: 1px solid #f0dcb8; border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 13.5px; color: #8a5d18; line-height: 1.5;
}
.stock-urgent b { color: #6d4711; }

.st-line { display: flex; align-items: stretch; background: var(--surface); }
.st-row {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  padding: 11px 13px; border: none; background: transparent; font: inherit;
  font-size: 14.5px; color: var(--ink); text-align: left; cursor: pointer;
}
.st-row:active { background: var(--surface-2); }
.st-row .pt { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.st-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-row .qt { flex: 0 0 auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.st-row .ex { flex: 0 0 auto; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
/* Code couleur : c'est l'information principale d'un stock */
.st-row.perime  .pt { background: #b23b3b; } .st-row.perime  .ex { color: #b23b3b; }
.st-row.urgent  .pt { background: #d1791f; } .st-row.urgent  .ex { color: #d1791f; }
.st-row.bientot .pt { background: #c9a227; } .st-row.bientot .ex { color: #a8861a; }
.st-row.ok      .ex { color: var(--faint); font-weight: 500; }
.st-row.inconnu .ex { color: var(--faint); font-weight: 500; }
.st-row.perime .nm { text-decoration: line-through; opacity: .75; }
/* Bouton « j'en ai utilisé un » */
.st-use {
  flex: 0 0 auto; width: 40px; border: none; border-left: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 17px; cursor: pointer;
}
.st-use:active { background: var(--surface-2); }

/* Scan */
.scan-view { position: relative; width: 100%; aspect-ratio: 4/3; background: #000;
  border-radius: var(--radius-sm); overflow: hidden; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 22% 12%; border: 2px solid rgba(255,255,255,.9);
  border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
}

/* ---------------------------------------------- Commande vocale */
.voc-mic { display: flex; align-items: center; justify-content: center; padding: 18px 0 6px; }
.voc-dot {
  width: 68px; height: 68px; border-radius: 50%; background: var(--surface-2);
  display: block; position: relative; transition: background .2s;
}
.voc-dot::after {
  content: '🎙'; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 28px;
}
.voc-mic.on .voc-dot { background: #e8f0ef; animation: voc-pulse 1.3s ease-in-out infinite; }
@keyframes voc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47,111,106,.35); }
  50%      { box-shadow: 0 0 0 14px rgba(47,111,106,0); }
}
.voc-state { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 4px; }
.voc-heard {
  background: var(--surface-2); border-radius: 10px; padding: 10px 12px;
  font-size: 14.5px; color: var(--ink); font-style: italic; margin: 0;
}
.voc-props { display: flex; flex-direction: column; gap: 1px; background: var(--line);
  border-radius: var(--radius-sm); overflow: hidden; }
.voc-props:empty { background: none; }
.voc-prop {
  display: flex; align-items: center; gap: 9px; padding: 11px 13px;
  background: var(--surface); font-size: 14.5px;
}
.voc-prop .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voc-prop .mv { color: #b23b3b; font-weight: 650; font-variant-numeric: tabular-nums; }
.voc-prop input {
  width: 62px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px; text-align: right;
}
.voc-prop.warn { background: #fdf3e3; }
.voc-prop .rm { border: none; background: none; color: var(--faint); font-size: 17px; cursor: pointer; padding: 0 2px; }
.voc-unknown { background: var(--surface); padding: 10px 13px; font-size: 13px; color: #b23b3b; }

/* Conditionnement affiche sous le nom du produit */
.st-row .dt { color: var(--faint); font-size: 11.5px; font-weight: 400; }

/* Conditionnement dans la fiche d'un article du stock */
.st-cond { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0; }
.st-cond > summary {
  padding: 11px 13px; cursor: pointer; list-style: none;
  font-size: 12.5px; font-weight: 650; color: var(--muted);
}
.st-cond > summary::-webkit-details-marker { display: none; }
.st-cond > summary::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 8px;
  border-right: 2px solid var(--line-strong); border-bottom: 2px solid var(--line-strong);
  transform: rotate(-45deg); transition: transform .18s;
}
.st-cond[open] > summary::before { transform: rotate(45deg); }
.st-cond > *:not(summary) { margin: 0 13px 11px; }
.cond-row .bd-when { font-variant-numeric: tabular-nums; }

/* =====================================================================
   v52 — La barre d'actions reste visible quand le clavier s'ouvre
   Les feuilles defilent (overflow:auto) : en rendant la barre collante en
   bas, le bouton Enregistrer reste atteignable sans fermer le clavier.
   ===================================================================== */
.sheet-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding: 10px 0 4px;
  margin-top: 8px;
  z-index: 2;
}
/* Un lisere marque la separation quand du contenu passe dessous */
.sheet-actions::before {
  content: ''; position: absolute; left: -18px; right: -18px; top: 0;
  height: 1px; background: var(--line);
}

/* Croix de suppression totale d'un article du stock */
.st-del {
  flex: 0 0 auto; width: 38px; border: none; border-left: 1px solid var(--line);
  background: var(--surface); color: var(--faint); font-size: 14px; cursor: pointer;
}
.st-del:active { background: #f7ecec; color: #b23b3b; }

/* Repas deja envoyes aux courses */
.meal-cell.sent { background: #eef5f4; }
.meal-cell.sent::after {
  content: '\1F6D2'; position: absolute; top: 3px; right: 4px;
  font-size: 10px; opacity: .65;
}
.meal-sent-note { font-size: 12.5px; color: var(--ben); margin: 0; }

/* Ce qu'un menu suggere permet d'ecouler */
.meal-ecoule { font-size: 12.5px; color: #8a5d18; background: #fdf3e3;
  border-radius: 8px; padding: 8px 11px; margin: 0; }

/* =====================================================================
   v53 — Le clavier ne doit plus masquer les boutons
   Deux mecanismes complementaires :
   1. interactiveWidget=resizes-content (meta viewport) : Chrome reduit la
      vue, `dvh` suit, et le sticky remonte tout seul.
   2. Repli mesure : --clavier vaut la hauteur reellement masquee, et la
      feuille se borne dessus. Indispensable sur Safari.
   ===================================================================== */
:root { --clavier: 0px; }
.sheet { max-height: calc(92dvh - var(--clavier)); }
html.clavier-ouvert .sheet { bottom: var(--clavier); }
/* Clavier ouvert, la barre d'actions doit rester compacte pour laisser voir
   le champ en cours de saisie. */
html.clavier-ouvert .sheet-actions { padding: 7px 0 3px; }
html.clavier-ouvert .sheet-actions .primary { padding: 10px; }

/* Quantites a cote des ingredients d'un repas */
.meal-qte { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.qt-chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: var(--surface-2); border-radius: 999px; padding: 3px 9px;
  font-size: 11.5px; color: var(--muted);
}
.qt-chip b { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
/* Deja au frigo : ne partira pas aux courses */
.qt-chip.ok { background: #e8f0ef; color: #2f6f6a; }
.qt-chip.ok b { color: #2f6f6a; }
.qt-chip.ok::before { content: '\2713 '; font-weight: 700; }

/* =====================================================================
   v55b — Ajustements smartphone
   ===================================================================== */
/* Le bouton « + » des champs d'ajout reste visible sur les tres petits ecrans (320 px). */
.todo-quick input { min-width: 0; }

@media (pointer: coarse) {
  /* 16 px minimum : en dessous, iOS zoome automatiquement a la saisie. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px !important; }
  /* Petits boutons des repas (✨, ✕) : zone de toucher plus confortable. */
  .meal-x { padding: 7px 8px; }
}
