/* DishFolder: warm light theme. Tokens first; no inline styles anywhere. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/fraunces.woff2') format('woff2');
}

:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --line: #e6dccd;
  --text: #2b2118;
  --muted: #76664f;
  --accent: #b84a33;
  --accent-soft: #f6e1d9;
  --accent-ink: #ffffff;
  --ok: #4f7f46;
  --warn: #b97a17;
  --danger: #a93b2b;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 48px;
  --pad: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Hebrew', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --tabbar-h: 64px;
  --shadow: 0 1px 2px rgb(43 33 24 / 6%), 0 4px 14px rgb(43 33 24 / 6%);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.center { text-align: center; }

.icon { width: 22px; height: 22px; flex: none; }

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) var(--pad) calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body.cooking .view { padding-bottom: 24px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 8px; min-height: var(--tap); }
.title { font: 600 1.9rem/1.1 var(--font-display); letter-spacing: -0.01em; flex: 1; }
.title.small { font-size: 1.25rem; }
.topbar-actions { display: flex; gap: 4px; margin-left: auto; }

.icon-btn {
  display: inline-grid; place-items: center;
  min-width: var(--tap); height: var(--tap);
  border: 0; border-radius: 999px; background: transparent; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { min-width: 36px; height: 36px; }
.icon-btn.small .icon { width: 18px; height: 18px; }
.icon-btn.accent { background: var(--accent); color: var(--accent-ink); }
.icon-btn:disabled { opacity: 0.35; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 600; cursor: pointer;
}
.btn .icon { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.big { min-height: 56px; font-size: 1.05rem; padding: 0 24px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; }
.btn:active { transform: translateY(1px); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 8px; }

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.actions-row .btn { flex: 1; }
.actions-row.sticky {
  position: sticky; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  z-index: 2;
}

/* Search and chips */
.search {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; min-height: var(--tap);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted);
}
.search input { flex: 1; border: 0; background: transparent; min-height: 46px; outline: none; color: var(--text); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 0.92rem; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.chip.check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }

/* Recipe grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card:active { transform: scale(0.99); }
.card-body { padding: 10px 12px 12px; display: grid; gap: 2px; }
.card-title { font: 600 1.02rem/1.25 var(--font-display); }
.card-meta { font-size: 0.82rem; color: var(--muted); }

.thumb, .hero, .mini { position: relative; display: grid; place-items: center; overflow: hidden; }
.thumb { aspect-ratio: 4 / 3; }
.hero { aspect-ratio: 16 / 10; border-radius: var(--radius); }
.mini { width: 44px; height: 44px; border-radius: var(--radius-sm); flex: none; }
.thumb img, .hero img, .mini img { width: 100%; height: 100%; object-fit: cover; }
.thumb-emoji { font-size: 2.6rem; filter: drop-shadow(0 2px 4px rgb(0 0 0 / 12%)); }
.hero .thumb-emoji { font-size: 4.5rem; }
.mini .thumb-emoji { font-size: 1.4rem; }
.tone-0 { background: linear-gradient(135deg, #f7d9c4, #efb99b); }
.tone-1 { background: linear-gradient(135deg, #e3ecd3, #c6d8a8); }
.tone-2 { background: linear-gradient(135deg, #fbe7b5, #f2cb7a); }
.tone-3 { background: linear-gradient(135deg, #f3d3d0, #e5a9a2); }
.tone-4 { background: linear-gradient(135deg, #dfe7ea, #bdd0d6); }
.tone-5 { background: linear-gradient(135deg, #eadff0, #d3bfe0); }

.fab {
  position: fixed; right: max(20px, calc(50% - 340px)); bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 20px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 20px rgb(184 74 51 / 35%);
  z-index: 5;
}
.fab .icon { width: 28px; height: 28px; }

.empty { text-align: center; padding: 48px 16px; display: grid; gap: 6px; }
.empty-title { font: 600 1.2rem var(--font-display); }

/* Panels and recipe page */
.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.panel h2 { font: 600 1.15rem var(--font-display); display: flex; align-items: center; gap: 8px; }
.panel.warn { background: #fff4dc; color: #6b4a0c; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row-link { display: flex; align-items: center; gap: 12px; font-weight: 600; min-height: 60px; grid-auto-flow: column; }
.row-link span { flex: 1; }

.recipe-head { display: grid; gap: 6px; }
.recipe-title { font: 600 1.9rem/1.15 var(--font-display); }
.source { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 0.92rem; min-height: 36px; }
.source .icon { width: 18px; height: 18px; }

.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: 999px; }
.stepper-value { min-width: 96px; text-align: center; font-weight: 600; font-size: 0.95rem; }

