:root {
  --ink: #173b35;
  --deep: #16473f;
  --green: #23695c;
  --mint: #dceae3;
  --mint-light: #edf4ef;
  --paper: #f5f2e9;
  --white: #fffef9;
  --orange: #dc7743;
  --orange-soft: #f3c49e;
  --line: rgba(23,59,53,.15);
  --muted: #75827d;
  --serif: "Songti SC", "Noto Serif CJK SC", STSong, SimSun, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); -webkit-font-smoothing: antialiased; padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { color: white; background: var(--green); }

body::before { content: ""; position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: .13; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.1'/%3E%3C/svg%3E"); }

.topbar { min-height: 74px; display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top) max(clamp(22px, 4vw, 64px), env(safe-area-inset-right)) 0 max(clamp(22px, 4vw, 64px), env(safe-area-inset-left)); background: rgba(245,242,233,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--orange); border: 1px solid var(--line); border-radius: 50%; }
.brand-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.brand b { display: block; font: 500 21px/1 var(--serif); letter-spacing: .08em; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; letter-spacing: .16em; }
.top-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; letter-spacing: .06em; }
.top-status i { width: 7px; height: 7px; border-radius: 50%; background: #55a279; box-shadow: 0 0 0 4px rgba(85,162,121,.12); }
.guide-button { padding: 8px 0 6px; color: var(--deep); background: none; border: 0; border-bottom: 1px solid var(--line); font-size: 11px; cursor: pointer; }
.guide-button span { margin-left: 8px; color: var(--orange); }

main { width: min(1530px, 100%); margin: 0 auto; }
.intro { display: grid; grid-template-columns: 1fr minmax(320px, 520px); align-items: end; gap: 60px; padding: 55px clamp(22px, 4vw, 64px) 42px; }
.eyebrow { margin: 0 0 12px; color: var(--orange); font-size: 9px; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; }
.intro h1 { margin: 0; font: 500 clamp(40px, 5vw, 68px)/1.08 var(--serif); letter-spacing: -.045em; }
.intro h1 em { color: var(--green); font-style: normal; }
.intro > p { margin: 0 0 4px; color: var(--muted); font-size: 12px; line-height: 1.9; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(410px, .85fr); align-items: start; border-top: 1px solid var(--line); }
.planner-panel { min-width: 0; padding: 45px clamp(22px, 4vw, 64px) 90px; border-right: 1px solid var(--line); }
.section-title { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 26px; }
.section-title > span { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; color: var(--orange); border: 1px solid var(--orange-soft); border-radius: 50%; font: 9px ui-monospace, monospace; }
.section-title h2 { margin: 0; font: 500 24px/1.15 var(--serif); }
.section-title p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.task-settings { padding-bottom: 43px; border-bottom: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: 1.4fr .8fr .8fr; gap: 15px; }
.field { display: block; }
.field > span:first-child { display: block; margin-bottom: 8px; color: #49665e; font-size: 10px; font-weight: 650; }
.field small { margin-left: 4px; color: #929c98; font-weight: 400; }
.field input, .field select { width: 100%; height: 44px; padding: 0 13px; color: var(--ink); background: rgba(255,254,249,.8); border: 1px solid var(--line); border-radius: 2px; outline: none; font-size: 12px; }
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35,105,92,.07); }
.stepper { display: grid !important; grid-template-columns: 35px 1fr 35px; margin: 0 !important; }
.stepper input { min-width: 0; padding: 0; border-left: 0; border-right: 0; border-radius: 0; text-align: center; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper button { color: var(--green); background: rgba(255,254,249,.8); border: 1px solid var(--line); cursor: pointer; }
.stepper button:hover { background: var(--mint); }
.quantity-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 16px; color: var(--muted); font-size: 9px; line-height: 1.6; }
.quantity-note svg { width: 15px; flex: 0 0 auto; fill: none; stroke: var(--orange); stroke-width: 1.6; }

.factor-picker { padding-top: 43px; }
.picker-title { align-items: center; }
.picker-title > div:nth-child(2) { flex: 1; }
.selected-counter { display: flex; align-items: baseline; gap: 5px; text-align: right; }
.selected-counter b { color: var(--green); font: 36px/1 var(--serif); }
.selected-counter small { color: var(--muted); font-size: 9px; }
.search-wrap { height: 47px; display: flex; align-items: center; gap: 11px; padding: 0 14px; background: var(--white); border: 1px solid var(--line); }
.search-wrap svg { width: 18px; fill: none; stroke: var(--green); stroke-width: 1.7; }
.search-wrap input { flex: 1; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 12px; }
.search-wrap button { width: 28px; color: #9ba39f; background: transparent; border: 0; font-size: 20px; cursor: pointer; }
.search-wrap .recognize-button { width: auto; min-width: 52px; height: 30px; padding: 0 11px; color: white; background: var(--deep); border-radius: 2px; font-size: 9px; }
.search-wrap .recognize-button:hover { background: var(--green); }
.paste-hint { margin: 8px 2px 0; color: var(--muted); font-size: 8px; line-height: 1.5; }
.category-tabs { display: flex; gap: 3px; margin: 19px 0; overflow-x: auto; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab { flex: 0 0 auto; padding: 9px 13px; color: var(--muted); background: transparent; border: 0; border-radius: 20px; font-size: 10px; cursor: pointer; }
.category-tab:hover { color: var(--green); }
.category-tab.active { color: var(--white); background: var(--deep); }
.factor-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; min-height: 200px; }
.factor-button { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 9px 11px; color: #48635c; background: rgba(255,254,249,.66); border: 1px solid var(--line); border-radius: 2px; font-size: 10px; line-height: 1.35; text-align: left; cursor: pointer; transition: color .16s, background .16s, border-color .16s; }
.factor-button:hover { border-color: rgba(35,105,92,.4); }
.factor-button::after { content: "+"; width: 18px; height: 18px; display: grid; place-items: center; flex: 0 0 auto; color: var(--green); background: var(--mint); border-radius: 50%; font-size: 12px; }
.factor-button.selected { color: var(--white); background: var(--green); border-color: var(--green); }
.factor-button.selected::after { content: "✓"; color: var(--green); background: var(--white); font-size: 10px; }
.no-factors { grid-column: 1/-1; padding: 70px 20px; color: var(--muted); text-align: center; font: 18px var(--serif); }
.selected-strip { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.selected-strip > div:first-child { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.selected-strip > div:first-child span { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.selected-strip > div:first-child button { padding: 0; color: var(--orange); background: none; border: 0; font-size: 9px; cursor: pointer; }
#selectedTags { display: flex; flex-wrap: wrap; gap: 6px; }
.selected-tag { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; color: var(--green); background: var(--mint); border: 0; border-radius: 20px; font-size: 9px; cursor: pointer; }
.selected-tag span { font-size: 12px; }

.result-panel { position: sticky; top: 0; min-height: 720px; padding: 45px clamp(25px, 3.4vw, 52px) 50px; background: var(--white); }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.result-head .eyebrow { margin-bottom: 7px; }
.result-head h2 { margin: 0; font: 500 31px var(--serif); }
.result-head > span { margin-top: 5px; color: var(--muted); font: 9px ui-monospace, monospace; }
.empty-result { min-height: 430px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-result svg { width: 77px; fill: none; stroke: #b6c4bd; stroke-width: 1.2; }
.empty-result h3 { margin: 20px 0 7px; color: #536d65; font: 500 20px var(--serif); }
.empty-result p { max-width: 280px; margin: 0; font-size: 10px; line-height: 1.7; }
.result-content { padding-top: 22px; }
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.summary-cards > div { min-height: 86px; padding: 13px 12px; background: var(--mint-light); }
.summary-cards .accent { color: white; background: var(--deep); }
.summary-cards small { display: block; color: var(--muted); font-size: 8px; }
.summary-cards .accent small { color: rgba(255,255,255,.62); }
.summary-cards b { display: inline-block; margin-top: 8px; font: 33px/1 var(--serif); }
.summary-cards span { margin-left: 3px; color: var(--muted); font-size: 8px; }
.summary-cards .accent span { color: var(--orange-soft); }
.plan-meta { margin: 17px 0; padding: 11px 13px; color: var(--muted); background: #f7f4ec; border-left: 2px solid var(--orange); font-size: 9px; line-height: 1.6; }
.bottle-plan { counter-reset: bottle; }
.bottle-row { position: relative; display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.bottle-row::before { counter-increment: bottle; content: counter(bottle, decimal-leading-zero); position: absolute; top: 17px; left: 0; color: var(--orange); font: 8px ui-monospace, monospace; }
.bottle-row.onsite { background: linear-gradient(90deg, rgba(220,234,227,.38), transparent); }
.bottle-badge { width: 45px; height: 47px; display: flex; align-items: end; justify-content: center; padding-bottom: 7px; margin-top: 12px; color: var(--green); background: var(--mint); clip-path: polygon(31% 0,69% 0,69% 12%,80% 20%,88% 100%,12% 100%,20% 20%,31% 12%); font-size: 8px; font-weight: 750; }
.bottle-info { padding-top: 1px; }
.bottle-info h3 { margin: 0 0 5px; font-size: 12px; font-weight: 700; }
.bottle-factors { margin: 0 0 7px; color: #536a63; font-size: 9px; line-height: 1.55; }
.bottle-rule { margin: 0; color: var(--muted); font-size: 8px; line-height: 1.55; }
.bottle-qty { padding-top: 13px; text-align: right; }
.bottle-qty b { display: block; font: 24px/1 var(--serif); }
.bottle-qty small { color: var(--muted); font-size: 8px; }
.mini-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mini-title h3 { margin: 0; font: 500 17px var(--serif); }
.mini-title span { color: var(--muted); font-size: 8px; }
.supply-summary, .field-alerts { margin-top: 30px; }
#supplyList { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.supply-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; background: var(--mint-light); font-size: 9px; }
.supply-item b { color: var(--green); font-size: 12px; }
.field-alerts ul { margin: 0; padding: 13px 15px 13px 30px; color: #665c4d; background: #f9efe4; border: 1px solid #f1dac4; font-size: 8px; line-height: 1.7; }
.field-alerts li { margin: 4px 0; }
.field-alerts li::marker { color: var(--orange); }
.deadline-card { margin-top: 30px; padding: 18px 19px; color: white; background: var(--deep); }
.deadline-card > span { display: block; color: var(--orange-soft); font-size: 8px; font-weight: 700; letter-spacing: .1em; }
.deadline-card > div { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; margin-top: 10px; }
.deadline-card b { font: 500 23px var(--serif); }
.deadline-card small { color: rgba(255,255,255,.62); font-size: 8px; text-align: right; }
.deadline-card p { margin: 10px 0 0; padding-top: 10px; color: rgba(255,255,255,.58); border-top: 1px solid rgba(255,255,255,.14); font-size: 8px; line-height: 1.65; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 28px; }
.result-actions button { min-height: 44px; border-radius: 2px; font-size: 10px; cursor: pointer; }
.copy-button { display: flex; align-items: center; justify-content: center; gap: 9px; color: white; background: var(--deep); border: 1px solid var(--deep); }
.copy-button:hover { background: var(--green); }
.copy-button svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.print-button { color: var(--deep); background: transparent; border: 1px solid var(--deep); }
.print-button:hover { background: var(--mint); }
.result-footnote { margin: 28px 0 0; padding-top: 17px; color: #929b97; border-top: 1px solid var(--line); font-size: 8px; line-height: 1.7; }

.guide-dialog { width: min(650px, calc(100% - 30px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; color: var(--ink); background: var(--paper); border: 0; box-shadow: 0 30px 100px rgba(13,48,41,.35); }
.guide-dialog::backdrop { background: rgba(11,38,32,.68); backdrop-filter: blur(4px); }
.guide-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; padding: 28px 32px 23px; background: var(--deep); }
.guide-head h2 { margin: 0; color: white; font: 500 28px var(--serif); }
.guide-head .eyebrow { color: var(--orange-soft); }
.guide-head button { color: white; background: none; border: 0; font-size: 25px; cursor: pointer; }
.guide-body { padding: 5px 32px 30px; }
.guide-body section { display: grid; grid-template-columns: 36px 1fr; gap: 13px; padding: 21px 0; border-bottom: 1px solid var(--line); }
.guide-body section > span { color: var(--orange); font: 9px ui-monospace, monospace; }
.guide-body h3 { margin: 0 0 7px; font: 500 17px var(--serif); }
.guide-body p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.8; }
.guide-body b { color: var(--green); }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 26px; padding: 11px 18px; color: white; background: var(--deep); border-radius: 2px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 10px; opacity: 0; visibility: hidden; transform: translate(-50%, 10px); transition: .2s; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.mobile-result-bar { display: none; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr; }
  .planner-panel { border-right: 0; }
  .result-panel { position: relative; min-height: 0; border-top: 1px solid var(--line); }
  .factor-list { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  .topbar { min-height: calc(65px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); }
  .brand-icon { width: 36px; height: 36px; }
  .brand b { font-size: 18px; }
  .brand small, .top-status { display: none; }
  .intro { grid-template-columns: 1fr; gap: 15px; padding: 43px 20px 30px; }
  .intro h1 { font-size: 43px; }
  .intro > p { font-size: 10px; }
  .planner-panel { padding: 35px 20px 60px; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid .field:first-child { grid-column: 1 / -1; }
  .factor-list { grid-template-columns: repeat(2, 1fr); }
  .result-panel { padding: 35px max(20px, env(safe-area-inset-right)) calc(45px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .result-actions { position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 5; padding: 8px; margin-left: -8px; margin-right: -8px; background: rgba(255,254,249,.93); backdrop-filter: blur(10px); }
  .mobile-result-bar:not([hidden]) { position: fixed; z-index: 15; left: 16px; right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; color: white; background: var(--deep); border: 0; border-radius: 3px; box-shadow: 0 13px 36px rgba(13,55,47,.28); font-size: 11px; cursor: pointer; }
  .mobile-result-bar b { color: var(--orange-soft); font: 22px var(--serif); }
  .mobile-result-bar em { color: rgba(255,255,255,.72); font-size: 9px; font-style: normal; }
  .mobile-result-bar.is-away { display: none !important; }
}

@media (max-width: 430px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .field:first-child { grid-column: auto; }
  .factor-list { grid-template-columns: 1fr 1fr; }
  .factor-button { min-height: 48px; }
  .summary-cards b { font-size: 29px; }
  .bottle-row { grid-template-columns: 45px 1fr auto; gap: 9px; }
  #supplyList { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  body::before, .topbar, .intro, .planner-panel, .result-actions, .guide-dialog, .toast, .mobile-result-bar { display: none !important; }
  main, .workspace { display: block; width: 100%; }
  .result-panel { position: static; padding: 0; background: white; }
  .result-footnote { margin-top: 20px; }
  .bottle-row { break-inside: avoid; }
}

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