:root {
  --cream-50: #0d120f;
  --cream-100: #090d0b;
  --cream-200: #181f1a;
  --cream-300: #2d372f;
  --ink: #f3efe6;
  --muted: #9aa39b;
  --green-900: #dcebcf;
  --green-800: #79aa57;
  --green-700: #86ba61;
  --green-100: #263722;
  --green-50: #192318;
  --orange: #db9a5d;
  --danger: #ef8175;
  --surface-app: rgba(11, 15, 12, 0.96);
  --surface-header: rgba(9, 13, 11, 0.88);
  --surface-card: rgba(20, 26, 22, 0.88);
  --surface-card-solid: #151b17;
  --surface-control: #1a211c;
  --surface-input: #111713;
  --surface-nav: rgba(10, 14, 11, 0.94);
  --surface-sheet: #111713;
  --surface-about: #132018;
  --border: rgba(225, 235, 222, 0.10);
  --border-strong: rgba(225, 235, 222, 0.17);
  --shadow-soft: 0 18px 46px rgba(0, 0, 0, 0.34);
  --shadow-card: 0 8px 26px rgba(0, 0, 0, 0.25);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --page-pad: clamp(16px, 4vw, 28px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream-100);
  color-scheme: dark;
  font-synthesis: none;
}

html[data-theme="light"] {
  --cream-50: #fffdf8;
  --cream-100: #f8f3e9;
  --cream-200: #eee5d6;
  --cream-300: #dfd3bf;
  --ink: #17231a;
  --muted: #6f776f;
  --green-900: #173e27;
  --green-800: #245435;
  --green-700: #356b45;
  --green-100: #dfe9df;
  --green-50: #edf3eb;
  --orange: #c9783a;
  --danger: #a44236;
  --surface-app: rgba(255, 253, 248, 0.96);
  --surface-header: rgba(255, 253, 248, 0.90);
  --surface-card: rgba(255, 255, 255, 0.76);
  --surface-card-solid: #ffffff;
  --surface-control: #ffffff;
  --surface-input: #fffdf8;
  --surface-nav: rgba(255, 253, 248, 0.94);
  --surface-sheet: #fffdf8;
  --surface-about: #173e27;
  --border: rgba(48, 72, 50, 0.10);
  --border-strong: rgba(36, 84, 53, 0.18);
  --shadow-soft: 0 14px 38px rgba(40, 45, 37, 0.09);
  --shadow-card: 0 7px 22px rgba(40, 45, 37, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream-100); }
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(93, 137, 70, 0.14), transparent 34rem),
    linear-gradient(180deg, var(--cream-50), var(--cream-100));
  color: var(--ink);
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface-app);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 16px) var(--page-pad) 14px;
  background: var(--surface-header);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font: 700 clamp(1.55rem, 4vw, 2rem)/1 Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}
.brand-mark { width: 27px; height: 27px; display: inline-grid; place-items: center; color: var(--green-700); }
.brand-mark .icon { width: 27px; height: 27px; }
.topbar-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 0.76rem; }
.topbar-actions { display: flex; gap: 8px; }
.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-control);
  cursor: pointer;
}
.icon-button:active { transform: scale(0.96); }
.install-button { background: var(--surface-about); color: white; }

.main-content {
  padding: 20px var(--page-pad) calc(112px + env(safe-area-inset-bottom));
  outline: none;
}
.view { display: none; animation: viewIn 260ms ease both; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2, h3, p { margin-top: 0; }
h1, h2, .continue-card h2, .recipe-card h3, .mini-recipe-card h3 {
  text-wrap: balance;
}
h1 {
  margin-bottom: 7px;
  font: 700 clamp(1.85rem, 6vw, 2.8rem)/1.05 Georgia, "Times New Roman", serif;
  letter-spacing: -0.04em;
}
h2 { margin-bottom: 0; font-size: 1.08rem; letter-spacing: -0.02em; }
h3 { font-size: 0.92rem; }
p { color: var(--muted); line-height: 1.5; }
.eyebrow, .section-kicker {
  margin-bottom: 7px;
  color: var(--green-700);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.home-heading, .page-heading { margin: 8px 0 24px; }
.home-heading p:last-child, .page-heading p:last-child { margin-bottom: 0; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }

.continue-card {
  margin-bottom: 30px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}
.section-label-row, .section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-label-row { margin-bottom: 13px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--green-50);
  color: var(--green-800);
  font-size: 0.68rem;
  font-weight: 700;
}
.continue-content { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 12px; }

img.image-load-failed {
  color: transparent;
  background:
    linear-gradient(135deg, rgba(47, 108, 69, 0.08), rgba(205, 181, 139, 0.18)),
    var(--cream-200);
}

.continue-content img { width: 74px; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-md); background: var(--cream-200); }
.continue-copy h2 { margin-bottom: 4px; font-size: 0.96rem; }
.continue-copy p { margin-bottom: 10px; font-size: 0.75rem; }
.progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: var(--cream-200); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green-700); }

.primary-button, .secondary-button, .filter-button, .text-button {
  border: 0;
  cursor: pointer;
  font-weight: 750;
}
.primary-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  background: var(--green-800);
  color: white;
  box-shadow: 0 8px 20px rgba(36, 84, 53, 0.16);
}
.primary-button.compact { min-height: 36px; padding: 0 13px; font-size: 0.74rem; }
.secondary-button {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-card-solid);
  color: var(--green-800);
}
.text-button { padding: 8px 0; background: transparent; color: var(--green-700); font-size: 0.78rem; }

.content-section { margin-top: 30px; }
.section-heading-row { margin-bottom: 14px; }
.section-heading-row .section-kicker { margin-bottom: 4px; }
.horizontal-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(142px, 42%);
  gap: 12px;
  overflow-x: auto;
  padding: 2px 1px 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.horizontal-cards::-webkit-scrollbar { display: none; }
