:root {
  --dan: #D6E6F5;
  --dan-ink: #1F4A75;
  --laura: #F6DCE6;
  --laura-ink: #8A2E55;
  --batch: #E4EBD3;
  --batch-ink: #4A5A1E;
  --takeaway: #FBE7C6;
  --takeaway-ink: #7A4A06;
  --bg: #ECF0EC;
  --paper: #FFFFFF;
  --paper-2: #F6F8F6;
  --ink: #18231E;
  --muted: #637069;
  --line: #D7DFD9;
  --basil: #2D5A43;
  --basil-soft: #DCE8E0;
  --on-basil: #FFFFFF;
  --saffron: #F2B33D;
  --saffron-soft: #FCEFD2;
  --tomato: #B8432E;
  --shadow: 0 1px 2px rgba(24, 35, 30, .06), 0 6px 20px rgba(24, 35, 30, .06);
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --nav-h: 68px;
  --ini: rgba(0, 0, 0, .55);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111714;
    --paper: #1A221E;
    --paper-2: #202a25;
    --ink: #E7EDE9;
    --muted: #97A69E;
    --line: #2B3731;
    --basil: #7CC09A;
    --basil-soft: #23382D;
    --on-basil: #0F1A14;
    --saffron: #F2B33D;
    --saffron-soft: #3a3120;
    --tomato: #E77B63;
    --shadow: none;
    --ini: rgba(0, 0, 0, .58);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #111714;
    --paper: #1A221E;
    --paper-2: #202a25;
    --ink: #E7EDE9;
    --muted: #97A69E;
    --line: #2B3731;
    --basil: #7CC09A;
    --basil-soft: #23382D;
    --on-basil: #0F1A14;
    --saffron: #F2B33D;
    --saffron-soft: #3a3120;
    --tomato: #E77B63;
    --shadow: none;
    --ini: rgba(0, 0, 0, .58);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; border-radius: 6px; }
a { color: var(--basil); }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
#app { min-height: 100dvh; }
.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
}
.screen.no-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }

.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 44px; }
.topbar h1 {
  font-family: var(--display);
  font-weight: 750;
  font-size: 34px;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
  flex: 1;
}
.topbar h1.small { font-size: 22px; font-weight: 700; }
.sub { color: var(--muted); font-size: 15px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--paper); box-shadow: var(--shadow);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.flat { background: transparent; box-shadow: none; }

.btn {
  text-decoration: none;
  border: 0; border-radius: 999px; padding: 12px 20px; min-height: 48px;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--basil); color: var(--on-basil); box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; border: 1.5px solid var(--line); }
