/* =========================================================
   口算小达人 · 样式
   ========================================================= */

:root {
  --bg: #f7f6ff;
  --card: #ffffff;
  --ink: #221c4a;
  --ink-soft: #3b3466;
  --muted: #6f6a8a;
  --line: #e9e6f6;
  --primary: #5b4bff;
  --primary-strong: #4a3ae0;
  --primary-soft: #eeecff;
  --mint: #10b981;
  --mint-soft: #e7f9f2;
  --coral: #ff6b81;
  --coral-soft: #fff0f2;
  --amber: #f5a524;
  --amber-soft: #fff6e5;
  --shadow: 0 22px 50px -24px rgba(49, 36, 129, 0.28);
  --shadow-soft: 0 10px 30px -18px rgba(49, 36, 129, 0.3);
  --radius: 26px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(91, 75, 255, 0.18);
}

/* ---------------- 背景装饰 ---------------- */

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: floaty 14s ease-in-out infinite alternate;
}

.blob-1 {
  width: 420px;
  height: 420px;
  top: -140px;
  left: -100px;
  background: #dcd6ff;
}

.blob-2 {
  width: 360px;
  height: 360px;
  top: 20%;
  right: -160px;
  background: #ffe3c7;
  animation-delay: -4s;
}

.blob-3 {
  width: 460px;
  height: 460px;
  bottom: -200px;
  left: 25%;
  background: #d4f4ec;
  animation-delay: -8s;
}

.dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(91, 75, 255, 0.13) 1.2px, transparent 1.2px);
  background-size: 26px 26px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 70%);
  opacity: 0.6;
}

@keyframes floaty {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(24px, 30px, 0) scale(1.08);
  }
}

/* ---------------- 顶部 ---------------- */

.site-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #6d5bff, #8b7bff);
  box-shadow: 0 12px 20px -10px rgba(91, 75, 255, 0.7);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-size: 19px;
  letter-spacing: 0.02em;
}