.mini-recipe-card { scroll-snap-align: start; cursor: pointer; }
.mini-recipe-card img { width: 100%; aspect-ratio: 1.25; object-fit: cover; border-radius: var(--radius-md); background: var(--cream-200); box-shadow: var(--shadow-card); }
.mini-recipe-card h3 { margin: 9px 0 3px; line-height: 1.25; }
.mini-recipe-card p { margin-bottom: 0; font-size: 0.72rem; }

.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.category-card {
  min-height: 102px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  text-align: left;
  cursor: pointer;
}
.category-card:active { transform: scale(0.98); }
.category-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--green-50);
  color: var(--green-800);
  font-weight: 800;
}
.category-card strong, .category-card small { display: block; }
.category-card strong { margin-bottom: 3px; font-size: 0.77rem; }
.category-card small { color: var(--muted); font-size: 0.63rem; }

.segmented-control { display: inline-flex; padding: 3px; border-radius: 13px; background: var(--cream-200); }
.segment { width: 38px; height: 34px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--muted); }
.segment.active { background: var(--surface-card-solid); color: var(--green-700); box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22); }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
.search-field {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-card);
}
.search-field.full-width { margin-bottom: 8px; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field input::placeholder { color: var(--muted); }
.filter-button { padding: 0 16px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-card-solid); color: var(--green-800); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 13px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-card);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.filter-chip.active { background: var(--green-800); color: white; }

.filter-panel {
  margin: 3px 0 18px;
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-card-solid);
  box-shadow: var(--shadow-soft);
}
.filter-panel-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 17px; }
.filter-form-grid { display: grid; gap: 13px; }
.filter-form-grid label { color: var(--ink); font-size: 0.75rem; font-weight: 750; }
.filter-form-grid input:not([type="checkbox"]), .filter-form-grid select {
  width: 100%; min-height: 44px; margin-top: 7px; padding: 0 12px; border: 1px solid var(--cream-300); border-radius: 12px; background: var(--surface-input); outline: none;
}
.checkbox-label { display: flex; align-items: center; gap: 10px; }
.checkbox-label input { width: 20px; height: 20px; accent-color: var(--green-800); }
.filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.recipe-library { display: grid; gap: 13px; }
.recipe-library.grid-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.recipe-library.list-layout { grid-template-columns: 1fr; }
.recipe-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  cursor: pointer;
}
.recipe-image-wrap { position: relative; }
.recipe-image-wrap > img { width: 100%; aspect-ratio: 1.25; object-fit: cover; background: var(--cream-200); }
.favourite-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 20, 16, 0.84);
  color: var(--green-800);
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(31, 44, 31, 0.12);
}
.favourite-button.active { color: var(--green-700); }
.image-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(44, 91, 52, 0.92);
  color: white;
  font-size: 0.58rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recipe-card-copy { padding: 11px; }
.recipe-card-copy h3 { min-height: 2.3em; margin-bottom: 5px; line-height: 1.2; }
.recipe-card-copy > p { margin-bottom: 8px; font-size: 0.68rem; }
.recipe-card-copy > p span { padding: 0 3px; }
.recipe-card-meta { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 0.61rem; }
.list-layout .recipe-card { display: grid; grid-template-columns: 118px 1fr; }
.list-layout .recipe-image-wrap > img { height: 100%; aspect-ratio: auto; }
.list-layout .recipe-card-copy { display: flex; flex-direction: column; justify-content: center; }
.list-layout .recipe-card-copy h3 { min-height: auto; font-size: 1rem; }
.compact-library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.empty-state { padding: 56px 24px; text-align: center; }
.empty-state > .empty-icon { width: 42px; height: 42px; color: var(--green-700); }
.empty-state h2 { margin: 12px 0 5px; }

.settings-section { margin-top: 26px; }
.settings-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-card);
}
.settings-card > button,
.settings-toggle-row,
.settings-static-row {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
}
.settings-card > :last-child { border-bottom: 0; }
.settings-card > button { grid-template-columns: 1fr auto auto; cursor: pointer; }
.settings-card span strong,
.settings-card span small,
.settings-card > button > span:nth-child(2),
.settings-toggle-row > span:nth-child(2),
.settings-static-row > span:nth-child(2) {
  display: block;
}
.settings-card button span, .settings-card span strong { font-size: 0.82rem; font-weight: 750; }
.settings-card small { margin-top: 3px; color: var(--muted); font-size: 0.66rem; }
.settings-card b { color: var(--muted); font-size: 0.7rem; }
.settings-card select { min-height: 36px; max-width: 124px; border: 1px solid var(--cream-300); border-radius: 10px; background: var(--surface-input); }
.settings-toggle-row input[type="checkbox"] { width: 42px; height: 24px; accent-color: var(--green-800); }
.danger-row span { color: var(--danger); }
.about-card { display: flex; align-items: center; gap: 14px; margin-top: 28px; padding: 18px; border-radius: var(--radius-lg); background: var(--surface-about); color: white; }
.about-card h2 { margin-bottom: 4px; font: 700 1.5rem Georgia, serif; }
.about-card p { margin-bottom: 9px; color: rgba(255,255,255,0.7); font-size: 0.74rem; }
.about-logo { width: 58px; height: 58px; overflow: hidden; display: grid; place-items: center; border-radius: 18px; background: rgba(255,255,255,0.08); }
.about-logo img { width: 100%; height: 100%; object-fit: cover; }
.about-card .status-pill { background: rgba(255,255,255,0.12); color: white; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  inset: auto 0 0 0;
  width: 100%;
  min-height: calc(72px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  padding: 8px max(var(--page-pad), env(safe-area-inset-left)) env(safe-area-inset-bottom) max(var(--page-pad), env(safe-area-inset-right));
  border-top: 1px solid var(--border);
  background: var(--surface-nav);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  transform: translateZ(0);
}
.nav-item {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #8b9188;
  cursor: pointer;
}
.nav-item small { font-size: 0.6rem; font-weight: 750; }
.nav-item.active { color: var(--green-800); }
.nav-add {
  width: 52px;
  height: 52px;
  justify-self: center;
  margin-top: -20px;
  border: 5px solid var(--cream-50);
  border-radius: 50%;
  background: var(--green-800);
  color: white;
  box-shadow: 0 10px 24px rgba(36,84,53,0.28);
  cursor: pointer;
}

.sheet-backdrop {
  position: fixed;
  z-index: 45;
  inset: 0;
  background: rgba(18, 25, 20, 0.42);
  opacity: 0;
  transition: opacity 220ms ease;
}
.sheet-backdrop.visible { opacity: 1; }
.bottom-sheet {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 0;
  width: min(100%, 560px);
  max-height: min(78vh, 680px);
  overflow: auto;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--surface-sheet);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.46);
  transform: translate(-50%, 104%);
  transition: transform 240ms cubic-bezier(.2,.8,.2,1);
}
.bottom-sheet.visible { transform: translate(-50%, 0); }
.sheet-open { overflow: hidden; }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 18px; border-radius: 999px; background: var(--cream-300); }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.sheet-header h2 { font: 700 1.5rem Georgia, serif; }
.add-options { display: grid; gap: 10px; }
.add-options > button {
  min-height: 86px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-card-solid);
  text-align: left;
  cursor: pointer;
}
.add-options strong, .add-options small { display: block; }
.add-options strong { margin-bottom: 5px; font-size: 0.86rem; }
.add-options small { color: var(--muted); font-size: 0.68rem; line-height: 1.35; }
.option-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--green-50); color: var(--green-800); font-size: 1.15rem; }

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  max-width: min(calc(100% - 32px), 440px);
  padding: 12px 16px;
  transform: translateX(-50%);
  border-radius: 14px;
  background: #f3efe6;
  color: #111713;
  box-shadow: var(--shadow-soft);
  font-size: 0.76rem;
  text-align: center;
}


