/* ============================================
   Uyghur Driving Exam — WeChat Style CSS v4.0
   Clean Design · Bottom Tab · Green Theme
   Bilingual RTL/LTR Support
   ============================================ */

/* ===== Design Tokens ===== */
:root {
  --bg: #ededed;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --muted: #888888;
  --border: #e5e5e5;
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #d4f5e0;
  --success: #07c160;
  --success-light: #d4f5e0;
  --danger: #fa5151;
  --danger-light: #ffe8e8;
  --warning: #ffa940;
  --warning-light: #fff3e0;
  --info: #4f46e5;
  --info-light: #e0e7ff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  --tabbar-h: 56px;

  --font: 'Noto Naskh Arabic', 'UKIJ Ekran', 'Alpida Unicode', 'Segoe UI', Tahoma, sans-serif;
  --font-zh: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;

  --max-w: 1080px;
}

/* ===== Font Size Control ===== */
html { font-size: 18px; }
html.fs-sm { font-size: 16px; }
html.fs-md { font-size: 18px; }
html.fs-lg { font-size: 21px; }
html.fs-xl { font-size: 24px; }

/* ===== LTR Font Switch (Chinese) ===== */
html[dir="ltr"] body { font-family: var(--font-zh); }

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.8;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}

html[dir="ltr"] body { direction: ltr; }

/* ===== Accessibility ===== */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  right: 16px;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-sm);
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s;
}
html[dir="ltr"] .skip-link { right: auto; left: 16px; }
.skip-link:focus { top: 16px; }

/* ===== Header ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  flex-shrink: 0;
}

.logo svg { width: 32px; height: 32px; flex-shrink: 0; }

.header-subject {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Settings Panel ===== */
.settings-wrap { position: relative; flex-shrink: 0; }

.settings-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: var(--muted);
}
.settings-btn:hover { background: var(--bg); color: var(--primary); }
.settings-btn svg { width: 22px; height: 22px; }

.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  min-width: 240px;
  z-index: 200;
  display: none;
}
html[dir="ltr"] .settings-panel { left: auto; right: 0; }
.settings-panel.open { display: block; animation: fadeIn 0.2s; }

.settings-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* Font Size Options */
.font-size-options { display: flex; gap: 6px; }

.font-size-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
  text-align: center;
}
.font-size-btn:hover { border-color: var(--primary); color: var(--primary); }
.font-size-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.font-size-btn .fs-label { display: block; font-size: 0.8rem; }
.font-size-btn .fs-preview { display: block; font-size: 1rem; font-weight: 700; margin-top: 2px; }

/* Language Options */
.language-options { display: flex; gap: 6px; }

.lang-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
  text-align: center;
}
.lang-btn:hover { border-color: var(--primary); color: var(--primary); }
.lang-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Subject Selector */
.subject-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.subject-btn {
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
  text-align: center;
  position: relative;
}
.subject-btn:hover { border-color: var(--primary); color: var(--primary); }
.subject-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.subject-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.subject-btn.disabled::after {
  content: '';
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

/* ===== Main ===== */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--sp-lg) 16px;
}

.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Section Headers ===== */
.section-title {
  font-weight: 700;
  font-size: 1.35rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title svg { width: 26px; height: 26px; color: var(--primary); flex-shrink: 0; }

.section-desc {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: var(--sp-lg);
}

.sub-title {
  font-weight: 700;
  font-size: 1.15rem;
  margin: var(--sp-xl) 0 var(--sp-md);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sub-title svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }

/* ===== Home ===== */
.hero { text-align: center; padding: var(--sp-lg) 0 var(--sp-xl); }
.hero h1 { font-weight: 700; font-size: 1.8rem; margin-bottom: var(--sp-sm); }
.hero p { font-size: 1rem; color: var(--muted); max-width: 600px; margin: 0 auto var(--sp-lg); }

.stats-row {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: var(--sp-xl);
  flex-wrap: wrap;
}

.stat-item { text-align: center; }

.stat-number {
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-md);
}

.hero-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: var(--font);
}

.hero-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.hero-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-sm);
}

.hero-card-icon svg { width: 28px; height: 28px; }

.hero-card h3 { font-weight: 700; font-size: 1.1rem; margin-bottom: var(--sp-xs); }
.hero-card p { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }

/* ===== Buttons ===== */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 11px 24px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-large { padding: 14px 40px; font-size: 1.1rem; }

.btn-primary svg, .btn-secondary svg { width: 20px; height: 20px; }
.btn-sm svg { width: 16px; height: 16px; }

