:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-card: #ffffff;
  --border: #e3e8ee;
  --text: #16202c;
  --text-muted: #5b6b7c;
  --accent: #437a77;
  --accent-soft: #e9f1f0;
  --success: #0f7b46;
  --success-soft: #e8f6ee;
  --warn: #9a5b00;
  --warn-soft: #fdf3e3;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 880px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-left: 16px;
}
.site-nav a:first-child { margin-left: 0; }
.site-nav a:hover { color: var(--accent); }

/* ---------- typography ---------- */
h1 { font-size: 28px; line-height: 1.28; letter-spacing: -0.02em; margin: 0 0 12px; }
h2 { font-size: 21px; line-height: 1.32; letter-spacing: -0.01em; margin: 40px 0 12px; }
h3 { font-size: 17px; margin: 26px 0 8px; }
p { margin: 0 0 14px; }
a { color: var(--accent); }
small { font-size: 13px; }
.lede { font-size: 17px; color: var(--text-muted); }
.muted { color: var(--text-muted); }

/* ---------- hero ---------- */
.hero { padding: 40px 0 8px; }

/* ---------- cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card + .card { margin-top: 18px; }

/* ---------- form ---------- */
.fieldset { border: 0; padding: 0; margin: 0; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label,
.field > .field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 7px;
}
.hint {
  display: block;
  font-weight: 400;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 14px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color .12s, background .12s;
}
.radio-row label:hover { border-color: #c8d2dc; }
.radio-row input { margin: 0; accent-color: var(--accent); }
.radio-row input:checked + span { font-weight: 600; }
.radio-row label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.input-unit { display: flex; gap: 8px; }
.input-unit input[type="number"] { flex: 1 1 auto; min-width: 0; }
input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
input[type="number"]:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
select.unit-select { flex: 0 0 96px; }

.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  padding: 13px 22px;
  cursor: pointer;
  width: 100%;
}
.btn:hover { background: #356360; }
.btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  padding: 10px 16px;
  width: auto;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- results ---------- */
.results { margin-top: 22px; }
.result-main {
  background: var(--success-soft);
  border: 1px solid #c7e6d5;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.result-main .big {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--success);
  display: block;
}
.result-main .big-unit { font-size: 16px; font-weight: 500; color: var(--text-muted); }
.result-main .label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}
.result-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg);
}
.result-cell .k { font-size: 13px; color: var(--text-muted); display: block; }
.result-cell .v { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.result-cell .u { font-size: 13px; color: var(--text-muted); font-weight: 400; }

.breakdown {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 14px;
}
.breakdown dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.breakdown dt { color: var(--text-muted); }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- notices ---------- */
.notice {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  margin-bottom: 12px;
  border: 1px solid;
}
.notice.danger { background: var(--danger-soft); border-color: #f3c6c3; color: #7a1a15; }
.notice.warn { background: var(--warn-soft); border-color: #f0dcb8; color: #6f4200; }
.notice strong { display: block; margin-bottom: 3px; }

/* ---------- methodology ---------- */
.formula {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  overflow-x: auto;
  margin: 12px 0;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 16px 0;
}
table.data th, table.data td {
  border: 1px solid var(--border);
  padding: 9px 11px;
  text-align: center;
  vertical-align: middle;
}
table.data th { background: var(--bg-soft); font-weight: 600; }
table.data td.num { text-align: center; font-variant-numeric: tabular-nums; }

/* 整段文字的那一列仍保持左对齐：
   居中排版的多行段落两侧都参差，反而更难读。给表格加 .prose 即启用。 */
table.data.prose td:nth-child(2) { text-align: left; }

@media (max-width: 560px) {
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 7px 8px; }
}

details.faq {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
details.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  list-style: none;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: " +"; color: var(--text-muted); font-weight: 400; }
details.faq[open] summary::after { content: " –"; }
details.faq p { margin: 10px 0 2px; color: var(--text-muted); }

/* ---------- compliance ---------- */
.disclaimer {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: #4a5560;
  margin-top: 34px;
}
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  padding: 26px 0 40px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.site-footer nav { margin-bottom: 12px; }
.site-footer nav a { margin-right: 16px; color: var(--text-muted); }
.site-footer nav a:hover { color: var(--accent); }

/* ---------- cookie banner ---------- */
#cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #16202c;
  color: #e8eef5;
  padding: 16px 20px;
  font-size: 14px;
  z-index: 50;
}
#cookie-banner .inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
#cookie-banner p { margin: 0; color: #c3cede; }
#cookie-banner .actions { display: flex; gap: 10px; flex-shrink: 0; }
#cookie-banner button {
  font-family: inherit;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
}
#cookie-banner .accept { background: var(--accent); color: #fff; font-weight: 600; }
#cookie-banner .decline { background: transparent; color: #c3cede; border-color: #46586c; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 560px) {
  h1 { font-size: 24px; }
  h2 { font-size: 19px; }
  .hero { padding: 26px 0 4px; }
  .card { padding: 18px; }
  .result-main .big { font-size: 28px; }
  .site-nav a { margin-left: 12px; }
}

/* ---------- 分享 / 打印 辅助 ---------- */
.print-only { display: none; }

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.share-row .btn.secondary { padding: 9px 15px; }
#share-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 10px 0 0;
}

#print-hint {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin: 10px 0 0;
}

