:root {
  color-scheme: light;
  --ink: #24272e;
  --muted: #59616e;
  --page: #f5f6f8;
  --surface: #fff;
  --line: #dce0e6;
  --accent: #2859ad;
  --accent-hover: #204786;
  --selected: #edf3ff;
  --danger: #9b302b;
  --warning: #785013;
  --success: #286047;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
::selection { background: #cbdcff; color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button, summary { cursor: pointer; }
button { min-height: 44px; padding: 9px 16px; border: 1px solid transparent; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; transition: background-color 150ms; }
button:hover { background: var(--accent-hover); }
button:active { background: #193969; }
button:disabled { background: #e6e9ee; color: #616a78; cursor: default; }
.quiet { background: var(--surface); color: var(--ink); border-color: #c7cdd6; }
.quiet:hover { background: #edf0f4; }
.text-button { background: transparent; color: var(--muted); padding: 6px 10px; font-size: 14px; }
.text-button:hover { background: #e8ecf1; color: var(--ink); }
input, select { border: 1px solid #9ba5b3; border-radius: 5px; background: white; color: var(--ink); min-height: 44px; padding: 9px 11px; min-width: 0; caret-color: var(--accent); }
input::placeholder { color: #626b78; opacity: 1; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; min-height: 18px; margin: 0; flex-shrink: 0; }
input:disabled { background: #f0f2f5; color: var(--muted); }
input[aria-invalid=true] { border-color: var(--danger); }
.app-header { display: flex; align-items: center; gap: 48px; min-height: 68px; padding: 0 max(24px, calc((100vw - 1040px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-size: 19px; font-weight: 700; color: var(--ink); text-decoration: none; }
nav { display: flex; gap: 4px; align-self: stretch; }
nav button { border-radius: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; padding-inline: 14px; }
nav button:hover { background: #f5f7fa; }
nav button[aria-current] { color: var(--accent); border-bottom-color: var(--accent); }
.account { margin-left: auto; position: relative; font-size: 14px; }
.account summary { padding: 12px 0 12px 12px; }
.account-menu { position: absolute; right: 0; top: 100%; width: 200px; background: white; border: 1px solid var(--line); border-radius: 6px; padding: 8px; z-index: 5; }
.account-menu a, .account-menu button { display: block; width: 100%; text-align: left; padding: 12px; }
.account-menu button { border: 0; font-weight: 400; }
main { max-width: 1088px; margin: auto; padding: 16px 24px 24px; }
.page-context { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.025em; margin: 0; font-weight: 650; }
h2 { font-size: 21px; line-height: 1.3; margin: 0 0 16px; font-weight: 650; }
h3 { font-size: 18px; line-height: 1.35; margin: 0 0 16px; font-weight: 650; }
p { max-width: 75ch; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 16px; }
.section-head p { margin: 8px 0 0; }
.muted, .help { color: var(--muted); }
.help { font-size: 14px; margin: 12px 0 20px; }
.search-label input { width: 250px; }
.stock-table-head, .stock-row { display: grid; grid-template-columns: minmax(180px, 1fr) 140px 230px; gap: 24px; align-items: center; }
.stock-table-head { color: var(--muted); font-size: 13px; padding: 12px 20px; }
.stock-table-head span:last-child { text-align: right; }
.stock-list { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.stock-row { padding: 13px 20px; border-bottom: 1px solid var(--line); }
.stock-row:last-child { border-bottom: none; }
.stock-row.is-dirty { background: #f3f7ff; }
.stock-row.has-error { background: #fff8f6; }
.stock-name { font-weight: 550; overflow-wrap: anywhere; }
.stock-name details { font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.stock-name summary { display: inline-block; padding: 3px 0; text-decoration: underline; text-underline-offset: 3px; }
.stock-name details p { margin: 7px 0; }
.stock-current { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.stock-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.stock-controls input[type=number] { width: 102px; text-align: right; }
.stock-unit { width: 30px; font-size: 14px; }
.estimate { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); min-height: 44px; }
.row-error { grid-column: 1/-1; color: var(--danger); font-size: 14px; margin: 0; }
.row-state { display: block; font-size: 13px; color: var(--accent); }
.save-bar { position: sticky; bottom: 12px; display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; align-items: center; border: 1px solid #c9d0db; border-radius: 8px; background: #fff; margin-top: 16px; padding: 16px 20px; z-index: 2; }
.save-feedback strong { display: block; font-size: 14px; font-weight: 550; }
#stock-save-result { display: block; color: var(--muted); font-size: 13px; }
.save-actions { display: flex; gap: 10px; grid-column: 2; grid-row: 1; }
.pending-count { grid-column: 1/-1; font-size: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.pending-count label { display: flex; align-items: flex-start; gap: 10px; }
.pending-count .help { margin: 6px 0 0 28px; }
.help-details { margin: 24px 0; font-size: 14px; color: var(--muted); }
.help-details summary { min-height: 44px; padding: 10px 0; }
.cards { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin: 24px 0; }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; margin-bottom: 16px; }
.empty { grid-column: 1/-1; padding: 40px 24px; text-align: center; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 8px; }
.empty h2 { color: var(--ink); font-size: 18px; margin-bottom: 8px; }
.empty p { margin: 0 auto; max-width: 50ch; font-size: 14px; }
.meta { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.ingredient { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ingredient label, .ingredient select { flex: 1; }
.ingredient input { width: 92px; }
.macros { display: flex; gap: 20px; flex-wrap: wrap; font-size: 14px; padding: 16px 0; margin: 8px 0; font-variant-numeric: tabular-nums; }
.macros b { font-weight: 650; }
.instructions { font-size: 14px; white-space: pre-line; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.form-row label { display: flex; flex: 1; min-width: 150px; flex-direction: column; gap: 6px; font-size: 14px; }
.actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.badge { border-radius: 4px; font-size: 13px; padding: 4px 8px; display: inline-block; background: #edf0f5; }
.done { background: #edf5ef; color: var(--success); }
.blocked, .uncertain { background: #fff0e0; color: var(--warning); }
.sync-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.sync-row small { font-size: 13px; }
.callout, #notice:not(:empty) { background: #fff4e5; color: #67451a; border: 1px solid #e8d2ad; border-radius: 6px; padding: 14px; font-size: 14px; margin: 16px 0; }
dialog { color: var(--ink); background: white; border: 0; border-radius: 12px; padding: 28px; max-width: 620px; max-height: calc(100dvh - 32px); width: calc(100% - 32px); }
dialog::backdrop { background: #1d263166; }
.close { display: block; margin-left: auto; margin-bottom: 20px; }
.review-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.review-item select { display: block; width: 100%; margin-top: 8px; }
footer { border-top: 1px solid var(--line); padding: 24px 0 0; margin-top: 40px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 16px; }
.login-panel { max-width: 400px; margin: 10vh auto; padding: 24px; }
.login-panel form { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.login-panel input { width: 100%; }
#login-error { color: var(--danger); }
.skip-link { position: absolute; top: -100px; left: 16px; background: white; padding: 12px; z-index: 10; }
.skip-link:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 700px) {
  .app-header { padding: 0 16px; gap: 12px; flex-wrap: wrap; min-height: 56px; }
  .brand { font-size: 18px; }
  nav { order: 3; width: 100%; height: 48px; }
  nav button { flex: 1; padding: 8px; }
  .account { margin-left: auto; }
  main { padding: 8px 16px 24px; }
  .page-context { margin-bottom: 16px; font-size: 13px; }
  h1 { font-size: 25px; }
  .section-head { align-items: flex-start; flex-wrap: wrap; gap: 16px; }
  .search-label, .search-label input { width: 100%; }
  .stock-table-head { display: none; }
  .stock-row { grid-template-columns: minmax(0,1fr) auto; gap: 4px 12px; padding: 14px; }
  .stock-name { grid-column: 1; font-size: 14px; }
  .stock-current { grid-column: 1; font-size: 13px; }
  .stock-current::before { content: 'Saved: '; }
  .stock-controls { grid-column: 2; grid-row: 1/3; flex-wrap: wrap; width: 142px; }
  .stock-controls input[type=number] { width: 94px; font-size: 16px; }
  .estimate { margin-left: auto; min-height: 36px; }
  .stock-name details { margin-top: 2px; }
  .stock-name details p { max-width: 100%; }
  .save-bar { bottom: 8px; padding: 12px; gap: 10px; grid-template-columns: 1fr; }
  .save-actions { grid-column: 1; grid-row: auto; }
  .save-actions button:last-child { flex: 1; }
  .pending-count { grid-column: 1; }
  .cards { grid-template-columns: 1fr; }
  .card, .panel { padding: 18px; }
  .ingredient { flex-wrap: wrap; }
  .ingredient label { min-width: 140px; }
  #builder-rows .ingredient select { flex-basis: 100%; }
  footer { flex-direction: column; gap: 6px; }
  .actions { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

#proposals { display: block; max-width: 820px; margin-inline: auto; }
.meal-date { margin: 32px 0 16px; font-size: 18px; }
.meal-card h3 { font-size: 21px; margin-bottom: 4px; }
.meal-card .macros { padding: 4px 0; margin: 8px 0 20px; }
.cooking-steps h4 { font-size: 15px; margin: 0 0 10px; }
.cooking-steps ol { padding-left: 24px; max-width: 65ch; }
.cooking-steps li { padding-left: 5px; margin-bottom: 12px; white-space: pre-line; }
.step-heading { list-style: none; font-weight: 600; margin-left: -24px; }
.meal-amounts, .meal-notes { border-top: 1px solid var(--line); margin-top: 16px; }
.meal-amounts summary, .meal-notes summary, .recipe-import summary { padding: 12px 0; min-height: 44px; }
.meal-notes p { font-size: 14px; color: var(--muted); }
.recipe-import { margin-bottom: 24px; }
.recipe-import label, .recipe-import textarea { display: block; width: 100%; margin-bottom: 12px; }
textarea { font: inherit; color: var(--ink); border: 1px solid #9ba5b3; border-radius: 5px; padding: 12px; }
#cooks { max-width: 820px; margin-inline: auto; }

.recipe-photo { display: block; max-width: 100%; width: 320px; max-height: 240px; object-fit: cover; border-radius: 8px; margin: 12px 0; }
