/* Meal Plan: an iPhone Home Screen web app. System font, Dynamic-Type-like sizes, light and dark. */
:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efeae2;
  --text: #1d1b18;
  --muted: #6b655c;
  --line: #e2dcd2;
  --accent: #2f6b4f;          /* olive-leaf green */
  --accent-text: #ffffff;
  --accent-soft: #e3efe7;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --danger: #b3261e;
  --free: #6b5aa6;
  --free-soft: #ece8f6;
  --radius: 14px;
  --tap: 44px;
  --font-scale: 1;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #23211e;
    --surface-2: #2d2a26;
    --text: #f2eee8;
    --muted: #a9a297;
    --line: #3a3631;
    --accent: #7cc39c;
    --accent-text: #10241a;
    --accent-soft: #1f3529;
    --warn: #f0b75e;
    --warn-soft: #3a2c14;
    --danger: #ff8a80;
    --free: #b9a9f0;
    --free-soft: #2c2740;
  }
}
html[data-text-size="1"] { --font-scale: 1.12; }
html[data-text-size="2"] { --font-scale: 1.25; }
html[data-text-size="3"] { --font-scale: 1.45; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: calc(17px * var(--font-scale)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: -apple-system-body;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--accent); }
p { margin: 0.35em 0; }
h1, h2, h3 { line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-size: 0.9em; }

