/* 默认深色主题；白色 / 柔和绿色主题在文件末尾通过 html[data-theme] 覆盖 */
:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.055);
  --card-strong: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef2ff;
  --muted: #98a2c0;
  --accent: #7aa2ff;
  --accent-2: #9a7bff;
  --danger: #ff7b7b;
  --ok: #4ade80;

  /* 控件与辅助色，浅色主题会整体覆盖 */
  --surface: rgba(255, 255, 255, 0.04);
  --surface-weak: rgba(255, 255, 255, 0.035);
  --track: rgba(255, 255, 255, 0.08);
  --dot: rgba(255, 255, 255, 0.25);
  --divider: rgba(255, 255, 255, 0.07);
  --text-soft: #d6dcf0;
  --text-soft-2: #c8d0e6;
  --placeholder: #6c7695;
  --footer: #6b7591;
  --footer-strong: #93a3c7;
  --ring-inner: #0d1326;
  --select-option-bg: #131a2e;
  --warn-text: #ffb3b3;
  --danger-text: #ffb3b3;
  --ok-text: #86efac;
  --shadow: rgba(122, 162, 255, 0.26);
  --card-shadow: none;
  --popover-bg: #161d33;
  --popover-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);

  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue',
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 70vh;
  background:
    radial-gradient(45% 45% at 25% 20%, rgba(122, 162, 255, 0.24), transparent 70%),
    radial-gradient(40% 40% at 78% 8%, rgba(154, 123, 255, 0.22), transparent 70%),
    radial-gradient(35% 35% at 60% 55%, rgba(56, 189, 248, 0.12), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
}

.boot {
  padding: 80px 0;
  text-align: center;
  color: var(--muted);
}

/* ---------------------------------------------------------------- 头部 */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: linear-gradient(140deg, rgba(122, 162, 255, 0.9), rgba(154, 123, 255, 0.85));
  box-shadow: 0 8px 24px rgba(122, 162, 255, 0.28);
}

.brand-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  margin: 20px 0 22px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

.step-tip {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 6px;
}

.card-desc {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 16px;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  position: relative;
  padding-left: 26px;
  margin-bottom: 12px;
  font-size: 14.5px;
  color: var(--text-soft);
}

.list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

.list li b {
  color: var(--text);
  font-weight: 600;
  margin-right: 6px;
}

.note {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

/* ---------------------------------------------------------------- 表单 */

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

.field-label .req {
  color: var(--danger);
  margin-left: 2px;
}

.input,
.select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  appearance: none;
  outline: none;
  /* 只过渡颜色，避免 select 的下拉箭头位置被带动画 */
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.input::placeholder {
  color: var(--placeholder);
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  /* 用 background-color 而不是 background 简写，保留 select 的箭头背景图 */
  background-color: rgba(122, 162, 255, 0.08);
  background-color: color-mix(in srgb, var(--accent) 8%, transparent);
}

.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 22px, calc(100% - 13px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.select option {
  background: var(--select-option-bg);
  color: var(--text);
}

.segment {
  display: flex;
  gap: 10px;
}

.segment button {
  flex: 1;
  height: 50px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment button.on {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.16);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
  font-weight: 600;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.time-select {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-select .select {
  flex: 1;
  min-width: 0;
}

.time-colon {
  color: var(--muted);
  font-size: 16px;
}

/* ---------------------------------------------------------------- 选项 */

.question {
  margin-bottom: 22px;
}

.question:last-child {
  margin-bottom: 0;
}

.q-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 12px;
}

.q-index {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(122, 162, 255, 0.18);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.q-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

.q-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-weak);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
}

.option:last-child {
  margin-bottom: 0;
}

.option .dot {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--dot);
  display: grid;
  place-items: center;
  transition: all 0.18s ease;
}

.option.on {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.14);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.option.on .dot {
  border-color: var(--accent);
}

.option.on .dot::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}

.pill.on {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.18);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  font-weight: 600;
}

/* ---------------------------------------------------------------- 按钮 */

.actions {
  margin-top: 22px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 26px var(--shadow);
}

.btn-primary[disabled] {
  opacity: 0.6;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  margin-top: 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  height: 48px;
  font-size: 15px;
}

.btn-text {
  margin-top: 14px;
  height: auto;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.error {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.12);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger-text);
  font-size: 13.5px;
}

.error.show {
  display: block;
}

/* ---------------------------------------------------------------- 结果 */

.result-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.score-ring {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 6px auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.score-ring::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--ring-inner);
}

.score-ring .score-num {
  position: relative;
  z-index: 1;
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}

.score-cap {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0 0 12px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.badge-warn {
  background: rgba(255, 123, 123, 0.16);
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--warn-text);
  border: 1px solid rgba(255, 123, 123, 0.4);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.badge-ok {
  background: rgba(74, 222, 128, 0.14);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok-text);
  border: 1px solid rgba(74, 222, 128, 0.38);
  border-color: color-mix(in srgb, var(--ok) 38%, transparent);
}

.result-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 10px;
}

.result-desc {
  font-size: 14.5px;
  color: var(--text-soft-2);
  margin: 0 0 4px;
}

.tips li::before {
  background: linear-gradient(140deg, var(--ok), var(--accent));
}

