:root {
  color-scheme: light;
  --canvas:#f4efe6;
  --paper:#fffaf2;
  --sheet:#fffdf9;
  --warm:#f8efe1;
  --line:#e5d8c7;
  --line-dark:#ccb59b;
  --ink:#382018;
  --muted:#6f5a4b;
  --terra:#9f3a19;
  --terra-dark:#772b16;
  --peach:#f8e5d6;
  --olive:#465c25;
  --sage:#e8edd6;
  --radius:15px;
  --serif:Georgia,"Times New Roman",serif;
  --sans:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-family:var(--sans);
  font-size:16px;
  color:var(--ink);
  background:var(--canvas);
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; min-width:0; }
button, input, select { font:inherit; color:inherit; }
button { cursor:pointer; }
button[disabled] { cursor:not-allowed; opacity:.5; }
button, input, select, a, summary { -webkit-tap-highlight-color:transparent; }
:focus-visible { outline:2px solid #785018; outline-offset:3px; }
h1,h2,h3,h4,p { margin:0; }
h1,h2,h3,h4 { font-family:var(--serif); }
a { color:var(--terra-dark); text-underline-offset:.15em; }
input:not([type=checkbox]),select {
  width:100%; min-width:0; min-height:40px; border:1px solid var(--line-dark);
  border-radius:9px; padding:7px 9px; background:#fffdf8; font-size:.88rem;
}
input[type=checkbox] { width:17px; height:17px; accent-color:var(--terra); flex:none; }
select { appearance:none; padding-right:27px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23654a38' stroke-width='1.5' d='m1 1 5 5 5-5'/%3E%3C/svg%3E"); background-position:right 9px center; background-repeat:no-repeat; }
.masthead {
  min-height:136px; display:flex; align-items:center; position:relative;
  background-color:#f6ebd7;
  background-image:linear-gradient(90deg,#f6ebd7 5%,rgba(246,235,215,.98) 30%,rgba(246,235,215,.13) 64%,transparent),url("assets/market-header.jpg");
  background-repeat:no-repeat; background-size:100% 100%,auto 117%; background-position:center,right center;
  border-bottom:1px solid var(--line-dark);
}
.mast-content { width:min(1680px,100%); padding:16px 26px 15px; margin:auto; }
.masthead h1 { font-size:clamp(2.15rem,3.8vw,3.7rem); color:#4a2416; line-height:1.01; letter-spacing:-.04em; }
#main-navigation { display:flex; flex-wrap:wrap; gap:8px; margin-top:13px; }
.primary,.secondary,.nav-button,.tab {
  border:1px solid transparent; border-radius:9px; padding:.62rem .88rem;
  min-height:41px; font-size:.9rem; font-weight:650; line-height:1.2;
}
.primary,.nav-button.active { background:var(--terra); color:#fff; border-color:var(--terra); }
.primary:not([disabled]):hover,.nav-button.active:hover { background:var(--terra-dark); }
.secondary,.nav-button,.tab { background:#fffaf2; color:var(--terra-dark); border-color:var(--line-dark); }
.secondary:not([disabled]):hover,.nav-button:not(.active):hover,.tab:hover { background:var(--peach); }
.full { width:100%; }
.text-button,.dish-open,.heart,.sheet-close,.dialog-close {
  font:inherit; color:inherit; background:transparent; border:0; border-radius:7px; padding:0;
}
.text-button { color:var(--terra-dark); font-size:.83rem; font-weight:650; padding:.32rem .42rem; min-height:28px; text-align:left; }
.text-button:hover { background:var(--peach); }
.market {
  width:min(1680px,100%); margin:auto; display:grid; grid-template-columns:minmax(280px,.91fr) minmax(380px,1.26fr) minmax(292px,1fr);
  gap:11px; padding:11px 12px 0; align-items:start;
}
.panel {
  background:var(--sheet); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:0 2px 8px #48351b0a; min-width:0; scrollbar-color:#c9af97 transparent; scrollbar-width:thin;
}
.catalog { display:flex; flex-direction:column; overflow:hidden; }
.recipe,.daily { overflow:auto; }
@media(min-width:1100px) {
  .panel { height:calc(100dvh - 174px); min-height:560px; }
}
.catalog-controls { padding:13px 14px 8px; border-bottom:1px solid var(--line); background:var(--paper); }
.search { display:flex; align-items:center; position:relative; }
.search span { position:absolute; left:11px; font-size:1.55rem; line-height:1; color:var(--terra); }
.search input { padding-left:35px; min-height:43px; font-size:.93rem; }
#filter-controls { margin-top:8px; }
summary { cursor:pointer; }
#filter-controls summary,.plan-settings summary { font-size:.86rem; font-weight:700; margin-bottom:7px; padding:4px 0; color:#613a25; }
.filters,.form-grid,.plan-inputs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.field { display:grid; grid-template-columns:minmax(0,1fr); gap:3px; min-width:0; }
.field>span { font-size:.79rem; color:var(--muted); font-weight:600; }
.filters input:not([type=checkbox]),.filters select { min-height:35px; padding-block:5px; font-size:.82rem; }
.check { display:flex; align-items:center; gap:6px; color:var(--muted); font-size:.84rem; min-height:33px; }
.filter-actions { grid-column:1 / -1; display:flex; align-items:center; justify-content:space-between; gap:8px; }
.filter-actions .check { font-size:.78rem; min-height:40px; }
.filter-actions .text-button { flex:none; min-height:40px; }
.results { padding:9px 14px 8px; font-size:.84rem; font-weight:650; color:var(--muted); background:#fffaf2; }
.recipe-list { overflow:auto; align-self:stretch; padding:0 8px 8px; }
.dish-row {
  display:grid; grid-template-columns:clamp(74px,7vw,106px) minmax(0,1fr) 31px;
  gap:9px; align-items:center; padding:8px; border:1px solid transparent; border-bottom-color:var(--line); border-radius:0;
}
.dish-row.selected { background:#fff0e2; border-color:#c7794a; border-radius:12px; }
.dish-row:hover:not(.selected) { background:#fcf4e8; }
.food { width:100%; aspect-ratio:1.36; object-fit:cover; border-radius:9px; background:#e8dac5; display:block; }
.fallback { display:grid; place-items:center; color:#9c6b43; font-size:1.85rem; }
.dish-info,.menu-dish { display:grid; gap:3px; min-width:0; }
.dish-open { text-align:left; width:100%; overflow-wrap:anywhere; font-family:var(--serif); font-weight:700; line-height:1.16; font-size:1rem; color:#342019; }
.dish-open:hover { color:var(--terra); text-decoration:underline; text-underline-offset:3px; }
.dish-sub,.dish-ingredients,.match-note,.flag { font-size:.76rem; color:var(--muted); line-height:1.25; }
.dish-ingredients { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.match-note,.flag { padding:2px 5px; border-radius:4px; background:var(--sage); color:var(--olive); width:fit-content; }
.flag { background:#fbe4cf; color:#722816; }
.heart { color:var(--terra); font-size:1.55rem; width:31px; min-height:38px; }
.heart:hover { background:#f8eadb; }
.hero-food { width:100%; height:clamp(190px,25vw,314px); aspect-ratio:auto; border-radius:14px 14px 0 0; object-position:center 50%; }
.recipe-body { padding:15px 17px 18px; }
.recipe-meta { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:.82rem; }
.pill { display:inline-block; max-width:100%; background:var(--peach); color:var(--terra-dark); padding:3px 8px; font-size:.76rem; font-weight:650; border-radius:50px; }
.recipe h2 { margin-top:8px; font-size:clamp(1.5rem,2.35vw,2.5rem); line-height:1.05; letter-spacing:-.035em; }
.recipe-kcal { margin-top:6px; color:var(--muted); font-size:.88rem; }
.recipe-actions { display:flex; flex-wrap:wrap; gap:7px; margin:12px 0; }
.tabs { display:flex; align-items:stretch; gap:4px; border-bottom:1px solid var(--line); margin:12px 0; }
.tab { flex:1; min-width:0; white-space:normal; padding:.52rem .25rem; border:0; border-radius:7px 7px 0 0; background:#faf1e5; }
.tab.chosen { background:var(--terra); color:#fff; }
.portion-label { font-size:.86rem; color:var(--olive); font-weight:700; margin:8px 0; }
.ingredient-group h3,.nutrition-detail summary { margin:8px 0; font-size:1.01rem; }
.ingredients ul { list-style:none; padding:0; margin:0; }
.ingredients li { border-bottom:1px solid #eee1d0; padding:6px 0; }
.ingredient-line { display:flex; justify-content:space-between; align-items:baseline; gap:9px; font-size:.88rem; }
.ingredient-line strong { text-align:right; font-weight:650; color:#634934; }
.ingredients .field { display:flex; align-items:center; margin-top:4px; }
.swap-select { width:auto; max-width:100%; min-height:31px; padding-block:3px; font-size:.78rem; }
.swap-help,.label-check { color:var(--muted); font-size:.79rem; padding:4px 0; }
.steps,.nutrition-detail ul { margin:6px 0; padding-left:21px; }
.steps li,.nutrition-detail li { padding:.4rem 0; }
.nutrition-detail>p,.nutrition-detail>details { margin:7px 0; }
.suggestions { display:grid; gap:8px; margin-top:15px; }
.suggestion { background:#eff0e3; border:1px solid #d6ddbe; border-radius:10px; padding:9px 11px; }
.suggestion h3 { font-size:1.05rem; color:var(--olive); margin-bottom:3px; }
.suggestion-dish { display:grid; grid-template-columns:68px 1fr; align-items:center; gap:8px; margin-top:5px; font-size:.86rem; }
.daily { padding:13px 14px; position:relative; }
.daily-head { display:flex; gap:9px; justify-content:space-between; align-items:center; margin:2px 0 12px; }
.daily-head h2 { font-size:clamp(1.4rem,2.35vw,2.35rem); color:#44251a; line-height:1.05; letter-spacing:-.04em; }
.date-label { font-size:.82rem; color:var(--muted); white-space:nowrap; }
.plan-inputs { margin-bottom:10px; }
.day-summary { background:#fbf3e8; border:1px solid var(--line); padding:10px; border-radius:12px; margin-bottom:10px; }
.summary-caption { display:flex; flex-wrap:wrap; gap:3px 7px; justify-content:space-between; font-size:.78rem; font-weight:650; color:#6c4b37; }
.summary-caption span { color:var(--muted); font-weight:450; }
.summary-top { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:3px; padding:5px 0; }
.day-total { font:700 clamp(1.21rem,2vw,1.72rem)/1.15 var(--serif); letter-spacing:-.035em; }
.budget-pill { background:var(--sage); color:var(--olive); padding:4px 6px; border-radius:7px; font-size:.73rem; font-weight:700; }
[data-state=over] .budget-pill,[data-state=under] .budget-pill { background:#fae1ca; color:#772b16; }
progress { appearance:none; width:100%; height:9px; border:0; margin-bottom:6px; accent-color:var(--olive); }
progress::-webkit-progress-bar { background:#e9dccb; border-radius:100px; }
progress::-webkit-progress-value { background:#778d48; border-radius:100px; }
progress::-moz-progress-bar { background:#778d48; border-radius:100px; }
.macros { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
.macros>div { border:1px solid #e8d6bd; border-radius:8px; padding:5px 3px; background:#fff4e1; text-align:center; }
.macros span { display:block; font-size:.73rem; color:#573b2c; }
.macros strong { display:block; font:700 1.06rem var(--serif); color:#435827; padding-top:3px; }
.status-line { margin-top:6px; font-size:.76rem; color:var(--muted); }
.meal-list { display:grid; margin:10px 0; gap:8px; }
.meal-group { border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.meal-head { display:flex; align-items:center; justify-content:space-between; background:#f9efe0; padding:4px 8px; }
.meal-head h3 { font-size:1rem; }
.menu-row { display:grid; grid-template-columns:60px 1fr; gap:7px; align-items:start; padding:7px; border-top:1px solid var(--line); }
.menu-row .dish-open { font-size:.94rem; }
.row-actions { display:flex; flex-wrap:wrap; column-gap:2px; }
.row-actions .text-button { font-size:.75rem; }
.row-actions .remove { color:#823a2a; }
.plan-settings { border-top:1px solid var(--line); margin-top:12px; padding-top:6px; }
.plan-settings>:is(label,p) { margin:6px 0; }
.tiny,.muted,.placeholder { color:var(--muted); line-height:1.4; }
.tiny { font-size:.76rem; }
.muted { font-size:.89rem; }
.placeholder { padding:15px; }
.warn { padding:8px 9px; margin:7px 0; border-radius:8px; color:#732c1a; background:#fae8da; font-size:.85rem; }
.footer { padding:7px 18px 11px; color:var(--muted); font-size:.74rem; }
.mobile-dock,.sheet-close { display:none; }
.veil { position:fixed; inset:0; z-index:2; background:#2c1c1291; }
.dialog-close,.sheet-close { font-size:1.65rem; width:40px; height:40px; text-align:center; color:var(--terra-dark); background:#fff6e9; }
.dialog-close:hover,.sheet-close:hover { background:var(--peach); }
dialog {
  width:min(calc(100% - 26px),590px); max-height:calc(100dvh - 36px); padding:0; overflow:auto;
  border:1px solid var(--line-dark); border-radius:17px; background:var(--sheet); color:var(--ink); box-shadow:0 18px 70px #2913064a;
}
dialog::backdrop { background:#3117068a; }
.dialog-head { position:sticky; inset-block-start:0; display:flex; z-index:1; justify-content:space-between; align-items:center; gap:8px; background:#fbf1e5; border-bottom:1px solid var(--line); padding:10px 15px; }
.dialog-head h2 { font-size:1.6rem; line-height:1.14; }
.dialog-content { padding:13px 15px 17px; display:grid; gap:10px; }
.dialog-actions { display:flex; flex-wrap:wrap; gap:7px; }
.dialog-dish { font:700 1.22rem var(--serif); }
.picker-list { max-height:48dvh; overflow:auto; display:grid; gap:5px; }
.picker-list h3 { font-size:1rem; margin:5px 0; color:var(--olive); }
.picker-dish { display:grid; grid-template-columns:54px minmax(0,1fr); align-items:center; gap:8px; text-align:left; background:var(--paper); border:1px solid var(--line); border-radius:8px; padding:6px; }
.picker-dish:hover { background:var(--peach); }
.picker-dish small { display:block; color:var(--muted); }
.preview-dish { display:grid; grid-template-columns:85px 1fr; gap:9px; align-items:center; }
.draft-row { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px; border-top:1px solid var(--line); padding-top:8px; }
.draft-dish { display:grid; justify-items:start; gap:3px; min-width:0; }
.draft-dish small { color:var(--muted); }
.draft-dish .dish-open,.replacement-dish .dish-open { overflow-wrap:anywhere; }
.draft-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center; gap:5px; }
.draft-actions button,.replacement-dish .primary { min-height:40px; padding:6px 9px; }
.draft-status { color:var(--olive); font-weight:700; font-size:.86rem; }
.draft-undo { min-width:40px; font-size:1.12rem; }
.replacement-dish { display:grid; grid-template-columns:54px minmax(0,1fr) auto; gap:8px; align-items:center; border:1px solid var(--line); border-radius:8px; padding:6px; }
.replacement-dish p { margin-top:2px; }
.proposal-back { margin:8px 14px; min-height:40px; }
@media (max-width:480px) {
  .draft-row { grid-template-columns:1fr; gap:3px; }
  .draft-actions { justify-content:flex-start; }
  .replacement-dish { grid-template-columns:48px minmax(0,1fr); }
  .replacement-dish .primary { grid-column:2; justify-self:start; }
}
.toast { position:fixed; bottom:15px; left:50%; transform:translateX(-50%); z-index:5; display:flex; align-items:center; justify-content:center; gap:9px; max-width:calc(100% - 16px); width:max-content; background:#38281c; color:#fff; padding:9px 12px; border-radius:9px; text-align:center; box-shadow:0 3px 22px #30190828; font-size:.86rem; }
.toast-action { color:white; background:#704829; padding:6px; border:1px solid #cbb79c; border-radius:6px; }
.print-preview { border:1px solid var(--line); border-radius:9px; max-height:48dvh; overflow:auto; }
.paper { color:black; background:#fff; padding:14px; }
.paper header { border-bottom:1px solid #aaa; margin-bottom:10px; padding:0 0 7px; }
.paper h1 { font-size:1.65rem; }
.paper .day-summary { padding:5px; }
.paper progress { display:none; }
.print-recipe { padding:8px 0; border-top:1px solid #ddd; }
.paper h2 { margin-top:10px; }
.paper h3 { margin-bottom:4px; }
.paper h4 { margin-top:5px; }
.paper ul,.paper ol { margin:4px 0 5px; padding-left:20px; }
.paper li { font-size:.88rem; padding:2px 0; line-height:1.38; }
.print-area { display:none; }
@media(max-width:1099px) and (min-width:781px) {
  .market { grid-template-columns:minmax(240px,.8fr) minmax(320px,1.2fr); }
  .catalog,.recipe { height:calc(100dvh - 170px); min-height:540px; }
  .daily { grid-column:1 / -1; }
  .meal-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:780px) {
  .masthead { min-height:120px; background-size:100% 100%,auto 96%; }
  .mast-content { padding:14px 13px; }
  .masthead h1 { font-size:clamp(2rem,8vw,3.2rem); }
  .market { display:block; padding:9px; }
  .catalog { min-height:calc(100dvh - 207px); }
  .catalog-controls { padding:10px; }
  .dish-row { grid-template-columns:84px minmax(0,1fr) 41px; padding:8px; }
  .heart { width:41px; min-height:44px; }
  .recipe-list { overflow:visible; }
  .footer { padding-bottom:70px; }
  .mobile-dock { display:flex; align-items:center; justify-content:space-between; position:fixed; z-index:1; bottom:max(env(safe-area-inset-bottom),9px); left:9px; right:9px; background:#e9eedc; color:#34441e; border:1px solid #9caf76; min-height:50px; padding:10px 12px; border-radius:11px; box-shadow:0 4px 18px #3d2b1c20; font-weight:750; }
  .mobile-dock span { font-size:1.04rem; }
  .market>.recipe,.market>.daily { display:none; }
  [data-sheet] { overflow:hidden; }
  [data-sheet=recipe] .market>.recipe,[data-sheet=menu] .market>.daily {
    display:block; position:fixed; bottom:0; left:0; right:0; z-index:3; width:100%; margin:0;
    max-height:94dvh; min-height:min(440px,80dvh); padding-bottom:max(12px,env(safe-area-inset-bottom)); overflow:auto;
    border-radius:19px 19px 0 0; overscroll-behavior:contain;
  }
  .sheet-close { position:sticky; z-index:2; top:8px; margin:8px 10px -48px auto; display:block; }
  .recipe .hero-food { height:210px; border-radius:17px 17px 0 0; }
  .recipe-body { padding:13px 12px 16px; }
  .recipe h2 { font-size:1.75rem; }
  .daily { padding-top:8px; }
  .daily-head { margin-right:49px; min-height:42px; }
  .daily-head h2 { font-size:1.65rem; }
  .toast { bottom:67px; }
}
@media print {
  @page { size:A4; margin:13mm; }
  body { background:#fff !important; color:#000; }
  body>*:not(.print-area) { display:none !important; }
  .print-area { display:block; }
  .print-area .paper { padding:0; font-family:Arial,sans-serif; }
  .print-area .macros>div,.print-area .day-summary,.print-area .budget-pill { background:white; color:#000; border-color:#aaa; }
  .print-area .macros strong,.print-area .muted,.print-area .day-total { color:#000; }
  .print-area :is(h1,h2,h3,h4) { break-after:avoid; }
  .print-area li { break-inside:avoid; }
}
