:root {
  --ink: #111827;
  --muted: #4b5563;
  --line: #d1d5db;
  --brand: #2f5496;
  --brand-dark: #1f3864;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --surface: #ffffff;
  --page: #f3f4f6;
  /* 使用者以老年人为主，基准字号比常规网页放大一档 */
  --font-base: 19px;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: var(--font-base);
  line-height: 1.6;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

h1 {
  font-size: 1.5em;
  margin: 0 0 12px;
  color: var(--brand-dark);
}

h2 {
  font-size: 1.15em;
  margin: 0 0 10px;
}

p {
  margin: 0 0 12px;
}

label {
  display: block;
  margin: 12px 0 6px;
}

.muted {
  color: var(--muted);
  font-size: 0.9em;
}

.btn {
  display: block;
  width: 100%;
  min-height: 60px;
  font-size: 1.05em;
  font-family: inherit;
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 10px;
}

.btn:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

/* 次要按钮：给"一个都没听清"用，视觉上比"提交"弱一档，
   但仍然明显可点——听不清的人不该去找按钮 */
.btn.secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
  min-height: 48px;
  font-size: 0.95em;
}

.btn.secondary:disabled {
  color: var(--muted);
  background: var(--line);
}

/* X 键：表示"这一位没听清"。跟数字键同样大小，
   放在键盘最后一位（拇指自然落点），颜色稍微区分开 */
.key.key-unclear {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
  font-weight: 600;
}

/* 删除键：去标识、不放品牌色，避免抢 X 键的注意力 */
.key.key-delete {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 1.6em;
}

.field {
  display: block;
  width: 100%;
  min-height: 60px;
  font-size: 1.2em;
  font-family: inherit;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}

#last4 {
  letter-spacing: 0.4em;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.key {
  min-height: 64px;
  font-size: 1.4em;
  font-family: inherit;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.answer {
  font-size: 1.8em;
  letter-spacing: 0.3em;
  text-align: center;
  min-height: 56px;
  padding: 6px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  margin: 12px 0;
}

.progress {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--brand);
}

/* ---------- 纯音测试界面 ----------
   面向老年人：字大、按钮大、状态一眼能看清；
   但动效只用在"正在播放"这一件事上，避免干扰听音判断。 */

.pt-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 0 6px;
}

.pt-orb {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.6em;
  background: #f9fafb;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

/* 正在播放：换成品牌色并扩散一圈波纹 */
.pt-orb.playing {
  border-color: var(--brand);
  color: var(--brand);
  background: #eef2ff;
}

.pt-orb.playing::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--brand);
  opacity: 0.5;
  animation: pt-ring 1.4s ease-out infinite;
}

.pt-orb.waiting {
  border-color: var(--brand-dark);
  color: var(--brand-dark);
  background: #eef2ff;
}

@keyframes pt-ring {
  0% { transform: scale(0.96); opacity: 0.55; }
  100% { transform: scale(1.18); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pt-orb.playing::after { animation: none; }
}

.pt-status {
  font-size: 1.05em;
  font-weight: 600;
  text-align: center;
  min-height: 1.6em;
}

/* 六个测量组，用点表示进度：不显示耳别与频率，只让受试者知道还剩几组 */
.pt-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 4px 0 16px;
}

.pt-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
}

.pt-dot.done {
  background: var(--ok);
}

.pt-dot.current {
  background: var(--brand);
  box-shadow: 0 0 0 4px #e0e7ff;
}

.pt-answer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pt-answer .btn {
  min-height: 76px;
  font-size: 1.1em;
  margin-top: 0;
}

.pt-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.92em;
  margin-top: 12px;
}

.pt-steps {
  margin: 10px 0 14px 20px;
  padding: 0;
  color: var(--muted);
}

.pt-steps li {
  margin-bottom: 6px;
}

/* ---------- 结果页 ---------- */

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 6px;
}

.result-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}

.result-table td.value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.advice-list {
  margin: 6px 0 0 20px;
  padding: 0;
}

.advice-list li {
  margin-bottom: 10px;
}

.result-chart {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}

.notice {
  border-left: 5px solid var(--warn);
  background: #fffbeb;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.notice.error {
  border-color: var(--danger);
  background: #fef2f2;
}

.notice.ok {
  border-color: var(--ok);
  background: #f0fdf4;
}

.grade {
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 8px;
}

.grade.green {
  color: var(--ok);
}

.grade.blue {
  color: var(--brand);
}

.grade.orange {
  color: var(--warn);
}

.grade.invalid {
  color: var(--muted);
}

/**
 * 场景题的选项。
 *
 * 选项做成整块可点的按钮而不是单选小圆点：
 * 主要在手机上作答，手指点得准比"看起来像表单"重要；
 * 选中的那一项要有明显变化，否则用户会怀疑自己到底点没点上。
 */
.scene-options {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.scene-option {
  text-align: left;
  padding: 14px 16px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
}

.scene-option.selected {
  border-color: var(--brand);
  background: #eef2ff;
  font-weight: 600;
}

/**
 * 界面语言开关（清单 36）。
 * 固定在卡片右上角：受试者一眼能看到，又不会挡到正文。
 */
.lang-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  font-size: 0.85em;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
}

.card {
  position: relative;
}