.segmented { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: transparent; font-weight: 600; font-size: 0.92rem; cursor: pointer; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented.small button { min-height: 34px; padding: 0 12px; font-size: 0.85rem; white-space: nowrap; }

.ingredients { list-style: none; margin: 0; padding: 0; display: grid; }
.ingredients li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ingredients li:last-child { border-bottom: 0; }
.amount { font-weight: 700; min-width: 4.5em; color: var(--accent); }
.ingredient-groups { display: grid; gap: 4px; }
/* Each dish in a meal (kebabs, vegetables, rice) reads as its own block. */
.group-name { font: 700 1.1rem/1.3 var(--font-display); color: var(--text); padding-bottom: 2px; border-bottom: 2px solid var(--accent-soft); }
.group-name ~ .group-name { margin-top: 22px; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 10px; }
.steps li::before {
  content: counter(step);
  width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.9rem;
}
.notes { white-space: pre-wrap; }

/* Cook mode */
.cook { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; gap: 18px; }
.cook-top { display: flex; align-items: center; gap: 8px; }
.cook-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cook-progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.cook-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.25s; }
.cook-step { font: 600 1.75rem/1.35 var(--font-display); flex: 1; padding-top: 12px; }
.cook-uses { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.cook-uses h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.cook-nav { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; padding-bottom: env(safe-area-inset-bottom); }

/* Editor */
.editor { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field-label, .field legend { font-size: 0.85rem; font-weight: 600; color: var(--muted); padding: 0; }
.field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
:where(input:not([type='checkbox']):not([type='file']), textarea, select) {
  width: 100%; min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
textarea { resize: vertical; line-height: 1.5; }
.search input, .add-item input { border: 0; }
.emoji-input { max-width: 96px; font-size: 1.4rem; text-align: center; }

/* Ingredient groups in the editor: bold dish name, its list, space before the next. */
.ing-editor { display: grid; gap: 22px; }
.ing-block { display: grid; gap: 6px; }
.group-name-input {
  font: 700 1.15rem/1.3 var(--font-display);
  color: var(--text);
  border: 0;
  border-bottom: 2px solid var(--accent-soft);
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
  min-height: 40px;
}
.group-name-input::placeholder { font-weight: 600; color: var(--muted); opacity: 0.7; }
.add-group { justify-self: start; }
.photo-pick { position: relative; display: block; cursor: pointer; border-radius: var(--radius); overflow: hidden; }
.photo-pick > img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.photo-label {
  position: absolute; right: 12px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: rgb(43 33 24 / 72%); color: #fff; font-weight: 600; font-size: 0.9rem;
}
.photo-label .icon { width: 18px; height: 18px; }

/* Plan */
.week-nav { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); }
.week-label { border: 0; background: none; font-weight: 600; min-height: var(--tap); cursor: pointer; }
.day { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: grid; gap: 4px; }
.day.today { outline: 2px solid var(--accent); }
.day-name { font: 600 1.05rem var(--font-display); padding-bottom: 4px; }
.slot { display: grid; grid-template-columns: 82px 1fr auto; align-items: center; gap: 8px; min-height: 44px; border-top: 1px solid var(--line); padding: 4px 0; }
.slot-name { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.slot-items { display: grid; gap: 4px; }
.plan-entry { display: flex; align-items: center; gap: 6px; }
.plan-link { display: flex; align-items: center; gap: 10px; flex: 1; font-weight: 600; min-width: 0; }
.plan-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-link .mini { width: 36px; height: 36px; }
.plan-note { flex: 1; font-style: italic; color: var(--muted); }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(43 33 24 / 35%); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 720px; max-height: 82dvh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px var(--pad) calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 12px;
}
.sheet h2 { font: 600 1.2rem var(--font-display); }
.sheet-grip { width: 40px; height: 5px; border-radius: 999px; background: var(--line); justify-self: center; }
.pick-list { display: grid; gap: 6px; }
.pick-recipe { display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; border-radius: var(--radius-sm); background: var(--surface); text-align: left; font-weight: 600; cursor: pointer; }
.pick-days { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pick-day { min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; cursor: pointer; }
.pick-note { display: flex; gap: 8px; }

/* Groceries */
.add-item { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 4px 4px 8px; }
.add-item input { flex: 1; background: transparent; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gsection { display: grid; gap: 6px; }
.gsection-head { display: flex; align-items: center; justify-content: space-between; }
.gsection h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.glist { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.gline { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px; padding: 0 8px 0 0; border-bottom: 1px solid var(--line); }
.gline:last-child { border-bottom: 0; }
.gcheck { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px; border: 0; background: none; text-align: left; cursor: pointer; grid-row: span 2; }
.box { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: #fff; }
.box .icon { width: 16px; height: 16px; }
.gline.checked .box { background: var(--ok); border-color: var(--ok); }
.gline.checked .gtext { color: var(--muted); text-decoration: line-through; }
.gline.checked .amount { color: var(--muted); }
.gtext { display: flex; gap: 8px; flex-wrap: wrap; }
.gtext .amount { min-width: 0; }
.gsrc { grid-column: 1; font-size: 0.78rem; color: var(--muted); padding: 0 12px 8px 48px; margin-top: -10px; }
.aisle-pick { grid-column: 2; grid-row: 1; width: auto; min-height: 32px; padding: 2px 6px; font-size: 0.75rem; color: var(--muted); border-color: transparent; background: var(--surface-2); max-width: 104px; }

/* Cookbooks */
.books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.book { background: var(--surface); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.book h3 { font: 600 1.05rem var(--font-display); }
.book-covers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); place-items: center; }
.book-covers .mini { width: 100%; height: 100%; border-radius: 0; }
.book-covers .muted { grid-column: span 2; }

/* Settings */
.activity { list-style: none; margin: 0; padding: 0; display: grid; }
.activity li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; align-items: center; }
.activity li:last-child { border-bottom: 0; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgb(250 246 240 / 94%); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.tab.on { color: var(--accent); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100% - 32px); padding: 10px 10px 10px 18px; min-height: 48px;
  background: var(--text); color: var(--bg); border-radius: 999px;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-action { border: 0; background: rgb(255 255 255 / 14%); color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
body.cooking .toast { bottom: 24px; }

/* Cook progress widths (no inline styles: one class per 5%). */
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

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