:root {
  --ink: #092d52;
  --ink-strong: #052644;
  --paper: #f7f3ea;
  --cream: #fffdf8;
  --line: #ded6c6;
  --muted: #6d7881;
  --gold: #cf9e42;
  --amber: #f08a19;
  --orange: #e97412;
  --green: #28794e;
  --danger: #9d4933;
  font-family: "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #e9e4d9; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100svh; display: grid; place-items: center; background: linear-gradient(155deg, #e6e1d7 0%, #f5f0e5 56%, #d7d0c1 100%); }
.app { width: 100%; max-width: 510px; min-height: 100svh; position: relative; overflow: hidden; background: var(--paper); padding-bottom: 84px; }

.topbar { min-height: 88px; padding: calc(16px + env(safe-area-inset-top)) 20px 16px; color: #fff; display: flex; align-items: center; gap: 11px; background: radial-gradient(circle at 85% 10%, #165383 0, transparent 37%), linear-gradient(140deg, #031f3b, #0a4775); box-shadow: inset 0 -1px 0 rgba(229, 186, 92, .65); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; color: #f3b74c; border: 1px solid rgba(255, 213, 128, .72); background: rgba(0, 19, 39, .32); border-radius: 50%; }
.brand-mark svg { width: 26px; height: 26px; stroke-width: 1.8; }
.brand-copy { flex: 1; }
.brand-copy h1 { margin: 0; font: 700 26px/1 "Noto Serif SC", serif; letter-spacing: 0; }
.brand-copy p { margin: 5px 0 0; font-size: 12px; color: #d9e1e6; }
.icon-button { border: 0; padding: 8px; color: inherit; display: grid; place-items: center; background: transparent; border-radius: 50%; }
.icon-button svg { width: 23px; height: 23px; }

.progress-wrap { padding: 14px 20px 13px; background: #fffaf0; border-bottom: 1px solid var(--line); }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.progress-track { margin-top: 9px; height: 4px; overflow: hidden; background: #e4dfd4; border-radius: 8px; }
.progress-track span { display: block; width: 33.333%; height: 100%; background: linear-gradient(90deg, #e98819, #f4bb55); transition: width .25s ease; }

.screen { display: none; padding: 25px 20px 20px; animation: appear .23s ease; }
.screen.active { display: block; }
.intro { margin-bottom: 25px; }
.eyebrow { margin: 0 0 7px; color: #b77d20; font-size: 13px; font-weight: 700; }
h2 { margin: 0; font: 700 30px/1.25 "Noto Serif SC", serif; letter-spacing: 0; color: var(--ink-strong); }
.intro > p:last-child, .result-heading > p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
fieldset { margin: 0 0 25px; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: 12px; color: #5d6670; font-size: 14px; font-weight: 700; }
legend span { display: inline-grid; width: 20px; height: 20px; margin-right: 7px; place-items: center; border-radius: 50%; background: #f0d6a6; color: #74501a; font-size: 11px; }

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.choice-card { min-height: 136px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; border: 1px solid var(--line); border-radius: 7px; background: var(--cream); color: var(--ink); transition: .16s ease; }
.choice-card input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card.selected { border-color: var(--gold); background: #fff9ed; box-shadow: 0 0 0 2px rgba(207, 158, 66, .14); }
.choice-icon { width: 37px; height: 37px; margin-bottom: 10px; display: grid; place-items: center; color: #3c8159; background: #eaf3e8; border-radius: 50%; }
.choice-icon.hotpot { color: #d65d18; background: #fff0df; }
.choice-icon svg { width: 20px; }
.choice-card > span:not(.choice-icon) { font-weight: 700; font-size: 15px; }
.choice-card small { margin-top: 7px; color: #818a90; font-size: 10px; line-height: 1.45; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border: 1px solid var(--line); background: #ebe7df; border-radius: 7px; }
.segmented label { min-height: 40px; display: grid; place-items: center; color: #697078; font-size: 14px; font-weight: 600; border-radius: 4px; }
.segmented label.selected { color: #fff; background: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.13); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.select-field, .range-field { display: flex; flex-direction: column; gap: 6px; color: #646f78; font-size: 12px; font-weight: 700; }
select { width: 100%; min-height: 45px; appearance: none; border: 1px solid var(--line); padding: 0 30px 0 11px; border-radius: 6px; color: var(--ink); background: var(--cream) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23092d52' stroke-width='1.8'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E") calc(100% - 11px) center / 12px no-repeat; outline-color: var(--gold); }
.range-field { margin-top: 18px; }
.range-field strong { color: var(--ink); font-size: 15px; }
input[type="range"] { width: 100%; margin: 7px 0 0; accent-color: var(--orange); }
.range-marks { display: flex; justify-content: space-between; color: #929393; font-size: 10px; }
.range-marks b { font-weight: 500; }

.primary-button, .secondary-button { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 6px; font-weight: 700; transition: transform .15s ease, filter .15s ease; }
.primary-button { width: 100%; border: 1px solid #d66d0c; color: #fff; background: linear-gradient(135deg, #f48e1d, #dd6d0c); box-shadow: 0 4px 8px rgba(194, 92, 3, .18); }
.primary-button:hover, .secondary-button:hover { filter: brightness(.97); transform: translateY(-1px); }
.primary-button svg, .secondary-button svg { width: 19px; }
.legal-note { margin: 15px 2px 0; display: flex; align-items: flex-start; gap: 7px; color: #7d858a; font-size: 11px; line-height: 1.65; }
.legal-note svg { flex: 0 0 auto; width: 15px; margin-top: 2px; color: #ad7c28; }

.result-heading { margin-bottom: 17px; }
.result-heading h2 { font-size: 25px; }
.back-button { margin: -4px 0 17px; display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; color: #62717d; background: transparent; font-size: 13px; }
.back-button svg { width: 16px; }
.result-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 15px; border-bottom: 1px solid var(--line); }
.result-tabs button { min-height: 39px; border: 0; border-bottom: 2px solid transparent; color: #7b8388; background: transparent; font-size: 14px; font-weight: 700; }
.result-tabs button.active { border-color: var(--orange); color: var(--ink); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.formula-card { overflow: hidden; border: 1px solid #dfd7c8; background: var(--cream); border-radius: 7px; }
.formula-card-top { padding: 14px 15px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e6dfd3; }
.formula-card-top span, .usage-card span, .metric-row span { display: block; color: #7a8287; font-size: 11px; }
.formula-card-top strong { display: block; margin-top: 4px; font-size: 16px; }
.status-pill { display: inline-flex !important; align-items: center; gap: 4px; padding: 5px 7px; border-radius: 999px; color: var(--green) !important; background: #e9f5e9; font-size: 11px !important; font-weight: 700; }
.status-pill svg { width: 13px; }
.ingredient-head, .ingredient-row { display: grid; grid-template-columns: 1fr 100px; align-items: center; }
.ingredient-head { padding: 8px 15px; color: #93999a; background: #f0ece4; font-size: 11px; }
.ingredient-row { min-height: 47px; padding: 6px 15px; border-top: 1px dashed #e4dfd6; }
.ingredient-row:first-child { border-top: 0; }
.ingredient-row strong { font-size: 13px; }
.ingredient-row small { display: block; margin-top: 2px; color: #899094; font-size: 10px; }
.ingredient-row > span { color: var(--orange); font-size: 15px; font-weight: 700; text-align: right; }
.usage-card { margin-top: 13px; padding: 13px; display: flex; align-items: center; gap: 11px; border: 1px solid #d8e2dd; background: #f2f8f4; border-radius: 7px; }
.usage-icon { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; color: var(--green); background: #dceee2; border-radius: 50%; }
.usage-icon svg { width: 18px; }
.usage-card strong { display: block; margin-top: 3px; font-size: 13px; line-height: 1.45; }
.metric-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.metric-row > div { min-height: 86px; padding: 12px; border: 1px solid #e1dcd2; border-radius: 7px; background: #fffdf9; }
.metric-row strong { display: block; margin: 7px 0 2px; color: var(--orange); font-size: 20px; line-height: 1; }
.metric-row small { color: #889093; font-size: 10px; }
.alert-card, .tip-card { margin-top: 12px; padding: 11px 12px; display: flex; gap: 8px; border-radius: 6px; color: #755b39; background: #fff5e3; font-size: 12px; line-height: 1.6; }
.alert-card svg, .tip-card svg { width: 17px; flex: 0 0 auto; margin-top: 1px; color: #d58516; }
.alert-card p, .tip-card p { margin: 0; }
.result-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 9px; margin-top: 18px; }
.secondary-button { border: 1px solid #9eb1bb; color: var(--ink); background: transparent; }
.compact { min-height: 50px; }

.steps-list { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps-list li { position: relative; min-height: 59px; padding: 0 0 17px 47px; color: #59646e; font-size: 13px; line-height: 1.65; }
.steps-list li::before { content: counter(step); counter-increment: step; position: absolute; left: 0; top: 0; width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid #d19d43; border-radius: 50%; color: #9a681b; font-size: 12px; font-weight: 700; background: #fffaf1; }
.steps-list li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 1px; background: #ded6c7; }
.steps-list strong { color: var(--ink); }

.saved-intro { margin-bottom: 17px; }
.saved-list { display: grid; gap: 10px; }
.saved-item { padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 10px; border: 1px solid var(--line); background: var(--cream); border-radius: 7px; }
.saved-item h3 { margin: 0; font-size: 15px; }
.saved-item p { margin: 5px 0 0; color: #7d878d; font-size: 11px; }
.saved-item button { align-self: center; border: 0; padding: 7px; color: var(--danger); background: transparent; }
.saved-item button svg { width: 18px; }
.empty-state { padding: 50px 15px; text-align: center; color: #879096; border: 1px dashed #c9c2b7; }
.empty-state > svg { width: 28px; height: 28px; color: #b68a43; }
.empty-state p { font-size: 14px; }
.text-button { border: 0; color: var(--orange); background: transparent; font-size: 13px; font-weight: 700; }

.bottom-nav { position: fixed; z-index: 3; bottom: 0; left: 50%; width: min(100%, 510px); min-height: 70px; padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); transform: translateX(-50%); border-top: 1px solid #d8d9d6; background: rgba(255, 253, 248, .96); backdrop-filter: blur(8px); }
.bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; color: #899197; background: transparent; font-size: 10px; }
.bottom-nav button svg { width: 20px; height: 20px; }
.bottom-nav button.active { color: var(--orange); font-weight: 700; }

dialog { width: min(calc(100% - 40px), 430px); padding: 28px 23px 21px; color: var(--ink); border: 0; border-radius: 8px; background: #fffdf8; box-shadow: 0 18px 70px rgba(0, 22, 42, .35); }
dialog::backdrop { background: rgba(0, 28, 50, .48); }
dialog h2 { margin-bottom: 15px; font-size: 24px; }
dialog ul { padding-left: 20px; margin: 0 0 20px; color: #59646b; font-size: 13px; line-height: 1.85; }
.dialog-close { position: absolute; right: 8px; top: 8px; color: #64717b; }

@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 511px) { .app { min-height: 780px; border-radius: 12px; box-shadow: 0 20px 60px rgba(35, 41, 42, .23); } .bottom-nav { bottom: max(0px, calc((100svh - 780px) / 2)); border-radius: 0 0 12px 12px; } }
@media (max-width: 365px) { h2 { font-size: 27px; } .choice-card > span:not(.choice-icon) { font-size: 14px; } .choice-card small { font-size: 9px; } .field-row { gap: 7px; } }
@media print { body { background: #fff; } .app { max-width: 100%; box-shadow: none; } .topbar, .progress-wrap, .bottom-nav, .result-tabs, .result-actions, .back-button, .tab-panel:not(#tab-recipe) { display: none !important; } #screen-result { display: block !important; padding: 0; } .result-heading { margin-bottom: 18px; } }
