:root {
  --primary: #0b4fc4;
  --primary-dark: #083b94;
  --primary-light: #0f6be0;
  --accent: #0e8de5;
  --danger: #e53935;
  --success: #2e7d32;
  --bg: #f2f5fa;
  --card-bg: #ffffff;
  --card-shadow: 0 12px 30px rgba(15, 60, 120, 0.08);
  --border: #e4e7ee;
  --text: #102136;
  --text-secondary: #596579;
  --radius-lg: 20px;
  /* mobile viewport fix */
  --vh: 1vh;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.app-root {
  min-height: 100vh;
  background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-left) env(safe-area-inset-bottom) env(safe-area-inset-right);
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: rgba(16, 33, 54, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(14, 26, 46, 0.3);
  transition: opacity 0.2s ease;
}

.toast.hidden {
  opacity: 0;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 18px;
  margin: 12px 16px;
}

.card--notice {
  border: 1px solid rgba(11, 79, 196, 0.15);
  background: #f7faff;
}

.card__title {
  font-weight: 600;
  margin-bottom: 6px;
}

.card__hint {
  font-size: 13px;
  color: var(--text-secondary);
  align-items: center;      /* 垂直居中 */
  margin-top: 0px;
}

.card__footer {
  margin-top: 14px;
  font-size: 14px;
  color: var(--primary);
  text-align: center;
}

.page-header {
  padding: calc(env(safe-area-inset-top) + 30px) 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header--light {
  background: linear-gradient(135deg, #f8fbff 0%, #e9f0ff 100%);
}

.header-actions { margin-left: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 2px; }

.page-header__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-header__title strong {
  font-size: 18px;
}

.page-header__title span {
  font-size: 13px;
  color: var(--text-secondary);
}

.icon-btn {
  border: 1px solid rgba(11, 79, 196, 0.15);
  background: #ffffff;
  color: var(--primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 8px 18px rgba(11, 79, 196, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 12px rgba(11, 79, 196, 0.18);
}

.header-actions .icon-btn {
  flex-shrink: 0;
  background: rgba(11, 79, 196, 0.12);
  border: 1px solid rgba(11, 79, 196, 0.25);
  color: var(--primary);
  box-shadow: none;
}

.home-header .header-actions .icon-btn,
.exam-header .header-actions .icon-btn {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #ffffff;
}
.entry-card .icon-btn {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  border: none;
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(11, 79, 196, 0.3);
}

.status-pill {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(11, 79, 196, 0.12);
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill--muted {
  background: rgba(90, 104, 130, 0.12);
  color: var(--text-secondary);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(11, 79, 196, 0.25);
}

.btn-outline {
  background: #f5f7fb;
  color: var(--primary);
}

.btn-danger {
  background: #fff0f0;
  color: var(--danger);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-item {
  background: rgba(15, 60, 120, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}


.progress {
  background: rgba(15, 60, 120, 0.08);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.2s ease;
}

.progress__bar--cool {
  background: var(--accent);
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

/* Inline variant: label before control to save height */
.form-group.form-inline { flex-direction: row; align-items: center; gap: 10px; }
.form-group.form-inline label { margin: 0; white-space: nowrap; }
.form-group.form-inline select { flex: 1; }

.form-group label {
  color: var(--text-secondary);
}

select,
input[type="range"],
input[type="number"],
input[type="email"],
input[type="text"],
input[type="tel"] {
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  width: 100%;
}

input[type="range"] {
  padding: 0;
}

.range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.range-field {
  flex: 1 1 calc(50% - 12px);
  min-width: calc(50% - 12px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Inline variant for range: label at left, slider fills */
.range-field.inline { flex-direction: row; align-items: center; gap: 10px; }
.range-field.inline label { margin: 0; white-space: nowrap; min-width: 50px; font-size: 15px; }
.range-field.inline input[type="range"] { flex: 1; }

.range-field label {
  color: var(--text-secondary);
  font-size: 13px;
}

.range-field input[type="range"] {
  border: none;
  background: transparent;
  width: 100%;
  margin-left: 0%;               /* ← 居中补偿 */
  margin: 0;
}

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

.choices {
  display: grid;
  gap: 10px;
  /* CW 训练选项：两行两列排布 */
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choices button,
.exam-option {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 让选项按钮在网格内自适应占满 */
.choices button { width: 100%; }

/* Exam module */
.exam-stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.exam-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 18px calc(env(safe-area-inset-left) + 18px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.exam-header strong {
  font-size: 18px;
}

.exam-header span {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  margin-top: 2px;
}

.exam-body {
  flex: 1;
  /* 避免与顶部导航重叠 */
  margin-top: 12px;
}

.exam-nav {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin: 0 16px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 6px;
  box-shadow: 0 8px 20px rgba(11, 79, 196, 0.12);
}

.exam-nav .btn {
  font-size: 14px;
  padding: 8px 12px;
}

.exam-options {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.exam-option input {
  width: 18px;
  height: 18px;
}

/* 题目通览中高亮正确选项 */
.exam-option.correct {
  border-color: rgba(46, 125, 50, 0.45);
  background: rgba(46, 125, 50, 0.06);
}

/* 标记用户误选的选项 */
.exam-option.wrong {
  border-color: rgba(229, 57, 53, 0.45);
  background: rgba(229, 57, 53, 0.06);
}

.exam-opt-key {
  font-weight: 600;
  color: var(--primary);
}

.exam-review {
  margin-top: 14px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.exam-card-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 6px;
}

.exam-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.srs-rating-group {
  display: flex;
  flex-direction: row;        /* 改为横向一行 */
  gap: 10px;
  width: 100%;
  align-items: stretch;
}
/* 仅在 SRS 评分区覆盖满宽按钮，三键等分一行 */
.srs-rating-group .btn { flex: 1 1 0; min-width: 0; }
.srs-rating-group .btn-full { width: auto; }

.srs-rating-note {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary, #666666);
}

.exam-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0 16px 20px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--card-shadow);
}

.exam-toolbar button {
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.exam-toolbar button.active {
  color: var(--primary);
}

/* Home page */
.home-page {
  padding: 0 ;
}

.home-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  /* 让蓝色块整体下移一点，与顶部留空 */
  margin: max(env(safe-area-inset-top), 8px) 14px 0;  /* ← px 让它更明显地下移 */
  padding: max(env(safe-area-inset-top), 28px) 20px 32px;
  border-radius: 28px;
  box-shadow: 0 16px 36px rgba(11, 79, 196, 0.28);
}

.home-header h1 {
  margin: 0;
  font-size: 24px;
}

.home-header p {
  margin: 6px 0 0;
  font-size: 14px;
  opacity: 0.85;
}

.home-status {
  display: inline-flex;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 14px;
}

.entry-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 0 16px 24px;
}

.entry-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.entry-card h3 {
  margin: 0;
  font-size: 18px;
}

.entry-card p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.entry-card .icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(11, 79, 196, 0.1);
  color: var(--primary);
  font-size: 20px;
}

.home-stats-card {
  padding: 16px;
  margin: 16px 0;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.home-stats-card strong {
  color: var(--text);
}

.login-card {
  padding: 20px;
  margin: 24px auto;           /* 上下24px，两侧自动居中 */
  width: calc(100% - 32px);    /* 与首页卡片同宽（两侧各留16px） */
  max-width: 440px;            /* 桌面端限制最大宽度 */
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  background: #fff;
  display: grid;
  gap: 16px;
}

.login-card .form-group {
  margin: 0;
}

.login-card .btn-group {
  display: grid;
  gap: 12px;
}

/* Utility */
.muted { color: var(--text-secondary); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; background: rgba(15, 60, 120, 0.08); color: var(--primary-dark); }
.pill.good { background: rgba(46, 125, 50, 0.12); color: var(--success); }
.pill.bad { background: rgba(229, 57, 53, 0.12); color: var(--danger); }

@media (min-width: 720px) {
  .app-root { max-width: 480px; margin: 0 auto; border-radius: 32px; box-shadow: 0 32px 80px rgba(15, 60, 120, 0.2); overflow: hidden; }
  body { background: linear-gradient(180deg, #e9f1ff 0%, #f5f6fa 40%, #f5f6fa 100%); padding: 32px 0; }
}
.card-body {
  display: grid;
  gap: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.toast-inline {
  margin-top: 10px;
  font-size: 13px;
  color: var(--danger);
}

.exam-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 24px;
}

/* Exam revamp */
.exam-page { display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }
.practice-layout { gap: 10px; padding-bottom: 28px; min-height: calc(var(--vh, 1vh) * 100); }
.practice-layout .exam-content { gap: 8px; }
.practice-layout .card { margin: 6px 12px; }
.practice-layout .practice-progress { gap: 8px; }
.practice-layout .practice-stage { gap: 10px; }
.practice-layout .practice-meta { margin-top: -4px; margin-bottom: 2px; }
.practice-layout .exam-content { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.practice-card-actions { position: sticky; bottom: max(env(safe-area-inset-bottom), 6px); z-index: 20; background: transparent; }
.practice-card-actions .exam-actions { width: 100%; justify-content: center; gap: 14px; margin-top: 0; align-items: center; }
.practice-card-actions .btn { min-width: 120px; }
/* SRS 三键横排在 actions 卡片里不应强制 120px 最小宽度，避免小屏溢出 */
.practice-card-actions .srs-rating-group .btn { min-width: 0; }
@media (max-width: 390px) {
  .srs-rating-group { gap: 8px; }
  .practice-card-actions .srs-rating-group .btn { padding: 10px 8px; font-size: 14px; }
}
.practice-card-meta { padding: 14px 16px; }
.practice-card-actions { padding: 12px 16px; display: flex; justify-content: center; }
.practice-card-actions .exam-actions { width: 100%; justify-content: center; gap: 14px; margin-top: 0; }
.exam-main { display: flex; flex-direction: column; gap: 14px; padding: 0 16px 32px; }
.exam-head { display: grid; gap: 16px; padding: 20px; }
.exam-head__top { display: flex; align-items: center; gap: 12px; }
.exam-head__title { margin: 0; font-size: 22px; }
.exam-head__home { width: 44px; height: 44px; }
.exam-head__select-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.exam-head__label { font-size: 14px; color: var(--text-secondary); }
.exam-head__select { min-width: 160px; }

.exam-mode-grid { margin-top: 8px; }
.exam-enter-btn { min-width: 84px; padding: 10px 16px; }

.exam-mode-body { display: flex; flex-direction: column; gap: 16px; }
.module-banner { display: flex; flex-direction: column; gap: 6px; padding: 16px; }
.module-banner__title { font-weight: 600; font-size: 15px; }
.module-banner__meta { font-size: 13px; color: var(--text-secondary); }
.card--loading, .card--error { text-align: center; }
.card--loading .muted { padding: 16px 0; }

.browse-list { display: grid; gap: 12px; }
.browse-head { display: grid; gap: 12px; }
.browse-toolbar { display: flex; gap: 12px; }
.browse-toolbar .form-input,
.browse-toolbar input[type="search"],
.browse-toolbar input[type="text"] { flex: 1; min-width: 0; }
.browse-item { scroll-snap-align: start; }
.browse-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.browse-pager { gap: 12px; justify-content: center; }

.practice-progress { display: flex; flex-direction: column; gap: 8px; }
.practice-stats { display: grid; gap: 6px; font-size: 14px; color: var(--text-secondary); }
.practice-stage { display: grid; gap: 10px; }
.toast-inline-host { display: grid; gap: 8px; margin-top: 12px; }
.practice-meta { font-size: 13px; color: var(--text-secondary); margin-top: -4px; margin-bottom: 2px; }
.practice-opts { padding: 12px 14px; }
.practice-opts__row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.practice-opts__row .form-input { width: 88px; }
.practice-opts__row .btn { margin-left: auto; }
.practice-opts__toggle { font-size: 13px; color: var(--text-secondary); }
.practice-opts__back { margin-top: 6px; justify-content: flex-start; }

.exam-question-card.is-correct { border: 1px solid rgba(46, 125, 50, 0.3); box-shadow: 0 8px 22px rgba(46,125,50,0.18); }
.exam-question-card.is-wrong { border: 1px solid rgba(229, 57, 53, 0.3); box-shadow: 0 8px 22px rgba(229,57,53,0.15); }

.exam-analysis { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(11,79,196,0.06); font-size: 13px; color: var(--text-secondary); display: grid; gap: 4px; }

.exam-status-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.exam-status-bar .status-item { font-size: 14px; color: var(--text-secondary); }

.mock-track { display: grid; gap: 12px; }
.mock-actions { justify-content: flex-start; gap: 12px; }
.mock-summary { margin-top: 8px; }

.mock-track::-webkit-scrollbar { display: none; }

@media (max-width: 600px) {
  .exam-main { display: flex; flex-direction: column; gap: 14px; padding: 0 16px 32px; }
  .exam-head { padding: 16px; }
  .exam-head__title { font-size: 20px; }
  .mock-card { min-width: 92%; }
}


.form-input {
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  width: 100%;
  background: #fff;
}




/* Footer link nowrap */
.card__footer a { white-space: nowrap; display: inline-block; }

/* Strong contrast for light headers (e.g. CW page) */
.page-header--light .header-actions .icon-btn { background: var(--primary); color: #fff; border: none; box-shadow: 0 8px 18px rgba(11,79,196,0.25); }
.exam-header .status-pill { background: rgba(255,255,255,0.18); color: #fff; border: 1px solid rgba(255,255,255,0.35); }



.entry-card:active {
  transform: scale(0.98);
  box-shadow: 0 12px 28px rgba(11, 79, 196, 0.18);
}
















/* Exam layout adjustments */
.exam-header {
  padding: calc(env(safe-area-inset-top) + 12px) 16px 14px calc(env(safe-area-inset-left) + 18px);
}
.header-actions {
  margin-left: -4px;
  margin-right: 8px;
}
.page-header__subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  margin-top: 2px;
}
.exam-head--compact {
  padding: 12px 16px;
}
.exam-head--compact .exam-head__select-row {
  width: 100%;
  margin: 0;
}
.entry-grid .entry-card,
.exam-main .entry-card {
  width: 100%;
  margin: 0;
}
.exam-main .entry-card + .entry-card,
.entry-grid .entry-card + .entry-card {
  margin-top: 12px;
}
.exam-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.exam-option input {
  width: 18px;
  height: 18px;
  margin: 0;
}
.exam-option .exam-opt-key {
  font-weight: 600;
  color: var(--primary);
}
.entry-card,
.exam-main .entry-card {
  height: 80px;                 /* 固定统一高度，可微调 */
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;              /* 防止内容溢出 */
}

/* === 统一选项控件样式修复区（新增） === */
/* 保证所有复选框/单选框在不同浏览器中大小一致、垂直居中 */
.exam-option {
  display: flex;
  align-items: center;      /* 垂直居中 */
  gap: 10px;                /* 文字与方框间距 */
  padding: 10px 14px;
  line-height: 1.4;
}

/* 固定 input 大小和颜色 */
.exam-option input[type="checkbox"],
.exam-option input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;           /* 防止被压缩 */
  margin: 0;
  accent-color: var(--primary);
}

/* 兼容旧浏览器：自定义勾选样式 */
@supports (-webkit-appearance: none) or (-moz-appearance: none) {
  .exam-option input[type="checkbox"],
  .exam-option input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    display: inline-block;
    position: relative;
    background: #fff;
  }

  .exam-option input[type="checkbox"]:checked::after,
  .exam-option input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 1px;
    width: 8px;
    height: 12px;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(45deg);
  }

  .exam-option input[type="radio"] {
    border-radius: 50%;
  }
}

/* 统一文字大小与行高，避免字体差异导致的错位 */
.exam-opt-key,
.exam-opt-text {
  font-size: 15px;
  line-height: 1.4;
}

/* 保证正确选项背景一致 */
.exam-option.correct {
  background-color: #f5fff0;
  border-color: rgba(46, 125, 50, 0.45);
}

.site-footer {
  margin: 0px 0 50px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  user-select: none;
}

.store-link {
  margin-bottom: 8px;
}

.store-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}

.store-link a:hover {
  text-decoration: underline;
}