.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon, .nav-icon, .nav-add-icon, .row-chevron, .empty-icon {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon { width: 20px; height: 20px; }
.nav-icon { width: 22px; height: 22px; }
.nav-add-icon { width: 27px; height: 27px; }
.row-chevron { width: 18px; height: 18px; color: var(--muted); }
.theme-toggle { position: relative; }
.theme-icon-sun, .theme-icon-moon { position: absolute; transition: opacity 160ms ease, transform 160ms ease; }
html[data-theme="dark"] .theme-icon-sun { opacity: 1; transform: scale(1); }
html[data-theme="dark"] .theme-icon-moon { opacity: 0; transform: scale(.7); }
html[data-theme="light"] .theme-icon-sun { opacity: 0; transform: scale(.7); }
html[data-theme="light"] .theme-icon-moon { opacity: 1; transform: scale(1); }

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.search-field > .icon { flex: 0 0 auto; color: var(--muted); }
.segment { display: inline-grid; place-items: center; }
.segment .icon { width: 18px; height: 18px; }
.favourite-button {
  display: grid;
  place-items: center;
}
.favourite-button .icon { width: 18px; height: 18px; }
.favourite-button.active .icon { fill: currentColor; }

.settings-card > button,
.settings-toggle-row,
.settings-static-row {
  grid-template-columns: 38px minmax(0, 1fr) auto;
}
.settings-card .settings-row-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: center;
  overflow: hidden;
  border-radius: 11px;
  background: var(--green-50);
  color: var(--green-700);
  line-height: 0;
}
.settings-card .settings-row-icon .icon {
  width: 18px;
  height: 18px;
  margin: 0;
  align-self: center;
  justify-self: center;
  transform: translate3d(0, 0, 0);
}
.settings-card > button > span:nth-child(2),
.settings-toggle-row > span:nth-child(2),
.settings-static-row > span:nth-child(2) {
  min-width: 0;
}
.settings-card > button span small,
.settings-toggle-row span small,
.settings-static-row span small { display: block; }

.option-icon .icon { width: 21px; height: 21px; }
.add-options > button { grid-template-columns: 42px 1fr 18px; }

html[data-theme="light"] body {
  background:
    radial-gradient(circle at top right, rgba(215, 227, 211, 0.65), transparent 34rem),
    linear-gradient(180deg, var(--cream-50), var(--cream-100));
}
html[data-theme="light"] .favourite-button { background: rgba(255,255,255,0.9); }

:focus-visible { outline: 3px solid rgba(53,107,69,0.35); outline-offset: 3px; }
@media (hover: hover) {
  .recipe-card, .mini-recipe-card, .category-card, .settings-card > button, .add-options > button { transition: transform 160ms ease, box-shadow 160ms ease; }
  .recipe-card:hover, .mini-recipe-card:hover, .category-card:hover, .add-options > button:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
}

@media (min-width: 760px) {
  .app-shell { min-height: calc(100vh - 32px); margin: 16px auto; border: 1px solid var(--border); border-radius: 32px; overflow: visible; box-shadow: 0 24px 70px rgba(32,43,34,0.1); }
  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 16px;
    width: min(calc(100% - 32px), 1180px);
    border-radius: 0 0 32px 32px;
    transform: translateX(-50%) translateZ(0);
  }
  .main-content { min-height: 760px; }
  .horizontal-cards { grid-auto-columns: 210px; }
  .category-grid { grid-template-columns: repeat(6, 1fr); }
  .recipe-library.grid-layout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-library { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1040px) {
  .topbar { padding-inline: 42px; }
  .main-content { padding-inline: 42px; }
  #view-home.active {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    column-gap: 34px;
    align-items: start;
  }
  #view-home .home-heading, #view-home .continue-card { grid-column: 1 / -1; }
  #view-home .content-section:nth-of-type(3) { margin-top: 30px; }
  .recipe-library.grid-layout { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .category-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}


/* Phase 1 close-out: consistent optical icon alignment */
.icon-button,
.option-icon,
.category-icon,
.settings-card .settings-row-icon,
.bottom-nav .nav-add {
  line-height: 0;
}

.icon-button > svg,
.option-icon > svg,
.category-icon > svg,
.settings-card .settings-row-icon > svg,
.bottom-nav .nav-add > svg {
  display: block;
  margin: auto;
  align-self: center;
  justify-self: center;
  transform-origin: 50% 50%;
}