/* ===== Search Box ===== */
.search-box { position: relative; margin-bottom: var(--sp-md); }

.search-box > svg {
  position: absolute;
  inset-inline-end: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 44px 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 1rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s;
}
html[dir="ltr"] .search-input { padding: 12px 16px 12px 44px; }

.search-input:focus { outline: none; border-color: var(--primary); }
.search-input::placeholder { color: var(--muted); }

.search-clear {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s;
}
.search-clear:hover { background: var(--muted); color: #fff; }
.search-clear svg { width: 16px; height: 16px; }

/* ===== Bank Filters ===== */
.bank-filters {
  display: flex;
  gap: 8px;
  margin-bottom: var(--sp-md);
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Progress Bar (Bank) ===== */
.bank-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  margin-bottom: var(--sp-md);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.bank-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.bank-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.4s;
}

/* ===== Question Cards ===== */
.question-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--sp-md);
  margin-bottom: var(--sp-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--primary);
}

.q-category {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.q-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: var(--sp-sm);
  line-height: 1.8;
}

/* ===== Question Image ===== */
.q-image {
  margin-bottom: var(--sp-sm);
  text-align: center;
}
.q-image svg {
  max-width: 120px;
  max-height: 120px;
  width: auto;
  height: auto;
}

.q-options { list-style: none; }

.q-options li {
  padding: 10px 14px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.q-options li.correct {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}

.q-option-letter {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.q-options li.correct .q-option-letter {
  background: var(--success);
  color: #fff;
}

.q-option-text { flex: 1; }

.q-correct-badge {
  margin-inline-start: auto;
  color: var(--success);
  display: flex;
  align-items: center;
}
.q-correct-badge svg { width: 18px; height: 18px; }

.q-explanation {
  margin-top: var(--sp-sm);
  padding: 12px 14px;
  background: var(--warning-light);
  border-inline-start: 3px solid var(--warning);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  color: var(--ink);
}

.q-explanation strong { color: var(--warning); }

/* ===== Exam Setup ===== */
.exam-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-xl) var(--sp-lg);
  box-shadow: var(--shadow-sm);
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.exam-box h3 { font-weight: 700; font-size: 1.3rem; margin-bottom: var(--sp-xs); }
.exam-box p { color: var(--muted); margin-bottom: var(--sp-lg); font-size: 1rem; }

.exam-info {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: var(--sp-lg);
  flex-wrap: wrap;
}

.exam-info-item { text-align: center; }
.exam-info-item .num { font-weight: 700; font-size: 1.6rem; color: var(--primary); }
.exam-info-item .label { font-size: 0.85rem; color: var(--muted); }

/* ===== Practice Modes ===== */
.practice-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-md);
}

.practice-mode-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: var(--font);
}

.practice-mode-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.practice-mode-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-sm);
}

.practice-mode-icon svg { width: 24px; height: 24px; }

.practice-mode-card h3 { font-weight: 700; font-size: 1.05rem; margin-bottom: var(--sp-xs); }
.practice-mode-card p { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }

/* ===== Practice Progress Bar ===== */
.practice-progress-bar { flex: 1; min-width: 160px; }

/* ===== Practice Feedback ===== */
.practice-feedback {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-top: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
}
.practice-feedback svg { width: 24px; height: 24px; flex-shrink: 0; }
.practice-feedback.correct {
  background: var(--success-light);
  color: var(--success);
}
.practice-feedback.wrong {
  background: var(--danger-light);
  color: var(--danger);
}

.practice-correct-answer {
  margin-top: var(--sp-sm);
  padding: 10px 14px;
  background: var(--success-light);
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  color: var(--success);
}

/* ===== Exam Running ===== */
.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-sm);
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.exam-exit-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s;
  flex-shrink: 0;
}
.exam-exit-btn:hover { background: var(--danger-light); color: var(--danger); }
.exam-exit-btn svg { width: 20px; height: 20px; }

