/* Look B, "Market": photo first. Herb white and basil green with a saffron highlight for timers,
   Young Serif for names and headings, Figtree for everything else, soft rounded shapes.
   Phone: floating pill tab bar. Desktop (900px+): the same nav becomes a side menu. */
@font-face {
  font-family: "Young Serif"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/young-serif-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Figtree"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/figtree-latin.woff2") format("woff2");
}

:root {
  --bg: #f1f3ec;
  --surface: #ffffff;
  --surface-2: #e5eadd;
  --text: #1f2a22;
  --muted: #66705f;
  --border: #dde2d5;
  --accent: #3b6e47;
  --accent-soft: rgba(59, 110, 71, 0.12);
  --accent-text: #ffffff;
  --highlight: #e9a23b;
  --highlight-text: #2b1d05;
  --danger: #b3261e;
  --badge-bg: rgba(255, 255, 255, 0.92);
  --shadow: 0 1px 2px rgba(31, 42, 34, 0.05), 0 6px 18px rgba(31, 42, 34, 0.06);
  --float-shadow: 0 10px 30px -8px rgba(31, 42, 34, 0.35);
  --radius: 22px;
  --radius-sm: 12px;
  --bar-bg: rgba(241, 243, 236, 0.94);
  --pill-bg: rgba(255, 255, 255, 0.94);
  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --gutter: 16px;
  --tabbar-h: 60px;
  /* Room kept free at the bottom of the page for the floating tab bar. */
  --tabbar-space: calc(var(--tabbar-h) + 26px);
  --nav-w: 232px;
  --header-h: 60px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2366705f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a16;
    --surface: #1e2621;
    --surface-2: #29332c;
    --text: #e8ede4;
    --muted: #9aa596;
    --border: #303a33;
    --accent: #86bb92;
    --accent-soft: rgba(134, 187, 146, 0.16);
    --accent-text: #0f1d13;
    --highlight: #f0b155;
    --danger: #f2877f;
    --badge-bg: rgba(20, 26, 22, 0.86);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --float-shadow: 0 10px 30px -6px rgba(0, 0, 0, 0.6);
    --bar-bg: rgba(20, 26, 22, 0.94);
    --pill-bg: rgba(30, 38, 33, 0.94);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239aa596' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: break-word;
}
a { color: var(--accent); }
a, button, summary, input, select, textarea, label { touch-action: manipulation; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; text-wrap: balance; }
h1, h2 { font-family: var(--serif); font-weight: 400; }
h2 { font-size: 1.35rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* App chrome */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: calc(env(safe-area-inset-top) + var(--header-h));
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + var(--gutter)) 8px calc(env(safe-area-inset-left) + var(--gutter));
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
}
.app-header h1 {
  margin: 0; font-size: 1.75rem; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.back-link {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin-left: -6px;
  font-weight: 600; text-decoration: none;
}
.back-link svg, .add-btn svg, .nav-add svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.add-btn {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
}

.page {
  max-width: 760px; margin: 0 auto;
  padding: 8px calc(env(safe-area-inset-right) + var(--gutter)) calc(env(safe-area-inset-bottom) + var(--tabbar-space) + 24px) calc(env(safe-area-inset-left) + var(--gutter));
}

/* Phone: a floating pill of icons. */
.tab-bar {
  position: fixed; z-index: 10;
  left: calc(env(safe-area-inset-left) + var(--gutter)); right: calc(env(safe-area-inset-right) + var(--gutter));
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  display: flex; align-items: center; gap: 4px; height: var(--tabbar-h); padding: 0 6px;
  max-width: 420px; margin: 0 auto;
  background: var(--pill-bg); border-radius: 999px; box-shadow: var(--float-shadow);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
}
.tab-bar a {
  flex: 1; min-width: 0; height: 46px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); text-decoration: none; border-radius: 999px;
}
.tab-bar svg {
  width: 24px; height: 24px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tab-bar a.active { color: var(--accent-text); background: var(--accent); }
.tab-bar a.active svg { stroke-width: 2.1; }
.tab-bar .tab-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.nav-brand, .tab-bar .nav-add { display: none; }

/* Desktop: the same nav as a side menu. */
@media (min-width: 900px) {
  body { padding-left: var(--nav-w); }
  :root { --tabbar-space: 0px; }
  .tab-bar {
    top: 0; bottom: 0; left: 0; right: auto; width: var(--nav-w); height: auto; max-width: none; margin: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: calc(env(safe-area-inset-top) + 26px) 16px 24px calc(env(safe-area-inset-left) + 16px);
    background: var(--bg); border-right: 1px solid var(--border); border-radius: 0; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .nav-brand { display: block; font-family: var(--serif); font-size: 1.75rem; line-height: 1; padding: 0 12px 24px; }
  .tab-bar a { flex: none; justify-content: flex-start; padding: 0 14px; font-weight: 500; }
  .tab-bar a:hover:not(.active) { background: var(--surface-2); color: var(--text); }
  .tab-bar .tab-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .tab-bar a.active .tab-label { font-weight: 700; }
  .tab-bar .nav-add {
    display: flex; margin-top: auto; justify-content: center; font-weight: 700;
    color: var(--accent); border: 1.5px solid var(--accent); background: var(--surface);
  }
  .app-header .add-btn { display: none; }
  .app-header { padding-left: 40px; padding-right: 40px; }
  .page { max-width: 1240px; padding: 8px 40px 48px; }
}

/* Surfaces */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card > h2:first-child { margin-bottom: 12px; }
.card-grid {
  display: grid; gap: 18px 12px; align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card-grid .card { margin: 0; padding: 0; overflow: hidden; }
.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty-state p { margin: 0; }
.muted { color: var(--muted); }
.hint { font-size: .9rem; margin: 8px 0 14px; }

/* Buttons and fields */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: transform .08s ease, opacity .08s ease;
}
.btn:active, button:active { transform: scale(.97); opacity: .85; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: .92rem; }
.btn-secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-danger { background: var(--danger); color: var(--accent-text); }
.btn-block { display: flex; width: 100%; }
.btn-grow { flex: 1; }
button:disabled { opacity: .6; cursor: default; }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px;
}
input[type="search"] { border-radius: 999px; padding-left: 18px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  -webkit-appearance: none; appearance: none;
  padding-right: 32px;
  background: var(--surface) var(--chevron) no-repeat right 14px center / 12px 8px;
}
input[type="file"] { padding: 8px; font-size: 15px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row > input, .row > select { flex: 1 1 0; min-width: 0; }
.error-text { color: var(--danger); font-weight: 600; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: .92rem; font-weight: 500; text-decoration: none;
}
.chip.active { background: var(--accent); color: var(--accent-text); }
.chip .muted { font-size: .85em; }
.chip.active .muted { color: inherit; opacity: .8; }
summary { -webkit-user-select: none; user-select: none; }

/* A row of chips that scrolls sideways on a phone and wraps on a wide screen. */
.filter-chips, .jump-chips {
  display: flex; gap: 8px; margin: 0 calc(-1 * var(--gutter)) 16px; padding: 2px var(--gutter);
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.filter-chips::-webkit-scrollbar, .jump-chips::-webkit-scrollbar { display: none; }
.filter-chips .chip, .jump-chips .chip { flex-shrink: 0; min-height: 40px; }
@media (min-width: 900px) {
  .filter-chips, .jump-chips { flex-wrap: wrap; margin-left: 0; margin-right: 0; padding: 0; }
}

/* Segmented control: full width on phones, equal segments */
.segmented {
  display: flex; width: 100%; max-width: 460px;
  padding: 4px; gap: 4px;
  background: var(--surface-2); border-radius: 999px;
}
.segmented a {
  flex: 1; display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 10px; border-radius: 999px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .92rem; white-space: nowrap;
}
.segmented a.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* Unit converter */
.convert-rows { list-style: none; padding: 0 18px; margin: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.convert-rows li { min-height: 48px; display: flex; align-items: center; border-bottom: 1px solid var(--border); font-weight: 600; font-variant-numeric: tabular-nums; }
.convert-rows li:last-child { border-bottom: 0; }
.convert-form .row > select { flex: 0 1 9em; }

/* Recipe cards: a tall rounded photo with the time on it, the name in serif below. */
.title-filter { margin-bottom: 12px; }
.title-filter label { margin-top: 0; }
.title-filter .row { margin-bottom: 0; }
.recipe-card { display: flex; flex-direction: column; color: var(--text); text-decoration: none; }
.recipe-card:not(.web-card) { background: none; box-shadow: none; border-radius: 0; overflow: visible !important; }
.recipe-card:active { transform: scale(.98); }
.recipe-card-media { position: relative; }
.recipe-card-photo { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.recipe-card-media .recipe-card-photo { aspect-ratio: 4 / 5; border-radius: 18px; }
.time-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--badge-bg); color: var(--text); font-size: .78rem; font-weight: 700;
}
.recipe-card-body { padding: 10px 12px 12px; }
.recipe-card:not(.web-card) .recipe-card-body { padding: 8px 2px 0; }
.recipe-card-body h3 {
  font-family: var(--serif); font-weight: 400; font-size: 1.02rem; line-height: 1.22; margin: 0 0 2px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-card-body p { margin: 0; font-size: .84rem; }
.photo-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}
.photo-placeholder span { font-family: var(--serif); font-size: 2.6rem; color: var(--accent); opacity: .6; }

/* Home: the newest recipe leads, full width with its name on the photo. */
.home-grid.has-lead > :first-child { grid-column: 1 / -1; }
.home-grid.has-lead > :first-child .recipe-card-photo { aspect-ratio: 16 / 11; border-radius: 24px; }
.home-grid.has-lead > :first-child .recipe-card-body {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 48px 18px 16px;
  border-radius: 0 0 24px 24px; color: #fff;
  background: linear-gradient(transparent, rgba(12, 20, 14, .8));
}
.home-grid.has-lead > :first-child { position: relative; }
.home-grid.has-lead > :first-child h3 { font-size: 1.5rem; }
.home-grid.has-lead > :first-child .muted { color: rgba(255, 255, 255, .85); }
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 26px 20px; }
  .home-grid.has-lead > :first-child { grid-column: span 2; }
  .home-grid.has-lead > :first-child .recipe-card-photo { aspect-ratio: 16 / 10; }
}
.match {
  display: inline-block; margin-top: 6px !important; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); font-weight: 600; font-size: .8rem !important;
}
.match-full { background: var(--accent-soft); color: var(--accent); }
.match-missing { margin-top: 4px !important; font-size: .8rem !important; }