.settings-card .row-chevron {
  align-self: center;
  justify-self: end;
}

/* Phase 2 Recipe System */
.featured-card {
  display: grid;
  grid-template-columns: minmax(112px, 34%) 1fr;
  gap: 15px;
  align-items: stretch;
  margin-bottom: 30px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}
.featured-image { min-height: 170px; overflow: hidden; border-radius: 16px; background: var(--cream-200); }
.featured-image img { width: 100%; height: 100%; object-fit: cover; }
.featured-copy { min-width: 0; padding: 5px 4px 5px 0; }
.featured-copy .section-label-row { align-items: flex-start; margin-bottom: 10px; }
.featured-copy h2 { margin-bottom: 7px; font: 700 1.2rem/1.12 Georgia, serif; }
.featured-copy > p { margin-bottom: 12px; font-size: .75rem; line-height: 1.42; }
.featured-macros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.featured-macros span { padding: 6px 8px; border-radius: 9px; background: var(--green-50); color: var(--muted); font-size: .63rem; }
.featured-macros strong { color: var(--ink); }

.mini-image-wrap { position: relative; }
.mini-image-wrap > img { width: 100%; aspect-ratio: 1.25; object-fit: cover; border-radius: var(--radius-md); background: var(--cream-200); box-shadow: var(--shadow-card); }
.mini-image-wrap .favourite-button { width: 29px; height: 29px; top: 7px; right: 7px; }
.inline-empty { padding: 15px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--muted); font-size: .75rem; }

.library-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 10px; }
.sort-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.sort-control { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-card); color: var(--muted); font-size: .69rem; font-weight: 700; }
.sort-control .icon { width: 17px; height: 17px; }
.sort-control select { max-width: 150px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .69rem; }
.filter-button { position: relative; min-width: 48px; }
.filter-count { min-width: 19px; height: 19px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--green-800); color: white; font-size: .57rem; }
.recipe-source-line { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; color: var(--green-700); font-size: .55rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.recipe-source-line span + span::before { content: '•'; margin-right: 6px; color: var(--muted); }
.list-layout .recipe-source-line { margin-bottom: 7px; }

.favourites-empty-state { padding: 56px 24px; text-align: center; }
.favourites-empty-state .empty-icon { width: 44px; height: 44px; color: var(--green-700); }
.favourites-empty-state h2 { margin: 13px 0 6px; }

.overlay-open { overflow: hidden; }
.modal-shell { position: fixed; z-index: 80; inset: 0; display: grid; place-items: end center; opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
.modal-shell.visible { opacity: 1; pointer-events: auto; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.68); backdrop-filter: blur(8px); }
.recipe-preview-panel,
.manager-panel { position: relative; z-index: 1; width: min(100%, 680px); max-height: min(92dvh, 900px); overflow: auto; border: 1px solid var(--border-strong); border-radius: 28px 28px 0 0; background: var(--surface-sheet); box-shadow: 0 -24px 80px rgba(0,0,0,.48); transform: translateY(28px); transition: transform 200ms cubic-bezier(.2,.8,.2,1); }
.modal-shell.visible .recipe-preview-panel,
.modal-shell.visible .manager-panel { transform: translateY(0); }
.modal-close { position: absolute; z-index: 3; top: calc(12px + env(safe-area-inset-top)); right: 14px; border-color: rgba(255,255,255,.15); background: rgba(8,12,9,.72); color: white; backdrop-filter: blur(10px); }
.preview-hero { height: min(34vh, 310px); overflow: hidden; background: var(--cream-200); }
.preview-hero img { width: 100%; height: 100%; object-fit: cover; }
.preview-body { padding: 20px var(--page-pad) calc(28px + env(safe-area-inset-bottom)); }
.preview-title-row { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 12px; }
.preview-title-row h2 { margin-bottom: 0; font: 700 clamp(1.65rem, 6vw, 2.2rem)/1.05 Georgia, serif; letter-spacing: -.035em; }
.preview-source { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 7px; color: var(--green-700); font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.preview-source span { padding: 5px 8px; border-radius: 999px; background: var(--green-50); }
.preview-favourite { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-card); color: var(--muted); }
.preview-favourite.active { color: var(--green-700); }
.preview-favourite.active .icon { fill: currentColor; }
.preview-description { margin: 12px 0; }
.preview-tags { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.preview-tags span { flex: 0 0 auto; padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .64rem; font-weight: 700; }
.macro-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 6px; margin: 18px 0 12px; }
.macro-grid > div { min-width: 0; padding: 10px 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-card); text-align: center; }
.macro-grid strong, .macro-grid span { display: block; }
.macro-grid strong { font-size: .82rem; }
.macro-grid span { margin-top: 3px; color: var(--muted); font-size: .53rem; }
.recipe-facts { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.recipe-facts span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .67rem; }
.recipe-facts .icon { width: 15px; height: 15px; }
.preview-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.preview-section h3 { margin-bottom: 13px; font-size: 1rem; }
.ingredient-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.ingredient-list li { position: relative; padding-left: 16px; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.ingredient-list li::before { content: ''; position: absolute; left: 0; top: .57em; width: 5px; height: 5px; border-radius: 50%; background: var(--green-700); }
.ingredient-list strong { color: var(--ink); }
.method-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: steps; }
.method-list li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; counter-increment: steps; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.method-list li::before { content: counter(steps); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--green-50); color: var(--green-700); font-size: .67rem; font-weight: 800; }
.note-section { padding: 15px; margin-top: 16px; border: 1px solid var(--border); border-radius: 15px; background: var(--green-50); }
.note-section p { margin-bottom: 7px; font-size: .74rem; }
.note-section p:last-child { margin-bottom: 0; }
.substitution-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 11px; border: 1px solid var(--border); border-radius: 13px; font-size: .7rem; }
.substitution-row > span { color: var(--green-700); }
.substitution-row small { grid-column: 1 / -1; color: var(--muted); }
.nutrition-note { margin: 18px 0; padding: 14px; border: 1px solid rgba(219,154,93,.25); border-radius: 14px; background: rgba(219,154,93,.07); }
.nutrition-note strong { font-size: .74rem; color: var(--orange); }
.nutrition-note p { margin: 5px 0 0; font-size: .67rem; }
.full-button { width: 100%; }

