/* ============================================================
   Meal Planner — app styles
   Rules that matter (PWA-CHECKLIST Part 1):
   · rem font sizes only, so Settings → Text size works;
   · grid children minmax(0,1fr), flex children min-width:0;
   · chip rows wrap, never a hidden scrollbar;
   · :hover only inside (hover:hover);
   · bottom bar on phones AND iPads; side menu only with a real mouse.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  font-size: 100%;
  background: var(--bg);
}
html[data-text="large"] { font-size: 112.5%; }
html[data-text="larger"] { font-size: 125%; }
html, body { overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font-body); color: var(--text); background: var(--bg);
  line-height: 1.55; font-size: var(--text-base);
  -webkit-font-smoothing: antialiased; font-synthesis-weight: none;
}
html[data-font="readable"] body { font-family: 'Atkinson Hyperlegible', var(--font-body); }
html[data-font="readable"] { --font-display: 'Atkinson Hyperlegible', Georgia, serif; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { color: var(--heading); margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; }
h2 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }
p { margin: 0; }
a { color: var(--link); }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
button, [role="button"], .chip, a { touch-action: manipulation; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.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; }
.stack > * + * { margin-top: var(--space-3); }
.stack-lg > * + * { margin-top: var(--space-5); }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; min-width: 0; }
.row > * { min-width: 0; }
.row-between { display: flex; gap: var(--space-2); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-between > * { min-width: 0; }
.grow { flex: 1 1 auto; }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }

:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 6px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }

/* ---------- Update banner ---------- */
#update-banner {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 150;
  padding: calc(10px + var(--safe-top)) 16px 10px; text-align: center;
  background: var(--info-bg); color: var(--info-text); font-size: var(--text-sm); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
#update-banner button {
  margin-left: 10px; padding: 6px 14px; border-radius: var(--radius-pill); border: 0; cursor: pointer;
  background: var(--btn-primary-bg); color: var(--btn-primary-text); font-weight: 600; font-size: var(--text-sm);
}

/* ============================================================
   SHELL — bottom bar by default, side menu only with a mouse
   ============================================================ */
.shell { min-height: 100vh; min-height: 100dvh; }
.main {
  min-width: 0;
  padding-bottom: calc(var(--bar-h) + var(--safe-bottom) + var(--space-6));
}
.page { max-width: var(--content-max); margin: 0 auto; padding: calc(var(--space-4) + var(--safe-top)) var(--space-4) var(--space-6); min-width: 0; }

.sidebar { display: none; }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--bar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--nav-bg); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
}
.bottom-bar a, .bottom-bar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--nav-text); text-decoration: none; font-size: var(--text-xs); font-weight: 600;
  background: none; border: 0; cursor: pointer; min-width: 0; padding: 4px 2px;
}
.bottom-bar svg { width: 1.375rem; height: 1.375rem; color: var(--nav-icon); }
.bottom-bar [aria-current="page"] { color: var(--nav-active-text); }
.bottom-bar [aria-current="page"] .bb-icon { background: var(--nav-active-bg); box-shadow: inset 0 -3px 0 var(--accent-1-deep); }
.bb-icon { display: flex; align-items: center; justify-content: center; width: 3rem; height: 1.875rem; border-radius: var(--radius-pill); }
body.sheet-open .bottom-bar { visibility: hidden; }

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .bottom-bar { display: none; }
  .main { margin-left: var(--nav-w); padding-bottom: var(--space-7); }
  .page { padding-top: var(--space-6); padding-left: var(--space-7); padding-right: var(--space-7); }
  .sidebar {
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: var(--nav-w);
    background: var(--nav-bg); border-right: 1px solid var(--border); z-index: 40; overflow-y: auto;
  }
  .sidebar::before { content: ''; display: block; height: 6px; background: var(--brand-stripe); flex: none; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px; color: var(--nav-text); font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); }
  .brand svg { width: 2rem; height: 2rem; flex: none; }
  .side-group { padding: 6px 10px; }
  .side-group__label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--nav-text); opacity: .8; padding: 10px 10px 4px; font-weight: 600; }
  .side-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--nav-text); text-decoration: none; font-weight: 500; font-size: var(--text-sm);
  }
  .side-link svg { width: 1.125rem; height: 1.125rem; color: var(--nav-icon); flex: none; }
  .side-link:hover { background: var(--nav-hover-bg); }
  .side-link[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-text); box-shadow: inset 3px 0 0 var(--accent-1-deep); font-weight: 600; }
  .side-foot { margin-top: auto; padding: 14px 20px 18px; font-size: var(--text-xs); color: var(--nav-text); }
}
[data-theme="rainbow"] .side-group .side-link:nth-child(6n+2) svg { color: var(--chip-1-text); }
[data-theme="rainbow"] .side-group .side-link:nth-child(6n+3) svg { color: var(--chip-2-text); }
[data-theme="rainbow"] .side-group .side-link:nth-child(6n+4) svg { color: var(--chip-3-text); }
[data-theme="rainbow"] .side-group .side-link:nth-child(6n+5) svg { color: var(--chip-4-text); }
[data-theme="rainbow"] .side-group .side-link:nth-child(6n+6) svg { color: var(--chip-5-text); }
[data-theme="rainbow"] .side-group .side-link:nth-child(6n+7) svg { color: var(--chip-6-text); }