.exam-timer {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  min-width: 90px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.exam-timer svg { width: 20px; height: 20px; }
.exam-timer.warning { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.exam-progress { flex: 1; min-width: 160px; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ===== Question Grid (Exam Navigation) ===== */
.q-grid-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.q-grid-toggle:hover { border-color: var(--primary); color: var(--primary); }
.q-grid-toggle svg { width: 18px; height: 18px; }

.q-grid {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-sm) var(--sp-md);
  margin-bottom: var(--sp-sm);
  box-shadow: var(--shadow-sm);
}
.q-grid.open { display: block; animation: fadeIn 0.2s; }

.q-grid-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.q-grid-buttons {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}

.q-grid-btn {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-grid-btn:hover { border-color: var(--primary); }
.q-grid-btn.answered {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.q-grid-btn.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== Exam Question ===== */
.exam-question {
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-sm);
}

.exam-q-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.exam-q-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.8;
  margin-bottom: var(--sp-md);
}

.exam-options { list-style: none; }

.exam-options li {
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
}

.exam-options li:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.exam-options li.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.exam-options li.correct {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
  font-weight: 600;
}

.exam-options li.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 600;
}

.exam-options li.correct .exam-option-letter {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.exam-options li.wrong .exam-option-letter {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.exam-options.locked li { cursor: default; }

.exam-option-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.2s;
}

.exam-options li.selected .exam-option-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.exam-option-text { flex: 1; }

.exam-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: var(--sp-md);
}

/* ===== Exam Results ===== */
.result-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-xl) var(--sp-lg);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.result-score {
  font-weight: 700;
  font-size: 3rem;
  margin-bottom: 8px;
  line-height: 1;
}

.result-score.pass { color: var(--success); }
.result-score.fail { color: var(--danger); }

.result-label {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--sp-lg);
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin-bottom: var(--sp-lg);
  flex-wrap: wrap;
}

.result-stat { text-align: center; }
.result-stat .num { font-weight: 700; font-size: 1.5rem; }
.result-stat .label { font-size: 0.85rem; color: var(--muted); }

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== Exam Review ===== */
.review-section { margin-top: var(--sp-xl); }

.review-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.review-title svg { width: 22px; height: 22px; color: var(--primary); }

.review-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--sp-sm) var(--sp-md);
  margin-bottom: var(--sp-xs);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--border);
}

.review-card.correct { border-inline-start-color: var(--success); }
.review-card.wrong { border-inline-start-color: var(--danger); }
.review-card.unanswered { border-inline-start-color: var(--muted); }

.review-q-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-q-text {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
  line-height: 1.7;
}

.review-answer {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-answer.user-correct { background: var(--success-light); color: var(--success); }
.review-answer.user-wrong { background: var(--danger-light); color: var(--danger); }
.review-answer.correct-answer { background: var(--success-light); color: var(--success); font-weight: 600; }
.review-answer svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== Exam History ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 460px;
  margin: 0 auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--muted);
  font-size: 0.9rem;
}

.history-item.pass { border-inline-start-color: var(--success); }
.history-item.fail { border-inline-start-color: var(--danger); }

.history-score { font-weight: 700; }
.history-date { color: var(--muted); font-size: 0.8rem; }
.history-status { font-weight: 600; font-size: 0.8rem; }
.history-item.pass .history-status { color: var(--success); }
.history-item.fail .history-status { color: var(--danger); }

/* ===== Wrong Book ===== */
.wrongbook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-md);
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.wrongbook-count-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--danger);
}

.wrongbook-actions-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wrongbook-card {
  border-inline-start-color: var(--danger);
}

.wrongbook-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.wrongbook-wrong-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 4px;
}
.wrongbook-wrong-count svg { width: 16px; height: 16px; }

.wrongbook-actions {
  margin-top: var(--sp-sm);
  display: flex;
  gap: 8px;
}

/* ===== Knowledge Section ===== */
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.knowledge-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--sp-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.knowledge-card:hover { box-shadow: var(--shadow); }

.knowledge-card h3 {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.knowledge-card h3 svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }

.knowledge-card ul { list-style: none; }

.knowledge-card li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  line-height: 1.7;
  padding-inline-start: 20px;
  position: relative;
}

.knowledge-card li::before {
  content: '';
  position: absolute;
  inset-inline-start: 4px;
  top: 16px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

.knowledge-card li:last-child { border-bottom: none; }

/* ===== Signs Gallery ===== */
.signs-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}

.sign-item {
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--sp-sm);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.sign-item:hover { border-color: var(--primary); transform: translateY(-2px); }

.sign-visual {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sign-visual svg { width: 56px; height: 56px; display: block; }

.sign-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.sign-desc { font-size: 0.8rem; color: var(--muted); }

/* ===== Speed Table ===== */
.table-wrap { overflow-x: auto; margin-bottom: var(--sp-lg); }

.speed-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.speed-table th {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  text-align: start;
  font-weight: 600;
  font-size: 0.9rem;
}

.speed-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.speed-table tr:last-child td { border-bottom: none; }
.speed-table tr:nth-child(even) td { background: rgba(7,193,96,0.03); }

.speed-val { font-weight: 700; color: var(--primary); }

/* ===== Emergency ===== */
.emergency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}