.manager-panel { padding: 20px var(--page-pad) calc(26px + env(safe-area-inset-bottom)); }
.manager-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.manager-header h2 { font: 700 1.6rem Georgia, serif; }
.manager-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 18px 0; padding: 4px; border-radius: 14px; background: var(--cream-200); }
.manager-tab { min-height: 39px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: .74rem; font-weight: 800; }
.manager-tab.active { background: var(--surface-card-solid); color: var(--green-700); box-shadow: var(--shadow-card); }
.manager-add-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; margin-bottom: 16px; }
.manager-add-form label { color: var(--muted); font-size: .68rem; font-weight: 700; }
.manager-add-form input { width: 100%; min-height: 44px; margin-top: 7px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-input); color: var(--ink); outline: none; }
.manager-list { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-card); }
.manager-row { min-height: 72px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.manager-row:last-child { border-bottom: 0; }
.manager-row-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: var(--green-50); color: var(--green-700); line-height: 0; }
.manager-row-icon .icon { width: 19px; height: 19px; }
.manager-row strong, .manager-row small { display: block; }
.manager-row strong { font-size: .79rem; }
.manager-row small { margin-top: 4px; color: var(--muted); font-size: .61rem; }
.manager-row-actions { display: flex; align-items: center; gap: 5px; }
.manager-row-actions button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-control); color: var(--muted); }
.manager-row-actions button:last-child { color: var(--danger); }
.manager-row-actions .icon { width: 17px; height: 17px; }
.locked-label { display: inline-flex !important; align-items: center; gap: 4px; color: var(--muted); font-size: .58rem !important; font-weight: 700 !important; }
.locked-label .icon { width: 13px; height: 13px; }

/* Professional icon system: fixed canvas, consistent optical weight, no inherited offsets. */
.icon,
.nav-icon,
.nav-add-icon,
.row-chevron,
.empty-icon {
  overflow: visible;
  flex: 0 0 auto;
  transform-box: view-box;
  transform-origin: center;
}
.settings-card .settings-row-icon,
.option-icon,
.category-icon,
.manager-row-icon,
.icon-button,
.segment,
.preview-favourite,
.manager-row-actions button {
  display: grid !important;
  place-items: center !important;
  padding: 0;
  line-height: 0;
}
.settings-card .settings-row-icon > svg,
.option-icon > svg,
.category-icon > svg,
.manager-row-icon > svg,
.icon-button > svg,
.segment > svg,
.preview-favourite > svg,
.manager-row-actions button > svg {
  position: static !important;
  inset: auto !important;
  display: block !important;
  margin: 0 !important;
  align-self: center !important;
  justify-self: center !important;
}
.settings-card .settings-row-icon { width: 40px; height: 40px; min-width: 40px; min-height: 40px; border-radius: 13px; }
.settings-card .settings-row-icon .icon { width: 20px; height: 20px; }
.settings-card > button,
.settings-toggle-row,
.settings-static-row { grid-template-columns: 44px minmax(0,1fr) auto; column-gap: 12px; }
@media (max-width: 420px) {
  .featured-card { grid-template-columns: 105px 1fr; gap: 12px; }
  .featured-image { min-height: 190px; }
  .featured-copy .status-pill { display: none; }
  .featured-macros span { padding: 5px 7px; }
  .macro-grid { gap: 4px; }
  .macro-grid strong { font-size: .72rem; }
  .macro-grid span { font-size: .49rem; }
  .filter-button span:not(.filter-count) { display: none; }
  .manager-add-form { grid-template-columns: 1fr; }
}

@media (min-width: 760px) {
  .modal-shell { place-items: center; padding: 24px; }
  .recipe-preview-panel,
  .manager-panel { border-radius: 28px; }
  .preview-hero { height: 310px; }
}


/* v0.2.1 — iOS native interaction and SVG viewport correction */
html,
body,
.app-shell {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

button,
a,
input,
select,
textarea,
[role="button"],
.nav-item,
.nav-add {
  touch-action: manipulation;
}

svg.icon,
svg.nav-icon,
svg.nav-add-icon,
svg.row-chevron,
svg.empty-icon {
  display: block;
  overflow: visible;
  transform: none !important;
  transform-box: view-box;
  transform-origin: 12px 12px;
  shape-rendering: geometricPrecision;
}

.settings-card .settings-row-icon > svg {
  width: 20px !important;
  height: 20px !important;
  place-self: center !important;
  margin: auto !important;
  transform: none !important;
}

.settings-card .settings-row-icon > svg > use {
  transform: none !important;
}

/* Phase 3 — Recipe creation and editing */
.recipe-photo-placeholder {
  width: 100%;
  height: 100%;
  min-height: 110px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  background:
    radial-gradient(circle at 70% 25%, rgba(121,170,87,.18), transparent 38%),
    linear-gradient(145deg, var(--surface-control), var(--cream-200));
  color: var(--green-700);
}
.recipe-photo-placeholder .icon { width: 34px; height: 34px; }
.recipe-photo-placeholder span { color: var(--muted); font-size: .65rem; font-weight: 750; }
.featured-image > .recipe-photo-placeholder,
.preview-hero > .recipe-photo-placeholder { min-height: 100%; }
.empty-featured { grid-column: 1 / -1; padding: 28px; text-align: center; }

.preview-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 15px 0 6px;
}
.preview-action-grid button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-card);
  color: var(--ink);
  font-size: .7rem;
  font-weight: 800;
}
.preview-action-grid .icon { width: 17px; height: 17px; }
.preview-action-grid .danger-action { color: var(--danger); }
.per-serving-line {
  margin: -3px 0 13px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--green-50);
  color: var(--muted);
  font-size: .65rem;
  line-height: 1.4;
}