/* More sheet (phones + iPads) */
.more-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); gap: var(--space-2); }
.more-link {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius);
  background: var(--surface-alt); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; font-size: var(--text-sm); min-width: 0;
}
.more-link svg { width: 1.25rem; height: 1.25rem; color: var(--accent-2-deep); flex: none; }
.more-link[aria-current="page"] { border-color: var(--border-accent); background: var(--callout-bg); }

/* ============================================================
   PAGE PARTS
   ============================================================ */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.page-head > div:first-child { min-width: 0; flex: 1 1 14rem; }
.page-head p { color: var(--text-muted); font-size: var(--text-sm); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.grid > *, .grid-2 > *, .grid-3 > * { min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-4); box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere;
}
.card--accent { border-color: var(--border-accent); border-width: 1.5px; }
.card--callout { background: var(--callout-bg); border: 1.5px solid var(--callout-border); box-shadow: none; }
.card--soft { background: var(--surface-alt); box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.card-head > div { min-width: 0; flex: 1 1 10rem; }
.card-title { font-weight: 600; font-size: var(--text-lg); color: var(--heading); display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 1.125rem; height: 1.125rem; color: var(--accent-2-deep); flex: none; }
.card-sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: 2px; }
.section-title { font-size: var(--text-sm); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: var(--space-5) 0 var(--space-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 2.75rem; padding: 0.5rem 1rem; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: var(--text-sm); cursor: pointer; text-decoration: none; line-height: 1.2;
  background: var(--btn-secondary-bg); color: var(--btn-secondary-text); text-align: center;
}
.btn svg { width: 1rem; height: 1rem; flex: none; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-ghost { background: transparent; color: var(--btn-ghost-text); border-color: var(--btn-ghost-border); }
.btn-danger { background: var(--danger-bg); color: var(--danger-text); border-color: transparent; }
/* On tinted backgrounds the ghost text color drops under 4.5:1 (Blush measured 3.9), so use body text there. */
.notice .btn-ghost, .slot--eaten .btn-ghost, .card--callout .btn-ghost, .hero .btn-ghost { color: var(--text); }
.btn-sm { min-height: 2.25rem; padding: 0.375rem 0.75rem; font-size: var(--text-xs); }
.btn-lg { min-height: 3.25rem; font-size: var(--text-base); padding: 0.75rem 1.25rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: transparent; border-color: var(--btn-ghost-border); color: var(--text-muted); cursor: not-allowed; }
@media (hover: hover) {
  .btn-primary:hover { background: var(--btn-primary-hover); }
  .btn-secondary:hover, .btn:not(.btn-primary):not(.btn-ghost):not(.btn-danger):hover { background: var(--btn-secondary-hover); }
  .btn-ghost:hover { background: var(--surface-alt); }
  .chip:hover { border-color: var(--border-accent); }
  .icon-btn:hover { background: var(--surface-alt); }
  .slot:hover, .tile:hover { border-color: var(--border-accent); }
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.5rem; height: 2.5rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 1.125rem; height: 1.125rem; }
html[data-touch="large"] .btn { min-height: 3.25rem; }
html[data-touch="large"] .icon-btn { width: 3rem; height: 3rem; }
html[data-touch="large"] .chip { min-height: 2.75rem; }

/* ---------- Chips (always wrap) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 2.25rem; padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: var(--text-sm); font-weight: 600; cursor: pointer; text-align: left;
  max-width: 100%; overflow-wrap: anywhere;
}
.chip[aria-pressed="true"] { background: var(--chip-2-bg); color: var(--chip-2-text); border-color: var(--chip-2-text); }
.chip[aria-pressed="true"] .muted { color: inherit; } /* muted grey on a pressed chip measured 4.3:1 in Neutral */
.chip svg { width: 0.875rem; height: 0.875rem; flex: none; }
.chip .chip-x { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; color: inherit; font-size: var(--text-base); line-height: 1; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; background: var(--chip-3-bg); color: var(--chip-3-text); max-width: 100%; overflow-wrap: anywhere; }
.tag-1 { background: var(--chip-1-bg); color: var(--chip-1-text); }
.tag-2 { background: var(--chip-2-bg); color: var(--chip-2-text); }
.tag-3 { background: var(--chip-3-bg); color: var(--chip-3-text); }
.tag-4 { background: var(--chip-4-bg); color: var(--chip-4-text); }
.tag-5 { background: var(--chip-5-bg); color: var(--chip-5-text); }
.tag-6 { background: var(--chip-6-bg); color: var(--chip-6-text); }
.tag-ok { background: var(--success-bg); color: var(--success-text); }
.tag-warn { background: var(--warning-bg); color: var(--warning-text); }
.tag-danger { background: var(--danger-bg); color: var(--danger-text); }

/* ---------- Notices ---------- */
.notice { border-radius: var(--radius); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); display: flex; gap: 10px; align-items: flex-start; }
.notice svg { width: 1.125rem; height: 1.125rem; flex: none; margin-top: 2px; }
.notice > div { min-width: 0; }
.notice-info { background: var(--info-bg); color: var(--info-text); }
.notice-ok { background: var(--success-bg); color: var(--success-text); }
.notice-warn { background: var(--warning-bg); color: var(--warning-text); }
.notice-danger { background: var(--danger-bg); color: var(--danger-text); }
.notice a, .notice .linkish { color: inherit; font-weight: 600; }
.linkish { background: none; border: 0; padding: 0; color: var(--link); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > * { min-width: 0; max-width: 100%; }
.field label, .label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.hint { font-size: var(--text-xs); color: var(--text-muted); }
.error { font-size: var(--text-xs); color: var(--danger-text); font-weight: 600; }
.fields-2 { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.fields-2 > * { min-width: 0; }
input, select, textarea {
  font: inherit; font-size: var(--text-base); color: var(--text); background: var(--surface);
  border: 1px solid var(--btn-ghost-border); border-radius: 10px; padding: 0.6rem 0.75rem; width: 100%; min-width: 0;
}
textarea { min-height: 5.5rem; resize: vertical; line-height: 1.5; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger-text); }
input[type="checkbox"], input[type="radio"] { width: 1.25rem; height: 1.25rem; accent-color: var(--accent-2-deep); padding: 0; flex: none; }
input[type="range"] { padding: 0; accent-color: var(--accent-2-deep); border: 0; background: transparent; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
/* iPhone draws date/time boxes at its own width and ignores width:100% */
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"] {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; max-width: 100%; text-align: left; min-height: 2.75rem;
}
input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.25em; }
/* iOS zooms into fields under 16px */
@media (pointer: coarse) { input, select, textarea { font-size: max(16px, 1rem); } }

.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; min-width: 0; }
.check-row > span { min-width: 0; overflow-wrap: anywhere; }
.check-row.is-done > span { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border-accent); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 0; border: 0; background: none; width: 100%; cursor: pointer; text-align: left; }
.switch > span:first-child { min-width: 0; }
.switch__track { width: 2.75rem; height: 1.5rem; border-radius: 999px; background: var(--progress-track); border: 1px solid var(--btn-ghost-border); position: relative; flex: none; transition: background .15s; }
.switch__track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 1.125rem; height: 1.125rem; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch[aria-checked="true"] .switch__track { background: var(--accent-2-deep); border-color: var(--accent-2-deep); }
.switch[aria-checked="true"] .switch__track::after { transform: translateX(1.25rem); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 2.75rem; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: var(--text-sm); }
.seg button[aria-pressed="true"] { background: var(--chip-2-bg); color: var(--chip-2-text); border-color: var(--chip-2-text); }