.clinic {
  background: rgba(122, 162, 255, 0.1);
  border: 1px solid rgba(122, 162, 255, 0.32);
}

.clinic-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.clinic-contact {
  font-size: 14px;
  color: var(--text-soft);
  word-break: break-all;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--divider);
}

.kv:last-child {
  border-bottom: none;
}

.kv span:first-child {
  color: var(--muted);
  flex: none;
}

.kv span:last-child {
  text-align: right;
  word-break: break-all;
}

.footer {
  margin-top: 26px;
  text-align: center;
  font-size: 12px;
  color: var(--footer);
  line-height: 1.8;
}

.footer-provider {
  margin-bottom: 2px;
  color: var(--footer-strong);
  font-weight: 500;
}

/* ---------------------------------------------------------------- 学校搜索 */

.school-picker {
  position: relative;
}

.school-input-wrap {
  position: relative;
}

/* 给右侧 loading 留出空间，避免遮挡输入文字 */
.school-input-wrap .input {
  padding-right: 42px;
}

.school-loading {
  position: absolute;
  right: 14px;
  top: calc(50% - 8px);
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: school-spin 0.7s linear infinite;
}

.school-loading[hidden] {
  display: none;
}

@keyframes school-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 无搜索结果提示放在下拉浮层外，避免遮挡手动填写按钮 */
.school-no-result {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--surface-weak);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.school-no-result[hidden] {
  display: none;
}

.school-options {
  display: none;
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  padding: 6px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--popover-bg);
  box-shadow: var(--popover-shadow);
  max-height: 260px;
  overflow-y: auto;
}

.school-options.show {
  display: block;
}

.school-option {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.school-option:hover,
.school-option:active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* 手动填写 / 返回名单选择的切换入口 */
.school-switch {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 字段级即时提示（如年龄超范围） */
.field-hint {
  display: none;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--danger-text);
}

.field-hint.show {
  display: block;
}

/* ---------------------------------------------------------------- 主题：白色 */

html[data-theme='light'] {
  --bg: #f3f6fb;
  --card: rgba(255, 255, 255, 0.92);
  --card-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #5b677e;
  --accent: #4f7cf7;
  --accent-2: #6da8e8;
  --danger: #e05555;
  --ok: #22a06b;
  --surface: rgba(15, 23, 42, 0.035);
  --surface-weak: rgba(15, 23, 42, 0.025);
  --track: rgba(15, 23, 42, 0.08);
  --dot: rgba(15, 23, 42, 0.25);
  --divider: rgba(15, 23, 42, 0.07);
  --text-soft: #334155;
  --text-soft-2: #334155;
  --placeholder: #94a3b8;
  --footer: #8a94a8;
  --footer-strong: #5b677e;
  --ring-inner: #ffffff;
  --select-option-bg: #ffffff;
  --warn-text: #c24141;
  --danger-text: #b23b3b;
  --ok-text: #15803d;
  --shadow: rgba(79, 124, 247, 0.2);
  --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --popover-bg: #ffffff;
  --popover-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

html[data-theme='light'] .aurora {
  background:
    radial-gradient(45% 45% at 25% 20%, rgba(79, 124, 247, 0.18), transparent 70%),
    radial-gradient(40% 40% at 78% 8%, rgba(109, 168, 232, 0.16), transparent 70%),
    radial-gradient(35% 35% at 60% 55%, rgba(134, 201, 163, 0.12), transparent 70%);
}

/* ---------------------------------------------------------------- 主题：柔和绿色 */

html[data-theme='green'] {
  --bg: #eef8f1;
  --card: rgba(255, 255, 255, 0.9);
  --card-strong: #ffffff;
  --line: rgba(22, 80, 45, 0.12);
  --text: #14352a;
  --muted: #5f7a6d;
  --accent: #4aa173;
  --accent-2: #7fc0a0;
  --danger: #cf5b5b;
  --ok: #2f9e63;
  --surface: rgba(22, 80, 45, 0.04);
  --surface-weak: rgba(22, 80, 45, 0.03);
  --track: rgba(22, 80, 45, 0.09);
  --dot: rgba(22, 80, 45, 0.25);
  --divider: rgba(22, 80, 45, 0.08);
  --text-soft: #2f4f41;
  --text-soft-2: #2f4f41;
  --placeholder: #8aa597;
  --footer: #7f968a;
  --footer-strong: #5f7a6d;
  --ring-inner: #f7fdf9;
  --select-option-bg: #ffffff;
  --warn-text: #b34747;
  --danger-text: #a53f3f;
  --ok-text: #1f7a4d;
  --shadow: rgba(74, 161, 115, 0.22);
  --card-shadow: 0 8px 24px rgba(22, 80, 45, 0.07);
  --popover-bg: #ffffff;
  --popover-shadow: 0 12px 30px rgba(22, 80, 45, 0.12);
}

html[data-theme='green'] .aurora {
  background:
    radial-gradient(45% 45% at 25% 20%, rgba(74, 161, 115, 0.2), transparent 70%),
    radial-gradient(40% 40% at 78% 8%, rgba(127, 192, 160, 0.18), transparent 70%),
    radial-gradient(35% 35% at 60% 55%, rgba(134, 201, 163, 0.14), transparent 70%);
}
