:root {
  --ink: #171914;
  --muted: #62665d;
  --paper: #f4f2ea;
  --surface: #fffef9;
  --line: #d9d8ce;
  --line-strong: #b9b9ae;
  --herb: #285b45;
  --herb-dark: #153e2d;
  --tomato: #c84b31;
  --tomato-dark: #92331f;
  --saffron: #e7ae36;
  --sky: #d9e5ec;
  --shadow: 0 14px 34px rgba(24, 31, 22, 0.09);
  --radius: 6px;
  --sans: "Manrope", sans-serif;
  --serif: "Newsreader", serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; overflow-x: clip; color: var(--ink); background: var(--paper); font-family: var(--sans); font-size: 15px; line-height: 1.55; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; opacity: .32; pointer-events: none; background-image: repeating-linear-gradient(90deg, transparent 0, transparent 47px, rgba(27, 63, 45, .04) 48px); }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; flex: 0 0 auto; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0; line-height: 1.04; }
h1 { margin-bottom: 14px; font-size: clamp(2.4rem, 5vw, 4.6rem); }
h2 { margin-bottom: 12px; font-size: clamp(1.65rem, 3vw, 2.4rem); }
h3 { margin-bottom: 8px; font-size: 1.5rem; }
label { display: grid; gap: 7px; color: #32362f; font-size: .82rem; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); background: var(--surface); padding: 11px 12px; outline: 0; transition: border-color 160ms ease, box-shadow 160ms ease; }
textarea { resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #8a8c84; }
input:focus-visible, textarea:focus-visible { border-color: var(--herb); box-shadow: 0 0 0 3px rgba(40, 91, 69, .15); }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(40, 91, 69, .28); outline-offset: 3px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin-bottom: 6px; color: var(--herb); font-size: .7rem; font-weight: 800; letter-spacing: .12em; line-height: 1.2; text-transform: uppercase; }
.muted { color: var(--muted); }

.site-header { position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 68px; padding: 0 clamp(18px, 4vw, 60px); border-bottom: 1px solid var(--line); background: rgba(244, 242, 234, .94); backdrop-filter: blur(14px); }
.brand { justify-self: start; display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.brand-mark { position: relative; display: flex; align-items: end; width: 26px; height: 24px; gap: 3px; border-bottom: 3px solid var(--tomato); }
.brand-mark i { display: block; width: 5px; border-radius: 5px 5px 0 0; background: var(--herb); }
.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 20px; background: var(--saffron); }
.brand-mark i:nth-child(3) { height: 16px; }
.primary-nav { display: flex; align-items: stretch; gap: 4px; height: 68px; }
.primary-nav a { position: relative; display: grid; place-items: center; padding: 0 15px; color: #50544c; font-size: .84rem; font-weight: 700; }
.primary-nav a::after { content: ""; position: absolute; right: 15px; bottom: -1px; left: 15px; height: 3px; background: transparent; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: var(--ink); }
.primary-nav a[aria-current="page"]::after { background: var(--tomato); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.header-actions form { display: flex; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: .82rem; font-weight: 800; transition: background 160ms ease, border-color 160ms ease, color 160ms ease; }
.button-primary { color: #fff; background: var(--herb); border-color: var(--herb); }
.button-primary:hover { background: var(--herb-dark); border-color: var(--herb-dark); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button-secondary:hover { border-color: var(--herb); color: var(--herb); }
.button-quiet { background: transparent; border-color: var(--line); }
.button-quiet:hover { background: rgba(40, 91, 69, .06); }
.button-danger { color: var(--tomato-dark); background: transparent; border-color: #dcaa9e; }
.button-danger:hover { color: #fff; background: var(--tomato-dark); }
.button-compact { min-height: 36px; padding: 7px 12px; }
.button-full { width: 100%; }
.icon-button { display: inline-grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 50%; cursor: pointer; background: transparent; transition: background 160ms ease, color 160ms ease, border-color 160ms ease; }
.icon-button:hover { background: rgba(40, 91, 69, .08); color: var(--herb); }
.back-link, .text-link { display: inline-flex; align-items: center; gap: 7px; color: var(--herb); font-size: .8rem; font-weight: 800; }
.back-link { margin-bottom: 22px; }
.text-link { border-bottom: 1px solid currentColor; }

.flash-stack { position: fixed; top: 78px; right: 22px; z-index: 80; display: grid; gap: 8px; width: min(360px, calc(100vw - 44px)); }
.flash { margin: 0; padding: 12px 15px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); font-size: .85rem; font-weight: 700; }
.flash-success { border-left: 4px solid var(--herb); }
.flash-error { border-left: 4px solid var(--tomato); }

.workspace-head { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(400px, 1.2fr); gap: clamp(28px, 8vw, 120px); align-items: end; padding: clamp(48px, 7vw, 92px) clamp(18px, 6vw, 88px) clamp(40px, 5vw, 70px); color: #f8f5e9; background-color: #173e2d; background-image: linear-gradient(110deg, rgba(255,255,255,.02), rgba(231,174,54,.08)), repeating-linear-gradient(135deg, transparent 0, transparent 25px, rgba(255,255,255,.025) 26px); }
.workspace-head h1 { max-width: 650px; margin-bottom: 10px; }
.workspace-head > div > p:last-child { max-width: 540px; margin-bottom: 0; color: #c7d2c9; }
.workspace-head .eyebrow { color: #f2c35f; }
.source-capture { display: grid; gap: 9px; padding: 24px; color: var(--ink); border-top: 4px solid var(--saffron); background: var(--surface); box-shadow: 14px 14px 0 rgba(7, 26, 18, .28); }
.source-capture > label { font-size: .78rem; }
.source-capture > p { margin: 0; color: var(--muted); font-size: .75rem; }
.source-capture a { color: var(--herb); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.capture-row { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.capture-row input { padding-left: 40px; }
.capture-row .input-icon { position: absolute; top: 0; bottom: 0; left: 12px; z-index: 1; display: grid; place-items: center; color: var(--muted); }

.ledger-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px clamp(18px, 6vw, 88px); border-bottom: 1px solid var(--line); background: var(--surface); }
.status-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.status-tabs::-webkit-scrollbar { display: none; }
.status-tabs a { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 8px; min-height: 38px; padding: 7px 11px; border: 1px solid transparent; border-radius: 4px; color: var(--muted); font-size: .77rem; font-weight: 800; }
.status-tabs a span { display: grid; min-width: 22px; height: 22px; place-items: center; padding: 0 5px; border-radius: 50%; background: #eeede6; font-size: .68rem; }
.status-tabs a:hover, .status-tabs a[aria-current="page"] { color: var(--herb); border-color: var(--line); background: #f5f8f4; }
.search-form { position: relative; width: min(260px, 32vw); }
.search-form svg { position: absolute; top: 50%; left: 12px; color: var(--muted); transform: translateY(-50%); }
.search-form input { height: 38px; padding: 8px 10px 8px 38px; font-size: .78rem; }

.ledger-body { padding: clamp(34px, 5vw, 68px) clamp(18px, 6vw, 88px) 90px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading > span { color: var(--muted); font-size: .75rem; font-weight: 700; }
.compact-heading { align-items: center; margin-bottom: 20px; }
.compact-heading h2 { font-size: 1.85rem; }
.recipe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.recipe-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color 180ms ease, box-shadow 180ms ease; }
.recipe-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.recipe-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #dfe6dc; }
.recipe-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 320ms ease; }
.recipe-card:hover .recipe-media img { transform: scale(1.025); }
.media-source { position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; color: #fff; background: rgba(18, 20, 16, .84); border-radius: 3px; font-size: .63rem; font-weight: 800; }
.media-source svg { width: 13px; height: 13px; }
.recipe-placeholder { display: grid; width: 100%; height: 100%; place-content: center; justify-items: center; gap: 8px; color: var(--herb); background-color: #dce7df; background-image: repeating-linear-gradient(-45deg, transparent 0, transparent 16px, rgba(255,255,255,.3) 17px); }
.recipe-placeholder-facebook { color: #2d527e; background-color: var(--sky); }
.recipe-placeholder svg { width: 38px; height: 38px; }
.recipe-placeholder small { font-size: .65rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.recipe-card-body { padding: 17px 18px 18px; }
.recipe-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.recipe-card-heading h3 { margin-top: 8px; margin-bottom: 6px; overflow-wrap: anywhere; }
.recipe-card-heading h3 a:hover { color: var(--herb); }
.favorite-button { margin: -5px -7px 0 0; color: #777b73; }
.favorite-button.is-active, .is-favorite { color: var(--tomato); }
.favorite-button.is-active svg, .is-favorite svg { fill: currentColor; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 3px 7px; border-radius: 3px; font-size: .61rem; font-weight: 800; letter-spacing: .06em; line-height: 1; text-transform: uppercase; }
.status-next_week { color: #6d4900; background: #f6e4b4; }
.status-someday { color: #46574d; background: #e3e8e4; }
.status-done { color: #1d5b40; background: #d9ecdf; }
.status-retry { color: #8f321f; background: #f4d8d0; }
.status-pill svg { width: 13px; height: 13px; }
.recipe-summary { display: -webkit-box; margin-bottom: 15px; overflow: hidden; color: var(--muted); font-size: .78rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.recipe-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: .69rem; font-weight: 700; }
.recipe-meta span { display: inline-flex; align-items: center; gap: 5px; }
.recipe-meta svg { width: 14px; height: 14px; }
.recipe-meta .retry-note { color: var(--tomato-dark); }
.empty-state { display: grid; min-height: 330px; place-content: center; justify-items: center; padding: 40px 20px; border: 1px dashed var(--line-strong); text-align: center; background: rgba(255, 254, 249, .55); }
.empty-state > svg { width: 42px; height: 42px; margin-bottom: 20px; color: var(--herb); }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 460px; margin-bottom: 22px; color: var(--muted); }
.draft-shelf { display: grid; gap: 14px; padding: 20px clamp(18px, 6vw, 88px); border-bottom: 1px solid var(--line); background: #e8efe9; }
.draft-shelf h2, .draft-shelf p { margin-bottom: 0; }
.draft-shelf h2 { font-size: 1.55rem; }
.draft-list { display: grid; gap: 6px; }
.draft-list a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 58px; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid #bfd0c4; background: var(--surface); }
.draft-list a > svg:first-child { color: var(--herb); }
.draft-list span { display: grid; min-width: 0; }
.draft-list b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-list small { color: var(--muted); font-size: .62rem; }
.collection-head { padding: clamp(48px, 7vw, 90px) clamp(18px, 6vw, 88px) 42px; border-bottom: 1px solid var(--line); background: var(--surface); }
.collection-head h1 { margin-bottom: 8px; }
.collection-head > p:last-child { max-width: 620px; margin-bottom: 0; color: var(--muted); }
.collection-body { padding-top: 40px; }

.login-page { min-height: 100vh; background: var(--herb-dark); }
.login-page .site-header { position: absolute; width: 100%; color: #fff; border-color: rgba(255,255,255,.12); background: transparent; backdrop-filter: none; }
.login-page main { min-height: 100vh; }
.login-shell { display: grid; grid-template-columns: 1.1fr minmax(320px, 480px); min-height: 100vh; padding: 130px clamp(24px, 8vw, 120px) 70px; align-items: center; gap: clamp(50px, 12vw, 180px); color: #fff; background-image: linear-gradient(125deg, transparent 0 60%, rgba(231, 174, 54, .13) 60%), repeating-linear-gradient(135deg, transparent 0, transparent 34px, rgba(255,255,255,.025) 35px); }
.login-copy h1 { max-width: 650px; margin-bottom: 18px; font-size: clamp(3.7rem, 8vw, 7rem); }
.login-copy > p:not(.eyebrow) { max-width: 520px; color: #c6d0c9; font-size: 1.05rem; }
.login-copy .eyebrow { color: var(--saffron); }
.ingredient-stamp { display: flex; gap: 24px; margin-top: 40px; color: #9bb0a2; font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.ingredient-stamp span { position: relative; }
.ingredient-stamp span:not(:last-child)::after { content: ""; position: absolute; top: 50%; left: calc(100% + 9px); width: 7px; height: 1px; background: var(--saffron); }
.login-form { display: grid; gap: 18px; padding: clamp(28px, 5vw, 46px); color: var(--ink); border-top: 5px solid var(--tomato); background: var(--surface); box-shadow: 18px 18px 0 rgba(5, 19, 12, .3); }
.login-form h2 { margin-bottom: 0; }

.recipe-editor { padding-bottom: 80px; }
.editor-head, .detail-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: clamp(38px, 6vw, 76px) clamp(18px, 6vw, 88px) 38px; border-bottom: 1px solid var(--line); background: var(--surface); }
.editor-head h1 { max-width: 780px; margin-bottom: 0; font-size: clamp(2.5rem, 5vw, 4.2rem); }
.editor-layout, .detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(35px, 6vw, 84px); max-width: 1500px; margin: 0 auto; padding: 0 clamp(18px, 6vw, 88px); }
.editor-main { min-width: 0; }
.form-section { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 16px; padding: 52px 0; border-bottom: 1px solid var(--line); }
.section-number { padding-top: 5px; color: var(--tomato); font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.form-section-content { min-width: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field-span-2 { grid-column: span 2; }
.field-with-icon { position: relative; display: block; }
.field-with-icon svg { position: absolute; top: 50%; left: 12px; color: var(--muted); transform: translateY(-50%); }
.field-with-icon input { padding-left: 40px; }
.ingredient-labels, .ingredient-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(70px, .7fr) minmax(70px, .7fr) minmax(130px, 1.2fr) 40px; gap: 8px; }
.ingredient-labels { padding: 0 2px 7px; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.ingredient-rows { display: grid; gap: 8px; }
.ingredient-row { position: relative; align-items: center; }
.ingredient-row input { min-width: 0; }
.ingredient-picker { position: relative; min-width: 0; }
.picker-results { position: absolute; top: calc(100% + 5px); left: 0; z-index: 30; width: max(100%, 270px); max-height: 260px; overflow-y: auto; padding: 5px; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.picker-results button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border: 0; border-radius: 3px; cursor: pointer; text-align: left; background: transparent; font-size: .78rem; }
.picker-results button:hover, .picker-results button.is-active { color: var(--herb); background: #edf3ee; }
.picker-results small { color: var(--muted); font-size: .61rem; }
.picker-results .picker-create { color: var(--tomato-dark); border-top: 1px solid var(--line); }
.remove-row { width: 36px; height: 36px; color: var(--muted); }
.method-section .form-section-content { display: grid; gap: 20px; }
.upload-field { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 18px; border: 1px dashed var(--line-strong); cursor: pointer; background: rgba(255,255,255,.45); }
.upload-field > span:first-child { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 10px; }
.upload-field > span:first-child svg { grid-row: span 2; color: var(--herb); }
.upload-field small { display: block; color: var(--muted); font-weight: 500; }
.upload-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-field output { flex-basis: 100%; color: var(--muted); font-size: .7rem; font-weight: 500; }
.editor-side, .detail-side { display: grid; align-content: start; gap: 18px; padding-top: 52px; }
.planning-panel, .facts-panel, .recipe-facts, .attempt-panel, .attempt-history { padding: 24px; border: 1px solid var(--line); background: var(--surface); }
.planning-panel h2, .attempt-panel h2 { font-size: 1.75rem; }
.status-picker, .outcome-picker { display: grid; gap: 8px; margin: 18px 0; padding: 0; border: 0; }
.status-picker label { display: block; cursor: pointer; }
.status-picker input, .outcome-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.status-picker label > span { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; transition: border-color 160ms ease, background 160ms ease; }
.status-picker label > span svg { grid-row: span 2; margin-top: 2px; color: var(--muted); }
.status-picker label > span b { font-size: .75rem; }
.status-picker label > span small { color: var(--muted); font-size: .65rem; font-weight: 500; }
.status-picker input:checked + span { border-color: var(--herb); background: #edf3ee; }
.status-picker input:checked + span svg { color: var(--herb); }
.status-picker input:focus-visible + span, .outcome-picker input:focus-visible + span { outline: 3px solid rgba(40,91,69,.25); outline-offset: 2px; }
.planning-panel > label { margin-top: 18px; }
.check-field { display: block !important; }
.check-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.check-field span { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-field span::before { content: ""; width: 18px; height: 18px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--surface); }
.check-field input:checked + span::before { border-color: var(--tomato); background: var(--tomato); box-shadow: inset 0 0 0 4px var(--surface); }
.check-field svg { color: var(--tomato); }
.side-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side-field-grid label:first-child { grid-column: span 2; }
.mobile-save-bar { display: none; }

.wizard-page { scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom)); overscroll-behavior-y: contain; }
.wizard-page .site-header { display: none; }
.recipe-wizard { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; background: var(--paper); }
.wizard-header { padding: 20px 18px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.wizard-header .back-link { min-height: 44px; margin: -8px 0 14px; }
.wizard-header h1 { margin-bottom: 8px; font-size: 2.35rem; }
.wizard-intro { max-width: 560px; margin-bottom: 22px; color: var(--muted); }
.wizard-progress { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 -4px; overflow: hidden; }
.wizard-progress a, .wizard-progress > span { position: relative; display: grid; min-width: 0; justify-items: center; gap: 5px; padding: 0 2px 12px; color: var(--muted); text-align: center; }
.wizard-progress a::after, .wizard-progress > span::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: transparent; }
.wizard-progress a > span, .wizard-progress > span > b { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); font-size: .72rem; text-decoration: none; }
.wizard-progress svg { width: 14px; height: 14px; }
.wizard-progress small { max-width: 100%; overflow: hidden; font-size: .62rem; font-weight: 800; text-overflow: ellipsis; }
.wizard-progress .is-current { color: var(--herb); }
.wizard-progress .is-current::after { background: var(--tomato); }
.wizard-progress .is-current > span, .wizard-progress > .is-current > b { color: #fff; border-color: var(--herb); background: var(--herb); }
.wizard-progress .is-complete > span { color: #fff; border-color: var(--herb); background: var(--herb); }
.wizard-body { padding: 18px 14px calc(100px + env(safe-area-inset-bottom)); }
.wizard-form { display: grid; gap: 14px; }
.wizard-form input, .wizard-form textarea, .barcode-dialog input { min-height: 48px; font-size: 16px; }
.wizard-form textarea { min-height: 120px; }
.wizard-section { display: grid; min-width: 0; gap: 18px; padding: 20px 16px; border: 1px solid var(--line); background: var(--surface); }
.wizard-section-title { display: flex; align-items: center; gap: 12px; }
.wizard-section-title > svg { width: 24px; height: 24px; color: var(--herb); }
.wizard-section-title h2, .wizard-section-title p { margin-bottom: 0; }
.wizard-section-title h2 { font-size: 1.55rem; }
.mobile-field-grid { display: grid; gap: 14px; }
.compact-status-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-status-picker label > span { min-height: 72px; grid-template-columns: 1fr; place-items: center; gap: 5px; padding: 9px 4px; text-align: center; }
.compact-status-picker label > span svg { grid-row: auto; margin: 0; }
.compact-status-picker label > span b { font-size: .68rem; }
.wizard-actions { position: sticky; bottom: 0; z-index: 35; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px -14px calc(-100px - env(safe-area-inset-bottom)); padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(244, 242, 234, .97); backdrop-filter: blur(14px); }
.wizard-actions .button { min-height: 48px; flex: 1; }
.wizard-actions > span { flex: 1; }
.discard-draft { display: flex; justify-content: center; margin-top: 118px; }
.discard-draft .button { min-height: 44px; }

.ingredient-card-list { display: grid; gap: 14px; }
.ingredient-card { display: grid; min-width: 0; gap: 15px; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.ingredient-card > header { display: grid; grid-template-columns: 30px 1fr 44px; align-items: center; gap: 8px; }
.ingredient-card > header strong { font-family: var(--serif); font-size: 1.35rem; }
.ingredient-count { display: grid; width: 28px; height: 28px; place-items: center; color: #fff; border-radius: 50%; background: var(--herb); font-size: .72rem; font-weight: 800; }
.ingredient-card .remove-row { width: 44px; height: 44px; justify-self: end; color: var(--tomato-dark); }
.ingredient-quantity-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 10px; }
.ingredient-card .picker-results { width: 100%; max-width: calc(100vw - 60px); }
.ingredient-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ingredient-tool { position: relative; display: flex; min-width: 0; min-height: 66px; align-items: center; gap: 9px; padding: 9px; overflow: hidden; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; text-align: left; background: #f8f8f3; }
.ingredient-tool, .add-ingredient-bottom { scroll-margin-bottom: calc(96px + env(safe-area-inset-bottom)); }
.ingredient-tool:hover { border-color: var(--herb); }
.ingredient-tool > svg { color: var(--herb); }
.ingredient-tool span { display: grid; min-width: 0; }
.ingredient-tool b { font-size: .7rem; }
.ingredient-tool small { overflow: hidden; color: var(--muted); font-size: .58rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.ingredient-tool input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ingredient-tools .ingredient-tool:nth-child(3) { grid-column: 1 / -1; }
.selected-product { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 10px; color: #17412e; border: 1px solid #aacbb8; background: #edf6f0; }
.selected-product svg { color: var(--herb); }
.selected-product span { display: grid; }
.selected-product b { font-size: .7rem; }
.selected-product small { color: var(--muted); font-size: .58rem; }
.text-button { min-height: 40px; padding: 4px 6px; color: var(--tomato-dark); border: 0; cursor: pointer; background: transparent; font-size: .68rem; font-weight: 800; }
.add-ingredient-bottom { display: flex; width: 100%; min-height: 70px; align-items: center; gap: 12px; padding: 14px 16px; color: var(--herb); border: 1px dashed var(--herb); border-radius: 4px; cursor: pointer; text-align: left; background: rgba(255,255,255,.45); }
.add-ingredient-bottom svg { width: 24px; height: 24px; }
.add-ingredient-bottom span { display: grid; }
.add-ingredient-bottom b { font-size: .8rem; }
.add-ingredient-bottom small { color: var(--muted); font-size: .65rem; }

.barcode-dialog { width: min(100% - 20px, 520px); max-height: calc(100dvh - 20px); margin: auto; padding: 0; overflow-x: hidden; overflow-y: auto; color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.barcode-dialog::backdrop { background: rgba(10, 20, 14, .72); backdrop-filter: blur(4px); }
.dialog-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog-head h2, .dialog-head p { margin-bottom: 0; }
.dialog-head h2 { font-size: 1.65rem; }
.barcode-camera { position: relative; min-height: 220px; overflow: hidden; background: #101611; }
.barcode-camera video { width: 100% !important; min-height: 220px; object-fit: cover; }
.barcode-camera #qr-shaded-region { border-width: 40px 20px !important; }
.scan-frame { position: absolute; inset: 50% auto auto 50%; width: min(280px, 76vw); height: 130px; pointer-events: none; border: 2px solid var(--saffron); transform: translate(-50%, -50%); }
.scan-status, .off-attribution { margin: 0; padding: 12px 16px; color: var(--muted); font-size: .72rem; }
.barcode-manual { display: grid; gap: 10px; padding: 4px 16px 16px; }
.product-preview { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 14px; margin: 0 16px 14px; padding: 12px; border: 1px solid var(--line); background: #f8f8f3; }
.product-preview img { width: 90px; height: 110px; object-fit: contain; background: #fff; }
.product-preview h3 { margin-bottom: 4px; font-size: 1.25rem; }
.product-preview p { margin-bottom: 8px; color: var(--muted); font-size: .68rem; }
.product-nutrients { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.product-nutrients span { display: grid; padding: 5px; background: #eceee8; font-size: .6rem; }
.product-nutrients b { overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; white-space: nowrap; }
.barcode-dialog > .button { width: calc(100% - 32px); margin: 0 16px; }
.off-attribution a { color: var(--herb); text-decoration: underline; }

.media-choice-grid { padding: 12px; }
.media-choice { position: relative; display: flex; min-height: 86px; align-items: center; gap: 14px; padding: 14px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; background: #f8f8f3; }
.media-choice > svg { width: 26px; height: 26px; color: var(--herb); }
.media-choice span { display: grid; }
.media-choice b { font-size: .82rem; }
.media-choice small { color: var(--muted); font-weight: 500; }
.media-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.selected-files { padding: 12px 14px; color: var(--muted); border: 1px solid var(--line); background: var(--surface); font-size: .72rem; }
.finish-summary { padding: 20px 16px; color: #fff; background: var(--herb-dark); }
.finish-summary .eyebrow { color: var(--saffron); }
.finish-summary h2 { overflow-wrap: anywhere; }
.finish-summary dl { display: flex; gap: 28px; margin: 0; }
.finish-summary dl div { display: grid; }
.finish-summary dt { color: #b9c8be; font-size: .65rem; font-weight: 700; }
.finish-summary dd { margin: 0; font-family: var(--serif); font-size: 1.2rem; }
.stale-draft-recovery { display: grid; gap: 10px; margin-top: 118px; padding: 16px; border: 1px solid #dcaa9e; background: #fae8e2; }
.stale-draft-recovery p { margin: 0; color: var(--tomato-dark); font-size: .75rem; font-weight: 700; }

.ingredient-profile-head { padding: 34px 18px 28px; color: #fff; background: var(--herb-dark); }
.ingredient-profile-head .back-link { color: #fff; }
.ingredient-profile-head .eyebrow { color: var(--saffron); }
.ingredient-profile-head h1 { margin-bottom: 8px; overflow-wrap: anywhere; font-size: 3rem; }
.ingredient-profile-head > p:last-child { max-width: 560px; margin: 0; color: #c6d0c9; }
.ingredient-profile-body { display: grid; gap: 18px; padding: 18px 14px 80px; }
.profile-section { min-width: 0; padding: 18px 14px; border: 1px solid var(--line); background: var(--surface); }
.ingredient-camera-upload { display: grid; gap: 10px; margin-bottom: 18px; }
.ingredient-camera-upload label { position: relative; display: flex; min-height: 78px; align-items: center; gap: 12px; padding: 14px; overflow: hidden; border: 1px dashed var(--herb); cursor: pointer; }
.ingredient-camera-upload label > svg { color: var(--herb); }
.ingredient-camera-upload label span { display: grid; }
.ingredient-camera-upload label small { color: var(--muted); font-weight: 500; }
.ingredient-camera-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ingredient-photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ingredient-photo-grid figure { position: relative; margin: 0; overflow: hidden; aspect-ratio: 1; background: #e5e7e1; }
.ingredient-photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.ingredient-photo-grid form { position: absolute; top: 6px; right: 6px; }
.ingredient-photo-grid .icon-button { color: var(--tomato-dark); background: rgba(255,254,249,.94); }
.empty-inline { padding: 22px 0; text-align: center; }
.product-list { display: grid; gap: 10px; }
.product-card { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 14px; padding: 12px; border: 1px solid var(--line); }
.product-card > img { width: 90px; height: 120px; object-fit: contain; background: #fff; }
.product-card h3 { margin-bottom: 4px; overflow-wrap: anywhere; font-size: 1.3rem; }
.product-card p { margin-bottom: 10px; color: var(--muted); font-size: .7rem; }
.product-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.product-badges span { padding: 4px 6px; color: #17412e; border-radius: 3px; background: #e0eee5; font-size: .58rem; font-weight: 800; }
.product-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.product-card dl div { display: grid; padding: 5px; background: #f0f1ec; }
.product-card dt { overflow: hidden; font-size: .55rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.product-card dd { margin: 0; font-size: .65rem; }
.product-copy { margin: 10px 0; padding-top: 10px; border-top: 1px solid var(--line); }
.product-copy b { font-size: .65rem; }
.product-copy p { margin: 3px 0 0; line-height: 1.5; }

@media (min-width: 640px) {
  .wizard-header { padding-right: 28px; padding-left: 28px; }
  .wizard-body { padding-right: 24px; padding-left: 24px; }
  .mobile-field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ingredient-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ingredient-tools .ingredient-tool:nth-child(3) { grid-column: auto; }
  .media-choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .media-choice { align-items: start; flex-direction: column; }
  .ingredient-profile-head { padding-right: max(28px, calc((100vw - 900px) / 2)); padding-left: max(28px, calc((100vw - 900px) / 2)); }
  .ingredient-profile-body { max-width: 900px; margin: 0 auto; padding-right: 24px; padding-left: 24px; }
  .ingredient-photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.ingredient-name-link { display: inline-flex; align-items: center; gap: 6px; }
.ingredient-name-link:hover { color: var(--herb); }
.ingredient-name-link svg { width: 14px; height: 14px; }
.ingredient-product-summary { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); }
.ingredient-product-summary span { padding: 3px 6px; border-radius: 3px; background: #eceee8; font-size: .58rem; }

.detail-head { align-items: end; }
.detail-head > div:first-child { max-width: 900px; }
.detail-head h1 { margin: 12px 0 8px; font-size: clamp(3rem, 6vw, 5.5rem); }
.detail-head p { max-width: 680px; margin-bottom: 0; color: var(--muted); }
.detail-status-line, .detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions { justify-content: end; }
.detail-actions form { display: flex; }
.detail-main { min-width: 0; padding-top: 52px; }
.source-video { position: relative; margin-bottom: 48px; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); background: #111; }
.source-video iframe { position: absolute; width: 100%; height: 100%; border: 0; }
.source-link-band { display: flex; align-items: center; gap: 16px; margin-bottom: 48px; padding: 18px 20px; color: #fff; background: #2d527e; }
.source-link-band:hover { background: #234364; }
.source-link-band > svg { width: 28px; height: 28px; }
.source-link-band span { display: grid; font-weight: 800; }
.source-link-band small { color: #ccdae9; font-size: .63rem; letter-spacing: .09em; text-transform: uppercase; }
.detail-section { padding: 0 0 48px; margin-bottom: 48px; border-bottom: 1px solid var(--line); }
.ingredient-list { display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.ingredient-list li { display: grid; grid-template-columns: 120px minmax(140px, 1fr) minmax(100px, .8fr); gap: 16px; align-items: baseline; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.ingredient-quantity { color: var(--tomato-dark); font-family: var(--serif); font-size: 1.12rem; font-weight: 600; }
.ingredient-list strong { font-size: .85rem; }
.ingredient-list small { color: var(--muted); }
.prose-block { white-space: pre-wrap; color: #393d36; font-family: var(--serif); font-size: 1.16rem; line-height: 1.72; }
.note-band { display: grid; grid-template-columns: auto 1fr; gap: 18px; margin: 0 0 48px; padding: 24px; border-left: 4px solid var(--saffron); background: #fcf3da; }
.note-band > svg { margin-top: 2px; color: #8a6209; }
.note-band .prose-block { font-size: 1rem; }
.attachment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.attachment-item { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.attachment-photo { aspect-ratio: 4 / 3; }
.attachment-photo img { width: 100%; height: 100%; object-fit: cover; }
.attachment-delete { position: absolute; top: 7px; right: 7px; width: 34px; height: 34px; color: var(--tomato-dark); background: rgba(255,254,249,.93); }
.audio-file { display: grid; gap: 12px; padding: 20px; }
.audio-file > svg { color: var(--herb); }
.audio-file strong { max-width: calc(100% - 40px); overflow: hidden; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.audio-file audio { width: 100%; height: 36px; }
.document-file { display: flex; min-height: 100px; align-items: center; gap: 12px; padding: 20px 54px 20px 20px; font-size: .78rem; font-weight: 700; overflow-wrap: anywhere; }
.document-file:hover { color: var(--herb); }
.document-file > svg { color: var(--herb); }
.recipe-facts dl { display: grid; margin: 14px 0 0; }
.recipe-facts dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recipe-facts dt { color: var(--muted); font-size: .7rem; font-weight: 700; }
.recipe-facts dd { margin: 0; font-family: var(--serif); font-size: 1.05rem; font-weight: 600; text-align: right; }
.attempt-panel form { display: grid; gap: 15px; margin-top: 16px; }
.outcome-picker { grid-template-columns: repeat(3, 1fr); margin: 0; }
.outcome-picker legend { margin-bottom: 7px; color: #32362f; font-size: .82rem; font-weight: 700; }
.outcome-picker label { display: block; cursor: pointer; }
.outcome-picker span { display: grid; min-height: 46px; place-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 3px; text-align: center; font-size: .65rem; }
.outcome-picker input:checked + span { color: #fff; border-color: var(--herb); background: var(--herb); }
.attempt-history ol { display: grid; gap: 18px; margin: 18px 0; padding: 0; list-style: none; }
.attempt-history li { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.attempt-history li > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.attempt-history li strong { font-family: var(--serif); font-size: 1.05rem; }
.attempt-history li p { margin: 8px 0 0; color: var(--muted); font-size: .75rem; }
.attempt-history li small { display: block; margin-top: 6px; color: var(--tomato-dark); font-size: .65rem; font-weight: 700; }
.outcome { padding: 3px 6px; border-radius: 3px; font-size: .58rem; font-weight: 800; text-transform: uppercase; }
.outcome-loved { color: #7e2c1b; background: #f2d4cc; }
.outcome-good { color: #28533f; background: #dbe9df; }
.outcome-needs_work { color: #715000; background: #f2e2b7; }
.danger-zone { margin-top: 18px; }

@media (max-width: 1050px) {
  .site-header { grid-template-columns: auto 1fr auto; }
  .primary-nav { justify-self: center; }
  .workspace-head { grid-template-columns: 1fr; align-items: start; }
  .source-capture { width: min(720px, 100%); }
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-layout, .detail-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 34px; }
  .ingredient-labels, .ingredient-row { grid-template-columns: minmax(150px, 2fr) 72px 72px minmax(100px, 1fr) 36px; }
}

@media (max-width: 780px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .site-header { position: sticky; grid-template-columns: 1fr auto; min-height: 62px; padding: 0 16px; }
  .brand { font-size: 1.4rem; }
  .primary-nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; height: 44px; margin: 0 -16px; padding: 0 10px; overflow-x: auto; border-top: 1px solid var(--line); background: var(--surface); }
  .primary-nav a { flex: 1 0 auto; padding: 0 11px; }
  .header-actions .button span { display: none; }
  .header-actions .button { width: 40px; padding: 0; }
  .workspace-head { padding-top: 42px; }
  .workspace-head h1 { font-size: 3.1rem; }
  .capture-row { grid-template-columns: 1fr; }
  .capture-row .input-icon { top: 12px; bottom: auto; }
  .capture-row .button { width: 100%; }
  .ledger-toolbar { align-items: stretch; flex-direction: column; padding: 12px 16px; }
  .search-form { width: 100%; }
  .recipe-grid { grid-template-columns: 1fr; }
  .ledger-body { padding-right: 16px; padding-left: 16px; }
  .login-page .site-header { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; padding: 120px 20px 60px; }
  .login-copy h1 { font-size: 4.2rem; }
  .ingredient-stamp { margin-top: 24px; }
  .editor-head, .detail-head { align-items: start; flex-direction: column; padding-right: 18px; padding-left: 18px; }
  .editor-save { display: none; }
  .editor-layout, .detail-layout { grid-template-columns: 1fr; padding: 0 18px; }
  .editor-side { grid-row: 1; padding-top: 28px; }
  .detail-side { padding-top: 0; }
  .form-section { grid-template-columns: 36px minmax(0, 1fr); padding: 40px 0; }
  .field-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .ingredient-labels { display: none; }
  .ingredient-row { grid-template-columns: minmax(0, 1fr) 70px 70px 36px; padding: 12px; border: 1px solid var(--line); background: var(--surface); }
  .ingredient-row > input[name="ingredient_note[]"] { grid-column: 1 / -1; grid-row: 2; }
  .ingredient-row .remove-row { grid-column: 4; grid-row: 1; }
  .picker-results { width: min(300px, calc(100vw - 92px)); }
  .mobile-save-bar { position: sticky; bottom: 0; z-index: 40; display: block; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(244,242,234,.95); backdrop-filter: blur(12px); }
  .detail-actions { width: 100%; justify-content: stretch; }
  .detail-actions > * { flex: 1; }
  .detail-actions .button { width: 100%; }
}

@media (max-width: 480px) {
  .workspace-head h1 { font-size: 2.7rem; }
  .source-capture { padding: 18px; box-shadow: 8px 8px 0 rgba(7,26,18,.28); }
  .section-heading { align-items: start; }
  .recipe-card-body { padding: 15px; }
  .login-copy h1 { font-size: 3.4rem; }
  .login-form { padding: 24px; box-shadow: 9px 9px 0 rgba(5,19,12,.3); }
  .form-section { grid-template-columns: 1fr; }
  .section-number { padding: 0; }
  .compact-heading { align-items: start; }
  .ingredients-section .compact-heading { flex-direction: column; }
  .ingredient-row { grid-template-columns: minmax(0, 1fr) 62px 62px 34px; gap: 6px; }
  .side-field-grid { grid-template-columns: 1fr; }
  .side-field-grid label:first-child { grid-column: auto; }
  .ingredient-list li { grid-template-columns: 88px minmax(0, 1fr); gap: 10px; }
  .ingredient-list small { grid-column: 2; }
  .attachment-grid { grid-template-columns: 1fr; }
  .outcome-picker { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}