.compact-modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 20px var(--page-pad) calc(24px + env(safe-area-inset-bottom));
  border: 1px solid var(--border-strong);
  border-radius: 28px 28px 0 0;
  background: var(--surface-sheet);
  box-shadow: 0 -24px 80px rgba(0,0,0,.48);
  transform: translateY(28px);
  transition: transform 200ms cubic-bezier(.2,.8,.2,1);
}
.modal-shell.visible .compact-modal-panel { transform: translateY(0); }
.modal-intro { margin: 4px 0 14px; font-size: .77rem; line-height: 1.5; }
.import-textarea {
  width: 100%;
  min-height: 330px;
  resize: vertical;
  padding: 15px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  outline: none;
  background: var(--surface-input);
  color: var(--ink);
  font: 500 .75rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.import-textarea:focus,
.editor-field input:focus,
.editor-field textarea:focus,
.editor-field select:focus,
.repeatable-row input:focus,
.repeatable-row textarea:focus,
.repeatable-row select:focus,
.nutrition-editor-grid input:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(121,170,87,.14);
}
.modal-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; }
.modal-action-row .primary-button,
.modal-action-row .secondary-button { min-height: 46px; }
.form-error-summary {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(239,129,117,.35);
  border-radius: 13px;
  background: rgba(239,129,117,.09);
  color: var(--danger);
  font-size: .72rem;
  line-height: 1.45;
}
.form-error-summary strong { display: block; margin-bottom: 4px; }
.form-error-summary ul { margin: 0; padding-left: 18px; }
.duplicate-search { margin: 12px 0 14px; }
.duplicate-list { display: grid; gap: 8px; }
.duplicate-recipe-row {
  width: 100%;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 18px;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-card);
  text-align: left;
}
.duplicate-thumb { width: 66px; height: 58px; overflow: hidden; border-radius: 11px; background: var(--cream-200); }
.duplicate-thumb img,
.duplicate-thumb .recipe-photo-placeholder { width: 100%; height: 100%; object-fit: cover; min-height: 0; }
.duplicate-thumb .recipe-photo-placeholder span { display: none; }
.duplicate-thumb .recipe-photo-placeholder .icon { width: 23px; height: 23px; }
.duplicate-recipe-row strong,
.duplicate-recipe-row small { display: block; }
.duplicate-recipe-row strong { margin-bottom: 4px; font-size: .79rem; }
.duplicate-recipe-row small { color: var(--muted); font-size: .64rem; }

.editor-shell {
  z-index: 100;
  display: block;
  overflow: hidden;
  background: var(--cream-100);
}
.recipe-editor-panel {
  position: absolute;
  inset: 0;
  width: min(100%, 920px);
  margin: 0 auto;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--cream-100);
  transform: translateY(18px);
  transition: transform 200ms cubic-bezier(.2,.8,.2,1);
}
.modal-shell.visible .recipe-editor-panel { transform: translateY(0); }
.editor-header {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: calc(env(safe-area-inset-top) + 11px) var(--page-pad) 11px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-header);
  backdrop-filter: blur(20px);
}
.editor-header .section-kicker { margin-bottom: 2px; }
.editor-header h2 { margin: 0; font: 700 1.12rem/1.1 Georgia, serif; }
.editor-save-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  background: var(--green-700);
  color: #071009;
  font-size: .72rem;
  font-weight: 850;
}
.editor-save-button .icon { width: 17px; height: 17px; }
.recipe-editor-form {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 18px var(--page-pad) calc(34px + env(safe-area-inset-bottom));
}
.editor-section {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}
.editor-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.editor-section-heading h3 { margin: 2px 0 0; font: 700 1rem/1.15 Georgia, serif; }
.editor-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.editor-field { display: block; min-width: 0; }
.editor-field.field-wide { grid-column: 1 / -1; }
.editor-field > span,
.nutrition-editor-grid label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
}
.editor-field input,
.editor-field textarea,
.editor-field select,
.repeatable-row input,
.repeatable-row textarea,
.repeatable-row select,
.nutrition-editor-grid input {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  outline: none;
  background: var(--surface-input);
  color: var(--ink);
}
.editor-field textarea,
.repeatable-row textarea { resize: vertical; line-height: 1.45; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 50px; }
.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 11px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .65rem;
  font-weight: 800;
  pointer-events: none;
}
.tag-editor { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.editor-tag-chip {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-control);
  color: var(--muted);
  font-size: .65rem;
  font-weight: 780;
}
.editor-tag-chip.active { border-color: var(--green-700); background: var(--green-100); color: var(--green-900); }
.nutrition-editor-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.nutrition-editor-grid input { min-width: 0; padding-right: 35px; }
.nutrition-editor-grid .input-suffix > span { right: 8px; }
.calculated-label { color: var(--green-700); font-size: .64rem; font-weight: 800; text-align: right; }

.editor-photo-card {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 17px;
  background: var(--surface-input);
}
.editor-photo-card img { width: 100%; height: 100%; object-fit: cover; }
.editor-photo-placeholder { height: 100%; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
.editor-photo-placeholder .icon { width: 35px; height: 35px; color: var(--green-700); }
.editor-photo-placeholder strong { color: var(--ink); font-size: .82rem; }
.editor-photo-placeholder span { font-size: .65rem; }
.photo-action-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.photo-action-row .secondary-button { min-height: 41px; display: inline-flex; align-items: center; gap: 7px; }
.photo-action-row .icon { width: 17px; height: 17px; }
.danger-text { color: var(--danger); }
.small-add-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-control);
  color: var(--green-700);
  font-size: .65rem;
  font-weight: 850;
}
.small-add-button .icon { width: 16px; height: 16px; }
.repeatable-list { display: grid; gap: 9px; }
.repeatable-row {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-input);
}
.row-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--green-50);
  color: var(--green-700);
  font-size: .65rem;
  font-weight: 850;
}
.ingredient-inputs { display: grid; grid-template-columns: 76px 76px minmax(0, 1fr); gap: 7px; }
.row-controls { display: grid; gap: 5px; }
.row-controls button,
.single-control {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-control);
  color: var(--muted);
}
.row-controls button:disabled { opacity: .28; }
.row-controls button .icon,
.single-control .icon { width: 16px; height: 16px; }
.row-controls .row-delete,
.row-delete { color: var(--danger); }
.method-row .method-text { min-height: 82px; }
.substitution-inputs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 7px; align-items: center; }
.substitution-inputs > span { color: var(--green-700); font-weight: 850; }
.editor-empty-row { margin: 0; padding: 13px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: .69rem; text-align: center; }
.editor-bottom-actions { padding-top: 2px; }