.brand-text small {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

/* ---------------- 通用按钮 ---------------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  height: 46px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.995);
}

.btn:focus-visible {
  outline: 3px solid rgba(91, 75, 255, 0.35);
  outline-offset: 2px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #6454ff, #7f6fff);
  box-shadow: 0 14px 26px -12px rgba(91, 75, 255, 0.72);
}

.btn-primary:hover {
  box-shadow: 0 18px 30px -12px rgba(91, 75, 255, 0.82);
}

.btn-ghost {
  background: #f1effb;
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: #e8e4fa;
}

.btn-warm {
  background: #fff0df;
  color: #a4570a;
}

.btn-warm:hover {
  background: #ffe7cb;
}

.btn-sm {
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
  border-radius: 11px;
}

.btn-lg {
  height: 56px;
  padding: 0 30px;
  font-size: 17px;
  border-radius: 17px;
}

/* ---------------- 主容器 / 首屏 ---------------- */

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px 48px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  align-items: center;
  gap: 18px;
  padding: 38px 44px;
  margin-bottom: 22px;
  border: 1px solid #e6e2ff;
  border-radius: 32px;
  background:
    radial-gradient(120% 160% at 0% 0%, #f0edff 0%, rgba(240, 237, 255, 0) 55%),
    radial-gradient(110% 140% at 100% 10%, #e5f7ff 0%, rgba(229, 247, 255, 0) 55%),
    #fbfaff;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -60px;
  bottom: -120px;
  border-radius: 50%;
  border: 26px solid rgba(124, 108, 255, 0.07);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: rgba(91, 75, 255, 0.09);
  color: var(--primary-strong);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero h1 {
  margin: 14px 0 10px;
  font-size: clamp(28px, 3.6vw, 42px);
  line-height: 1.22;
  letter-spacing: 0.01em;
  font-weight: 800;
}

.hero h1 em {
  font-style: normal;
  color: var(--primary);
  font-size: 1.12em;
}

.hero p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.75;
}

.hero-art {
  position: relative;
  display: grid;
  place-items: center;
}

.mascot {
  width: 100%;
  max-width: 230px;
  height: auto;
  animation: bob 5s ease-in-out infinite alternate;
  filter: drop-shadow(0 18px 24px rgba(91, 75, 255, 0.14));
}

@keyframes bob {
  from {
    transform: translateY(0) rotate(-1deg);
  }
  to {
    transform: translateY(-9px) rotate(1deg);
  }
}

/* ---------------- 设置卡片 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.settings-card {
  padding: 32px 36px 30px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 40px;
}

.field {
  min-width: 0;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
}

.field-head label,
.field-head .label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.field-body {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.num-input {
  width: 104px;
  height: 48px;
  padding: 0 10px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fdfcff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.num-input::placeholder {
  color: #b6b1cc;
  font-size: 14px;
  font-weight: 600;
}

.num-input:hover {
  border-color: #d8d2f5;
}

.num-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(91, 75, 255, 0.12);
}

.unit {
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
}

.chip {
  appearance: none;
  height: 38px;
  padding: 0 15px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: #cfc8f2;
  color: var(--ink-soft);
}

.chip.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: 0 6px 14px -10px rgba(91, 75, 255, 0.55);
}

.chip:focus-visible,
.seg-btn:focus-visible {
  outline: 3px solid rgba(91, 75, 255, 0.3);
  outline-offset: 2px;
}

/* 分段选择 */

.segmented {
  display: grid;
  gap: 4px;
  margin-top: 11px;
  padding: 4px;
  background: #f3f1fb;
  border-radius: 14px;
}

.segmented.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.seg-btn {
  appearance: none;
  border: 0;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.seg-btn:hover {
  color: var(--ink-soft);
}

.seg-btn.is-active {
  background: #fff;
  color: var(--primary-strong);
  box-shadow: 0 5px 12px -8px rgba(49, 36, 129, 0.45);
}

/* 开关 */

.switch-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 14px;
  cursor: pointer;
  user-select: none;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #ddd8ef;
  transition: background 0.18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(34, 28, 74, 0.2);
  transition: transform 0.18s ease;
}

.switch-row input:checked + .switch {
  background: linear-gradient(135deg, #6454ff, #8273ff);
}

.switch-row input:checked + .switch::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch {
  outline: 3px solid rgba(91, 75, 255, 0.3);
  outline-offset: 2px;
}

.switch-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* 开始按钮 */

.start-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 32px;
  padding-top: 26px;
  border-top: 1px dashed #e7e3f6;
}

.start-note {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------------- 练习页 ---------------- */

.practice-card {
  padding: 26px 28px 30px;
}

.practice-head {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px -22px rgba(49, 36, 129, 0.5);
}

.practice-info {
  flex: 1;
  min-width: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f1fb;
  color: #5a5378;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #efedfa;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b7bff, #5b4bff);
  transition: width 0.28s ease;
}

#progressText {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.practice-timer {
  text-align: right;
  flex: none;
}

.timer-label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

#timerDisplay {
  display: block;
  font-size: 29px;
  line-height: 1.15;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

#timerDisplay.is-low {
  color: var(--coral);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

.timer-bar {
  height: 6px;
  margin-top: 12px;
  border-radius: 999px;
  background: #efedfa;
  overflow: hidden;
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b7bff, #5b4bff);
  transition: width 0.25s linear;
}

.timer-bar.is-low span {
  background: linear-gradient(90deg, #ff9aa8, #ff6b81);
}

/* 题目网格 */

.questions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.q {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 78px;
  padding: 12px 16px;
  border: 1.5px solid #ece9f8;
  border-radius: 16px;
  background: #fcfbff;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.q:focus-within {
  border-color: #c9c0ff;
  background: #fff;
  box-shadow: 0 8px 22px -18px rgba(91, 75, 255, 0.55);
}

.q-no {
  flex: none;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #f1effa;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.q-expr {
  flex: 1 1 150px;
  min-width: 0;
  font-size: clamp(19px, 2vw, 22px);
  font-weight: 800;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: break-word;
}

.q-answer {
  flex: none;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.q-input {
  width: 92px;
  height: 50px;
  padding: 0 8px;
  border: 2px solid #ded9f6;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 23px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.q-input::-webkit-outer-spin-button,
.q-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.q-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(91, 75, 255, 0.12);
}

.q-input:disabled {
  background: transparent;
  opacity: 1;
}

.q-mark {
  min-height: 0;
  font-size: 11.5px;
  line-height: 1.15;
  text-align: center;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}

.q-mark:empty {
  display: none;
}

.q.is-correct {
  border-color: rgba(16, 185, 129, 0.45);
  background: #f4fdf9;
}

.q.is-correct .q-no {
  background: var(--mint-soft);
  color: var(--mint);
}

.q.is-correct .q-mark {
  color: var(--mint);
  font-size: 15px;
}

.q.is-wrong {
  border-color: rgba(255, 107, 129, 0.55);
  background: #fff9fa;
}

.q.is-wrong .q-no {
  background: var(--coral-soft);
  color: var(--coral);
}

.q.is-wrong .q-input {
  border-color: rgba(255, 107, 129, 0.5);
}

.q.is-wrong .q-mark {
  color: var(--coral);
  white-space: nowrap;
}

/* 底部操作 */

.practice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 11px;
  margin-top: 26px;
}

.print-answer-toggle {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.print-answer-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ---------------- 页脚 ---------------- */

.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 34px;
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: #9c97b4;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* ---------------- 弹窗 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 22, 72, 0.44);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: fadeIn 0.18s ease;
}

.modal-card {
  position: relative;
  width: min(100%, 640px);
  max-height: calc(100vh - 40px);
  padding: 30px 32px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 40px 90px -30px rgba(30, 20, 80, 0.55);
  overflow-y: auto;
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f4f2fb;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: #ece8fa;
  color: var(--ink);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.modal-actions .btn {
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
}

/* 成绩 */

.result-card {
  width: min(100%, 680px);
}

.result-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-right: 26px;
}

.score-ring {
  --p: 0;
  --ring: #10b981;
  flex: none;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), #efeefb 0);
  display: grid;
  place-items: center;
  transition: background 0.3s ease;
}

.score-ring > span {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  box-shadow: inset 0 0 0 1px #f3f1fb;
}

.score-ring b {
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.score-ring small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  margin-top: 2px;
}

.result-copy h2 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: 0.01em;
}

.result-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.stat {
  padding: 11px 12px;
  border-radius: 14px;
  background: #f8f7fe;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat span {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.stat strong {
  font-size: 15.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wrong-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed #e7e3f6;
}

.wrong-block h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--ink-soft);
}

