:root {
  --bg: #f3f5fb;
  --card: #ffffff;
  --primary: #4f6ef7;
  --primary-dark: #3b55e0;
  --primary-soft: #eef1ff;
  --accent: #f59e0b;
  --accent-soft: #fff4e0;
  --success: #22c55e;
  --success-soft: #e8f9ef;
  --danger: #ef4444;
  --danger-soft: #fdecec;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e5e9f2;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(30, 41, 59, 0.06);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
}

#app { max-width: 560px; margin: 0 auto; padding: 16px; padding-bottom: 40px; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }

h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; cursor: pointer; font-size: 15px; font-weight: 600;
  padding: 12px 18px; transition: all .15s; text-decoration: none; color: var(--text);
  background: #eef1f6; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: #fff; border: 1.5px solid var(--border); }
.btn-outline-primary { background: #fff; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 15px 20px; font-size: 17px; border-radius: 14px; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 15px; outline: none; transition: border .15s; background: #fff; color: var(--text);
}
.input:focus { border-color: var(--primary); }
.input-lg { font-size: 20px; padding: 15px 16px; }

/* ---------- 顶部导航 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 8px;
}
.topbar .brand { font-size: 20px; font-weight: 800; color: var(--primary); }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; }

/* ---------- 认证页 ---------- */
.auth-wrap { padding-top: 40px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo { font-size: 44px; }
.auth-logo h1 { color: var(--primary); }
.auth-tabs { display: flex; background: #e9edf6; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; padding: 10px; border: none; border-radius: 9px; background: transparent;
  font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; }
.auth-tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---------- 年级/科目卡片 ---------- */
.section-title { font-size: 15px; font-weight: 700; color: var(--muted); margin: 18px 0 10px; }
.grade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grade-card {
  position: relative;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 16px; text-align: center; cursor: pointer; border: 2px solid transparent;
  transition: all .15s;
}
.g-share { position: absolute; top: 10px; right: 10px; font-size: 12px; font-weight: 600;
  color: var(--primary); background: var(--primary-soft); padding: 4px 9px; border-radius: 12px; }
.grade-card:active { transform: scale(.98); }
.grade-card .g-icon { font-size: 38px; }
.grade-card .g-name { font-size: 19px; font-weight: 700; margin-top: 8px; }
.grade-card .g-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }
.subject-tabs { display: flex; gap: 10px; margin-bottom: 14px; }
.subject-tabs button {
  flex: 1; padding: 13px; border-radius: 12px; border: 1.5px solid var(--border); background: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.subject-tabs button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- 单元列表 ---------- */
.banner { background: var(--accent-soft); border: 1px solid #ffe0a8; color: #8a5a00;
  border-radius: 12px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px; }
.semester-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.semester-tabs button { padding: 8px 16px; border-radius: 20px; border: 1.5px solid var(--border);
  background: #fff; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.semester-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.unit-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px;
  padding: 15px 16px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow);
  border: 1.5px solid transparent; transition: all .15s;
}
.unit-row:active { transform: scale(.99); }
.unit-row .u-no {
  width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.unit-row .u-info { flex: 1; min-width: 0; }
.unit-row .u-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-row .u-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.unit-row.locked { opacity: .62; }
.unit-row .u-arrow { color: #c3cad6; font-size: 18px; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-trial { background: var(--accent); color: #fff; }
.badge-locked { background: #e9edf6; color: var(--muted); }
.badge-free { background: var(--success-soft); color: var(--success); }

/* ---------- 词表预览 ---------- */
.word-list { display: flex; flex-direction: column; gap: 8px; }
.word-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #f8fafc;
  border-radius: 12px; border: 1px solid var(--border);
}
.word-item .w-idx { color: var(--muted); font-size: 13px; width: 28px; text-align: center; flex-shrink: 0; }
.word-item .w-content { font-size: 17px; font-weight: 600; }
.word-item .w-sub { font-size: 12.5px; color: var(--muted); }
.voice-seg { display: flex; background: #e9edf6; border-radius: 12px; padding: 4px; margin: 10px 0; }
.voice-seg button { flex: 1; padding: 10px; border: none; border-radius: 9px; background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.voice-seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.pace-row { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 10px 0; }
.pace-row .lbl { font-size: 13px; color: var(--muted); }

/* ---------- 听写界面 ---------- */
.dictation {
  position: fixed; inset: 0; background: linear-gradient(160deg, #1e2b5e 0%, #22346e 45%, #2b3f85 100%);
  color: #fff; display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.dictation .d-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.dictation .d-quit { color: rgba(255,255,255,.75); font-size: 14px; cursor: pointer; padding: 6px 4px; }
.dictation .d-unit { color: rgba(255,255,255,.8); font-size: 13px; text-align: center; }
.dictation .d-count { font-size: 14px; font-weight: 700; color: rgba(255,255,255,.9); }
.d-progress { height: 5px; background: rgba(255,255,255,.15); margin: 8px 20px; border-radius: 3px; overflow: hidden; }
.d-progress .bar { height: 100%; background: #7fd0ff; border-radius: 3px; transition: width .3s; }

.d-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 24px; }
.speaker { width: 108px; height: 108px; border-radius: 50%; background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px; position: relative; }
.speaker .emoji { font-size: 46px; }
.wave { display: flex; align-items: flex-end; gap: 5px; height: 30px; }
.wave span { width: 5px; background: #7fd0ff; border-radius: 3px; height: 8px; transition: height .2s; }
.wave.on span { animation: wave 0.9s ease-in-out infinite; }
.wave span:nth-child(2) { animation-delay: .1s; } .wave span:nth-child(3) { animation-delay: .2s; }
.wave span:nth-child(4) { animation-delay: .3s; } .wave span:nth-child(5) { animation-delay: .4s; }
@keyframes wave { 0%,100% { height: 8px; } 50% { height: 28px; } }
.d-hint { color: rgba(255,255,255,.75); font-size: 14px; min-height: 22px; margin-bottom: 14px; }

.d-input-wrap { width: 100%; max-width: 420px; }
.d-input {
  width: 100%; padding: 16px 18px; border-radius: 14px; border: 2px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.1); color: #fff; font-size: 22px; text-align: center; outline: none;
}
.d-input::placeholder { color: rgba(255,255,255,.4); }
.d-input:focus { border-color: #7fd0ff; background: rgba(255,255,255,.16); }

.d-controls { display: flex; gap: 12px; justify-content: center; padding: 18px 20px 26px; flex-wrap: wrap; }
.d-btn {
  min-width: 74px; padding: 13px 18px; border-radius: 14px; border: 1.5px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.12); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.d-btn:active { background: rgba(255,255,255,.25); }
.d-btn.primary { background: #7fd0ff; color: #1e2b5e; border-color: #7fd0ff; }

/* ---------- 成绩页 ---------- */
.score-hero { text-align: center; padding: 26px 16px; }
.score-ring { width: 130px; height: 130px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center; position: relative; }
.score-ring .pct { font-size: 34px; font-weight: 800; }
.score-hero .s-label { color: var(--muted); font-size: 14px; }
.wrong-list { margin-top: 8px; }
.wrong-item { padding: 13px 14px; background: var(--danger-soft); border-radius: 12px; margin-bottom: 8px; }
.wrong-item .w-ans { font-size: 15px; font-weight: 600; color: var(--danger); }
.wrong-item .w-correct { font-size: 17px; font-weight: 700; color: var(--success); margin-top: 2px; }
.wrong-item .w-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- 收款码 ---------- */
.qr-box { text-align: center; padding: 8px 0; }
.qr-img { width: 100%; max-width: 340px; height: auto; object-fit: contain; border-radius: 14px; border: 1px solid var(--border); cursor: zoom-in; }
.qr-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.qr-box .qr-note { margin-top: 10px; font-size: 14px; color: var(--muted); }
.qr-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 20px; }
.qr-lightbox img { width: auto; height: auto; max-width: 94vw; max-height: 90vh; background: #fff; padding: 16px; border-radius: 16px; }

/* ---------- 记录列表 ---------- */
.record-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: #f8fafc;
  border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--border); }
.record-row .r-score { font-size: 18px; font-weight: 800; color: var(--primary); width: 46px; text-align: center; }
.record-row .r-info { flex: 1; }
.record-row .r-name { font-weight: 600; font-size: 14px; }
.record-row .r-time { font-size: 12px; color: var(--muted); }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 400px; }
.modal h3 { margin-bottom: 14px; text-align: center; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: rgba(15,23,42,.92);
  color: #fff; padding: 11px 20px; border-radius: 24px; font-size: 14px; z-index: 300; max-width: 90%;
  transition: opacity .25s; }
.toast.hide { opacity: 0; }

/* ---------- 加载 ---------- */
.spinner { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