/* Recipe page. Phone: full-width photo with the details sliding up over it like a sheet.
   Wide screens: the photo is a banner with the title on it; ingredients sit beside the steps. */
.recipe-hero { margin: -8px calc(-1 * var(--gutter)) 0; }
.recipe-photo { display: block; width: 100%; height: clamp(200px, 30vh, 280px); object-fit: cover; }
.recipe-head {
  position: relative; padding: 22px var(--gutter) 4px;
  background: var(--bg); border-radius: 26px 26px 0 0;
}
.recipe-hero:not(.no-photo) .recipe-head { margin-top: -26px; }
.recipe-title { font-size: 1.85rem; line-height: 1.12; margin: 0 0 4px; }
.recipe-source { margin: 0; color: var(--muted); font-size: .95rem; }
.recipe-source a { font-weight: 600; text-decoration: none; }
.recipe-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 4px;
  margin: 16px 0; padding: 12px 8px;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); text-align: center;
}
.recipe-facts > div { min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.recipe-facts dt { color: var(--muted); font-size: .76rem; font-weight: 500; }
.recipe-facts dd { margin: 0; font-family: var(--serif); font-size: 1.12rem; line-height: 1.25; }
.recipe-facts dd small { display: block; font-family: var(--sans); font-size: .7rem; color: var(--muted); }
.recipe-facts dd a { color: var(--accent); text-decoration: none; }
/* Phone and tablet: times across the top, the main ingredient on its own line underneath. */
@media (max-width: 1023px) {
  .recipe-facts { display: flex; flex-wrap: wrap; }
  .recipe-facts > div { flex: 1 1 0; }
  .recipe-facts > div:last-child:not(:first-child) {
    flex-basis: 100%; flex-direction: row; justify-content: center; align-items: baseline; gap: 8px;
    margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border);
  }
  .recipe-facts > div:last-child dd small { display: inline; margin-left: 6px; }
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; }
.tag-list .chip { min-height: 32px; padding: 0 12px; background: var(--surface-2); font-size: .85rem; }
.recipe-body { display: grid; gap: 0; }
.notes { white-space: pre-line; margin: 0; }
.recipe-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.recipe-actions form { margin: 0; }
.recipe-actions > form:last-child { margin-left: auto; }