/* ---------- Sheet (pop-up) ---------- */
.sheet-host { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(20, 16, 18, 0.42); }
.sheet {
  position: relative; width: 100%; max-width: 38rem; background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: 92vh; max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - 8px);
  overscroll-behavior: contain; animation: sheetUp .22s ease;
}
.sheet--wide { max-width: 52rem; }
@media (min-width: 640px) { .sheet-host { align-items: center; padding: 16px; } .sheet { border-radius: var(--radius-lg); } }
.sheet__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-4) var(--space-2); flex: none; }
.sheet__head > div { flex: 1; min-width: 0; }
.sheet__head h2 { font-size: var(--text-xl); }
.sheet__head p { color: var(--text-muted); font-size: var(--text-sm); margin-top: 4px; }
.sheet__grip { position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border); }
.sheet__body { padding: var(--space-2) var(--space-4) var(--space-4); overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.sheet__foot { padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-bottom)); border-top: 1px solid var(--divider); display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; flex: none; }
.sheet__foot .btn { flex: 1 1 8rem; }
body.sheet-open { overflow: hidden; overscroll-behavior: none; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--bar-h) + var(--safe-bottom) + 14px); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) { .toast-host { bottom: 24px; left: var(--nav-w); } }
.toast { pointer-events: none; max-width: 30rem; background: var(--heading); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-size: var(--text-sm); font-weight: 600; box-shadow: var(--shadow-lg); animation: sheetUp .2s ease; }
.toast button { pointer-events: auto; margin-left: 10px; background: none; border: 0; color: inherit; text-decoration: underline; font-weight: 600; cursor: pointer; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: var(--space-2); }
.item {
  display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.item__main { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.item__title { font-weight: 600; }
.item__meta { color: var(--text-muted); font-size: var(--text-xs); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.item__actions { display: flex; gap: 6px; flex: none; }
.emoji { font-size: 1.5rem; line-height: 1; flex: none; width: 2.75rem; height: 2.75rem; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--surface-alt); }
.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-muted); }
.empty .emoji { margin: 0 auto var(--space-2); width: 3.5rem; height: 3.5rem; font-size: 1.875rem; }
.empty h3 { color: var(--heading); margin-bottom: 4px; }
.empty .btn { margin-top: var(--space-3); }

