/* Forkful: Wishful's look (cream, ink, coral; Instrument Serif + Inter Tight), tuned for food photos.
   Follows the phone's light/dark setting; the sun/moon button overrides it. */
:root {
  --bg: oklch(98.6% 0.005 87.5);
  --surface: oklch(94.6% 0.011 86.8);
  --surface-2: oklch(99.4% 0.007 88.6);
  --ink: oklch(22.5% 0.004 128.7);
  --muted: oklch(58% 0.012 89.8);
  --line: oklch(22.5% 0.004 128.7 / 0.11);
  --accent: oklch(61.5% 0.163 34.5);
  --accent-ink: oklch(97.9% 0.011 45.7);
  --danger: oklch(53.5% 0.147 33.2);
  --shadow: 0 24px 70px oklch(25.6% 0.02 80.3 / 0.18);
  --material: color-mix(in srgb, var(--bg) 78%, transparent);
  --serif: "Instrument Serif", ui-serif, "New York", Georgia, serif;
  --sans: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --space-xs: 8px; --space-s: 16px; --space-m: 24px; --space-l: 32px; --space-xl: 48px;
  --pad: 16px;
  --spring: linear(0, .075 4.2%, .227 8.3%, .39 12.5%, .536 16.7%, .656 20.8%, .75 25%, .821 29.2%, .873 33.3%, .911 37.5%, .938 41.7%, .957 45.8%, .971 50%, .98 54.2%, .986 58.3%, .991 62.5%, .994 66.7%, .996 70.8%, .998 79.2%, .999 87.5%, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: oklch(18.1% 0.003 145.5); --surface: oklch(23.4% 0.004 164.7); --surface-2: oklch(25.8% 0.003 164.8);
  --ink: oklch(92.6% 0.017 84.6); --muted: oklch(62% 0.01 128.6); --line: oklch(92.6% 0.017 84.6 / 0.1);
  --accent: oklch(71.8% 0.13 34.9); --accent-ink: oklch(17.5% 0.028 40.2); --danger: oklch(70% 0.123 32.7);
  --shadow: 0 24px 70px oklch(0% 0 0 / 0.45); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(18.1% 0.003 145.5); --surface: oklch(23.4% 0.004 164.7); --surface-2: oklch(25.8% 0.003 164.8);
    --ink: oklch(92.6% 0.017 84.6); --muted: oklch(62% 0.01 128.6); --line: oklch(92.6% 0.017 84.6 / 0.1);
    --accent: oklch(71.8% 0.13 34.9); --accent-ink: oklch(17.5% 0.028 40.2); --danger: oklch(70% 0.123 32.7);
    --shadow: 0 24px 70px oklch(0% 0 0 / 0.45); color-scheme: dark;
  }
}
@media (min-width: 720px) { :root { --pad: 40px; } }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; touch-action: manipulation; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:active:not(:disabled) { transform: scale(.97); transition: transform 60ms; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: var(--space-s);
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 10px; background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.brand { display: flex; align-items: center; gap: 6px; }
.brand h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -.02em; line-height: 1; }
.brand-mark { width: 24px; height: 24px; }
.brand-mark .dot { fill: var(--accent); stroke: none; }
.tools { display: flex; align-items: center; gap: 4px; }
.tool-button { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
@media (hover: hover) { .tool-button:hover { color: var(--ink); background: var(--surface); } }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; } :root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .icon-sun { display: none; } :root:not([data-theme="light"]) .icon-moon { display: block; } }
.search-box { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 99px; color: var(--muted); }
.search-box:focus-within { background: var(--surface); }
.search-box input { width: 64px; border: 0; outline: 0; background: transparent; font-size: 16px; transition: width .25s var(--spring); }
.search-box input:focus, .search-box input:not(:placeholder-shown) { width: 130px; }
.search-box input::-webkit-search-cancel-button { display: none; }
.add-button { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 14px 0 10px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 500; }
.add-button svg { width: 16px; height: 16px; stroke-width: 2; }
@media (max-width: 420px) { .add-button span { display: none; } .add-button { padding: 0; width: 34px; justify-content: center; } }