/* Steps: tap one to mark where you are. */
.steps { padding: 0; margin: 0; list-style: none; }
.steps li {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px;
  padding: 12px 12px; margin: 0 -12px; border-radius: 16px; cursor: pointer;
}
.steps li p { margin: 0; transition: opacity .15s; }
.step-num { font-family: var(--serif); font-size: 1.35rem; line-height: 1.1; color: var(--accent); }
.steps li.is-done p, .steps li.is-done .step-num { opacity: .45; }
.steps li.is-now { background: var(--accent-soft); }
.steps li.step-section { display: block; cursor: default; padding: 14px 12px 2px; }
.steps li.step-section h3 { margin: 0; font-size: 1rem; }
.steps-card .hint { margin: 10px 0 0; font-size: .82rem; }

/* Times inside steps become timers. */
.timer {
  display: inline-flex; min-height: 0; min-width: 0; padding: 1px 10px 1px 8px; gap: 5px; vertical-align: baseline;
  background: var(--highlight); color: var(--highlight-text);
  font-size: .95em; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.timer::before {
  content: ""; width: .8em; height: .8em; flex-shrink: 0; align-self: center;
  border: 2px solid currentColor; border-radius: 50%;
}
.timer.is-running { background: var(--accent); color: var(--accent-text); }
.timer.is-finished, .tray-timer.is-finished { animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 50% { transform: scale(1.06); } }
.timer-tray {
  position: fixed; z-index: 11; right: calc(env(safe-area-inset-right) + var(--gutter));
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 22px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.tray-timer {
  display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 16px;
  background: var(--text); color: var(--bg); border-radius: 999px; box-shadow: var(--float-shadow);
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.tray-timer.is-finished { background: var(--highlight); color: var(--highlight-text); }
.tray-timer .tray-step { font-weight: 500; opacity: .8; margin-right: 6px; }
.tray-timer button { min-height: 36px; min-width: 36px; padding: 0; background: transparent; color: inherit; font-size: 1.2rem; }
@media (min-width: 900px) { .timer-tray { bottom: 24px; right: 32px; } }

/* Ingredient panel */
.ingredient-panel h2 { margin-bottom: 12px; }
.scale-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--accent-soft); border-radius: var(--radius-sm); font-weight: 600;
}
.scale-banner > span { flex-basis: 100%; }
.scale-banner form { margin: 0; }
.panel-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.servings-stepper { display: inline-flex; align-items: center; gap: 10px; }
.servings-stepper .btn { padding: 0; font-size: 1.3rem; border: 0; background: var(--accent-soft); }
.servings-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredient { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.ingredient:last-child { border-bottom: 0; }
.ingredient-section h3 { font-size: .85rem; letter-spacing: .02em; margin: 16px 0 2px; color: var(--muted); }
.ingredient-name { flex: 1; min-width: 0; transition: opacity .15s; }
.tick {
  width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0; position: relative;
  border-radius: 50%; border: 2px solid var(--accent); background: transparent;
}
.tick::after {
  content: ""; position: absolute; left: 8px; top: 4px; width: 6px; height: 11px;
  border: solid var(--accent-text); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); opacity: 0;
}
.tick[aria-pressed="true"] { background: var(--accent); }
.tick[aria-pressed="true"]::after { opacity: 1; }
.ingredient.is-done .ingredient-name, .ingredient.is-done .amount-editor { opacity: .45; }
.ingredient.is-done .ingredient-name { text-decoration: line-through; }
.amount-editor { position: static; flex-shrink: 0; }
.amount-editor summary {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 52px; padding: 0 12px;
  list-style: none; cursor: pointer; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--accent-soft); border-radius: 999px; color: var(--accent);
}
.amount-editor summary::-webkit-details-marker { display: none; }
.amount-editor[open] summary { background: var(--accent); color: var(--accent-text); }
.amount-popover {
  position: absolute; left: 0; right: 0; top: calc(100% - 2px); z-index: 5;
  padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}
