:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --muted-2: #9aa3af;
  --line: #e8ecf0;
  --brand: #2f6fed;
  --brand-soft: #eaf1ff;
  --brand-edge: #cfe0ff;
  --good: #0f9d6e;
  --good-soft: #e8f8f1;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
  --shadow-lift: 0 2px 4px rgba(47, 111, 237, 0.06), 0 8px 20px rgba(47, 111, 237, 0.08);
  --max: 980px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: var(--max);
  margin: 0 auto;
}
.main {
  flex: 1;
  padding: 18px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 40;
}
.tab, .tab-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--muted);
}
.tab[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.tab-icon { font-size: 18px; line-height: 1; }
.tab-label { font-size: 11px; font-weight: 600; }
/* 返回考拉：弱于三个内部 Tab */
.tab-link {
  color: var(--muted-2);
  opacity: 0.78;
}
.tab-link .tab-label { font-weight: 500; font-size: 10px; }
.tab-link .tab-icon { font-size: 15px; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.hero h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.hero p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.section { margin-bottom: 14px; }
.section-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.section-title-soft {
  color: var(--muted-2);
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.card + .card { margin-top: 10px; }

/* 昨日无数据：一行轻提示，无完整卡 */
.yesterday-empty {
  margin: 0 0 6px;
  padding: 0;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.4;
}
.section-yesterday-empty { margin-bottom: 8px; }

.stat-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.stat-main {
  font-size: 26px;
  font-weight: 760;
  letter-spacing: -0.03em;
}
.stat-main em { font-style: normal; color: var(--brand); }
.stat-sub { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 6px; }

/* 继续学习：首页主操作区 */
.continue-card {
  padding: 18px 16px;
  border: 1px solid var(--brand-edge);
  background: linear-gradient(180deg, #f7faff 0%, #ffffff 55%);
  box-shadow: var(--shadow-lift);
  border-radius: 18px;
}
.continue-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.continue-name {
  font-size: 17px;
  font-weight: 750;
  margin: 0 0 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.continue-meta { color: var(--muted); font-size: 13px; margin: 0; }
.continue-card .btn {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-ghost {
  background: transparent;
  color: var(--brand);
  font-weight: 650;
  min-height: 36px;
  padding: 0 8px;
  box-shadow: none;
}
.btn-link {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  min-height: 32px;
  padding: 0;
  text-decoration: none;
}
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

.repo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 720px) {
  .repo-grid { grid-template-columns: 1fr 1fr; }
  .main { padding-left: 24px; padding-right: 24px; }
  .continue-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .continue-card .btn { width: auto; min-width: 120px; }
}
.repo-card {
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.repo-card:hover { border-color: var(--brand-edge); }
.repo-name {
  font-size: 15px;
  font-weight: 740;
  margin: 0;
  line-height: 1.35;
}
.repo-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.repo-foot {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f4f8;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
.chip-pending {
  background: #fff4e8;
  color: #b45309;
  font-variant-numeric: tabular-nums;
}
.arrow { color: var(--brand); font-weight: 700; font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.record-card, .wrong-card {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.record-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: start;
}
.record-title {
  margin: 0;
  font-size: 14px;
  font-weight: 740;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}
.acc {
  font-size: 18px;
  font-weight: 780;
  color: var(--brand);
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.record-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  grid-column: 1 / -1;
}
.record-meta .meta-progress-done {
  color: var(--brand);
}

.record-meta .meta-status-done {
  color: var(--good);
  font-weight: 650;
}
.record-meta .meta-status-progress {
  color: var(--brand);
  font-weight: 650;
}
.module-card {
  cursor: pointer;
}
.module-card:hover {
  border-color: var(--brand-edge);
}
.btn-module-continue,
.btn-module-done {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  align-self: start;
  justify-self: end;
}
.btn-module-done {
  background: var(--good);
}
.module-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  justify-self: end;
  min-width: 96px;
}
.btn-outline,
.btn-module-secondary {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand-edge);
  box-shadow: none;
  font-weight: 650;
}
.btn-outline:active,
.btn-module-secondary:active { background: var(--brand-soft); }
.btn-module-secondary {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}
.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.42);
}
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: var(--max);
  max-height: min(78vh, 560px);
  overflow: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 28px rgba(16, 24, 40, 0.14);
  padding: 12px 14px calc(16px + var(--safe-b));
  z-index: 1;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.sheet-title {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.35;
  min-width: 0;
}
.sheet-close {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 999px;
}
.sheet-close:hover { background: var(--bg); color: var(--text); }
.sheet-body { display: flex; flex-direction: column; gap: 8px; }
.sheet-action-btn { width: 100%; min-height: 44px; }
.sheet-mode-btn { width: 100%; }
@media (min-width: 720px) {
  .sheet-root { align-items: center; padding: 24px; }
  .sheet-panel {
    border-radius: 18px;
    max-width: 420px;
    max-height: min(70vh, 520px);
  }
}


.wrong-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.wrong-card:hover { border-color: var(--brand-edge); }
.wrong-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.wrong-title {
  margin: 0;
  font-size: 14px;
  font-weight: 740;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}
.wrong-meta {
  margin: 0;
  color: var(--muted-2);
  font-size: 12px;
}
.wrong-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}
.wrong-actions .btn {
  flex: 1;
  min-height: 40px;
}

.page-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.page-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.back-btn {
  flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
}

/* 模式选择：紧凑 action list */
.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  min-height: 56px;
}
.mode-btn:last-child { border-bottom: 0; }
.mode-btn:active { background: #f7f9fc; }
.mode-btn .mode-text { min-width: 0; flex: 1; }
.mode-btn strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
  font-weight: 740;
}
.mode-btn span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.mode-btn .mode-chevron {
  color: var(--muted-2);
  font-size: 16px;
  flex: 0 0 auto;
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eef1f5 25%, #f7f8fa 37%, #eef1f5 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
  height: 72px;
  margin-bottom: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 16px; }
.error-box {
  padding: 16px;
  border-radius: var(--radius);
  background: #fff5f5;
  border: 1px solid #ffd2d2;
  color: #9b1c1c;
}
.load-more { margin-top: 12px; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

@media (max-width: 374px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .hero h1 { font-size: 22px; }
  .acc { font-size: 16px; }
}

/* Practice records grouping + status */
.records-group-title { margin-top: 10px; }
.record-card { cursor: pointer; }
.record-card:active { transform: scale(0.995); }
.record-card-progress { border-color: var(--brand-edge); }
.record-card-stale { opacity: 0.78; }
.acc-progress { color: var(--brand); font-size: 16px; }
.acc-stale { color: var(--muted-2); font-size: 13px; font-weight: 650; }

.chip-ok {
  background: var(--good-soft);
  color: var(--good);
}
.chip-bad {
  background: #fff1f0;
  color: #c0392b;
}

/* Result detail */
.result-summary { margin-bottom: 12px; }
.result-stats { margin-top: 10px; align-items: baseline; gap: 12px; }
.result-note {
  margin: 8px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.4;
}
.result-tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 12px;
}
.result-tab {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}
.result-tab.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}
.result-q-list { margin-bottom: 12px; }
.result-q-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.result-q-card.is-wrong { border-color: #ffd2d2; }
.result-q-card.is-correct { border-color: #cceede; }
.result-q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.result-q-idx { font-size: 12px; color: var(--muted); font-weight: 650; }
.result-q-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}
.result-q-meta {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.result-q-analysis {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f7f9fc;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}
.result-foot {
  /* Normal flow after question list — not sticky between list and bottom nav */
  position: static;
  margin-top: 8px;
  padding: 12px 0 calc(12px + var(--safe-b));
  background: transparent;
}

.wrong-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.chip-mastery {
  background: var(--brand-soft);
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wrong-item-card { cursor: default; }
.wrong-item-card:hover { border-color: var(--line); }
.wrong-q-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}
.wrong-options {
  margin: 0 0 6px;
  padding-left: 18px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
.wrong-options li { margin: 2px 0; }
.mode-btn.is-disabled,
.mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.mode-disabled-hint {
  display: block;
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 2px;
}


/* Admin-only soft entry to V1 (classic practice) */
.classic-practice {
  margin: 8px 0 0;
  font-size: 12px;
}
.classic-practice-link {
  color: var(--muted-2);
  text-decoration: none;
}
.classic-practice-link:hover {
  color: var(--muted);
  text-decoration: underline;
}