/* ---------- Meal slots ---------- */
.slots { display: grid; gap: var(--space-2); grid-template-columns: minmax(0, 1fr); }
.slot {
  display: flex; align-items: center; gap: var(--space-3); padding: 12px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.slot--eaten { background: var(--success-bg); border-color: transparent; }
.slot--eaten .slot__state { color: var(--success-text); }
.slot--skipped { opacity: .75; }
.slot__main { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.slot__label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.slot__name { font-weight: 600; }
.slot__name button { all: unset; cursor: pointer; }
.slot__state { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); }
.slot__actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: none; max-width: 55%; }
@media (max-width: 480px) {
  .slot { flex-wrap: wrap; }
  .slot__main { flex-basis: calc(100% - 3.75rem); }
  .slot__actions { max-width: none; width: 100%; justify-content: flex-start; }
}

/* ---------- Week planner ---------- */
.week { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); min-width: 0; }
.day-card--today { border-color: var(--border-accent); border-width: 1.5px; }
.day-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-bottom: var(--space-2); }
.day-card__head strong { font-size: var(--text-base); }
.mini-slot { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px dashed var(--border); background: var(--surface-alt); cursor: pointer; text-align: left; margin-top: 6px; min-height: 2.75rem; }
.mini-slot.is-filled { border-style: solid; background: var(--surface); }
.mini-slot.is-eaten { background: var(--success-bg); border-color: transparent; }
.mini-slot__label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; width: 4.25rem; flex: none; }
.mini-slot__name { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); font-weight: 500; }

