/* Kitchen-notebook direction: warm paper, ink, terracotta; serif display + humanist sans. */
:root {
  --paper: #f4ede1;
  --paper-2: #ece3d3;
  --card: #fffcf6;
  --ink: #2a241d;
  --ink-2: #5a5045;
  --muted: #94897a;
  --line: #e2d7c4;
  --accent: #c2502f;
  --accent-soft: #f3d9cc;
  --sage: #6c8460;
  --mustard: #cf9b2c;
  --clay: #b8674b;
  --shadow: 0 1px 0 rgba(60, 40, 20, .04), 0 12px 28px -14px rgba(70, 45, 20, .28);
  --radius-l: 26px;
  --radius-m: 18px;
  --radius-s: 12px;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Onest", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="dark"] {
  --paper: #1b1814;
  --paper-2: #24201b;
  --card: #2a2520;
  --ink: #f3eadb;
  --ink-2: #cdbfab;
  --muted: #8f8474;
  --line: #3a332b;
  --accent: #e4774f;
  --accent-soft: #4a2c20;
  --sage: #93ab85;
  --mustard: #e2b450;
  --clay: #d98a6c;
  --shadow: 0 14px 30px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image: radial-gradient(rgba(120, 90, 50, .06) 1px, transparent 1px);
  background-size: 4px 4px;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app { padding: 18px 18px calc(96px + var(--safe-b)); max-width: 560px; margin: 0 auto; }

/* ---------- boot / states ---------- */
.boot, .state { min-height: 70vh; display: grid; place-content: center; text-align: center; gap: 14px; color: var(--ink-2); }
.boot__plate {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
.state h1 { font: 600 30px/1.1 var(--serif); color: var(--ink); margin: 0; }
.state p { margin: 0; max-width: 280px; }
.state__emoji { font-size: 54px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- header ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 16px; }
.eyebrow { font: 600 11px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.head h1 { font: 700 32px/1.02 var(--serif); margin: 8px 0 0; letter-spacing: -.01em; }
.head h1 em { font-style: italic; font-weight: 500; color: var(--ink-2); }
.icon-btn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow);
  transition: transform .2s var(--ease);
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg, .tab svg, .chip svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- date strip ---------- */
.dates {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -18px 18px; padding: 4px 18px 8px; scrollbar-width: none;
}
.dates::-webkit-scrollbar { display: none; }
.date {
  flex: none; width: 52px; padding: 9px 0 10px; border-radius: 16px; scroll-snap-align: center;
  display: grid; justify-items: center; gap: 2px; background: var(--card); border: 1px solid var(--line);
  transition: background .25s var(--ease), color .25s var(--ease), transform .2s var(--ease);
}
.date small { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.date b { font: 600 19px/1.1 var(--serif); }
.date i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.date.is-today i { background: var(--accent); }
.date.is-prep { border-style: dashed; border-color: var(--mustard); }
.date.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); transform: translateY(-2px); }
.date.is-active small { color: inherit; opacity: .7; }
.date.is-active.is-today i { background: var(--accent); }

/* ---------- day hero ---------- */
.hero {
  position: relative; display: grid; grid-template-columns: 112px 1fr; gap: 18px; align-items: center;
  padding: 18px; border-radius: var(--radius-l); background: var(--card); box-shadow: var(--shadow); margin-bottom: 22px;
  overflow: hidden;
}
.hero::after {
  content: attr(data-num); position: absolute; right: 14px; top: -22px;
  font: italic 600 96px/1 var(--serif); color: var(--paper-2); z-index: 0; pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.ring { width: 112px; height: 112px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--paper-2); }
.ring .seg { transition: stroke-dasharray .9s var(--ease); }
.ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__label b { font: 700 26px/1 var(--serif); }
.ring__label span { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.hero__title { font: 600 13px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hero__name { font: 700 24px/1.1 var(--serif); margin: 6px 0 12px; }
.macros { display: grid; gap: 7px; }
.macro { display: grid; grid-template-columns: 66px 1fr 44px; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.macro__bar { height: 6px; border-radius: 6px; background: var(--paper-2); overflow: hidden; }
.macro__bar i { display: block; height: 100%; border-radius: inherit; transform-origin: left; animation: grow .9s var(--ease) both; }
.macro b { text-align: right; font-weight: 600; color: var(--ink); }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- meals ---------- */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 12px; }
.section-title h2 { font: 700 22px/1.1 var(--serif); margin: 0; }
.section-title span { color: var(--muted); font-size: 13px; }
.meals { display: grid; gap: 14px; }
.meal {
  display: grid; grid-template-columns: 108px 1fr; gap: 14px; align-items: stretch; text-align: left; width: 100%;
  background: var(--card); border-radius: var(--radius-m); padding: 10px; box-shadow: var(--shadow);
  animation: rise .5s var(--ease) both; transition: transform .2s var(--ease);
}
.meal:active { transform: scale(.98); }
.meal:nth-child(2) { animation-delay: .05s; } .meal:nth-child(3) { animation-delay: .1s; } .meal:nth-child(4) { animation-delay: .15s; }
.meal__img { width: 108px; height: 108px; border-radius: 13px; object-fit: cover; background: var(--paper-2); }
.meal__body { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding-right: 4px; min-width: 0; }
.meal__type { font: 600 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.meal__title { font: 600 18px/1.2 var(--serif); }
.meal__meta { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); }
.meal__meta b { color: var(--ink-2); font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft); color: var(--ink); padding: 12px 14px; border-radius: var(--radius-m); margin-bottom: 16px; font-size: 14px;
}

/* ---------- buttons / chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: 14px; transition: transform .2s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn--accent { background: var(--accent); color: #fff; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.chips { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.chip {
  flex: none; padding: 9px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 14px; font-weight: 500; transition: all .2s var(--ease);
}
.chip.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- prep ---------- */
.prep-card { border-radius: var(--radius-l); background: var(--ink); color: var(--paper); padding: 20px; margin-bottom: 20px; position: relative; overflow: hidden; }
.prep-card .eyebrow { color: var(--mustard); }
.prep-card h2 { font: 700 28px/1.05 var(--serif); margin: 10px 0 4px; }
.prep-card p { margin: 0; opacity: .75; font-size: 14px; }
.thumbs { display: flex; margin-top: 16px; }
.thumbs img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; border: 3px solid var(--ink); margin-right: -12px; background: var(--paper-2); }
.tip { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px dashed var(--mustard); border-radius: var(--radius-m); padding: 12px 14px; margin-bottom: 18px; font-size: 14px; color: var(--ink-2); }
.tip b { color: var(--ink); }

/* ---------- checklist ---------- */
.progress { display: flex; align-items: center; gap: 12px; margin: 0 2px 14px; font-size: 13px; color: var(--muted); }
.progress__bar { flex: 1; height: 6px; background: var(--paper-2); border-radius: 6px; overflow: hidden; }
.progress__bar i { display: block; height: 100%; background: var(--sage); border-radius: inherit; transition: width .4s var(--ease); }
.group { background: var(--card); border-radius: var(--radius-m); box-shadow: var(--shadow); padding: 4px 0; margin-bottom: 14px; }
.group h3 { margin: 0; padding: 12px 16px 6px; font: 600 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.item {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 16px; border-top: 1px solid var(--line);
}
.group h3 + .item, .group > .item:first-child { border-top: 0; }
.box { width: 22px; height: 22px; border-radius: 7px; border: 1.6px solid var(--muted); display: grid; place-items: center; transition: all .2s var(--ease); }
.box svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; transform: scale(.4); transition: all .2s var(--ease); }
.item.is-done .box { background: var(--sage); border-color: var(--sage); }
.item.is-done .box svg { opacity: 1; transform: scale(1); }
.item__name { font-size: 15px; }
.item__name::first-letter { text-transform: uppercase; }
.item__name small { display: block; color: var(--accent); font-size: 12px; margin-top: 2px; }
.item__qty { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.item.is-done .item__name, .item.is-done .item__qty { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }

/* ---------- book ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rcard { text-align: left; background: var(--card); border-radius: var(--radius-m); box-shadow: var(--shadow); padding: 8px; transition: transform .2s var(--ease); animation: rise .45s var(--ease) both; }
.rcard:active { transform: scale(.97); }
.mosaic { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: var(--paper-2); }
.mosaic img { width: 100%; height: 100%; object-fit: cover; }
.rcard__foot { display: flex; align-items: baseline; justify-content: space-between; padding: 9px 4px 3px; }
.rcard__foot b { font: italic 600 22px/1 var(--serif); }
.rcard__foot span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rcard__foot .badge { color: #fff; background: var(--accent); padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.rcard.is-today { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- sheet (recipe / settings) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; background: var(--paper); overflow-y: auto; animation: sheet-in .38s var(--ease) both; overscroll-behavior: contain; }
.sheet.is-closing { animation: sheet-out .25s ease-in both; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@keyframes sheet-out { to { transform: translateY(40px); opacity: 0; } }
.recipe__photo { position: relative; height: 46vh; min-height: 280px; max-height: 420px; }
.recipe__photo img { width: 100%; height: 100%; object-fit: cover; }
.recipe__photo::after { content: ""; position: absolute; inset: auto 0 0; height: 90px; background: linear-gradient(transparent, var(--paper)); }
.recipe__close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.recipe__body { padding: 0 20px calc(40px + var(--safe-b)); margin-top: -34px; position: relative; z-index: 1; max-width: 560px; margin-left: auto; margin-right: auto; }
.recipe__body h1 { font: 700 30px/1.08 var(--serif); margin: 8px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 22px; }
.stat { background: var(--card); border-radius: 14px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font: 700 19px/1.1 var(--serif); }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat--kcal b { color: var(--accent); }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.stepper button { width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1; background: var(--paper-2); }
.stepper b { min-width: 64px; text-align: center; font-size: 13px; font-weight: 600; }
.steps { font-size: 16px; line-height: 1.6; color: var(--ink-2); }
.steps p { margin: 0 0 12px; padding-left: 34px; position: relative; }
.steps p::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font: 700 13px/24px var(--sans); text-align: center;
}
.steps { counter-reset: step; }
.settings { padding: 22px 20px calc(40px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.settings h1 { font: 700 30px/1.1 var(--serif); margin: 6px 0 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; background: var(--card); border-radius: var(--radius-m); box-shadow: var(--shadow); margin-bottom: 12px; }
.row p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin: 18px 4px; line-height: 1.5; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 20; max-width: 536px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; border-radius: 24px;
  background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 10px 30px -12px rgba(40, 25, 10, .35), inset 0 0 0 1px var(--line);
}
.tab { display: grid; justify-items: center; gap: 3px; padding: 8px 0 6px; border-radius: 18px; color: var(--muted); font-size: 11px; font-weight: 600; transition: color .2s, background .2s; }
.tab.is-active { color: var(--ink); background: var(--paper-2); }
.tab.is-active svg { stroke: var(--accent); }

.view { animation: fade .3s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }

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