:root {
  --bg: #fff8f0;
  --surface: #ffffff;
  --surface-2: #fbeee1;
  --ink: #2b2118;
  --ink-soft: #6f5f52;
  --line: #efdccb;
  --tomato: #e0552f;
  --tomato-ink: #ffffff;
  --basil: #3f7d4e;
  --basil-soft: #e3f0e5;
  --mustard: #f2b33d;
  --mustard-soft: #fdf0d3;
  --tomato-soft: #fde4da;
  --panic: #da291c;
  --panic-gold: #ffc72c;
  --shadow: 0 1px 2px rgba(60, 35, 15, 0.06), 0 6px 18px rgba(60, 35, 15, 0.08);
  --radius: 22px;
  --display: "Fraunces", Georgia, serif;
  --body: "Nunito", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1511;
    --surface: #271f19;
    --surface-2: #33291f;
    --ink: #f7ede3;
    --ink-soft: #bfae9e;
    --line: #3e3228;
    --tomato: #ec6a43;
    --basil: #7cc08b;
    --basil-soft: #203325;
    --mustard: #f2b33d;
    --mustard-soft: #3a2f18;
    --tomato-soft: #3d241b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--display); font-weight: 650; line-height: 1.15; margin: 0; }
h1 { font-size: 2.1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.25rem; }
.muted { color: var(--ink-soft); }
.hidden { display: none !important; }

/* Top bar with a back button on inner screens */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px -8px;
  min-height: 48px;
}
.back {
  border: 0;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.back:active { background: var(--surface-2); }

/* Home */
.home { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.greeting { margin: 12px 0 8px; }
.greeting p { margin: 6px 0 0; font-size: 1.1rem; }

.big-choice {
  border: 0;
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
  background: var(--surface);
  transition: transform 0.12s ease;
}
.big-choice:active { transform: scale(0.98); }
.big-choice .emoji { font-size: 3rem; line-height: 1; }
.big-choice strong { display: block; font-family: var(--display); font-size: 1.6rem; font-weight: 650; }
.big-choice span.sub { color: var(--ink-soft); font-size: 1rem; }
.big-choice.cook { background: var(--basil-soft); }
.big-choice.order { background: var(--mustard-soft); }

.panic-wrap { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.panic {
  position: relative;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 22px;
  background: var(--panic);
  color: #fff;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 0 #9e1d12, 0 10px 24px rgba(218, 41, 28, 0.35);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.panic .fill {
  position: absolute;
  inset: 0;
  background: var(--panic-gold);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0.55;
}
.panic.holding .fill { transform: scaleX(1); transition: transform var(--hold-ms, 800ms) linear; }
.panic.holding { transform: translateY(3px); box-shadow: 0 3px 0 #9e1d12, 0 6px 16px rgba(218, 41, 28, 0.35); }
.panic .label { position: relative; }
.panic-hint { font-size: 0.9rem; color: var(--ink-soft); }

/* Cards */
.stack { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.idea {
  border: 0;
  width: 100%;
  text-align: left;
  padding: 18px;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 4px 14px;
  align-items: start;
}
.idea:active { transform: scale(0.99); }
.idea .emoji { grid-row: span 3; font-size: 2.8rem; line-height: 1; background: var(--surface-2); border-radius: 18px; width: 64px; height: 64px; display: grid; place-items: center; }
.idea h3 { font-size: 1.3rem; }
.idea p { margin: 0; color: var(--ink-soft); font-size: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
}
.chip.good { background: var(--basil-soft); color: var(--basil); }
.chip.need { background: var(--mustard-soft); color: #8a5d00; }
@media (prefers-color-scheme: dark) { .chip.need { color: var(--mustard); } }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  font-weight: 700;
}
.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s; pointer-events: none; }
.switch .track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--basil); }
.switch input:checked + .track::after { transform: translateX(24px); }

/* Buttons */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 15px 22px;
  font-weight: 800;
  font-size: 1.05rem;
  background: var(--surface-2);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: 52px;
}
.btn:active { filter: brightness(0.95); }
.btn.primary { background: var(--tomato); color: var(--tomato-ink); }
.btn.green { background: var(--basil); color: #fff; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; }
.link-btn { border: 0; background: none; color: var(--ink-soft); font-weight: 700; padding: 10px; text-decoration: underline; text-underline-offset: 3px; }

.footer-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* Loading */
.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 40px 0; }
.loading .pot { font-size: 4rem; animation: bob 1.1s ease-in-out infinite; }
.loading p { font-size: 1.15rem; color: var(--ink-soft); min-height: 1.5em; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }

.message { text-align: center; padding: 30px 10px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.message .big { font-size: 3.4rem; }

/* Recipe */
.recipe-head { text-align: center; margin-bottom: 18px; }
.recipe-head .emoji { font-size: 4rem; line-height: 1.1; }
.recipe-head .chips { justify-content: center; }
.section { padding: 18px; margin-bottom: 14px; }
.section h3 { margin-bottom: 10px; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { border-top: 1px solid var(--line); }
.ingredients li:first-child { border-top: 0; }
.ingredients button {
  border: 0; background: none; width: 100%; text-align: left; padding: 11px 0;
  display: flex; gap: 12px; align-items: baseline; font-size: 1.1rem;
}
.ingredients .box { flex: none; width: 22px; height: 22px; border: 2px solid var(--line); border-radius: 7px; transform: translateY(4px); display: grid; place-items: center; font-size: 0.8rem; color: transparent; }
.ingredients .done .box { background: var(--basil); border-color: var(--basil); color: #fff; }
.ingredients .done .text { text-decoration: line-through; color: var(--ink-soft); }
.ingredients .amount { font-weight: 800; }
.ingredients .buy { font-size: 0.8rem; font-weight: 800; color: #8a5d00; background: var(--mustard-soft); border-radius: 999px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 1.15rem; line-height: 1.5; }
.steps li:first-child { border-top: 0; padding-top: 2px; }
.steps li::before { content: counter(step); width: 34px; height: 34px; border-radius: 50%; background: var(--tomato); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1rem; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; margin-bottom: 14px; font-size: 1.02rem; }
.note .emoji { font-size: 1.5rem; line-height: 1.2; }

/* Restaurants */
.place .photo { height: 150px; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; font-size: 3.4rem; }
.place .body { padding: 16px 18px 18px; }
.place .meta { color: var(--ink-soft); font-size: 1rem; margin: 4px 0 0; }
.place .meta b { color: var(--ink); }
.place .summary { font-size: 0.98rem; margin: 8px 0 0; }
.place .actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-top: 14px; }
.place .actions .btn { padding: 12px 10px; font-size: 0.98rem; min-height: 48px; }
.place .dismiss { display: block; margin: 8px auto 0; font-size: 0.95rem; }

/* Panic overlay */
.panic-screen {
  position: fixed; inset: 0; z-index: 50;
  background: var(--panic);
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center;
  animation: siren 0.35s steps(1) 6;
}
@keyframes siren { 0% { background: var(--panic); } 50% { background: #b01e12; } }
.panic-screen .fries { font-size: 6rem; animation: pop 0.6s cubic-bezier(.2, 1.6, .4, 1) both; }
.panic-screen h1 { font-size: 2.6rem; color: var(--panic-gold); animation: pop 0.6s 0.15s cubic-bezier(.2, 1.6, .4, 1) both; }
.panic-screen p { font-size: 1.2rem; margin: 0; max-width: 22em; animation: fade 0.5s 0.5s both; }
.panic-screen .actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; margin-top: 10px; animation: fade 0.5s 0.7s both; }
.panic-screen .btn { background: var(--panic-gold); color: #3a1a00; }
.panic-screen .btn.ghost { background: rgba(255, 255, 255, 0.16); color: #fff; }
.panic-screen .link-btn { color: rgba(255, 255, 255, 0.85); }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Celebration */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span { position: absolute; top: -40px; font-size: 1.8rem; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 700;
  z-index: 70; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Text boxes (her order note; the pantry page has its own additions) */
.input {
  width: 100%;
  border: 2px solid var(--line);
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 50px;
  resize: vertical;
}
.input:focus { outline: none; border-color: var(--tomato); }
.panic-screen .input { background: rgba(255, 255, 255, 0.95); color: #2b2118; border-color: transparent; }
.panic-screen .alerted { font-weight: 800; background: rgba(0, 0, 0, 0.18); border-radius: 999px; padding: 6px 16px; }

/* Tonight page */
.tonight-when { text-align: center; color: var(--ink-soft); font-weight: 700; margin: -4px 0 16px; }
.her-note { padding: 16px 18px; margin: 14px 0; font-size: 1.15rem; border-left: 6px solid var(--tomato); }
.her-note b { display: block; font-size: 0.85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }

/* Favorites */
.big-choice.favorites { background: var(--tomato-soft); }
.ingredients.static li { padding: 10px 0; font-size: 1.1rem; }
.ingredients .mark { display: inline-block; width: 1.4em; font-weight: 800; color: var(--ink-soft); }
.ingredients .done-have .mark { color: var(--basil); }
.ingredients .optional { font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