/* Filters */
main { padding-bottom: calc(env(safe-area-inset-bottom) + var(--space-xl)); }
.meals, .facets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 var(--pad); }
.meals::-webkit-scrollbar, .facets::-webkit-scrollbar { display: none; }
.meals { padding-top: var(--space-xs); }
.facets { padding-top: var(--space-xs); align-items: center; }
.facet-group { display: contents; }
.sep { flex: none; width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.chip { flex: none; display: flex; align-items: baseline; gap: 4px; padding: 7px 12px; border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 13px; white-space: nowrap; transition: color .15s, background .15s; }
.chip em { font-style: normal; font-size: 11px; opacity: .7; }
.facets .chip { padding: 5px 10px; font-size: 12px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
@media (hover: hover) { .chip:hover { color: var(--ink); } }
.chip.active { background: var(--ink); color: var(--bg); box-shadow: none; }
.count { margin: var(--space-s) var(--pad) var(--space-xs); color: var(--muted); font-size: 12px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-s) 12px; padding: 0 var(--pad); }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-m) var(--space-s); } }
.card { display: flex; flex-direction: column; gap: 4px; text-align: left; min-width: 0; }
.photo { position: relative; display: block; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden; background: var(--surface); margin-bottom: 4px; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--spring); }
@media (hover: hover) { .card:hover .photo img { transform: scale(1.03); } }
.no-photo { display: grid; place-items: center; height: 100%; font-family: var(--serif); font-size: 44px; color: var(--muted); }
.badge { position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 99px; font-size: 11px; background: var(--material); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.card .title { font-size: 14px; font-weight: 500; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty; }
.card .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.fresh .photo { animation: fresh 1.2s ease-out; }
@keyframes fresh { 0% { box-shadow: 0 0 0 0 var(--accent); } 30% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.empty { padding: var(--space-xl) var(--pad); text-align: center; color: var(--muted); font-size: 14px; }
.empty-title { font-family: var(--serif); font-size: 28px; color: var(--ink); margin: 0 0 var(--space-xs); }

/* Sheets */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92dvh; border-radius: 22px 22px 0 0;
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow); overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 720px) { .sheet { margin: auto; border-radius: 22px; } }
.sheet::backdrop { background: oklch(0% 0 0 / .35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet[open] { animation: sheet-in .45s var(--spring); }
.sheet[open]::backdrop { animation: fade-in .3s ease; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet[open], .sheet[open]::backdrop, .card.fresh .photo { animation: none; } }
.sheet-inner { padding: var(--space-m) var(--pad) calc(env(safe-area-inset-bottom) + var(--space-m)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -.01em; line-height: 1.05; text-wrap: balance; }
.close { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); }
.hint { color: var(--muted); font-size: 14px; margin: var(--space-xs) 0 var(--space-s); }
.link-row { display: flex; gap: var(--space-xs); }
.link-row input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--surface); font-size: 16px; outline: 0; }
.link-row input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.pill { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 99px; background: var(--surface); font-size: 14px; color: var(--ink); text-decoration: none; }
.link-row .pill { height: 44px; border-radius: 12px; }
.primary { width: 100%; height: 46px; margin-top: var(--space-s); border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.primary:disabled { opacity: .6; }
.status { min-height: 1.4em; margin: var(--space-xs) 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* One recipe */
.recipe-sheet .sheet-inner { padding: 0 0 calc(env(safe-area-inset-bottom) + var(--space-l)); }
.hero { position: relative; min-height: 64px; }
.hero img { display: block; width: 100%; max-height: 52dvh; object-fit: cover; }
.close.floating { position: absolute; top: 12px; right: 12px; background: var(--material); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.recipe-text { padding: var(--space-m) var(--pad) 0; }
.by { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-s); }
.pills span { padding: 4px 10px; border-radius: 99px; font-size: 12px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-s); }
.pill.primary-pill { background: var(--accent); color: var(--accent-ink); }
.pill.danger { color: var(--danger); margin-left: auto; }
.title-input { width: 100%; font-family: var(--serif); font-size: 28px; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: 0; padding: 0 0 4px; }
.edit-row { display: flex; gap: var(--space-s); margin-top: var(--space-s); }
.edit-row label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
.edit-row select { height: 40px; border-radius: 10px; border: 0; background: var(--surface); padding: 0 10px; font-size: 16px; color: var(--ink); }
.recipe-text h3 { margin: var(--space-l) 0 var(--space-xs); font-size: 13px; font-weight: 500; text-transform: none; color: var(--muted); }
.recipe-text h3 em { font-style: normal; opacity: .7; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { border-bottom: 1px solid var(--line); }
.ingredients label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; font-size: 15px; line-height: 1.35; cursor: pointer; }
.ingredients input { appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line); transition: background .15s, box-shadow .15s; }
.ingredients input:checked { background: var(--accent); box-shadow: none; }
.ingredients input:checked + span { color: var(--muted); text-decoration: line-through; }
.steps { margin: 0; padding-left: 22px; }
.steps li { padding: 6px 0 10px 4px; font-size: 15px; line-height: 1.45; }
.steps li::marker { color: var(--accent); font-weight: 500; }
.notes { font-size: 15px; line-height: 1.5; white-space: pre-line; color: var(--ink); margin: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); z-index: 50; display: flex; gap: var(--space-s); align-items: center;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px;
  transform: translate(-50%, 140%); opacity: 0; transition: transform .45s var(--spring), opacity .2s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { color: var(--accent); font-weight: 500; }
