:root {
  --ink: #19221c;
  --muted: #667068;
  --paper: #f3f0e8;
  --white: #fffdf8;
  --line: #d8d5cc;
  --green: #194d37;
  --lime: #c8f04a;
  --orange: #e96538;
  --danger: #a83828;
  --shadow: 0 18px 55px rgba(33, 44, 36, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; overflow-x: hidden; background: var(--paper); color: var(--ink); font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }

.topbar { height: 78px; padding: 0 max(4vw, 24px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; background: var(--green); color: var(--lime); font: 700 22px/1 SimSun, serif; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .12em; font-size: 16px; }
.brand small { margin-top: 3px; color: var(--muted); letter-spacing: .16em; font-size: 8px; }
.standard-tag { padding: 9px 13px; border: 1px solid #b5b9b3; font: 700 12px/1 Arial, sans-serif; letter-spacing: .08em; }
.standard-tag span { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(200,240,74,.2); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.simulator-link { padding: 10px 13px; border: 1px solid #b5b9b3; color: var(--green); text-decoration: none; font-size: 11px; font-weight: 700; }
.simulator-link:hover { border-color: var(--green); background: var(--white); }

main { max-width: 1500px; margin: auto; padding: 0 max(4vw, 24px) 64px; }
.hero { min-height: 390px; padding: 74px 0 62px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 48px; }
.eyebrow { margin: 0 0 22px; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .3em; }
h1 { margin: 0; font: 700 clamp(42px, 6vw, 82px)/1.05 SimSun, "STSong", serif; letter-spacing: -.04em; }
h1 em { color: var(--green); font-style: normal; }
.hero-copy { max-width: 640px; margin: 27px 0 0; color: var(--muted); font-size: 15px; line-height: 1.9; }
.hero-stats { display: flex; border-top: 1px solid var(--ink); }
.hero-stats div { min-width: 145px; padding: 18px 12px 0 0; }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font: 700 34px/1 Georgia, serif; }
.hero-stats span { margin-top: 8px; color: var(--muted); font-size: 11px; }

.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: 720px; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.catalog { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); background: #ece9e0; scrollbar-width: thin; }
.catalog-head { padding: 25px 24px 17px; display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; letter-spacing: .14em; }
.menu-toggle { display: none; border: 0; background: none; color: var(--green); }
.search { margin: 0 18px 14px; height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--white); border: 1px solid var(--line); }
.search input { width: 100%; border: 0; outline: 0; background: none; font-size: 12px; }
.method-group-title { padding: 16px 24px 8px; color: #848b85; font-size: 10px; letter-spacing: .18em; }
.method-link { width: 100%; padding: 14px 16px 14px 24px; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: start; gap: 7px; border: 0; border-left: 4px solid transparent; background: transparent; color: var(--ink); text-align: left; transition: .18s ease; }
.method-link:hover { background: rgba(255,255,255,.55); }
.method-link.active { background: var(--white); border-left-color: var(--orange); }
.method-link code { color: var(--green); font: 700 11px/1.5 Consolas, monospace; }
.method-link span { font-size: 12px; line-height: 1.5; }
.method-status { margin-top: 1px; padding: 3px 4px; color: var(--green); border: 1px solid #aebbb2; font-size: 8px; line-height: 1; white-space: nowrap; }
.method-empty { padding: 30px 24px; color: var(--muted); font-size: 12px; }

.calculator { min-width: 0; scroll-margin-top: 12px; padding: 44px clamp(26px, 5vw, 70px) 60px; }
.calculator-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 31px; }
.method-meta { display: flex; gap: 8px; }
.method-meta span { padding: 6px 8px; background: var(--green); color: white; font: 700 10px/1 Consolas, monospace; letter-spacing: .04em; }
.method-meta span + span { background: #e4e2da; color: var(--muted); }
h2 { margin: 15px 0 10px; font: 700 clamp(25px, 3vw, 38px)/1.25 SimSun, serif; }
#method-description { max-width: 720px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.head-actions, .result-actions { display: flex; gap: 8px; align-items: flex-start; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.button { min-height: 38px; padding: 0 15px; border: 1px solid var(--line); background: white; color: var(--ink); font-size: 12px; font-weight: 700; }
.button:hover { border-color: var(--green); }
.button-dark { border-color: var(--green); background: var(--green); color: white; }
.trial-mode { min-height: 38px; display: flex; padding: 3px; background: #e7e5de; border: 1px solid var(--line); }
.trial-mode button { min-width: 76px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.trial-mode button.active { background: var(--green); color: white; box-shadow: 0 2px 7px rgba(25,77,55,.16); }
.trial-mode button:disabled { cursor: not-allowed; opacity: .42; }
.notice { margin: 24px 0; padding: 13px 16px; border-left: 3px solid var(--orange); background: #fff4ea; color: #784733; font-size: 12px; line-height: 1.7; }
.notice:empty { display: none; }

.form-section { min-width: 0; margin-top: 32px; overflow-x: auto; overscroll-behavior-inline: contain; }
.form-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-index { color: var(--orange); font: 700 9px/1 Consolas, monospace; letter-spacing: .14em; }
.form-section h3, .result-head h3 { margin: 0; font: 700 18px/1.2 SimSun, serif; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { position: relative; }
.field label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.field .hint { color: var(--muted); font-weight: 400; }
.input-wrap { display: flex; background: white; border: 1px solid var(--line); transition: .18s; }
.input-wrap:focus-within { border-color: var(--green); box-shadow: 0 0 0 2px rgba(25,77,55,.08); }
.input-wrap input, .input-wrap select { min-width: 0; width: 100%; height: 45px; padding: 0 12px; border: 0; outline: 0; background: transparent; }
.input-wrap .unit { min-width: 55px; padding: 0 12px; display: grid; place-items: center; border-left: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sieve-table { width: 100%; min-width: 540px; border-collapse: collapse; font-size: 12px; }
.sieve-table th { padding: 10px; color: var(--muted); background: #efede7; font-size: 10px; text-align: right; }
.sieve-table th:first-child { text-align: left; }
.sieve-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.sieve-table td:first-child { text-align: left; font-family: Consolas, monospace; }
.sieve-table input { width: 105px; height: 36px; padding: 0 9px; border: 1px solid var(--line); text-align: right; }
.soundness-options { margin-bottom: 18px; }
.soundness-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.soundness-table { min-width: 690px; }
.soundness-table input { width: 145px; }
.soundness-table input::placeholder { color: #9a9e99; font-size: 10px; }
.soundness-table tr[data-soundness-row] { opacity: .56; transition: opacity .16s, background .16s; }
.soundness-table tr[data-soundness-row].selected { opacity: 1; background: #f7faef; }
.grade-check { min-width: 66px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.grade-check input { width: 17px; height: 17px; accent-color: var(--green); }
.grade-check span { font-size: 11px; }
.soundness-result { margin-top: 22px; }
.soundness-result h4 { margin: 0 0 10px; font: 700 15px/1.3 SimSun, serif; }
.submit-row { display: flex; align-items: center; gap: 14px; margin-top: 32px; }
.calculate-button { min-height: 50px; padding: 0 28px; border: 0; background: var(--lime); color: var(--ink); font-weight: 800; }
.calculate-button:hover { filter: brightness(.96); transform: translateY(-1px); }
.autosave-note { color: var(--muted); font-size: 11px; }
.error-box { margin-top: 18px; padding: 12px 14px; border: 1px solid #e4b3aa; background: #fff0ed; color: var(--danger); font-size: 12px; line-height: 1.7; }

.result-panel { min-width: 0; margin-top: 42px; padding-top: 31px; border-top: 2px solid var(--ink); }
#result-content { min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; }
.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.result-head > div:first-child { display: flex; align-items: center; gap: 12px; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); border: 1px solid var(--line); }
.result-card { min-height: 118px; padding: 19px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-card:nth-child(3n) { border-right: 0; }
.result-card span, .result-card strong, .result-card small { display: block; }
.result-card span { color: var(--muted); font-size: 11px; }
.result-card strong { margin-top: 13px; color: var(--green); font: 700 27px/1 Georgia, serif; }
.result-card small { margin-top: 9px; color: var(--muted); font-size: 10px; }
.result-card.primary { background: var(--green); }
.result-card.primary span, .result-card.primary small { color: #c6d5cb; }
.result-card.primary strong { color: var(--lime); }
.result-message { margin-top: 15px; padding: 13px 15px; background: #edf4e8; color: var(--green); font-size: 12px; line-height: 1.7; }
.result-message.warning { background: #fff0ed; color: var(--danger); }
.formula { margin-top: 17px; padding: 17px; border: 1px dashed #bbbdb7; color: var(--muted); font: 12px/1.8 Consolas, "Microsoft YaHei", monospace; white-space: pre-wrap; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; padding: 12px 16px; background: var(--ink); color: white; font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
footer { padding: 22px max(4vw, 24px); display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }

@media (max-width: 1180px) {
  main { padding-left: 28px; padding-right: 28px; }
  .workspace { grid-template-columns: 270px minmax(0, 1fr); }
  .method-link { grid-template-columns: 68px minmax(0, 1fr); }
  .method-status { display: none; }
  .calculator { padding-left: 34px; padding-right: 34px; }
  .calculator-head { flex-direction: column; }
  .head-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 820px) {
  .hero { min-height: auto; grid-template-columns: 1fr; padding: 55px 0; }
  .hero-stats { width: max-content; }
  .workspace { grid-template-columns: 1fr; }
  .catalog { position: relative; top: auto; z-index: 2; max-height: none; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .catalog-head { min-height: 56px; align-items: center; padding-top: 14px; padding-bottom: 14px; }
  .menu-toggle { min-width: 64px; min-height: 40px; display: block; padding: 0 12px; border: 1px solid #b9beb9; background: var(--white); font-weight: 700; }
  .catalog .search, .catalog nav { display: none; }
  .catalog.open .search, .catalog.open nav { display: flex; }
  .catalog.open nav { display: block; max-height: min(52vh, 430px); overflow: auto; overscroll-behavior: contain; }
  .method-link { min-height: 48px; grid-template-columns: 78px minmax(0, 1fr) auto; align-items: center; }
  .method-status { display: block; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-card:nth-child(3n) { border-right: 1px solid var(--line); }
  .result-card:nth-child(2n) { border-right: 0; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
  .brand-mark { width: 36px; height: 36px; }
  .brand strong { font-size: 14px; }
  .standard-tag { padding: 8px; font-size: 9px; letter-spacing: .03em; }
  .topbar-actions { gap: 6px; }
  .simulator-link { padding: 8px; font-size: 9px; }
  main { padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: 40px; padding-left: max(12px, env(safe-area-inset-left)); }
  .hero { padding: 42px 2px; gap: 34px; }
  .eyebrow { margin-bottom: 16px; font-size: 10px; letter-spacing: .2em; }
  h1 { font-size: clamp(34px, 11vw, 44px); line-height: 1.12; }
  .hero-copy { margin-top: 20px; font-size: 13px; line-height: 1.75; }
  .hero-stats { width: 100%; }
  .hero-stats div { min-width: 0; flex: 1; }
  .workspace { border-right: 0; border-left: 0; box-shadow: 0 12px 35px rgba(33,44,36,.08); }
  .catalog-head { padding-right: 16px; padding-left: 16px; }
  .search { margin-right: 12px; margin-left: 12px; }
  .method-link { grid-template-columns: 70px minmax(0, 1fr); padding: 13px 14px 13px 16px; }
  .method-status { display: none; }
  .calculator { padding: 28px 16px 38px; }
  .calculator-head { gap: 20px; padding-bottom: 24px; }
  h2 { font-size: 26px; }
  .notice { margin: 18px 0; }
  .field-grid, .result-grid { grid-template-columns: 1fr; }
  .field-grid { gap: 14px; }
  .input-wrap input, .input-wrap select { height: 50px; font-size: 16px; }
  .result-card, .result-card:nth-child(2n), .result-card:nth-child(3n) { border-right: 0; }
  .head-actions, .result-actions { width: 100%; }
  .head-actions .button, .result-actions .button { min-height: 44px; flex: 1; }
  .trial-mode { width: 100%; }
  .trial-mode button { min-height: 42px; flex: 1; }
  .form-section { margin-top: 26px; overflow-x: auto; overscroll-behavior-inline: contain; }
  .sieve-table { min-width: 500px; }
  .submit-row { align-items: stretch; flex-direction: column; margin-top: 26px; }
  .calculate-button { width: 100%; min-height: 54px; }
  .autosave-note { text-align: center; }
  .result-head { align-items: flex-start; flex-direction: column; gap: 18px; }
  .sieve-table input { width: 96px; height: 42px; font-size: 16px; }
  .toast { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; text-align: center; }
  footer { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); flex-direction: column; }
}

@media (max-width: 380px) {
  .brand small { display: none; }
  .standard-tag { display: none; }
  .calculator { padding-right: 12px; padding-left: 12px; }
  .method-meta { flex-wrap: wrap; }
}

@media (hover: none) and (pointer: coarse) {
  .button, .menu-toggle, .method-link, .calculate-button { -webkit-tap-highlight-color: transparent; }
  .method-link:hover, .button:hover, .calculate-button:hover { transform: none; }
}

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

@media print {
  body { background: white; }
  .topbar, .hero, .catalog, .head-actions, .notice, form, .result-actions, footer { display: none !important; }
  main { padding: 0; }
  .workspace { display: block; border: 0; box-shadow: none; }
  .calculator { padding: 20px; }
  .calculator-head { display: block; }
  .result-panel { display: block !important; }
}
