:root {
  --ink: #12263a;
  --ink-soft: #4f6476;
  --navy: #19324a;
  --blue: #315f7d;
  --line: #d9e3ea;
  --line-soft: #edf2f5;
  --paper: #ffffff;
  --wash: #f3f7f9;
  --mint: #dcefe9;
  --mint-strong: #2f735f;
  --danger: #c93b3b;
  --danger-wash: #fff1f0;
  --shadow: 0 12px 36px rgba(28, 55, 76, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #eaf1f4;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-height: 100%;
  background: #eaf1f4;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 85% -8%, rgba(89, 150, 158, 0.24), transparent 36%),
    linear-gradient(180deg, #e7eff3 0, #f4f7f8 320px, #f4f7f8 100%);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { -webkit-appearance: none; appearance: none; }

.app-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 14px calc(env(safe-area-inset-bottom) + 30px);
}

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 4px 20px;
}

.app-icon {
  width: 64px;
  height: 64px;
  border-radius: 17px;
  box-shadow: 0 10px 26px rgba(24, 51, 73, 0.18);
  flex: 0 0 auto;
}

.hero-copy { min-width: 0; }
.eyebrow, .section-kicker {
  margin: 0 0 3px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 6px;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -.03em;
}
h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: var(--mint-strong);
  font-weight: 700;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3aa37b;
  box-shadow: 0 0 0 3px rgba(58,163,123,.12);
}
.status-badge.offline { color: var(--ink-soft); }
.status-badge.offline .status-dot { background: #81909a; box-shadow: none; }

.install-banner {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 34px 1fr 18px;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(47, 115, 95, .22);
  border-radius: 16px;
  background: linear-gradient(135deg, #effaf6, #e2f3ed);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 22px rgba(47, 115, 95, .08);
}
.install-symbol {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--mint-strong);
  color: white;
  font-size: 20px;
  font-weight: 800;
}
.install-banner strong, .install-banner small { display: block; }
.install-banner strong { font-size: 14px; }
.install-banner small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; line-height: 1.35; }
.chevron { color: var(--mint-strong); font-size: 28px; font-weight: 300; }

.card, .info-card {
  border: 1px solid rgba(126, 151, 168, .24);
  border-radius: 22px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}
.card { padding: 20px 18px; }
.card + .card { margin-top: 14px; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.required-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
  font-size: 11px;
}
.required-note i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #df6d63;
}
.required-mark::after {
  content: " *";
  color: #d34f48;
  font-weight: 700;
}

fieldset { min-width: 0; }
.field-block {
  margin: 0;
  padding: 0 0 16px;
  border: 0;
}
.field-label, .gender-field legend {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}
.field-help {
  margin: 6px 1px 0;
  color: #82909a;
  font-size: 11px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.segmented label { position: relative; }
.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--wash);
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 700;
  transition: .16s ease;
}
.segmented input:checked + span {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
  box-shadow: 0 7px 15px rgba(25,50,74,.18);
}
.segmented input:focus-visible + span { outline: 3px solid rgba(49,95,125,.22); }