#wrongList {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 210px;
  overflow-y: auto;
  border-radius: 14px;
  background: #fff9fa;
  border: 1px solid #ffe4e8;
}

#wrongList li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid #ffe9ec;
  font-size: 14px;
}

#wrongList li:last-child {
  border-bottom: 0;
}

#wrongList b {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#wrongList span {
  color: #b06a76;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* 确认框 */

.confirm-card {
  width: min(100%, 430px);
  padding: 28px 28px 24px;
}

.confirm-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

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

/* 练习记录 */

.history-card {
  width: min(100%, 560px);
}

.history-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.history-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 15px;
  border-radius: 14px;
  background: #f9f8fe;
  border: 1px solid #f0edfb;
}

.history-list li.history-empty {
  justify-content: center;
  padding: 34px 16px;
  color: var(--muted);
  font-size: 13.5px;
  border-style: dashed;
  background: #fcfbff;
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-main strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.history-main span {
  color: var(--muted);
  font-size: 12px;
}

.history-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
}

.history-rate {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.history-rate.good {
  color: var(--mint);
}

.history-rate.ok {
  color: var(--amber);
}

.history-rate.low {
  color: var(--coral);
}

.history-side time {
  color: #a19cb8;
  font-size: 11.5px;
}

/* ---------------- Toast / 撒花 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  transform: translate(-50%, 14px);
  max-width: calc(100vw - 40px);
  padding: 12px 20px;
  border-radius: 999px;
  background: #241d4f;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 18px 40px -18px rgba(20, 12, 60, 0.7);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------- 打印 ---------------- */

.print-only {
  display: none;
}

@media print {
  @page {
    margin: 14mm;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html,
  body {
    background: #fff !important;
  }

  .bg-decor,
  .site-header,
  .site-footer,
  #setupView,
  .modal,
  .toast,
  .confetti,
  .timer-bar,
  .practice-timer,
  .progress-row,
  .meta-row,
  .practice-head .btn,
  .practice-actions,
  .q-mark {
    display: none !important;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .practice-card {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .practice-head {
    position: static;
    display: block;
    border: 0;
    padding: 0;
    box-shadow: none;
    background: transparent;
  }

  .print-header {
    display: block !important;
    margin-bottom: 18px;
  }

  .print-header h2 {
    margin: 0 0 4px;
    font-size: 20pt;
    letter-spacing: 0.08em;
  }

  .print-header p {
    margin: 4px 0;
    font-size: 10.5pt;
    color: #444;
  }

  .print-line {
    margin-top: 12px !important;
  }

  .questions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 26px;
    margin-top: 8px;
  }

  .q {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 8px;
    min-height: 0;
    padding: 13px 0;
    border: 0;
    border-bottom: 1px dashed #cfcfcf;
    border-radius: 0;
    background: none !important;
    break-inside: avoid;
  }

  .q-expr {
    flex: 0 1 auto;
  }

  .q-answer {
    margin-left: 0;
  }

  .q-no {
    background: transparent !important;
    color: #333 !important;
    font-size: 10pt;
    width: 18px;
  }

  .q-expr {
    font-size: 16pt;
    color: #111;
  }

  .q-input {
    width: 62px;
    height: 30px;
    border: 0;
    border-bottom: 1.4px solid #333;
    border-radius: 0;
    background: transparent;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    box-shadow: none;
    font-size: 16pt;
  }

  .q-input:focus {
    border-color: transparent;
    border-bottom-color: #333;
    box-shadow: none;
  }

  .answer-key {
    display: none;
  }

  body.print-answers .answer-key {
    display: block !important;
    page-break-before: always;
  }

  .answer-key h3 {
    margin: 0 0 12px;
    font-size: 16pt;
  }

  .answer-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px 16px;
    font-size: 11pt;
    font-variant-numeric: tabular-nums;
  }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 860px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 170px;
    padding: 30px 32px;
  }

  .mascot {
    max-width: 180px;
  }

  .settings-grid {
    gap: 24px 28px;
  }
}

@media (max-width: 720px) {
  .site-header {
    padding: 18px 16px 4px;
  }

  .app {
    padding: 10px 16px 36px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 26px 24px 20px;
    border-radius: 26px;
  }

  .hero-art {
    position: absolute;
    right: 6px;
    bottom: 2px;
    width: 100px;
    opacity: 0.92;
    pointer-events: none;
  }

  .mascot {
    max-width: 100px;
  }

  .hero-copy {
    position: relative;
    z-index: 1;
    padding-right: 0;
  }

  .hero p {
    padding-right: 100px;
    font-size: 13.5px;
    line-height: 1.7;
  }

  .settings-card {
    padding: 24px 20px 22px;
    border-radius: 22px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .start-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 26px;
    padding-top: 22px;
    text-align: center;
  }

  .start-row .btn {
    width: 100%;
  }

  .practice-card {
    padding: 16px 14px 22px;
    border-radius: 22px;
  }

  .practice-head {
    top: 6px;
    gap: 10px;
    padding: 10px 12px;
  }

  #timerDisplay {
    font-size: 24px;
  }

  .practice-head .btn-sm {
    height: 34px;
    padding: 0 12px;
    font-size: 12.5px;
  }

  .pill {
    font-size: 11px;
    padding: 3px 8px;
  }

  .questions {
    grid-template-columns: 1fr;
    gap: 9px;
    margin-top: 14px;
  }

  .q {
    min-height: 70px;
    padding: 10px 12px;
    gap: 6px 9px;
  }

  .q.is-long {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "no expr"
      "answer answer";
    align-items: start;
  }

  .q.is-long .q-no {
    grid-area: no;
  }

  .q.is-long .q-expr {
    grid-area: expr;
  }

  .q.is-long .q-answer {
    grid-area: answer;
    justify-self: end;
  }

  .q-input {
    width: 82px;
    height: 46px;
    font-size: 21px;
  }

  .q-expr {
    font-size: 20px;
  }

  .practice-actions {
    justify-content: stretch;
    margin-top: 20px;
  }

  .print-answer-toggle {
    width: 100%;
    margin-right: 0;
    justify-content: center;
  }

  .practice-actions .btn-lg {
    flex: 1;
  }

  .practice-actions .btn {
    flex: 1;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    padding: 24px 20px;
    border-radius: 22px;
  }

  .result-hero {
    gap: 16px;
    padding-right: 20px;
  }

  .score-ring {
    width: 92px;
    height: 92px;
  }

  .score-ring > span {
    width: 72px;
    height: 72px;
  }

  .score-ring b {
    font-size: 26px;
  }

  .result-copy h2 {
    font-size: 20px;
  }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions .btn {
    width: 100%;
  }

  #wrongList li {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }
}

@media (max-width: 380px) {
  .brand-text small {
    display: none;
  }

  .hero p {
    padding-right: 0;
  }

  .hero-art {
    display: none;
  }

  .q-expr {
    font-size: 18px;
  }

  .q-input {
    width: 74px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}