.btn.danger { background: transparent; box-shadow: none; color: var(--tomato); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-inner { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nav a {
  text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 16px; font-size: 13px; font-weight: 700;
}
.nav a svg { width: 26px; height: 26px; }
.nav a.active { color: var(--basil); background: var(--basil-soft); }

/* ---------- Plan ---------- */
.weekbar { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.weekbar .label { flex: 1; text-align: center; font-weight: 700; }
.weekbar .label small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }

.day {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.day:last-child { border-bottom: 0; }
.day-mark { position: relative; padding-top: 2px; }
.day-mark .dn {
  font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1;
  letter-spacing: -0.03em;
}
.day-mark .dd { color: var(--muted); font-size: 14px; margin-top: 4px; }
.day.today .day-mark .dn { color: var(--basil); }
.day.today .day-mark::after {
  content: ""; position: absolute; left: 0; bottom: -6px; width: 34px; height: 5px;
  background: var(--saffron); border-radius: 3px;
}
.day.past { opacity: .62; }
.slots { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.meal {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--paper); border: 0; border-radius: var(--r-md);
  padding: 10px 12px 10px 10px; text-align: left; box-shadow: var(--shadow);
}
.meal .thumb { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.meal .info { min-width: 0; flex: 1; }
.meal .slot-name { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.meal .title { font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meal .sides { font-size: 14.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-meal {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 1.5px dashed var(--line); border-radius: var(--r-md);
  padding: 12px 14px; color: var(--muted); text-align: left; font-weight: 700;
}
.add-meal svg { width: 20px; height: 20px; }

/* ---------- Thumbs ---------- */
.thumb { background: var(--basil-soft); display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ini { font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--ini); letter-spacing: -0.02em; }

/* ---------- Recipes ---------- */
.search {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  border-radius: 999px; padding: 0 16px; min-height: 50px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { border: 0; background: transparent; outline: none; flex: 1; min-width: 0; padding: 12px 0; }
.chips { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.chip {
  border: 1.5px solid var(--line); background: transparent; border-radius: 999px;
  padding: 7px 14px; font-weight: 700; font-size: 15px; white-space: nowrap; color: var(--muted);
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.rlist { display: flex; flex-direction: column; gap: 10px; }
.rcard {
  display: flex; gap: 14px; align-items: center; background: var(--paper);
  border-radius: var(--r-lg); padding: 10px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
}
.rcard .thumb { width: 76px; height: 76px; border-radius: 16px; flex: none; }
.rcard .info { min-width: 0; flex: 1; }
.rcard .title { font-weight: 700; font-size: 17.5px; line-height: 1.25; }
.rcard .meta { color: var(--muted); font-size: 14.5px; margin-top: 3px; }
.fav-dot { color: var(--saffron); }

.fab {
  text-decoration: none;
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); z-index: 15;
  border: 0; border-radius: 999px; background: var(--basil); color: var(--on-basil);
  padding: 0 22px 0 18px; height: 56px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(45, 90, 67, .35);
}
.fab svg { width: 24px; height: 24px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h2 { font-family: var(--display); color: var(--ink); font-size: 24px; margin: 0 0 6px; }
.empty p { margin: 0 0 18px; }

/* ---------- Recipe detail ---------- */
.hero { margin: 0 -16px 18px; position: relative; }
.hero .thumb { width: 100%; aspect-ratio: 16 / 10; border-radius: 0 0 28px 28px; }
.hero .thumb .ini { font-size: 56px; }
.hero .thumb:not(:has(img)) { aspect-ratio: 5 / 2; }
.hero-bar { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px; display: flex; justify-content: space-between; }
.r-title { font-family: var(--display); font-size: 30px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 8px; }
.r-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 15px; margin-bottom: 18px; align-items: center; }
.r-meta a { font-weight: 700; text-decoration: none; display: inline-flex; gap: 5px; align-items: center; }
.r-meta svg { width: 16px; height: 16px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 26px; }
.actions .btn { white-space: nowrap; padding: 12px 12px; }
h3.sec { font-family: var(--display); font-size: 21px; font-weight: 700; margin: 26px 0 10px; letter-spacing: -0.01em; }
.group-label { font-weight: 700; color: var(--muted); font-size: 15px; margin: 14px 0 4px; }
.ing { list-style: none; padding: 0; margin: 0; }
.ing li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ing .amt { font-weight: 700; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px 0; }
.steps li::before {
  content: counter(s); font-family: var(--display); font-weight: 800; font-size: 15px;
  width: 28px; height: 28px; border-radius: 50%; background: var(--basil-soft); color: var(--basil);
  display: grid; place-items: center; margin-top: 1px;
}
.notes { background: var(--saffron-soft); border-radius: var(--r-md); padding: 14px 16px; white-space: pre-line; }

/* ---------- Cooking view ---------- */
.cook { font-size: 21px; line-height: 1.5; }
.cook .r-title { font-size: 28px; }
.cook .ing li { grid-template-columns: 30px 110px 1fr; align-items: start; cursor: pointer; }
.cook .ing li .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); margin-top: 3px; display: grid; place-items: center; }
.cook .ing li.got { color: var(--muted); }
.cook .ing li.got .box { background: var(--basil); border-color: var(--basil); color: var(--on-basil); }
.cook .ing li.got .txt { text-decoration: line-through; }
.cook .steps li { grid-template-columns: 40px 1fr; padding: 16px 12px; border-radius: var(--r-md); cursor: pointer; margin: 0 -12px; }
.cook .steps li::before { width: 34px; height: 34px; font-size: 17px; }
.cook .steps li.current { background: var(--paper); box-shadow: var(--shadow); }
.cook .steps li.done { color: var(--muted); }
.cook .steps li.done::before { content: "✓"; background: var(--basil); color: var(--on-basil); }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--paper); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 20px; font-weight: 700; }
.stepper span { min-width: 74px; text-align: center; font-weight: 700; font-size: 16px; }

/* ---------- Shopping ---------- */
.add-item { display: flex; gap: 8px; margin-bottom: 18px; }
.add-item input {
  flex: 1; min-width: 0; border: 0; background: var(--paper); border-radius: 999px; padding: 0 18px; min-height: 50px; box-shadow: var(--shadow); outline: none;
}
.aisle { margin-bottom: 18px; }
.aisle h4 { margin: 0 0 6px; font-size: 15px; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; }
.items { background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line);
  width: 100%; border-left: 0; border-right: 0; border-top: 0; background: transparent; text-align: left;
}
.item:last-child { border-bottom: 0; }
.item .tick {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: transparent;
}
.item .tick svg { width: 16px; height: 16px; }
.item .what { flex: 1; min-width: 0; }
.item .nm { font-weight: 700; }
.item .amt { color: var(--basil); font-weight: 700; margin-right: 6px; }
.item .for { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.done .tick { background: var(--basil); border-color: var(--basil); color: var(--on-basil); }
.item.done .nm, .item.done .amt { color: var(--muted); text-decoration: line-through; font-weight: 400; }
.item .x { border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; display: grid; place-items: center; }
.item .x svg { width: 18px; height: 18px; }
.basket-toggle { width: 100%; border: 0; background: transparent; color: var(--muted); font-weight: 700; padding: 10px 0; display: flex; justify-content: space-between; }
.progress { height: 6px; border-radius: 3px; background: var(--line); margin: -4px 0 18px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--basil); border-radius: 3px; transition: width .3s; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 15px; }
.field .hint { color: var(--muted); font-size: 14px; margin-top: 5px; }
.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--r-md);
  padding: 12px 14px; outline: none; min-height: 50px;
}
.input:focus { border-color: var(--basil); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 220px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--paper); border-radius: 999px; padding: 4px; margin-bottom: 18px; box-shadow: var(--shadow); }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 10px 6px; font-weight: 700; color: var(--muted); font-size: 15px; }
.seg button.on { background: var(--basil); color: var(--on-basil); }
.drop {
  border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 30px 18px; text-align: center; color: var(--muted);
  display: block; cursor: pointer; background: var(--paper);
}
.drop svg { width: 40px; height: 40px; color: var(--basil); margin: 0 auto 8px; }
.drop strong { color: var(--ink); display: block; font-size: 18px; margin-bottom: 4px; }
.tip { background: var(--basil-soft); border-radius: var(--r-md); padding: 12px 14px; font-size: 15px; margin-bottom: 16px; }
.tip.warn { background: var(--saffron-soft); }
.shots { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.shots img { width: 72px; height: 110px; object-fit: cover; border-radius: 10px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 12px 0 4px; }
.bar i { display: block; height: 100%; width: 0; background: var(--basil); transition: width .2s; }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 13, .42); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88dvh; overflow: auto;
  background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 22px);
  max-width: 640px; margin: 0 auto; transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .9, .3, 1);
}
.sheet.show { transform: translateY(0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-family: var(--display); font-size: 22px; margin: 4px 0 4px; letter-spacing: -0.01em; }
.sheet .sub { margin-bottom: 14px; }
.menu { background: var(--paper); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 12px; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 16px; border: 0; background: transparent;
  border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; text-decoration: none; color: var(--ink);
}
.menu button:last-child, .menu a:last-child { border-bottom: 0; }
.menu svg { width: 22px; height: 22px; color: var(--basil); flex: none; }
.menu .danger, .menu .danger svg { color: var(--tomato); }
.pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 46dvh; overflow: auto; margin: 0 -4px; padding: 0 4px 4px; }
.pick {
  display: flex; align-items: center; gap: 12px; border: 0; background: var(--paper); border-radius: var(--r-md); padding: 8px; text-align: left; box-shadow: var(--shadow);
}
.pick .thumb { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.pick .title { font-weight: 700; }
.pick.sel { outline: 2.5px solid var(--basil); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; }
.login h1 { font-family: var(--display); font-size: 44px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 0 0 8px; }
.login .mark { width: 64px; height: 64px; margin-bottom: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 700; z-index: 60;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline { background: var(--saffron-soft); color: var(--ink); text-align: center; font-size: 14px; padding: 6px; font-weight: 700; }

.settings-list label { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.settings-list label:last-child { border-bottom: 0; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch:checked { background: var(--basil); }
.switch:checked::after { transform: translateX(20px); }

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

/* ---------- Who's cooking and diners ---------- */
.selects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; font-weight: 700;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23637069' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 38px;
}
.meal .tags { display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
.tag { font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.tag.dan { background: var(--dan); color: var(--dan-ink); }
.tag.laura { background: var(--laura); color: var(--laura-ink); }
.tag.batch { background: var(--batch); color: var(--batch-ink); }
.tag.takeaway { background: var(--takeaway); color: var(--takeaway-ink); }
.meal .diners { font-size: 13px; color: var(--muted); }
