:root {
  --paper: #f8f4eb;
  --paper-deep: #f1eadc;
  --surface: #fffdf8;
  --ink: #2a201a;
  --muted: #766d63;
  --line: #ddd3c3;
  --line-soft: #e9e1d4;
  --tomato: #d94728;
  --tomato-dark: #ba321c;
  --green: #5e8d2d;
  --shadow: 0 18px 50px rgba(60, 43, 28, .08);
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(217, 71, 40, .22); outline-offset: 2px; }
.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; }

.topbar { height: 88px; padding: 0 clamp(24px, 3.2vw, 54px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid rgba(164, 145, 120, .3); background: rgba(248, 244, 235, .94); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand { justify-self: start; display: inline-flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; font-family: var(--display); font-size: 31px; font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: #fff9ef; background: var(--tomato); box-shadow: inset 0 -2px 0 rgba(94, 23, 12, .15); }
.brand-mark svg { width: 33px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.main-nav { display: flex; align-self: stretch; gap: 46px; }
.nav-item { position: relative; border: 0; background: transparent; padding: 4px 0 0; cursor: pointer; font-weight: 650; font-size: 15px; letter-spacing: .03em; }
.nav-item::after { content: ""; position: absolute; left: 50%; bottom: 14px; width: 0; height: 2px; border-radius: 2px; background: var(--tomato); transform: translateX(-50%); transition: width .2s ease; }
.nav-item:hover, .nav-item.active { color: var(--tomato); }
.nav-item.active::after { width: 40px; }
.nav-item span { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--tomato); color: white; font-size: 10px; vertical-align: 1px; }
.kitchen-label { justify-self: end; color: #5f554d; font-size: 14px; }
.bowl-icon { display: inline-block; transform: rotate(180deg); margin-right: 6px; }

.workspace { min-height: calc(100vh - 88px); display: grid; grid-template-columns: minmax(470px, 1.34fr) minmax(410px, 1.05fr) minmax(260px, .63fr); max-width: 1600px; margin: 0 auto; }
.fridge-pane, .recipe-pane, .shopping-pane { min-width: 0; padding: 34px clamp(22px, 2.25vw, 38px); }
.recipe-pane, .shopping-pane { border-left: 1px solid var(--line); background: rgba(255, 253, 248, .46); }
.shopping-pane { position: relative; display: flex; flex-direction: column; padding-left: 28px; padding-right: 28px; overflow: hidden; }

.intro h1 { margin: 5px 0 10px; font-family: var(--display); font-size: clamp(39px, 3.2vw, 54px); line-height: 1.16; letter-spacing: .015em; font-weight: 800; }
.intro p { margin: 0 0 24px; color: var(--muted); line-height: 1.8; }
.ingredient-form { height: 82px; display: grid; grid-template-columns: 72px 1fr auto; align-items: center; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,253,248,.6); box-shadow: 0 8px 28px rgba(77,55,36,.035); overflow: hidden; }
.tomato-sketch { width: 68px; height: 68px; margin-left: 7px; fill: none; stroke: #cfc2ae; stroke-width: 1.25; opacity: .75; }
.ingredient-form input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; }
.ingredient-form input::placeholder { color: #91877c; }
.ingredient-form button, .cook-button { border: 0; border-radius: 10px; background: var(--tomato); color: white; font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: .05em; cursor: pointer; box-shadow: inset 0 -2px 0 rgba(114,22,10,.18); transition: transform .16s ease, background .16s ease; }
.ingredient-form button { height: 54px; margin-right: 12px; padding: 0 23px; }
.ingredient-form button:hover, .cook-button:hover { background: var(--tomato-dark); transform: translateY(-1px); }
.input-hint { margin: 8px 4px 0; color: #9b9186; font-size: 12px; }
.selected-line { margin-top: 15px; display: flex; justify-content: space-between; align-items: center; color: #665d55; }
.selected-line b { font-weight: 500; color: #968b80; }
.text-button { border: 0; background: transparent; color: #7f746a; padding: 5px 0; cursor: pointer; }
.text-button:hover { color: var(--tomato); }
.selected-chips { min-height: 47px; padding: 9px 0 12px; display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--line); }
.selected-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid #cfc2b0; background: rgba(255,253,248,.65); border-radius: 8px; box-shadow: 0 2px 0 rgba(79,56,35,.04); }
.selected-chip button { border: 0; background: transparent; color: #695e54; padding: 0 1px; cursor: pointer; font-size: 18px; line-height: 1; }
.empty-chips { color: #9a9086; padding: 8px 0; }
.fridge-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 0 10px; }
.fridge-heading h2, .pane-title h2 { margin: 0; font-family: var(--display); font-size: 23px; letter-spacing: .04em; }
.fridge-heading span { color: #958b81; font-size: 12px; }
.shelves { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(255,253,248,.4); }
.shelf { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.shelf:last-child { border-bottom: 0; }
.shelf-label { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-family: var(--display); font-size: 15px; font-weight: 700; }
.shelf-label small { color: #91867a; font-family: var(--sans); font-weight: 400; }
.shelf-items { display: flex; flex-wrap: wrap; gap: 7px; }
.shelf-item { border: 1px solid #d8cdbc; border-radius: 7px; background: rgba(255,253,248,.72); padding: 7px 10px; cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.shelf-item:hover { transform: translateY(-1px); border-color: #bcae99; }
.shelf-item.selected { color: #3e352e; border-color: #d7b7a8; background: #fff8f1; box-shadow: inset 0 -2px 0 rgba(217,71,40,.08); }
.shelf-item.selected::after { content: "✓"; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 6px; border-radius: 50%; background: var(--tomato); color: white; font-size: 10px; }

.pane-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.pane-title h2 { position: relative; }
.recipe-pane > .pane-title h2::after { content: ""; display: block; width: 38px; height: 2px; background: var(--tomato); margin-top: 8px; }
.change-recipe span { font-size: 18px; margin-left: 3px; }
.recipe-photo-wrap { position: relative; }
.recipe-photo { width: 100%; aspect-ratio: 4 / 2.65; object-fit: cover; display: block; border-radius: 12px 18px 13px 20px; border: 1px solid #c9bda9; box-shadow: var(--shadow); background: var(--paper-deep); }
.match-seal { position: absolute; right: 13px; bottom: 12px; display: grid; place-items: center; width: 61px; height: 61px; border-radius: 50%; background: rgba(255,253,248,.92); border: 2px solid var(--green); color: var(--green); font-weight: 750; font-size: 17px; box-shadow: 0 5px 18px rgba(39,38,23,.14); }
.recipe-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0 8px; }
.recipe-summary h3 { margin: 0 0 7px; font-family: var(--display); font-size: 28px; letter-spacing: .04em; }
.recipe-meta { display: flex; align-items: center; gap: 10px; margin: 0; color: #776e65; }
.recipe-meta b { font-weight: 500; }
.recipe-meta i { width: 1px; height: 14px; background: var(--line); }
.save-button { flex: 0 0 auto; width: 43px; height: 43px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,253,248,.75); cursor: pointer; color: #5d534a; font-size: 24px; }
.save-button.saved { color: var(--tomato); }
.recipe-description { color: var(--muted); line-height: 1.65; margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.ingredient-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ingredient-section-title h4 { margin: 0; font-family: var(--display); font-size: 17px; }
.ingredient-section-title > div { color: #786e64; font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 4px 1px 10px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--tomato); }
.ingredient-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.ingredient-list { min-height: 105px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: rgba(255,253,248,.55); }
.ingredient-list h5 { margin: 0 0 8px; color: #6e645c; font-weight: 600; }
.ingredient-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.ingredient-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 7px; color: #6c635a; font-size: 12px; align-items: center; }
.ingredient-list li span:last-child { color: #978d83; text-align: right; }
.status-icon { width: 14px; height: 14px; display: grid; place-items: center; border-radius: 50%; font-size: 9px; }
.available-list .status-icon { background: var(--green); color: white; }
.missing-list .status-icon { border: 1px solid var(--tomato); color: var(--tomato); }
.ingredient-empty { color: #9d9388; font-size: 12px; }
.add-missing { width: 100%; margin-top: 8px; border: 0; background: transparent; color: var(--tomato); cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.add-missing:disabled { color: #a99f95; text-decoration: none; cursor: default; }
.cook-button { width: 100%; height: 54px; margin-top: 12px; }
.cook-button span { margin-left: 10px; font-family: var(--sans); font-size: 24px; vertical-align: -2px; }

.shopping-title { display: block; margin-bottom: 10px; }
.shopping-title h2 { white-space: nowrap; }
.bag-icon { color: var(--tomato); margin-right: 5px; }
.shopping-total { display: block; margin-top: 14px; color: #655c53; }
.shopping-actions { position: absolute; right: 26px; top: 69px; }
.outline-button { border: 1px solid var(--tomato); border-radius: 8px; color: var(--tomato); background: transparent; padding: 8px 11px; cursor: pointer; }
.outline-button:hover { color: white; background: var(--tomato); }
.shopping-list { margin-top: 11px; border-top: 1px solid var(--line); }
.shopping-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.shopping-item input { appearance: none; width: 22px; height: 22px; margin: 0; border: 1px solid #bfb4a4; border-radius: 6px; cursor: pointer; }
.shopping-item input:checked { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 5px var(--surface); }
.shopping-item.checked .shopping-name { text-decoration: line-through; color: #a49a90; }
.shopping-name { display: block; font-weight: 650; margin-bottom: 3px; }
.shopping-quantity { color: #877d73; font-size: 12px; }
.shopping-delete { border: 0; background: transparent; color: #aaa096; cursor: pointer; font-size: 18px; }
.shopping-delete:hover { color: var(--tomato); }
.clear-checked { border: 0; background: transparent; color: #8d8379; cursor: pointer; margin: 11px auto 0; }
.shopping-empty { flex: 1; display: grid; place-content: center; text-align: center; color: #958b81; min-height: 280px; }
.shopping-empty svg { width: 110px; margin: 0 auto 18px; fill: none; stroke: #d8ccba; stroke-width: 1.3; }
.shopping-empty p { line-height: 1.8; }
.shopping-note { margin-top: auto; padding-top: 24px; text-align: center; color: #a1988e; font-size: 12px; }

.cook-dialog { width: min(610px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 28px)); border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 28px 90px rgba(40,27,17,.28); }
.cook-dialog::backdrop { background: rgba(47,34,25,.45); backdrop-filter: blur(3px); }
.dialog-card { position: relative; padding: 38px; }
.dialog-close { position: absolute; right: 18px; top: 16px; border: 0; background: transparent; color: #82776d; font-size: 27px; cursor: pointer; }
.dialog-kicker { color: var(--tomato); margin: 0 0 8px; }
.dialog-card h2 { margin: 0; font-family: var(--display); font-size: 34px; }
.dialog-subtitle { color: var(--muted); }
.steps { margin: 25px 0; padding: 0; list-style: none; counter-reset: steps; display: grid; gap: 10px; }
.step { counter-increment: steps; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 10px; cursor: pointer; line-height: 1.65; }
.step::before { content: counter(steps); display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #c8bbaa; border-radius: 50%; color: #776d64; }
.step.done { color: #8e857b; text-decoration: line-through; background: #f6f2e9; }
.step.done::before { content: "✓"; background: var(--green); border-color: var(--green); color: white; text-decoration: none; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.dialog-footer button { border: 0; border-radius: 9px; background: var(--tomato); color: white; padding: 10px 22px; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 9px; background: #33271f; color: white; box-shadow: 0 10px 30px rgba(31,20,13,.2); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(430px, 1.1fr) minmax(390px, 1fr); }
  .shopping-pane { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); min-height: 340px; }
  .shopping-empty { min-height: 150px; }
  .shopping-actions { top: 35px; }
}

@media (max-width: 780px) {
  .topbar { height: 72px; grid-template-columns: 1fr auto; padding: 0 18px; position: relative; backdrop-filter: none; }
  .brand { font-size: 25px; }
  .brand-mark { width: 41px; height: 41px; }
  .main-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: 62px; justify-content: space-around; gap: 0; background: rgba(255,253,248,.97); border-top: 1px solid var(--line); box-shadow: 0 -8px 25px rgba(45,31,21,.07); }
  .nav-item { flex: 1; font-size: 13px; }
  .nav-item::after { bottom: auto; top: 0; }
  .kitchen-label { display: none; }
  .workspace { display: block; padding-bottom: 62px; }
  .fridge-pane, .recipe-pane, .shopping-pane { padding: 28px 18px; border-left: 0; border-top: 1px solid var(--line); }
  .fridge-pane { border-top: 0; }
  .intro h1 { font-size: 40px; }
  .ingredient-form { grid-template-columns: 44px 1fr; height: auto; padding: 10px; }
  .tomato-sketch { width: 42px; height: 42px; margin-left: 0; }
  .ingredient-form button { grid-column: 1 / -1; width: 100%; margin: 9px 0 0; }
  .fridge-heading { align-items: end; }
  .fridge-heading span { max-width: 140px; text-align: right; }
  .recipe-photo { aspect-ratio: 4 / 2.7; }
  .shopping-pane { min-height: 470px; }
  .shopping-actions { top: 28px; right: 18px; }
  .dialog-card { padding: 32px 20px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
