:root {
  color-scheme: light;
  --ink: #14231f;
  --muted: #64736e;
  --paper: #f3f0e8;
  --card: #fffdf8;
  --line: #dedbd1;
  --accent: #176b5b;
  --accent-dark: #123b35;
  --accent-soft: #dcece6;
  --warn: #9a5b16;
  --warn-soft: #fff0d9;
  --danger: #9b3636;
  --danger-soft: #fbe4e4;
  --shadow: 0 18px 50px rgba(29, 48, 41, 0.09);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(23, 107, 91, 0.13), transparent 28rem),
    radial-gradient(circle at 100% 15%, rgba(195, 155, 84, 0.12), transparent 24rem),
    var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  line-height: 1.65;
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px max(18px, calc((100vw - 980px) / 2));
  color: #f8f3e8;
  background: var(--accent-dark);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 14px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
}
.topbar strong { display: block; font-size: 16px; letter-spacing: .04em; }
.topbar span { display: block; color: rgba(255,255,255,.66); font-size: 12px; }

.page-shell {
  width: min(980px, calc(100% - 28px));
  margin: 26px auto 54px;
}
.hero {
  padding: 20px 4px 28px;
}
.eyebrow, .step-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(32px, 7vw, 56px);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -.035em;
}
.hero-copy {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.hero-badges span {
  padding: 6px 11px;
  color: var(--accent-dark);
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(23,107,91,.16);
  border-radius: 999px;
  font-size: 12px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(222,219,209,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-card { padding: clamp(20px, 4vw, 34px); }
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.section-heading h2 {
  margin: 0;
  font-size: clamp(21px, 4vw, 27px);
  line-height: 1.25;
}
.required-note, .result-note {
  flex: 0 0 auto;
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 600; }
.field em { color: var(--muted); font-size: 12px; font-style: normal; font-weight: 400; }
.field input {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  color: var(--ink);
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(23,107,91,.1); }

.gender-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}
.gender-field legend { float: left; margin-right: 8px; font-size: 14px; font-weight: 600; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  padding: 9px 18px;
  color: var(--muted);
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.choice input:checked + span { color: #fff; background: var(--accent); border-color: var(--accent); }
.upload-heading { margin-top: 32px; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-card {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 22px;
  overflow: hidden;
  text-align: center;
  background:
    linear-gradient(145deg, rgba(220,236,230,.62), rgba(255,253,248,.9));
  border: 1px dashed rgba(23,107,91,.4);
  border-radius: 18px;
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.upload-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 12px 28px rgba(23,107,91,.1); }
.upload-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 10px;
  color: #fff;
  background: var(--accent);
  border-radius: 18px;
  font-family: "Songti SC", serif;
  font-size: 26px;
}
.upload-title { font-weight: 700; }
.upload-help { max-width: 220px; margin-top: 3px; color: var(--muted); font-size: 12px; }
.preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.upload-card.has-image::after {
  content: "点击更换";
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 9px;
  color: #fff;
  background: rgba(18,59,53,.78);
  border-radius: 999px;
  font-size: 11px;
}

.capture-tips {
  margin-top: 18px;
  padding: 16px 18px;
  color: #384a44;
  background: #f6f3ea;
  border-left: 3px solid #c39b54;
  border-radius: 4px 14px 14px 4px;
  font-size: 13px;
}
.capture-tips strong { display: block; margin-bottom: 5px; }
.capture-tips ul { margin: 0; padding-left: 18px; }
.capture-tips li + li { margin-top: 3px; }

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  color: #3f504a;
  font-size: 13px;
}
.consent input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.privacy-note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.privacy-note summary { cursor: pointer; color: var(--accent); }
.privacy-note p { margin: 8px 0 0; }
.form-error { margin: 14px 0 0; padding: 10px 13px; color: var(--danger); background: var(--danger-soft); border-radius: 10px; font-size: 13px; }
.local-model-note { margin: 10px 2px 0; color: var(--muted); font-size: 12px; text-align: center; }

.primary-button, .secondary-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: transform .2s, opacity .2s, background .2s;
}
.primary-button { margin-top: 18px; color: #fff; background: var(--accent-dark); box-shadow: 0 12px 24px rgba(18,59,53,.18); }
.primary-button:hover { transform: translateY(-1px); background: #0c2e29; }
.primary-button:disabled { cursor: wait; opacity: .55; transform: none; }
.secondary-button { color: var(--accent-dark); background: var(--accent-soft); }
.secondary-button:hover { background: #cfe5dc; }

.status-card, .error-card { margin-top: 20px; padding: 24px; }
.status-topline { display: flex; justify-content: space-between; gap: 12px; }
.status-topline span { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; }
.progress-track { height: 8px; margin: 14px 0 10px; overflow: hidden; background: #e7e3d9; border-radius: 999px; }
.progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, #176b5b, #58a58e); border-radius: inherit; transition: width .35s ease; }
.status-card p { margin: 0; color: var(--muted); font-size: 13px; }
.status-steps { display: flex; justify-content: space-between; gap: 4px; margin-top: 16px; color: #98a39e; font-size: 11px; }
.status-steps span.active { color: var(--accent); font-weight: 700; }
.error-card h2 { margin: 0 0 8px; color: var(--danger); font-size: 22px; }
.error-card p { margin: 0 0 18px; color: var(--muted); white-space: pre-wrap; }

.result-stack { display: grid; gap: 18px; margin-top: 20px; }
.result-card { padding: clamp(20px, 4vw, 30px); }
.quality-banner { padding: 16px 18px; border-radius: 16px; font-size: 14px; }
.quality-banner.ok { color: #17483e; background: #dff1e8; border: 1px solid #bfe0d2; }
.quality-banner.warn { color: var(--warn); background: var(--warn-soft); border: 1px solid #f0d3a3; }
.quality-banner.danger { color: var(--danger); background: var(--danger-soft); border: 1px solid #efc3c3; }
.quality-banner strong { display: block; margin-bottom: 5px; }
.quality-banner ul { margin: 8px 0 0; padding-left: 19px; }
.quality-banner li + li { margin-top: 4px; }

.measurement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.measurement {
  padding: 17px 14px;
  text-align: center;
  background: #f6f3ea;
  border: 1px solid #ece7dc;
  border-radius: 15px;
}
.measurement span { display: block; color: var(--muted); font-size: 12px; }
.measurement strong { display: block; margin-top: 4px; font-family: "DIN Alternate", "Bahnschrift", sans-serif; font-size: clamp(24px, 5vw, 34px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.measurement small { color: var(--muted); font-size: 11px; }

.posture-list { display: grid; gap: 10px; }
.posture-item { padding: 14px 15px; background: #faf8f2; border: 1px solid #e8e3d8; border-radius: 14px; }
.posture-item-top { display: flex; align-items: center; gap: 10px; }
.posture-item-top strong { flex: 1; min-width: 0; font-size: 14px; }
.posture-value { flex: 0 0 auto; font-family: "DIN Alternate", "Bahnschrift", sans-serif; font-size: 18px; font-variant-numeric: tabular-nums; }
.posture-unit { margin-left: 2px; color: var(--muted); font-size: 11px; }
.status-pill { flex: 0 0 auto; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.status-usable { color: #176b5b; background: #dcece6; }
.status-marginal { color: var(--warn); background: var(--warn-soft); }
.status-value_only, .status-trend_only { color: #5e5a85; background: #ebe8f7; }
.status-unavailable { color: var(--danger); background: var(--danger-soft); }
.posture-item details { margin-top: 6px; color: var(--muted); font-size: 12px; }
.posture-item summary { cursor: pointer; color: var(--accent); }
.posture-item p { margin: 7px 0 0; }
.fine-print { margin: 16px 0 0; color: var(--muted); font-size: 11px; }
.result-actions { margin-top: 2px; }
.result-meta { color: var(--muted); font-size: 11px; text-align: center; }
.footer { padding: 24px 18px 34px; color: var(--muted); text-align: center; font-size: 11px; }

html.embed .topbar,
html.embed .footer {
  display: none;
}

html.embed .page-shell {
  margin-top: 0;
  padding-top: 12px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

html.embed .hero {
  padding-top: 8px;
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 980px); margin-top: 14px; }
  .hero { padding: 12px 7px 20px; }
  .field-grid, .upload-grid { grid-template-columns: 1fr; }
  .upload-card { min-height: 180px; }
  .measurement-grid { grid-template-columns: 1fr; }
  .measurement { display: flex; align-items: baseline; justify-content: space-between; text-align: left; }
  .measurement strong { margin-top: 0; }
  .topbar { padding: 14px 16px; }
}