@media print {
  .site-header,
  .site-nav,
  .site-footer,
  #cookie-banner,
  #guides,
  #faq,
  #method,
  form,
  .share-row,
  .btn,
  .no-print { display: none !important; }

  html, body { background: #fff; }
  body { font-size: 11.5pt; color: #000; }
  .wrap { max-width: none; padding: 0; margin: 0; }
  .hero { padding: 0 0 10px; }
  h1 { font-size: 18pt; }

  .print-only { display: block !important; }
  .print-head {
    border-bottom: 1px solid #999;
    padding-bottom: 8px;
    margin-bottom: 14px;
  }
  .print-head strong { display: block; font-size: 12pt; }
  .print-head span { font-size: 9.5pt; color: #444; }

  .hero .lede { display: none !important; }

  .print-profile {
    border: 1px solid #aaa;
    border-radius: 6px;
    padding: 11px 14px;
    margin: 0 0 14px;
    break-inside: avoid;
  }
  .print-profile h2 {
    font-size: 11pt;
    margin: 0 0 9px;
    padding: 0;
  }
  .print-profile dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 20px;
    margin: 0;
    font-size: 10.5pt;
  }
  .print-profile dt { color: #444; }
  .print-profile dd { margin: 0; font-weight: 600; }

  .card,
  .result-main,
  .result-cell,
  .notice,
  .disclaimer {
    border: 1px solid #aaa !important;
    background: #fff !important;
    break-inside: avoid;
  }
  .result-main .big { color: #000; font-size: 22pt; }
  .notice strong { color: #000; }
  .notice.danger, .notice.warn { color: #000; }
  #results { display: block !important; }
  a { color: #000; text-decoration: none; }
  details.faq { display: none; }
}

/* ---------- BCS 九分量程参照 ---------- */
.bcs-scale {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
  margin: 20px 0 12px;
}
.bcs-scale span {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.bcs-low  { background: #fdf3e3; color: #7a4a00; border: 1px solid #e8cfa0; }
.bcs-good { background: #e8f6ee; color: #0b5c35; border: 1px solid #a8d9bf; }
.bcs-high { background: #fdf3e3; color: #7a4a00; border: 1px solid #e8cfa0; }
.bcs-obese{ background: #fdecea; color: #8a1f18; border: 1px solid #e8b4b0; }

.bcs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}
.bcs-legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: 0;
}

.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 1px;
}

.checks {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0;
}
.checks ol { margin: 0; padding-left: 22px; }
.checks li { margin-bottom: 12px; }
.checks li:last-child { margin-bottom: 0; }
.checks strong { display: block; }

@media (max-width: 560px) {
  .bcs-scale { gap: 2px; }
  .bcs-scale span { font-size: 12px; padding: 8px 0; }
}

/* ---------- 插图 ---------- */
.figure {
  margin: 26px 0;
}
.figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.figure figcaption {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 11px;
}

.hero-figure {
  margin: 24px 0 30px;
}
.hero-figure img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 560px) {
  .figure { margin: 20px 0; }
  .figure figcaption { font-size: 13px; }
  .hero-figure { margin: 18px 0 22px; }
}

/* ---------- 粮袋标签示意图 ----------
   用 HTML/CSS 而非图片：这张图的价值全在文字上，
   文字必须真实、可选中、可搜索、可被屏幕阅读器读取。 */
.label-figure { margin: 24px 0; }
.label-mock {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.label-title { font-size: 14px; font-weight: 600; margin: 0 0 3px; }
.label-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 20px; }
.label-sec { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.label-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0 0 20px;
}
.label-table td {
  padding: 3px 0;
  text-align: left;
  color: var(--text-muted);
}
.label-table td:last-child {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.label-callout {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.label-callout-h {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 6px;
}
.label-callout-v {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.label-note { font-size: 13px; color: var(--accent); margin: 10px 0 20px; }
.label-foot { font-size: 12.5px; color: var(--text-muted); margin: 0; }

@media (max-width: 560px) {
  .label-mock { padding: 16px; }
  .label-callout-v { font-size: 14px; }
}

/* =========================================================
   响应式收口层 —— 放在文件最后，确保覆盖前面的零散移动端规则。
   按视口宽度分三档：
     ≤760px  手机 + 竖屏平板
     ≤560px  主流手机
     ≤380px  小屏手机
   ========================================================= */

@media (max-width: 760px) {
  /* 关键修复：数据表列多（体重对照表有 6 列），窄屏下必须横向滚动，
     否则各列被压到几十像素宽、换行错乱，完全读不了。
     .prose 表只有 2–3 列且是整段文字，保持正常换行，不要 nowrap。 */
  table.data:not(.prose) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.data:not(.prose) th,
  table.data:not(.prose) td { padding: 8px 14px; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }

  /* iOS Safari 在输入框字号小于 16px 时会在聚焦时自动放大整页，必须顶到 16px */
  input[type="number"],
  select { font-size: 16px; }

  h1 { font-size: 22px; }
  h2 { font-size: 19px; }
  .hero { padding: 22px 0 4px; }
  .lede { font-size: 16px; }

  .card { padding: 16px; }
  .result-main { padding: 16px; }
  .result-main .big { font-size: 26px; }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .result-cell { padding: 10px 12px; }
  .result-cell .v { font-size: 17px; }

  .radio-row { gap: 6px; }
  .radio-row label { padding: 9px 13px; }

  .checks { padding: 15px 16px; }
  .disclaimer { padding: 13px 14px; font-size: 13.5px; }

  .bcs-scale span { padding: 8px 0; }

  #cookie-banner { padding: 14px 16px; }
  #cookie-banner .inner { gap: 10px; }
  #cookie-banner .actions { width: 100%; }
  #cookie-banner button { flex: 1 1 0; }
}

@media (max-width: 380px) {
  .wrap { padding: 0 14px; }
  h1 { font-size: 20px; }
  h2 { font-size: 17px; }
  .result-grid { grid-template-columns: 1fr; }
  .site-nav a { margin-left: 10px; font-size: 13px; }
  .bcs-scale span { font-size: 11px; }
}