.amount-popover label { margin-top: 0; }
.amount-popover .row { margin-bottom: 0; }
.amount-popover .error-text { margin: 8px 0 0; }
@media (min-width: 700px) {
  .amount-popover { right: auto; width: 320px; }
}

@media (min-width: 1024px) {
  .recipe-hero {
    display: grid; margin: 8px 0 28px; border-radius: 28px; overflow: hidden;
  }
  .recipe-hero > * { grid-area: 1 / 1; }
  .recipe-photo { height: 400px; }
  .recipe-hero:not(.no-photo) .recipe-head {
    align-self: end; margin: 0; border-radius: 0; padding: 110px 34px 28px; color: #fff;
    background: linear-gradient(transparent, rgba(12, 20, 14, .85));
    display: grid; grid-template-columns: minmax(0, 1fr) 440px; column-gap: 32px; align-items: end;
  }
  .recipe-hero:not(.no-photo) .recipe-title { font-size: 2.9rem; grid-column: 1; }
  .recipe-hero:not(.no-photo) .recipe-source { grid-column: 1; color: rgba(255, 255, 255, .85); }
  .recipe-hero:not(.no-photo) .recipe-source a { color: #fff; }
  .recipe-hero:not(.no-photo) .recipe-facts { grid-column: 2; grid-row: 1 / span 3; margin: 0; color: var(--text); }
  .recipe-hero:not(.no-photo) .tag-list { grid-column: 1; margin: 14px 0 0; }
  .recipe-hero:not(.no-photo) .tag-list .chip { background: rgba(255, 255, 255, .2); color: #fff; }
  .recipe-hero.no-photo .recipe-head { padding: 8px 0 0; background: none; }
  .recipe-hero.no-photo .recipe-title { font-size: 2.6rem; }
  .recipe-body { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); gap: 32px; align-items: start; }
  .recipe-side {
    position: sticky; top: calc(env(safe-area-inset-top) + var(--header-h) + 12px);
    max-height: calc(100vh - var(--header-h) - 28px); overflow-y: auto; border-radius: var(--radius);
    scrollbar-width: thin;
  }
  .recipe-side .card { margin-bottom: 0; }
  .recipe-side .panel-controls .segmented { max-width: none; }
  .steps li { font-size: 1.06rem; }
}

/* Recipe form */
.form-banner {
  padding: 12px 14px; margin-bottom: 14px;
  border: 1.5px solid var(--accent); border-left-width: 6px; border-radius: var(--radius-sm);
  background: var(--surface); font-weight: 600; white-space: pre-line;
}
.ai-action { margin-bottom: 14px; }
.recipe-form .card > label:first-child { margin-top: 0; }
.recipe-form .error-text { margin: 4px 0 0; }
[aria-invalid="true"] { border-color: var(--danger); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.field-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.paste-box summary, .ing-text summary {
  display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--accent);
}
.paste-box .btn, .paste-box button { margin-top: 10px; }
.ing-row, .step-row { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ing-row:first-child, .step-row:first-child { padding-top: 0; }
.ing-row { display: block; }
.ing-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.ing-name, .ing-note { grid-column: 1 / -1; }
.ing-note { min-height: 40px; padding-top: 8px; padding-bottom: 8px; font-size: 15px; }
.row-footer { position: relative; min-height: 40px; margin-top: 4px; }
.ing-text summary { width: fit-content; min-height: 40px; font-size: .9rem; }
.ing-text-panel label { font-weight: 400; margin-top: 6px; }
.flag-text { margin: 6px 0 0; color: var(--danger); font-size: .9rem; }
.row-buttons { display: flex; gap: 6px; justify-content: flex-end; }
.row-footer .row-buttons { position: absolute; top: 0; right: 0; }
.row-buttons button {
  min-height: 40px; min-width: 40px; padding: 0;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-size: 1rem;
}
.row-buttons [data-remove-row] { color: var(--danger); }
.step-list { counter-reset: step; }
.step-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: start; }
.step-row::before { counter-increment: step; content: counter(step) "."; font-weight: 700; min-width: 1.4em; padding-top: 10px; }
.step-row textarea { min-height: 64px; }
.step-row .row-buttons { grid-column: 2; }
.ing-list + button, .step-list + button { margin-top: 12px; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-chips .chip { cursor: pointer; font-weight: 400; min-height: 38px; border: 1px solid var(--border); }
.form-photo { display: block; width: 160px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 8px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.recipe-form .form-actions {
  position: sticky; bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-space)); z-index: 6;
  margin: 0 calc(-1 * var(--gutter)); padding: 10px var(--gutter);
  background: var(--bar-bg); border-radius: var(--radius);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
@media (min-width: 600px) {
  .ing-fields { grid-template-columns: 5.5em 8em 2fr 1.5fr; }
  .ing-name, .ing-note { grid-column: auto; }
}
@media (min-width: 900px) {
  .recipe-form, .feedback-add, .feedback-list, .convert-form, .convert-rows, .page > form.card, .page > .card:not(.empty-state) { max-width: 820px; }
}

/* Browse: categories (Protein, Vegetables…), each with a row per item (Beef, Broccoli…). */
.segmented + .jump-chips { margin-top: 14px; }
.browse-category { margin-top: 26px; scroll-margin-top: calc(var(--header-h) + 10px); }
.category-title { font-size: 1.6rem; margin: 0 0 4px; }
.browse-group { margin-top: 18px; scroll-margin-top: calc(var(--header-h) + 10px); }
.browse-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; margin-bottom: 10px; }
.browse-head h2 { margin: 0; font-size: 1.3rem; }
.browse-head h3 { margin: 0; font-size: 1.02rem; font-weight: 700; }
.browse-head .muted { font-family: var(--sans); font-weight: 600; font-size: .9rem; margin-left: 4px; }
.browse-group:target .browse-head h3 { color: var(--accent); }
.tag-manage summary {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px;
  border-radius: 999px; background: var(--surface-2); color: var(--text);
  font-size: .85rem; font-weight: 600; cursor: pointer; list-style: none;
}
.tag-manage summary::-webkit-details-marker { display: none; }
.tag-manage[open] { flex-basis: 100%; }
.tag-manage[open] summary { margin-left: auto; display: flex; width: fit-content; }
.tag-manage-panel { margin-top: 8px; padding: 12px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.tag-manage-panel label { margin-top: 0; }
.tag-manage-panel form + form { margin-top: 6px; }
@media (max-width: 699px) {
  .card-scroller {
    display: grid; grid-auto-flow: column; grid-auto-columns: 40%; grid-template-columns: none;
    overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter) 8px; scroll-padding: 0 var(--gutter);
    scrollbar-width: none;
  }
  .card-scroller::-webkit-scrollbar { display: none; }
  .card-scroller > * { scroll-snap-align: start; }
}

/* Loading: overlay for slow actions, top bar for live updates, skeleton cards */
.busy-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(12, 20, 14, .45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade-in .2s ease;
}
.busy-card {
  width: min(340px, 100%); padding: 26px 22px 20px; text-align: center;
  background: var(--surface); border-radius: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.busy-pot { width: 84px; height: 84px; margin-bottom: 6px; overflow: visible; }
.busy-pot .pot { fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.busy-pot path.pot:first-of-type { fill: var(--accent-soft); animation: bubble 1.4s ease-in-out infinite; transform-origin: 32px 54px; }
.busy-pot .steam { fill: none; stroke: var(--muted); stroke-width: 2.6; stroke-linecap: round; opacity: 0; animation: steam 2.1s ease-in-out infinite; }
.busy-pot .s2 { animation-delay: .7s; }
.busy-pot .s3 { animation-delay: 1.4s; }
.busy-title { margin: 0; font-family: var(--serif); font-size: 1.2rem; }
.busy-hint { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }
.busy-hint:empty { display: none; }
.busy-time { margin: 12px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(6px); }
  30% { opacity: .9; }
  100% { opacity: 0; transform: translateY(-10px); }
}
@keyframes bubble { 50% { transform: scale(1.04, .96); } }
@keyframes fade-in { from { opacity: 0; } }

html.is-loading::before {
  content: ""; position: fixed; z-index: 60; top: 0; left: 0; height: 3px; width: 40%;
  background: var(--accent); border-radius: 0 3px 3px 0;
  animation: loading-bar 1s ease-in-out infinite;
}
@keyframes loading-bar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.skeleton { pointer-events: none; }
.skeleton .sk {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 6px;
}
.skeleton .sk-photo { aspect-ratio: 4 / 3; border-radius: 0; }
.skeleton .sk-line { height: 13px; margin: 12px 12px 0; }
.skeleton .sk-line.short { width: 55%; margin-bottom: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.discover-status { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .busy-pot *, .skeleton .sk, html.is-loading::before, .spinner { animation-duration: 3s; }
  .timer.is-finished, .tray-timer.is-finished { animation: none; }
}

/* Import from a photo */
.photo-import h2 { font-size: 1.2rem; margin-bottom: 4px; }
.photo-pick { position: relative; cursor: pointer; }
.photo-pick svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.photo-pick:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.photo-previews { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.photo-previews:empty { display: none; }
.photo-previews img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.photo-import > button[type=submit] { margin-top: 12px; }

/* Home search: your recipes + recipes to import */
.section-title { font-size: 1.25rem; margin: 22px 0 12px; }
.title-filter + .section-title { margin-top: 4px; }
.discover { margin-top: 8px; }
.loading-card { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 600; }
.spinner {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.web-card { display: flex; flex-direction: column; }
.web-card-link { display: block; }
.web-card .recipe-card-body { flex: 1; }
.web-card-action { padding: 0 12px 12px; }
.web-card-action form { margin: 0; }
.stars { margin-top: 4px !important; font-weight: 700; color: var(--text); }
.stars > span[aria-hidden] { color: var(--highlight); }
.source-note { font-size: .8rem; margin-top: 12px; }

/* Feedback */
.feedback-add textarea { min-height: 80px; }
.feedback-add button { margin-top: 14px; width: 100%; }
.feedback-add > label:first-child { margin-top: 0; }
.feedback-list { list-style: none; padding: 0; margin: 14px 0 0; }
.feedback-meta { margin: 8px 0 0; color: var(--muted); font-size: .85rem; }
.feedback-actions { display: flex; gap: 8px; margin-top: 12px; }
.feedback-actions form { margin: 0; }
.feedback-actions form:last-child { margin-left: auto; }
.feedback-actions button { min-height: 38px; font-size: .92rem; padding: 0 14px; }

/* Shown once on a recipe right after it was imported. */
.saved-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--radius-sm); background: var(--accent-soft); border: 1.5px solid var(--accent);
}
.saved-banner svg { flex: none; width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.saved-banner p { margin: 0; flex: 1; min-width: 0; }
.saved-banner .btn { flex: none; }
@media (max-width: 520px) { .saved-banner { flex-wrap: wrap; } .saved-banner .btn { margin-left: 38px; } }

/* Several links at once */
.bulk-import summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.bulk-import summary::-webkit-details-marker { display: none; }
.bulk-import summary h2 { font-size: 1.2rem; margin: 0; }
.bulk-import summary::after { content: "+"; font-size: 1.5rem; line-height: 1; color: var(--accent); }
.bulk-import[open] summary::after { content: "−"; }
.bulk-import[open] summary { margin-bottom: 10px; }
.bulk-import textarea { width: 100%; font-size: 16px; }
.bulk-import button[type=submit] { margin-top: 12px; }

.bulk-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip-ok { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-bad { color: var(--danger); font-weight: 600; }
.bulk-list { list-style: none; padding: 0; margin: 0; }
.bulk-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--surface-2); }
.bulk-item:first-child { border-top: 0; }
.bulk-text { flex: 1; min-width: 0; }
.bulk-text p { margin: 2px 0 0; font-size: .88rem; }
.bulk-text > a { font-weight: 600; }
.bulk-url { overflow-wrap: anywhere; font-size: .85rem !important; }
.bulk-item .error-text { margin: 2px 0 0; }
.bulk-item form { flex: none; }
.bulk-results + .btn, .bulk-results + .btn + .btn { margin-top: 10px; }

/* Meal plan */
.plan-add { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; }
.plan-add select { flex: 1 1 auto; min-width: 0; max-width: 220px; min-height: 38px; padding-top: 6px; padding-bottom: 6px; }
.plan-added { margin: -4px 0 14px; color: var(--accent); font-weight: 600; font-size: .92rem; }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.week-nav .btn { min-width: 44px; padding: 0; font-size: 1.4rem; }
.week-title { text-align: center; }
.week-title h2 { margin: 0; }
.week-title a, .week-title span { font-size: .85rem; }
.grocery-link { gap: 10px; margin-bottom: 16px; }
.grocery-link svg, .copy-btn svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.plan-days { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
@media (min-width: 900px) { .plan-days { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.plan-day { margin: 0; scroll-margin-top: calc(var(--header-h) + 12px); }
.plan-day.is-today { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.plan-day h3 { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; margin: 0 0 10px; }
.plan-day h3 small { font-family: var(--sans); font-size: .8rem; }
.plan-meal { padding: 8px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.plan-meal-link { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.plan-meal-link img, .plan-thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.plan-thumb { display: grid; place-items: center; background: var(--surface-2); font-family: var(--serif); font-size: 1.5rem; color: var(--accent); }
.plan-meal-title { font-weight: 600; line-height: 1.25; }
.plan-meal-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.plan-meal-tools form { margin: 0; }
.plan-meal-tools .servings-stepper button { min-width: 38px; min-height: 38px; padding: 0; font-size: 1.2rem; border: 0; background: var(--accent-soft); }
.plan-more { position: relative; }
.plan-more summary { list-style: none; cursor: pointer; padding: 6px 12px; border-radius: 999px; color: var(--muted); letter-spacing: .1em; }
.plan-more summary::-webkit-details-marker { display: none; }
.plan-more[open] summary { background: var(--surface-2); }
.plan-more-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 240px; padding: 12px;
  display: grid; gap: 8px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--float-shadow);
}
.plan-more-body .row { margin: 0; }
.plan-more-body .btn-danger { width: 100%; }
.plan-pick { margin: 0; }
.plan-pick select { color: var(--muted); }

/* Grocery list */
.grocery-summary p { margin: 0; }
.grocery-summary > p:first-child { font-size: 1.05rem; margin-bottom: 12px; }
.copy-btn { display: flex; width: 100%; gap: 10px; }
.copy-btn.is-copied { background: var(--highlight); color: var(--highlight-text); }
.grocery-summary .hint { margin: 10px 0 4px; }
.ai-sorting { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.ai-sorting .spinner { width: 16px; height: 16px; border-width: 2px; }
.copy-fallback summary { font-size: .9rem; color: var(--accent); cursor: pointer; padding: 6px 0; }
.copy-fallback textarea { margin-top: 6px; font-size: 16px; }
.grocery-aisle h3 { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; }
.grocery-items { list-style: none; margin: 0; padding: 2px 6px 2px 14px; }
.grocery-item { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); }
.grocery-item:last-child { border-bottom: 0; }
.grocery-item form { margin: 0; }
.grocery-check { flex: 1; min-width: 0; }
.grocery-check button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 0;
  background: none; color: var(--text); text-align: left; font-weight: 400; border-radius: 0;
  justify-content: flex-start; white-space: normal; flex-shrink: 1;
}
.grocery-text { align-items: flex-start; }
.grocery-check button:active { transform: none; }
.g-tick {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--border);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.is-have .g-tick { background: var(--accent); border-color: var(--accent); }
.is-have .g-tick::after {
  content: ""; width: 10px; height: 5px; margin-top: -2px;
  border-left: 2.2px solid var(--accent-text); border-bottom: 2.2px solid var(--accent-text); transform: rotate(-45deg);
}
.grocery-text { display: flex; flex-direction: column; min-width: 0; }
.grocery-name { font-weight: 600; }
.grocery-amount { font-weight: 400; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.grocery-text small { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-have .grocery-name { text-decoration: line-through; color: var(--muted); }
.is-have .grocery-text { opacity: .7; }
.icon-btn {
  min-width: 40px; min-height: 40px; padding: 0; background: none; color: var(--muted); font-size: 1.4rem; font-weight: 400;
}
.staple-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.staple-btn.is-staple { color: var(--highlight); }
.staple-btn.is-staple svg { fill: currentColor; }
.grocery-add { margin: 0 0 14px; padding: 10px; }
.grocery-add label { margin-top: 0; }
.grocery-add .row { margin: 0; }

/* Plan: mains and sides, leftovers, eating out, recipe picker */
.plan-add .plan-role { flex: 0 0 auto; max-width: 96px; }
.plan-meal.is-side { padding-left: 22px; }
.plan-meal.is-side .plan-meal-link img, .plan-meal.is-side .plan-thumb { width: 44px; height: 44px; }
.plan-meal.is-leftover .plan-meal-link img { opacity: .75; }
.plan-meal-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.plan-badge {
  font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
}
.leftover-badge { color: var(--highlight-text); background: color-mix(in srgb, var(--highlight) 35%, transparent); }
.plan-note { font-size: .85rem; }
.leftover-form { display: grid; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.leftover-title { margin: 0; font-weight: 600; font-size: .9rem; }
.leftover-days { display: flex; flex-wrap: wrap; gap: 6px; }
.leftover-days label {
  margin: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 999px; background: var(--surface-2); font-weight: 500; font-size: .9rem; cursor: pointer;
}
.leftover-days input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.leftover-days label:has(input:checked) { background: var(--accent); color: var(--accent-text); }
.leftover-hint { margin: 0; font-size: .8rem; }
.plan-more-body { width: 270px; }

.plan-day.is-out { background: var(--surface-2); }
.eating-out { display: flex; align-items: center; gap: 12px; padding: 4px 0 10px; }
.eating-out svg { width: 30px; height: 30px; flex-shrink: 0; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eating-out p { margin: 0; flex: 1; display: flex; flex-direction: column; }
.eating-out p span { color: var(--muted); font-size: .9rem; }
.eating-out form { margin: 0; }
.out-picker { margin-top: 8px; }
.out-picker summary { font-size: .88rem; color: var(--muted); cursor: pointer; padding: 6px 0; list-style: none; }
.out-picker summary::-webkit-details-marker { display: none; }
.out-picker .row { margin: 4px 0 0; }

.plan-picker > summary { list-style: none; }
.plan-picker > summary::-webkit-details-marker { display: none; }
.plan-picker[open] > summary { margin-bottom: 10px; }
.plan-picker-form { display: grid; gap: 10px; }
.role-toggle { display: flex; }
.role-toggle label { flex: 1; margin: 0; cursor: pointer; }
.role-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.role-toggle span { display: flex; justify-content: center; align-items: center; min-height: 36px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.role-toggle input:checked + span { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.role-toggle input:focus-visible + span { outline: 3px solid var(--accent); }
.pick-results { max-height: 360px; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-item {
  display: flex; width: 100%; align-items: center; justify-content: flex-start; gap: 12px; padding: 6px 4px; min-height: 56px;
  background: none; color: var(--text); text-align: left; font-weight: 400; border-radius: var(--radius-sm);
  white-space: normal; flex-shrink: 1;
}
.pick-item:active { background: var(--accent-soft); transform: none; }
.pick-item img, .pick-item .plan-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0; font-size: 1.2rem; }
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-title { font-weight: 600; line-height: 1.25; }
.pick-text small { font-size: .78rem; }
.pick-add { font-size: 1.4rem; color: var(--accent); padding: 0 6px; }
.pick-empty { margin: 4px; font-size: .9rem; }

/* Plan, round three: days from today on, compact day cards, the add sheet, toast */
.plan-earlier { display: inline-block; margin: 0 0 10px; font-size: .9rem; text-decoration: none; padding: 6px 0; }
.plan-more-days { margin-top: 14px; }
.plan-day { padding-top: 14px; padding-bottom: 12px; }
.plan-day.is-past { opacity: .72; }
.plan-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.plan-day-head h3 { margin: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.add-dish { flex-shrink: 0; min-height: 36px; padding: 0 14px; }
.plan-empty { margin: 2px 0 0; font-size: .9rem; }
.plan-meal { padding: 10px 0; margin: 0; border-bottom: 0; border-top: 1px solid var(--border); }
.plan-day-head + .plan-meal { border-top: 0; }
.plan-meal-row { display: flex; align-items: center; gap: 6px; }
.plan-meal-row .plan-meal-link { flex: 1; min-width: 0; }
.plan-meal-link img, .plan-meal-link .plan-thumb { width: 52px; height: 52px; }
.plan-meal-text small { font-size: .78rem; }
.plan-meal .servings-stepper { display: inline-flex; align-items: center; gap: 4px; margin: 8px 0 0 64px; padding: 2px; }
.plan-meal .servings-stepper form { margin: 0; }
.plan-meal .servings-stepper button { min-width: 36px; min-height: 36px; padding: 0; font-size: 1.2rem; border: 0; background: var(--accent-soft); }
.plan-meal .servings-count { padding: 0 6px; font-size: .9rem; }
.plan-meal.is-side { padding-left: 0; }
.plan-meal.is-side .servings-stepper { margin-left: 52px; }
.plan-more summary { min-width: 40px; min-height: 40px; display: grid; place-items: center; padding: 0 8px; }
.plan-more-body { width: min(280px, calc(100vw - 2 * var(--gutter) - 24px)); }
.leftover-days label.is-blocked { opacity: .45; text-decoration: line-through; cursor: not-allowed; }
.out-picker { margin-top: 4px; }
.plan-meal.is-new { animation: plan-new 2.4s ease-out; border-radius: var(--radius-sm); }
@keyframes plan-new { 0%, 40% { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); } 100% { background: transparent; box-shadow: none; } }

html:has(dialog[open]) { overflow: hidden; }
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh;
  padding: 0; border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text);
  box-shadow: var(--float-shadow); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .22s ease-out; }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet .plan-picker-form {
  display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1;
  padding: 14px var(--gutter) calc(env(safe-area-inset-bottom) + 12px);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; }
.sheet .pick-results { flex: 1; min-height: 120px; max-height: none; overflow-y: auto; margin: 0 -6px; padding: 0 6px; overscroll-behavior: contain; }
@media (min-width: 900px) { .sheet { inset: 0; margin: auto; border-radius: var(--radius); max-height: 80vh; } }
.pick-replace { margin: 0 0 6px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: .88rem; background: color-mix(in srgb, var(--highlight) 22%, transparent); }
.pick-custom .plan-thumb { background: var(--accent-soft); font-family: var(--sans); font-size: 1.1rem; }
.pick-item.htmx-request { background: var(--accent-soft); }
.pick-item.htmx-request .pick-add { animation: pick-pulse .6s ease-in-out infinite alternate; }
@keyframes pick-pulse { to { opacity: .2; } }

.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 30px);
  width: max-content; max-width: calc(100vw - 2 * var(--gutter)); padding: 12px 18px;
  background: var(--text); color: var(--bg); border-radius: 16px; box-shadow: var(--float-shadow);
  font-weight: 600; font-size: .95rem; line-height: 1.3; animation: toast-in .25s ease-out;
  transition: opacity .4s, transform .4s;
}
.toast.is-hiding { opacity: 0; transform: translate(-50%, 10px); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (min-width: 900px) { .toast { bottom: 24px; left: calc(50% + var(--nav-w) / 2); } }

.grocery-head { margin: 0 0 12px; }
.grocery-head h2 { margin: 0 0 2px; }
.grocery-meals summary { cursor: pointer; color: var(--muted); font-size: .92rem; padding: 4px 0; }
.grocery-meals ul { margin: 6px 0 0; padding-left: 18px; font-size: .92rem; }
.grocery-meals li { margin: 2px 0; }
.grocery-done { margin-top: 18px; display: grid; gap: 10px; }
.grocery-done form { margin: 0; }
.grocery-done .row { align-items: center; }
.grocery-done .row p { margin: 0; flex: 1; font-size: .9rem; }

/* Search: each ingredient is a chip under the bar */
.term-form .row { margin-bottom: 0; }
.add-term-btn { min-width: 52px; padding: 0; font-size: 1.6rem; font-weight: 400; }
.term-chips { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 16px; padding: 0; }
.term-chip { min-height: 38px; padding: 0 12px 0 14px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.term-chip span { font-size: 1.2rem; line-height: 1; opacity: .85; }
.term-clear { font-size: .9rem; padding: 8px 4px; }
/* Long "used in" lines wrap inside the card instead of running off it. */
.grocery-check .grocery-text { flex: 1 1 auto; min-width: 0; }
.grocery-text small { white-space: normal; overflow-wrap: anywhere; }

/* Add sheet, sized for iPhone Safari: a fixed height and grid rows. Safari collapsed the flex
   version (flex: 1 inside an auto-height dialog) so only the sheet's top strip showed. */
.sheet { height: 85vh; height: 85dvh; max-height: none; }
.sheet[open] { display: grid; grid-template-rows: minmax(0, 1fr); }
.sheet .plan-picker-form {
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); align-content: stretch;
  height: 100%; min-height: 0; box-sizing: border-box;
}
.sheet .pick-results { min-height: 0; height: 100%; flex: none; }
@media (min-width: 900px) { .sheet { height: 80vh; } }

/* Grocery: "I have some" of an item */
.grocery-item { position: relative; }
.have-some summary { list-style: none; display: grid; place-items: center; cursor: pointer; }
.have-some summary::-webkit-details-marker { display: none; }
.have-some summary svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.have-some summary svg path { fill: currentColor; stroke: none; }
.have-some[open] summary { color: var(--accent); }
.have-some-body {
  position: absolute; right: 0; top: calc(100% - 4px); z-index: 5; width: min(300px, calc(100vw - 2 * var(--gutter) - 12px));
  display: grid; gap: 8px; padding: 12px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--float-shadow);
}
.have-some-body label { margin: 0; font-size: .9rem; }
.have-some-body .row { margin: 0; }
.have-some-body input { min-width: 0; }
.have-note { font-size: .8rem; font-weight: 600; color: var(--accent); }
.have-note.is-off { color: var(--danger); }

/* Grocery list v19: compact summary, aisle picker, checked-off items collapsed at the bottom */
.grocery-count { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grocery-summary > .grocery-count p { margin: 0; font-size: 1.05rem; }
.grocery-summary .copy-btn { width: auto; flex-shrink: 0; gap: 6px; }
.grocery-summary .copy-btn svg { width: 18px; height: 18px; }
.grocery-aisle h3 { display: flex; align-items: center; gap: 8px; }
.aisle-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: .72rem; letter-spacing: 0; font-weight: 600;
}
.grocery-item > .grocery-check + * { margin-left: auto; }
.aisle-btn { position: relative; display: grid; place-items: center; cursor: pointer; margin: 0; }
.aisle-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.aisle-btn.is-chosen { color: var(--accent); }
/* The native picker opens on tap (a wheel on iPhone); 16px stops iOS zooming in. */
.aisle-btn select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.grocery-done-list { margin-top: 22px; }
.grocery-done-list summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  min-height: 48px; padding: 0 4px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.grocery-done-list summary::-webkit-details-marker { display: none; }
.grocery-done-list summary > span { display: flex; align-items: center; gap: 8px; }
.grocery-done-list .chev { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .2s; }
.grocery-done-list[open] .chev { transform: rotate(180deg); }
.grocery-done-list .grocery-check button { min-height: 46px; }
.grocery-done-list .hint { margin: 8px 4px 0; font-size: .82rem; }
@media (max-width: 420px) {
  .grocery-items { padding: 2px 2px 2px 10px; }
  .grocery-item { gap: 0; }
  .icon-btn { min-width: 38px; }
  .grocery-check button { gap: 10px; }
}