.emergency-item {
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--sp-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--danger);
  transition: transform 0.2s;
}
.emergency-item:hover { transform: translateY(-2px); }

.emergency-item .em-num { font-weight: 700; font-size: 1.8rem; color: var(--danger); }
.emergency-item .em-label { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }

/* ===== Coming Soon Overlay ===== */
.coming-soon-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
}

.coming-soon-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-2xl) var(--sp-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
}

.coming-soon-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--sp-md);
  color: var(--primary);
}
.coming-soon-icon svg { width: 72px; height: 72px; }

.coming-soon-box h2 {
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: var(--sp-sm);
}

.coming-soon-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: var(--sp-sm);
}

.coming-soon-desc {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: var(--sp-sm);
}

.coming-soon-msg {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: var(--sp-lg);
  line-height: 1.7;
}

/* ===== Bottom Tab Bar (WeChat Style) ===== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  max-width: var(--max-w);
  margin: 0 auto;
}

.tab-item {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  transition: color 0.2s;
  padding: 6px 0;
  position: relative;
}

.tab-item .tab-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.tab-item .tab-label {
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1;
}

.tab-item.active { color: var(--primary); }
.tab-item:active { background: var(--bg); }

/* ===== Tab Badge ===== */
.tab-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(50%);
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
html[dir="ltr"] .tab-badge { right: auto; left: 50%; transform: translateX(-50%); }

/* ===== Footer ===== */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: var(--sp-md) 16px;
  margin-top: var(--sp-xl);
  font-size: 0.85rem;
  color: var(--muted);
}

footer p { margin-bottom: 4px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: var(--sp-xl);
  color: var(--muted);
}
.empty-state svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: 0.4; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html { font-size: 16px; }
  html.fs-sm { font-size: 14px; }
  html.fs-md { font-size: 16px; }
  html.fs-lg { font-size: 19px; }
  html.fs-xl { font-size: 22px; }

  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: 0.95rem; }
  main { padding: var(--sp-md) 12px; }
  .header-inner { padding: 8px 12px; }
  .exam-question { padding: var(--sp-sm); }
  .stats-row { gap: 20px; }
  .result-score { font-size: 2.5rem; }
  .knowledge-grid { grid-template-columns: 1fr; }
  .q-grid-buttons { grid-template-columns: repeat(8, 1fr); }
  .header-subject { display: none; }
  .exam-info { gap: 20px; }
  .hero-cards { grid-template-columns: 1fr; }
  .practice-modes { grid-template-columns: 1fr; }
  .wrongbook-header { flex-direction: column; align-items: stretch; }
  .wrongbook-actions-bar { justify-content: stretch; }
  .wrongbook-actions-bar button { flex: 1; justify-content: center; }
  .tab-item .tab-label { font-size: 0.6rem; }
  .tab-item .tab-icon { width: 20px; height: 20px; }
}

@media (max-width: 480px) {
  .exam-info { gap: 16px; }
  .result-stats { gap: 16px; }
  .q-grid-buttons { grid-template-columns: repeat(6, 1fr); }
  .tab-item .tab-label { font-size: 0.55rem; }
  .stat-number { font-size: 1.4rem; }
  .stats-row { gap: 16px; }
}

/* ===== Reduced Motion ===== */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

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

/* ===== High Contrast ===== */
@media (prefers-contrast: high) {
  :root {
    --border: #888;
    --muted: #333;
    --bg: #fff;
  }
  .question-card, .exam-question, .knowledge-card, .sign-item, .emergency-item {
    border-width: 2px;
  }
}

/* ===== Print ===== */
@media print {
  header, .tabbar, footer, .skip-link, .toast, .btn-primary, .btn-secondary,
  .settings-wrap, .q-grid, .q-grid-toggle, .bank-filters, .search-box,
  .coming-soon-overlay, .wrongbook-actions-bar {
    display: none !important;
  }
  .section { display: block !important; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .question-card, .knowledge-card {
    break-inside: avoid;
    border: 1px solid #ccc;
    box-shadow: none;
  }
}

/* ===== Touch ===== */
.touch .exam-options li { padding: 16px 16px; }
.touch .hero-card { cursor: default; }
.touch .tab-item:active { background: var(--bg); }
.touch .practice-mode-card { cursor: default; }