@media (max-width: 620px) {
  .nutrition-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nutrition-editor-grid label:first-child { grid-column: 1 / -1; }
  .ingredient-inputs { grid-template-columns: 76px 70px minmax(0, 1fr); }
  .repeatable-row { grid-template-columns: 26px minmax(0, 1fr); }
  .repeatable-row .row-controls { grid-column: 2; grid-template-columns: repeat(3, 34px); justify-content: end; }
  .substitution-editor-row .single-control { grid-column: 2; justify-self: end; }
  .modal-action-row { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .editor-field-grid { grid-template-columns: 1fr; }
  .editor-field.field-wide { grid-column: auto; }
  .ingredient-inputs { grid-template-columns: 1fr 78px; }
  .ingredient-name { grid-column: 1 / -1; }
  .calculated-label { max-width: 145px; }
  .editor-save-button span { display: none; }
  .editor-save-button { width: 42px; justify-content: center; padding: 0; }
}

@media (min-width: 760px) {
  .compact-modal-panel { border-radius: 26px; }
  .recipe-editor-panel { inset: 18px 0; border: 1px solid var(--border-strong); border-radius: 28px; box-shadow: 0 28px 90px rgba(0,0,0,.55); }
  .editor-header { border-radius: 28px 28px 0 0; }
}


/* Phase 4 — Recipe Details */
.recipe-preview-panel {
  width: min(100%, 760px);
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: var(--surface-sheet);
}

.detail-hero {
  min-height: 290px;
  height: min(42dvh, 390px);
  overflow: hidden;
  background: var(--cream-200);
}
.detail-hero > img,
.detail-hero > .recipe-photo-placeholder {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
}
.detail-hero > img { filter: saturate(.94) contrast(1.02); }

.detail-floating-panel {
  position: relative;
  z-index: 2;
  margin: -68px 14px 0;
  padding: 19px;
  border: 1px solid var(--border-strong);
  border-radius: 25px;
  background: color-mix(in srgb, var(--surface-card-solid) 96%, transparent);
  box-shadow: 0 18px 45px rgba(0,0,0,.34);
  backdrop-filter: blur(18px);
}
.detail-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}
.detail-title-row h2 {
  margin: 5px 0 0;
  font: 700 clamp(1.72rem, 7vw, 2.55rem)/1.02 Georgia, serif;
  letter-spacing: -.045em;
}
.detail-category,
.detail-section-label {
  color: var(--green-700);
  font-size: .65rem;
  font-weight: 850;
  letter-spacing: .095em;
  text-transform: uppercase;
}
.detail-description { margin: 12px 0 0; font-size: .76rem; line-height: 1.52; }

.macro-view-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 17px 0 11px;
  padding: 4px;
  border-radius: 14px;
  background: var(--cream-200);
}
.macro-view-switch button {
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
}
.macro-view-switch button.active {
  background: var(--surface-card-solid);
  color: var(--green-700);
  box-shadow: var(--shadow-card);
}

.detail-macro-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.detail-macro-grid > div {
  min-width: 0;
  padding: 10px 3px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-control);
  text-align: center;
}
.detail-macro-grid strong,
.detail-macro-grid span { display: block; }
.detail-macro-grid strong { font-size: clamp(.72rem, 3vw, .9rem); white-space: nowrap; }
.detail-macro-grid span { margin-top: 4px; color: var(--muted); font-size: .52rem; }
.detail-macro-grid .calorie-macro { background: var(--green-50); }
.detail-macro-grid .calorie-macro strong { color: var(--green-700); }

.detail-body { padding: 19px var(--page-pad) 10px; }
.serving-scale-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface-card);
}
.serving-stepper {
  display: grid;
  grid-template-columns: 38px 55px 38px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface-input);
}
.serving-stepper button {
  width: 38px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--green-700);
}
.serving-stepper button:disabled { color: var(--muted); opacity: .38; }
.serving-stepper .icon { width: 17px; height: 17px; }
.serving-stepper input {
  width: 55px;
  height: 40px;
  padding: 0;
  border: 0;
  border-inline: 1px solid var(--border);
  outline: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-weight: 850;
  appearance: textfield;
}
.serving-stepper input::-webkit-inner-spin-button,
.serving-stepper input::-webkit-outer-spin-button { appearance: none; margin: 0; }

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.detail-facts > span {
  min-width: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 1px 7px;
  align-items: center;
  padding: 11px 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-card);
}
.detail-facts .icon { grid-row: 1 / span 2; width: 18px; height: 18px; color: var(--green-700); }
.detail-facts strong { overflow: hidden; font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.detail-facts small { color: var(--muted); font-size: .53rem; }

.detail-tags { display: flex; gap: 7px; overflow-x: auto; padding: 1px 0 10px; scrollbar-width: none; }
.detail-tags span { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .63rem; font-weight: 750; }
.detail-tags::-webkit-scrollbar { display: none; }

.detail-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 3px 0 8px;
}
.detail-actions button {
  min-height: 45px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-card);
  color: var(--muted);
  font-size: .67rem;
  font-weight: 800;
}
.detail-actions .icon { width: 17px; height: 17px; }
.detail-actions .danger-action { color: var(--danger); }

.detail-section { padding: 24px 0; border-bottom: 1px solid var(--border); }
.detail-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.detail-section-heading h3 { margin: 4px 0 0; font: 700 1.12rem/1.15 Georgia, serif; }
.detail-section-heading > span { color: var(--muted); font-size: .65rem; font-weight: 800; }
.compact-detail-section { padding-block: 20px; }

