:root {
  --ink: #111820;
  --secondary: #405665;
  --line: #9eabb4;
  --paper: #ffffff;
  --mineral: #dfeaf0;
  --mineral-strong: #bdd2dd;
  --accent: #294c5f;
  --accent-dark: #183746;
  --success: #286447;
  --danger: #8b3340;
  --nav-height: 76px;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 720px); min-height: 100dvh; margin: 0 auto; padding: env(safe-area-inset-top) 18px calc(var(--nav-height) + env(safe-area-inset-bottom)); }
.app-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px 2px 18px; }
.eyebrow { margin: 0 0 5px; color: var(--secondary); font-size: .76rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; line-height: 1.06; letter-spacing: -.035em; }
h1 { font-size: clamp(1.8rem, 8vw, 2.45rem); font-weight: 800; }
h2 { font-size: 1.55rem; font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 800; }
p { line-height: 1.45; }

.icon-button { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: 50%; background: var(--mineral); color: var(--ink); font-size: 1.35rem; font-weight: 800; }
.view[hidden] { display: none; }
.view.active { display: block; }

.meal-card { padding: 20px; border: 1.5px solid var(--line); border-left: 7px solid var(--accent); border-radius: 8px 22px 22px 8px; background: var(--mineral); }
.meal-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--secondary); font-size: .82rem; font-weight: 700; }
.meal-card h2 { margin: 16px 0 8px; font-size: clamp(1.65rem, 7vw, 2.2rem); }
.meal-card > p { margin: 0; font-size: 1rem; font-weight: 600; }
.meal-actions { display: grid; gap: 9px; margin-top: 16px; }

.primary-button, .secondary-button, .text-button { min-height: 48px; border-radius: 13px; padding: 13px 16px; font-weight: 800; }
.primary-button { border: 0; background: var(--accent); color: #fff; }
.primary-button:active { background: var(--accent-dark); }
.secondary-button { border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); }
.text-button { border: 0; background: transparent; color: var(--accent-dark); text-decoration: underline; text-underline-offset: 4px; }
.primary-button:focus-visible, .secondary-button:focus-visible, .text-button:focus-visible, .icon-button:focus-visible, .nav-button:focus-visible { outline: 3px solid #72a9c2; outline-offset: 2px; }

.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 22px 2px 10px; }
.section-heading h2, .section-heading h3 { font-size: .86rem; letter-spacing: .08em; text-transform: uppercase; }
.section-heading span { color: var(--secondary); font-size: .82rem; font-weight: 650; }
.portion-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); }
.portion { padding: 13px 10px; }
.portion + .portion { border-left: 1.5px solid var(--line); }
.portion strong { display: block; margin-bottom: 4px; font-size: .96rem; }
.portion span { color: var(--secondary); font-size: .79rem; font-weight: 600; }

.week-toolbar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; margin-bottom: 14px; }
.week-toolbar > div { text-align: center; }
.week-toolbar strong { display: block; font-size: .98rem; }
.week-toolbar span { color: var(--secondary); font-size: .78rem; }
.day-list { display: grid; gap: 7px; }
.day-row { width: 100%; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 13px 10px; border: 1.5px solid transparent; border-bottom-color: var(--line); background: var(--paper); color: var(--ink); text-align: left; }
.day-row.today { border-color: var(--line); border-left: 6px solid var(--accent); border-radius: 8px 15px 15px 8px; background: var(--mineral); }
.day-label { font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.day-meal { font-size: .95rem; font-weight: 750; line-height: 1.25; }
.day-side { max-width: 72px; color: var(--secondary); font-size: .72rem; font-weight: 650; text-align: right; }
.sticky-action { position: sticky; bottom: calc(var(--nav-height) + 10px); margin-top: 16px; box-shadow: 0 12px 30px rgb(18 50 66 / .25); }

.category { margin: 0 0 22px; }
.category h2 { margin: 0 0 5px; font-size: .84rem; letter-spacing: .08em; text-transform: uppercase; }
.check-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; min-height: 50px; border-bottom: 1px solid var(--line); }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.check-row span { font-size: .98rem; font-weight: 650; }
.check-row small { color: var(--secondary); font-size: .76rem; font-weight: 650; }
.check-row.checked span { color: var(--secondary); text-decoration: line-through; }
.progress-note { margin: -5px 0 18px; color: var(--secondary); font-size: .9rem; font-weight: 650; }

.shopping-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.shopping-head strong { font-size: 1.05rem; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty-state { padding: 30px 20px; border: 1.5px dashed var(--line); border-radius: 16px; text-align: center; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--secondary); }

.library-grid { display: grid; gap: 9px; }
.library-item, .choice-card { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); text-align: left; }
.library-item strong, .choice-card strong { display: block; font-weight: 800; }
.library-item small, .choice-card small { color: var(--secondary); font-weight: 600; }
.tag { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border-radius: 999px; background: var(--mineral); color: var(--accent-dark); font-size: .73rem; font-weight: 800; }
.version-card { margin-top: 20px; padding: 15px; border-left: 5px solid var(--accent); background: var(--mineral); }
.version-card strong { display: block; margin-bottom: 3px; }
.version-card span { color: var(--secondary); font-size: .82rem; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; width: min(100%, 720px); min-height: var(--nav-height); transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-top: 1.5px solid var(--line); background: rgb(255 255 255 / .96); backdrop-filter: blur(16px); }
.nav-button { min-width: 0; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: transparent; color: #62727b; font-size: .64rem; font-weight: 750; }
.nav-button.active { color: var(--accent-dark); }
.nav-icon { font-size: 1.25rem; line-height: 1; font-weight: 800; }

.sheet-dialog { width: min(100% - 20px, 680px); max-height: calc(100dvh - 20px); margin: auto auto 10px; padding: 20px; border: 1.5px solid var(--line); border-radius: 24px 24px 10px 10px; background: var(--paper); color: var(--ink); }
.sheet-dialog::backdrop { background: rgb(12 24 31 / .55); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.ingredient-list { padding-left: 20px; }
.ingredient-list li { margin: 9px 0; font-weight: 600; }
.dialog-actions { display: grid; gap: 8px; margin-top: 20px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--nav-height) + 18px); transform: translate(-50%, 20px); width: max-content; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .84rem; font-weight: 750; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 620px) {
  .app-shell { padding-inline: 30px; }
  .meal-actions { grid-template-columns: 1.35fr 1fr; }
  .library-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .app-shell { padding-inline: 13px; }
  .portion-grid { grid-template-columns: 1fr; }
  .portion + .portion { border-left: 0; border-top: 1px solid var(--line); }
  .nav-button { font-size: .57rem; }
}

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