/* ---------- Recipes ---------- */
.recipe-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: var(--space-3); min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; color: var(--text); position: relative;
}
.tile__emoji { font-size: 2rem; line-height: 1; }
.tile__name { font-weight: 600; overflow-wrap: anywhere; }
.tile__meta { font-size: var(--text-xs); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tile__fav { position: absolute; top: 8px; right: 8px; }
.steps { padding-left: 1.25rem; margin: 0; }
.steps li + li { margin-top: 6px; }
.ing-list { padding-left: 1.125rem; margin: 0; }
.ing-list li + li { margin-top: 3px; }
.cook-step { font-size: var(--text-2xl); line-height: 1.4; font-weight: 500; min-height: 8rem; padding: var(--space-4) 0; overflow-wrap: anywhere; }

/* ---------- Progress, rings, stats ---------- */
.progress { height: 0.625rem; background: var(--progress-track); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--progress-fill); border-radius: 999px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chart-edge) 35%, transparent); }
.stats { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); }
.stat { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.stat__value { font-size: var(--text-xl); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; color: var(--heading); line-height: 1.2; overflow-wrap: anywhere; }
.stat__label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }
.ring { display: block; }
.ring__track { stroke: var(--chart-track); }
.ring__fill { stroke: var(--accent-2-deep); transition: stroke-dashoffset .4s; }

/* Heatmap */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 0.875rem); grid-auto-columns: 0.875rem; gap: 3px; overflow-x: auto; padding: 4px 0 8px; }
.heatmap i { border-radius: 3px; background: var(--chart-track); }
.heatmap i[data-l="1"] { background: color-mix(in srgb, var(--accent-2-deep) 30%, var(--surface)); }
.heatmap i[data-l="2"] { background: color-mix(in srgb, var(--accent-2-deep) 55%, var(--surface)); }
.heatmap i[data-l="3"] { background: color-mix(in srgb, var(--accent-2-deep) 80%, var(--surface)); }
.heatmap i[data-l="4"] { background: var(--accent-2-deep); }
.heat-key { display: flex; gap: 4px; align-items: center; font-size: var(--text-xs); color: var(--text-muted); }
.heat-key i { width: 0.75rem; height: 0.75rem; border-radius: 3px; display: inline-block; }

/* Bar chart (HTML, labelled) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 9rem; padding-top: 1.25rem; }
.bars > div { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bar { width: 100%; max-width: 2.75rem; border-radius: 6px 6px 3px 3px; background: var(--chart-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chart-edge) 35%, transparent); min-height: 2px; }
.bar-val { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-lbl { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; overflow-wrap: anywhere; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--text-xs); color: var(--text-muted); }
.legend i { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; margin-right: 5px; vertical-align: -1px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chart-edge) 35%, transparent); }
.hbar { display: grid; grid-template-columns: minmax(0, 7rem) minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: var(--text-sm); }
.hbar + .hbar { margin-top: 8px; }
.hbar .progress { height: 0.75rem; }

/* Meds & appetite timeline */
.timeline { position: relative; height: 2.75rem; border-radius: 10px; background: var(--chart-track); overflow: hidden; }
.timeline span { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 600; overflow: hidden; white-space: nowrap; padding: 0 4px; }
.tl-before { background: var(--chip-2-bg); color: var(--chip-2-text); }
.tl-low { background: var(--chip-1-bg); color: var(--chip-1-text); }
.tl-back { background: var(--chip-4-bg); color: var(--chip-4-text); }
.tl-now { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: var(--heading); border-radius: 2px; }
.tl-scale { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; }

/* Decider options */
.options { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.option { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); border-radius: var(--radius); border: 1.5px solid var(--border-accent); background: var(--surface); min-width: 0; }
.option__why { font-size: var(--text-xs); color: var(--text-muted); }

/* ============================================================
   DASHBOARD WELCOME PANEL (pwa-dashboard-illustration)
   ============================================================ */