.input-wrap, .unit-input {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 50px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--wash);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.input-wrap:focus-within, .unit-input:focus-within {
  border-color: #5b8298;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(72, 117, 143, .12);
}
input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
input::placeholder { color: #9ca9b1; opacity: 1; }
.unit-input > span {
  padding-right: 13px;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}
.grow { flex: 1; }

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -2px 0 14px;
  color: #87959e;
  font-size: 11px;
}
.or-divider::before, .or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.age-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.form-divider {
  height: 1px;
  margin: 2px 0 17px;
  background: var(--line-soft);
}
.metric-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.metric-field { padding-bottom: 14px; }
.reference-value {
  min-width: 54px;
  color: var(--blue);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.reference-value:not(:empty)::before { content: "中值 "; color: #8a99a3; }
.optional-tag {
  padding: 5px 7px;
  border-radius: 8px;
  background: #edf1f4;
  color: #73838e;
  font-size: 11px;
  white-space: nowrap;
}

.bmi-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  margin: 1px 0 16px;
  padding: 0 13px;
  border-radius: 13px;
  background: #eaf3f6;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}
.bmi-strip output {
  color: var(--ink);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.bmi-strip.warn { background: var(--danger-wash); color: var(--danger); }
.bmi-strip.warn output { color: var(--danger); }

.primary-button, .secondary-button, .icon-button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.primary-button {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-radius: 15px;
  background: linear-gradient(135deg, #315f7d, #19324a);
  color: #fff;
  font-size: 16px;
  font-weight: 750;
  box-shadow: 0 10px 22px rgba(25,50,74,.2);
}
.primary-button:active { transform: translateY(1px); box-shadow: 0 6px 14px rgba(25,50,74,.18); }

.result-card { min-height: 246px; }
.result-heading { margin-bottom: 12px; }
.icon-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  background: #eaf1f5;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}
.icon-button:disabled { opacity: .42; cursor: default; }
.notice {
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #fff8e8;
  color: #8a6425;
  font-size: 12px;
  line-height: 1.45;
}
.result-empty {
  min-height: 118px;
  display: grid;
  align-content: center;
  justify-items: center;
  color: #8998a2;
  text-align: center;
}
.result-empty > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 50%;
  background: #eef3f6;
  color: var(--blue);
}
.result-empty p { margin: 0 0 4px; font-size: 14px; font-weight: 650; }
.result-empty small { font-size: 11px; line-height: 1.45; }
.result-body {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #f8fafb;
}
.result-line {
  padding: 11px 13px;
  border-bottom: 1px solid #e9eff2;
  color: #253b4c;
  font-size: 13px;
  line-height: 1.58;
  word-break: break-word;
}
.result-line:last-child { border-bottom: 0; }
.result-line:first-child { background: #edf3f6; color: var(--navy); font-weight: 750; }
.result-line.warn { background: var(--danger-wash); color: var(--danger); font-weight: 750; }

.secondary-button {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
}

.info-card {
  margin-top: 14px;
  padding: 0 17px;
  box-shadow: none;
}
.info-card summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}
.info-card summary::-webkit-details-marker { display: none; }
.info-card summary::after { content: "+"; color: var(--blue); font-size: 20px; font-weight: 400; }
.info-card[open] summary::after { content: "−"; }
.info-content {
  padding: 0 0 13px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}
.info-content p { margin: 0 0 8px; }
.info-content p:last-child { margin-bottom: 0; }

footer {
  padding: 16px 8px 0;
  color: #7b8b95;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}
footer p { margin-bottom: 0; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(16, 32, 45, .92);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 8px 26px rgba(0,0,0,.2);
}

.modal {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 20, 30, .48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: 90vh;
  overflow: auto;
  padding: 14px 22px calc(env(safe-area-inset-bottom) + 20px);
  border-radius: 24px 24px 0 0;
  background: #fff;
  box-shadow: 0 -16px 60px rgba(0,0,0,.2);
}
.modal-handle {
  width: 38px;
  height: 5px;
  margin: 0 auto 13px;
  border-radius: 99px;
  background: #d8dfe3;
}
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #edf2f4;
  color: var(--ink-soft);
  font-size: 23px;
}
.modal-sheet > img { border-radius: 18px; box-shadow: 0 8px 20px rgba(25,50,74,.14); }
.modal-sheet h2 { margin: 14px 0 12px; font-size: 22px; }
.modal-sheet ol { margin: 0 0 12px; padding-left: 24px; color: #3f5362; font-size: 14px; line-height: 1.85; }
.modal-sheet > p { margin: 0 0 16px; color: #7a8992; font-size: 12px; }
.share-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #a9b7c0;
  border-radius: 6px;
  color: var(--blue);
  font-weight: 800;
}

noscript {
  display: block;
  margin: 20px;
  padding: 20px;
  border-radius: 12px;
  background: #fff2f0;
  color: var(--danger);
}

@media (min-width: 560px) {
  .app-shell { padding-left: 20px; padding-right: 20px; }
  .card { padding: 24px 22px; }
}

@media (max-width: 340px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .card { padding-left: 14px; padding-right: 14px; border-radius: 18px; }
  .app-icon { width: 56px; height: 56px; border-radius: 15px; }
  h1 { font-size: 23px; }
  .reference-value { min-width: 47px; font-size: 11px; }
}

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