:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --ink: #1f2428;
  --muted: #687076;
  --line: #d9ddd8;
  --accent: #2f6f73;
  --accent-dark: #1d4d50;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--accent-dark);
  outline: 3px solid rgba(47, 111, 115, 0.22);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

button:disabled:hover {
  background: var(--accent);
  outline: 0;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #eef1ee;
  color: var(--ink);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: #dfe5e1;
}

#app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

#app.has-admin {
  grid-template-columns: 320px 1fr;
}

.admin-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  min-height: 36px;
  padding: 0 12px;
  background: #3b4247;
  font-size: 13px;
  opacity: 0.72;
}

.admin-toggle:hover,
.admin-toggle:focus-visible {
  opacity: 1;
  background: #2e353a;
}

.admin {
  border-right: 1px solid var(--line);
  background: #ecefeb;
  padding: 24px;
  overflow: auto;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.admin label {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.admin input,
.admin select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

.admin h2 {
  margin: 26px 0 14px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--muted);
}

.meta {
  margin: -10px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.admin-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.admin-actions button {
  background: #3b4247;
}

.surface {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 48px;
}

.card {
  width: min(720px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 42px;
  text-align: left;
}

.card h1 {
  margin: 0 0 18px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: 0;
}

.card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.practice-intro-card {
  display: grid;
  gap: 18px;
}

.practice-intro-card p {
  margin-bottom: 0;
}

.practice-example {
  display: grid;
  gap: 14px;
  justify-items: center;
  margin: 6px 0 8px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.example-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.equation-example,
.stroop-example {
  color: var(--ink);
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
}

.stroop-example {
  font-size: 64px;
}

.example-caption {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

/* 键位训练 */
.keyboard-training-keys {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 6px 0 20px;
}

.key-box {
  display: grid;
  place-items: center;
  min-height: 130px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--muted);
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.key-box.key-hit {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(47, 111, 115, 0.08);
}

/* 答题区 */
.trial {
  width: min(900px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  align-items: center;
  text-align: center;
}

.progress,
.key-hint,
.kicker {
  color: var(--muted);
  font-size: 16px;
}

.stimulus {
  padding: 18px;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: clamp(76px, 16vw, 172px);
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stimulus.trial-new {
  animation: trial-pulse 180ms ease-out;
}

@keyframes trial-pulse {
  from {
    background: rgba(47, 111, 115, 0.1);
    border-color: rgba(47, 111, 115, 0.42);
  }
  to {
    background: transparent;
    border-color: transparent;
  }
}

.math-operator-stimulus {
  display: grid;
  gap: 28px;
  justify-items: center;
}

.math-formula {
  width: min(100%, 980px);
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
  font-size: clamp(48px, 8vw, 96px);
  line-height: 1.05;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.parity-stimulus {
  display: grid;
  gap: 28px;
  justify-items: center;
}

.parity-number {
  font-size: clamp(96px, 18vw, 180px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stroop-stimulus {
  display: grid;
  gap: 28px;
  justify-items: center;
}

.stroop-word {
  font-size: clamp(104px, 16vw, 180px);
  font-weight: 900;
  line-height: 1;
}

.stroop-options {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 28px;
  color: var(--muted);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  white-space: nowrap;
}

.answer-options span {
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
}

.nback-audio-stimulus {
  display: grid;
  gap: 18px;
  justify-items: center;
  font-size: 18px;
  line-height: 1.35;
}

.nback-audio-cue {
  color: var(--muted);
  font-size: 24px;
  font-weight: 600;
}

.nback-listening {
  display: grid;
  place-items: center;
  width: min(420px, 100%);
  min-height: 130px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.letter-example {
  min-height: 90px;
  font-size: 24px;
}

.replay-button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.practice-feedback {
  min-height: 84px;
  display: grid;
  place-items: center;
}

.feedback-card {
  display: inline-grid;
  gap: 6px;
  min-width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  background: #ffffff;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.35;
}

.feedback-card strong {
  font-size: 22px;
}

.feedback-correct {
  border-color: #8bb09a;
}

.feedback-correct strong {
  color: #2f6f4f;
}

.feedback-wrong {
  border-color: #bf9a8f;
}

.feedback-wrong strong {
  color: #8b3f2f;
}

.interval {
  text-align: center;
}

/* 完成页汇总表 */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 22px;
  font-size: 16px;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
}

.summary-table th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.card .secondary-button {
  margin-left: 10px;
}

/* 心算填空 */
.math-answer-row {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.math-answer-row button {
  min-height: 56px;
  padding: 0 26px;
  font-size: 20px;
  font-weight: 700;
}

.math-input {
  width: 220px;
  min-height: 64px;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0 16px;
  background: #ffffff;
  color: var(--ink);
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.math-input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(47, 111, 115, 0.22);
}

.math-input.input-error {
  border-color: #bf5f4a;
  animation: input-shake 240ms ease-in-out;
}

@keyframes input-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.math-input-example {
  display: inline-grid;
  place-items: center;
  width: 160px;
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  font-size: 28px;
  font-weight: 800;
}

/* 10 秒倒计时条 */
.time-wrap {
  width: min(420px, 80%);
  margin: 0 auto;
}

.time-track {
  height: 6px;
  border-radius: 999px;
  background: #e3e7e3;
  overflow: hidden;
}

.time-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 100ms linear;
}

.time-fill.time-low {
  background: #b04a35;
}

.time-text {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* 完成页成绩面板 */
.score-panel {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin: 6px 0 24px;
  padding: 26px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbf9;
  text-align: center;
}

.score-value {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

.score-total {
  margin-left: 6px;
  font-size: 26px;
  font-weight: 700;
  color: var(--muted);
}

.score-badge {
  display: inline-block;
  padding: 6px 22px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
}

.score-pass {
  background: rgba(47, 111, 79, 0.12);
  color: #2f6f4f;
  border: 1px solid #8bb09a;
}

.score-fail {
  background: rgba(139, 63, 47, 0.1);
  color: #8b3f2f;
  border: 1px solid #bf9a8f;
}

.score-detail {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* 心算（听算）：算式只朗读、不显示在屏幕上 */
.math-listen {
  font-size: clamp(22px, 3.2vw, 34px);
}

.math-listen-fallback {
  max-width: min(760px, 100%);
  padding: 12px 18px;
  border: 1px solid #bf5f4a;
  border-radius: 8px;
  background: rgba(191, 95, 74, 0.08);
  color: #8c4433;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
}

/* 后台的复选框（备用显示算式） */
.admin label.admin-checkbox {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.admin-checkbox input[type="checkbox"] {
  width: auto;
  min-height: 0;
  margin: 0;
}

@media (max-width: 860px) {
  #app,
  #app.has-admin {
    grid-template-columns: 1fr;
  }

  .admin {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .surface {
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .card {
    padding: 28px 22px;
  }

  .keyboard-training-keys {
    grid-template-columns: 1fr;
  }
}