/* Layout */
.view {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
.view.recipe { padding-bottom: calc(env(safe-area-inset-bottom) + 120px); }
.center { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 16px; text-align: center; }
section { margin: 18px 0; }
.top { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.top h1 { font-size: 1.8rem; margin: 0; flex: 1; letter-spacing: -0.01em; }
.top .segmented { flex-basis: 100%; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 0.9rem; }
.day-header .titles { flex: 1; text-align: center; }
.day-header h1 { flex: none; }
.recipe-header h1 { font-size: 1.45rem; }
.nav-arrow {
  min-width: var(--tap); min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem; line-height: 1; text-decoration: none; color: var(--accent); background: none; border: 0; border-radius: 50%;
}
.aa { min-width: var(--tap); min-height: var(--tap); background: var(--surface-2); border: 0; border-radius: 10px; font-weight: 600; }
.back-today { text-align: center; margin-top: -4px; }

.section-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin: 0 0 6px;
}
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.small-head { font-size: 0.95rem; margin: 12px 0 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--line); }
.card h2 { font-size: 1.3rem; margin: 4px 0; }
.card h2 a { color: inherit; text-decoration: none; }
.card.hero { border: 0; box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(0,0,0,0.06); }
.card.info { background: var(--accent-soft); border-color: transparent; }
.card.free { background: var(--free-soft); border-color: transparent; }
.card.free .eyebrow { color: var(--free); }
.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; margin: 0; }
.meta { color: var(--muted); font-size: 0.9rem; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.link-card { display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: inherit; min-height: var(--tap); }
.banner { display: flex; align-items: center; gap: 12px; background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; }
.banner p { flex: 1; margin: 0; }
.banner.warn { background: var(--warn-soft); }
.error { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: var(--radius); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 16px;
  border-radius: 12px; border: 0; background: var(--surface-2); color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 0.9rem; }
.btn.wide { width: 100%; margin: 6px 0; }
.btn.link { background: none; color: var(--accent); padding: 0 4px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.btn-row .btn { flex: 1; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 600; text-decoration: underline; min-height: 30px; }

.segmented { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button {
  flex: 1; min-height: 36px; border: 0; background: none; border-radius: 8px; font-weight: 600; font-size: 0.9rem; color: var(--muted); padding: 0 6px;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* Reminders */
.reminders { margin-top: 8px; }
.reminder { display: flex; gap: 12px; align-items: flex-start; background: var(--warn-soft); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.reminder.done { background: var(--surface); opacity: 0.7; }
.reminder.done .reminder-text p { text-decoration: line-through; }
.reminder-text { flex: 1; }
.reminder-text p { margin: 0 0 4px; }
.tick {
  flex: none; width: 32px; height: 32px; margin: 6px 0; border-radius: 50%; border: 2px solid var(--muted); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent-text); position: relative;
}
.tick::after { content: ""; position: absolute; inset: -8px; }  /* a 48 px target */
.tick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.tick.placeholder { visibility: hidden; }
.icon { font-style: normal; }

/* Meal lists */
.meals { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.meal + .meal { border-top: 1px solid var(--line); }
.meal-link, .meal.free {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px; color: inherit; text-decoration: none;
  width: 100%; background: none; border: 0; text-align: left;
}
.meal-link > div, .meal.free > div { flex: 1; }
.meal-kind { flex: none; width: 6.4em; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.meal-title { margin: 0; font-weight: 600; }
.meal.free .meal-title { color: var(--free); }
.chev { color: var(--muted); font-size: 1.4rem; }
.totals { text-align: center; margin-top: 8px; }

/* Recipe */
.intro { color: var(--muted); }
.ingredients { list-style: none; padding: 0; margin: 0 0 12px; }
.ing {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 2px; border-bottom: 1px solid var(--line); min-height: var(--tap);
}
.ing .box { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--muted); margin-top: 2px; }
.ing.on { color: var(--muted); }
.ing.on .box { background: var(--accent); border-color: var(--accent); }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { display: flex; gap: 12px; padding: 12px 10px; border-radius: var(--radius); margin: 0 -10px; cursor: pointer; }
.steps li.current { background: var(--accent-soft); }
.steps li p { margin: 0; font-size: 1.08rem; }
.step-no {
  flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem;
}
.steps li.current .step-no { background: var(--accent); color: var(--accent-text); }
.timer-btn {
  display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--accent); color: var(--accent); background: var(--surface);
  border-radius: 999px; padding: 1px 10px; font-weight: 600; min-height: 32px; margin: 2px 0;
}
.tip { background: var(--surface-2); padding: 10px 14px; border-radius: var(--radius); }
details { margin: 16px 0; }
details > summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; color: var(--accent); }
.nutrition table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.nutrition th, .nutrition td { text-align: right; padding: 4px; border-bottom: 1px solid var(--line); }
.nutrition th:first-child { text-align: left; }
.nutrition { overflow-x: auto; }

/* Timers */
.timerbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--text); color: var(--bg); display: grid; gap: 6px;
}
.timer { display: flex; align-items: center; gap: 10px; }
.timer-label { flex: 1; font-size: 0.9rem; }
.timer-time { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 700; }
.timer.ringing { animation: flash 0.8s infinite alternate; }
.timer .btn { background: var(--bg); color: var(--text); }
@keyframes flash { from { opacity: 1; } to { opacity: 0.4; } }

/* Plan calendar */
.legend { margin-top: 0; }
.calendar { list-style: none; padding: 0; margin: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.calendar li + li { border-top: 1px solid var(--line); }
.cal-day { display: flex; gap: 12px; align-items: center; padding: 8px 12px; text-decoration: none; color: inherit; min-height: 56px; }
.cal-day.today { background: var(--accent-soft); }
.cal-day.past { opacity: 0.6; }
.cal-date { flex: none; width: 2.8em; text-align: center; line-height: 1.1; }
.cal-wd { display: block; font-size: 0.75rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.cal-dm { display: block; font-size: 1.25rem; font-weight: 700; }
.cal-meals { flex: 1; min-width: 0; }
.cal-dinner { margin: 0; font-weight: 600; }
.cal-dinner.free { color: var(--free); }
.cal-marks { flex: none; display: flex; gap: 4px; color: var(--accent); }
.pager { display: flex; gap: 8px; justify-content: space-between; }

/* Recipes list */
.search { width: 100%; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; margin: 4px 0 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 0.9rem; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { margin: 6px 0; }
.notes { padding-left: 1.1em; }
.notes li { margin: 8px 0; }

/* Shopping */
.range { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row .segmented { flex: 1; }
.range-label { width: 3em; color: var(--muted); font-size: 0.9rem; }
.date { min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; flex: 1; }
.summary { margin: 12px 2px; }
.shop { list-style: none; padding: 0; margin: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.shop-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px 8px 12px; }
.shop-row + .shop-row { border-top: 1px solid var(--line); }
.shop-row.on .shop-main { opacity: 0.5; }
.shop-row.on .shop-name { text-decoration: line-through; }
.shop-main { flex: 1; min-width: 0; cursor: pointer; padding: 4px 0; }
.shop-name { margin: 0; font-weight: 600; }
.shop-amount { margin: 0; }
.shop-row .small { margin: 2px 0; }
.hint { color: var(--warn); }
.more { flex: none; min-width: var(--tap); min-height: var(--tap); border: 0; background: none; color: var(--muted); font-size: 1.3rem; }
.tips { margin-top: 20px; }

/* Settings and forms */
.group { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 12px 14px; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 36px; }
.row-item span:last-child { text-align: right; overflow-wrap: anywhere; }
.switch { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.form { display: grid; gap: 6px; }
.form label, .group label { font-weight: 600; font-size: 0.9rem; margin-top: 8px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 8px 12px;
}
.group input, .group select { margin: 6px 0; }
fieldset { border: 0; padding: 0; margin: 12px 0; }
legend { font-weight: 600; font-size: 0.9rem; }
.help { color: var(--muted); font-size: 0.9rem; }
.help ol { padding-left: 1.2em; }

/* Sheets and toasts */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0); display: flex; align-items: flex-end; justify-content: center;
  transition: background 0.2s;
}
.sheet-backdrop.open { background: rgba(0,0,0,0.35); }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px); transform: translateY(20px); transition: transform 0.2s;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet h2 { margin-top: 0; font-size: 1.25rem; }
.sheet-actions { margin-top: 12px; }
.effects { padding-left: 1.1em; }
.effects li { margin: 6px 0; }
.stepper { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 8px 0; font-weight: 600; }
.stepper .btn { min-width: var(--tap); min-height: var(--tap); font-size: 1.3rem; }
.choices .btn { justify-content: flex-start; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 50; max-width: 600px; margin: 0 auto;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; gap: 12px;
}
.toast span { flex: 1; }
.toast-action { background: none; border: 0; color: var(--accent-soft); font-weight: 700; min-height: 36px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0 4px; min-height: 52px;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; font-weight: 600;
}
.tab-icon { font-size: 1.3rem; line-height: 1.2; }
.tab.on { color: var(--accent); }
body:has(.tabbar) .timerbar { bottom: calc(env(safe-area-inset-bottom) + 53px); padding-bottom: 8px; }
body:has(.timerbar) .toast { bottom: calc(env(safe-area-inset-bottom) + 140px); }