.scaled-ingredient-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.scaled-ingredient-list li {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(74px, auto) 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-card);
}
.scaled-ingredient-list strong { color: var(--green-700); font-size: .72rem; }
.scaled-ingredient-list span { color: var(--muted); font-size: .74rem; line-height: 1.35; }
.scaled-ingredient-list .ingredient-name-only { grid-column: 1 / -1; color: var(--muted); }

.detail-method-list {
  display: grid;
  gap: 15px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: detail-steps;
}
.detail-method-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  counter-increment: detail-steps;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.56;
}
.detail-method-list li::before {
  content: counter(detail-steps);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green-50);
  color: var(--green-700);
  font-size: .68rem;
  font-weight: 850;
}

.detail-note-list,
.detail-substitution-list,
.detail-history-list { display: grid; gap: 9px; }
.detail-note-list p {
  margin: 0;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--green-50);
  font-size: .72rem;
}
.detail-substitution-list > div {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-card);
  font-size: .68rem;
}
.detail-substitution-list > div > span { color: var(--green-700); }
.history-summary,
.history-entry {
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-card);
}
.history-summary { display: flex; justify-content: space-between; gap: 12px; font-size: .72rem; }
.history-summary span { color: var(--muted); }
.history-entry > div { display: flex; justify-content: space-between; gap: 10px; font-size: .72rem; }
.history-entry p { margin: 7px 0 0; font-size: .69rem; }
.history-rating { color: var(--orange); letter-spacing: .05em; }

.detail-sticky-action {
  position: sticky;
  z-index: 4;
  bottom: 0;
  padding: 12px var(--page-pad) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--surface-sheet) 26%);
}
.detail-start-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 54px;
  border-radius: 16px;
}
.detail-start-button .icon { width: 19px; height: 19px; fill: currentColor; }

@media (max-width: 680px) {
  .modal-shell:has(.recipe-preview-panel) { padding: 0; place-items: stretch; }
  .recipe-preview-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .detail-hero { height: min(40dvh, 350px); min-height: 280px; }
}

@media (min-width: 681px) {
  .recipe-preview-panel { max-height: min(94dvh, 940px); border-radius: 28px; }
  .detail-floating-panel { margin-inline: 28px; }
  .detail-body { padding-inline: 34px; }
  .detail-sticky-action { padding-inline: 34px; }
}

@media (max-width: 380px) {
  .detail-floating-panel { margin-inline: 10px; padding: 16px 13px; }
  .detail-macro-grid { gap: 4px; }
  .detail-macro-grid > div { padding-inline: 1px; }
  .detail-facts { gap: 5px; }
  .detail-facts > span { padding-inline: 7px; }
}

/* v0.5.0 — tracker-ready recipe foundation and photo framing */
.recipe-image-wrap,
.mini-image-wrap,
.featured-image,
.detail-hero,
.duplicate-thumb,
.editor-photo-card,
.crop-preview-card,
.crop-preview-hero,
.crop-stage {
  overflow: hidden;
}

.recipe-image-wrap > img,
.mini-image-wrap > img,
.featured-image > img,
.detail-hero > img,
.duplicate-thumb > img,
.editor-photo-card > img,
.crop-preview-card > img,
.crop-preview-hero > img,
.crop-stage > img {
  will-change: transform, object-position;
}

.photo-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-action-row {
  align-items: flex-start;
}

.macro-view-switch.three-options {
  grid-template-columns: repeat(3, 1fr);
}

.detail-facts.four-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-field small {
  color: var(--muted);
  font-size: .58rem;
  font-weight: 700;
}

.crop-editor-shell {
  z-index: 120;
  display: block;
  overflow: hidden;
  background: var(--cream-100);
}

.crop-editor-panel {
  position: absolute;
  inset: 0;
  width: min(100%, 720px);
  margin: 0 auto;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--cream-100);
  transform: translateY(18px);
  transition: transform 200ms cubic-bezier(.2,.8,.2,1);
}

.modal-shell.visible .crop-editor-panel {
  transform: translateY(0);
}

.crop-editor-header {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: calc(env(safe-area-inset-top) + 11px) var(--page-pad) 11px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-header);
  backdrop-filter: blur(20px);
}

.crop-editor-header h2 {
  margin: 0;
  font: 700 1.12rem/1.1 Georgia, serif;
}

.crop-editor-content {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 20px var(--page-pad) calc(32px + env(safe-area-inset-bottom));
}

.crop-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 14px;
  background: var(--cream-200);
}

.crop-mode-switch button {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
}

.crop-mode-switch button.active {
  background: var(--surface-card-solid);
  color: var(--green-700);
  box-shadow: var(--shadow-card);
}

.crop-stage {
  position: relative;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 19px;
  background: #050807;
  box-shadow: var(--shadow-soft);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.crop-stage:active { cursor: grabbing; }
.crop-stage.card-mode { aspect-ratio: 1.25; }
.crop-stage.hero-mode { aspect-ratio: 16 / 9; }

.crop-stage img,
.crop-live-previews img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-help {
  margin: 10px 2px 17px;
  color: var(--muted);
  font-size: .67rem;
  line-height: 1.45;
  text-align: center;
}

.crop-zoom-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 52px;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-card);
}

.crop-zoom-control span,
.crop-zoom-control output {
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
}

.crop-zoom-control output { text-align: right; }
.crop-zoom-control input { width: 100%; accent-color: var(--green-700); }

.crop-live-previews {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin: 18px 0;
}

.crop-live-previews > div > span {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: .62rem;
  font-weight: 800;
}

.crop-preview-card,
.crop-preview-hero {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--cream-200);
  box-shadow: var(--shadow-card);
}

.crop-preview-card { aspect-ratio: 1.25; }
.crop-preview-hero { aspect-ratio: 16 / 9; }

@media (min-width: 760px) {
  .crop-editor-panel {
    inset: 18px 0;
    border: 1px solid var(--border-strong);
    border-radius: 28px;
    box-shadow: 0 28px 90px rgba(0,0,0,.55);
  }
  .detail-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .detail-facts.four-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