.hero {
  container-type: inline-size; position: relative;
  background: var(--hero-bg); border: 1.5px solid var(--hero-border); border-radius: var(--radius-lg);
  padding: var(--space-4); overflow: hidden; min-width: 0;
}
.hero__grid { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem; grid-template-areas: "text art" "foot foot"; gap: var(--space-3) var(--space-3); align-items: center; }
.hero__text { grid-area: text; min-width: 0; }
.hero__art { grid-area: art; min-width: 0; align-self: center; }
.hero__art svg { display: block; width: 100%; height: auto; }
.hero__foot { grid-area: foot; min-width: 0; }
.hero__eyebrow { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--hero-eyebrow-bg); color: var(--hero-eyebrow-text); font-size: var(--text-xs); font-weight: 600; }
.hero__title { font-family: var(--font-display); font-size: var(--text-2xl); margin-top: 8px; overflow-wrap: anywhere; }
.hero__msg { color: var(--text); margin-top: 6px; font-size: var(--text-sm); }
@container (min-width: 600px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr) clamp(13rem, 36cqi, 17rem); }
}
@container (min-width: 880px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr) clamp(18rem, 36cqi, 24rem); grid-template-areas: "text art" "foot art"; }
  .hero__art { align-self: end; }
}
/* Picture fills, by class (Safari doesn't reliably resolve var() in fill="") */
.ma-glow { fill: var(--art-glow); }
.ma-board { fill: var(--art-board); }
.ma-board-edge { fill: var(--art-board-edge); }
.ma-bowl { fill: var(--art-bowl); }
.ma-rim { fill: var(--art-bowl-rim); }
.ma-food1 { fill: var(--art-food1); }
.ma-food2 { fill: var(--art-food2); }
.ma-food3 { fill: var(--art-food3); }
.ma-leaf { fill: var(--art-leaf); }
.ma-leaf2 { fill: var(--art-leaf2); }
.ma-pot { fill: var(--art-pot); }
.ma-card { fill: var(--art-card); }
.ma-ink { fill: var(--art-ink); }
.ma-ink-line { stroke: var(--art-ink); fill: none; }
.ma-steam { stroke: var(--art-steam); fill: none; }
.ma-shadow { fill: var(--art-shadow); }
.ma-spark { fill: var(--art-spark); }
.ma-steam-anim { animation: steam 6s ease-in-out infinite; transform-origin: center; }
@keyframes steam { 0%, 100% { transform: translateY(0); opacity: .9; } 50% { transform: translateY(-4px); opacity: .45; } }

/* Free demo only (html.is-demo is set by the demo build) */
html.is-demo .demo-hide { display: none !important; }
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; padding: 8px 16px; background: var(--callout-bg); border-bottom: 1px solid var(--callout-border); color: var(--text); font-size: var(--text-sm); font-weight: 600; text-align: center; }
.demo-card { border: 1.5px solid var(--border-accent); background: var(--callout-bg); }

/* Install card / sync card bits */
.qr-pics { display: flex; gap: 8px; font-size: 2rem; }
.code-big { font-size: var(--text-3xl); font-weight: 600; letter-spacing: .12em; font-variant-numeric: tabular-nums; }

/* ============================================================
   COMFORT MODES
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }
html[data-calm="on"] .hero { background: var(--surface); }
html[data-calm="on"] .hero__art { display: none; }
html[data-calm="on"] .hero__grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "foot"; }

/* ============================================================
   PRINT — light ink on white, whatever the theme; chrome hidden
   ============================================================ */
.print-only { display: none; }
@media print {
  :root, [data-theme] {
    --bg: #fff; --surface: #fff; --surface-alt: #fff; --text: #222; --heading: #111; --text-muted: #555;
    --border: #ccc; --divider: #ddd; --success-bg: #fff; --success-text: #222; color-scheme: light;
  }
  @page { margin: 14mm; }
  html, body { background: #fff !important; color: #222 !important; overflow: visible !important; }
  .sidebar, .bottom-bar, .toast-host, #update-banner, .demo-bar, .no-print, .page-actions, .item__actions, .slot__actions, .sheet-host, .hero__art, .skip-link { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .page { padding: 0 !important; max-width: none !important; }
  .card, .slot, .item, .day-card, .tile { box-shadow: none !important; break-inside: avoid; border-color: #ccc !important; background: #fff !important; }
  .hero { background: #fff !important; border-color: #ccc !important; }
  .tag, .chip { background: #fff !important; color: #222 !important; border: 1px solid #bbb !important; }
  .mini-slot { background: #fff !important; border: 1px solid #ccc !important; }
  .mini-slot__name .muted { visibility: hidden; } /* empty slots print as blank lines to write on */
  .stat { background: #fff !important; }
  .print-only { display: block; }
  a { color: inherit; text-decoration: none; }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.printing-sheet .main { display: none !important; }
  body.printing-sheet .sheet-host { display: block !important; position: static; }
  body.printing-sheet .sheet-scrim, body.printing-sheet .sheet__foot, body.printing-sheet .sheet__head .icon-btn { display: none !important; }
  body.printing-sheet .sheet { max-height: none !important; box-shadow: none !important; animation: none; max-width: none; }
  body.printing-sheet .sheet__body { overflow: visible !important; }
}
