:root {
  --outer-bg: #e2e8f0;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #111827;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --accent: #7c3aed;
  --accent-soft: #f5f3ff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  --q-font: 16px;
}

body.dark {
  --outer-bg: #050914;
  --bg: #0b1220;
  --surface: #162033;
  --surface-alt: #1f2d46;
  --text: #f1f5f9;
  --text-sub: #94a3b8;
  --border: #2c3c58;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: #1b3459;
  --ok: #22c55e;
  --ok-soft: #123624;
  --danger: #f87171;
  --danger-soft: #3c1c24;
  --warn: #fbbf24;
  --warn-soft: #3a2d11;
  --accent: #a78bfa;
  --accent-soft: #2a2048;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

body.large-font { --q-font: 19px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--outer-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Pure mobile app frame (edge-to-edge on phone, centered 480px phone shell on wide screens) */
.mobile-frame {
  max-width: 480px;
  width: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 36px rgba(15, 23, 42, 0.14);
}
@media (max-width: 500px) {
  html, body { background: var(--bg); }
  .mobile-frame { max-width: none; box-shadow: none; }
}

/* Login screen */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: linear-gradient(160deg, var(--primary-soft) 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 22px 24px;
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.1);
}
.login-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}
.login-card h1 { margin: 0; text-align: center; font-size: 20px; }
.login-sub { margin: 6px 0 22px; text-align: center; font-size: 13px; color: var(--text-sub); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.field-group input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
.field-group input:focus { border-color: var(--primary); background: var(--surface); }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 46px; }
.pwd-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 18px;
  width: 36px;
  height: 36px;
}
.login-keep-tip {
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  text-align: center;
}
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* Main shell */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.brand { display: flex; align-items: center; cursor: pointer; }
.brand-badge {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.sync-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 3px 7px;
  border-radius: 99px;
  white-space: nowrap;
}
.sync-pill.syncing { color: var(--primary); background: var(--primary-soft); }
.sync-pill.err { color: var(--warn); background: var(--warn-soft); }

.icon-btn, .ghost-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.ghost-btn.sm, .primary-btn.sm, .nav-btn.sm, .danger-btn.sm {
  padding: 6px 11px;
  font-size: 12px;
}
.file-label { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.center-text { text-align: center; }

/* Views */
.view {
  display: none;
  padding: 12px 12px calc(82px + env(safe-area-inset-bottom));
}
.view.active { display: block; }

/* Resume banner */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface));
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-bottom: 12px;
}
.resume-info { min-width: 0; flex: 1; font-size: 13px; }
.resume-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.resume-tag {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}
.resume-sub { font-size: 11px; color: var(--text-sub); }

/* Hero */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.hero-card h1 { margin: 0; font-size: 17px; }
.hero-sub { margin: 3px 0 12px; font-size: 12px; color: var(--text-sub); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
}
.stat-box.warn { border-left-color: var(--warn); }
.stat-box.danger { border-left-color: var(--danger); }
.stat-box.ok { border-left-color: var(--ok); }
.stat-num { font-size: 22px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

.hero-progress-row { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.hp-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.hp-head strong { color: var(--text); }

/* Home tabs */
.home-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.home-tabs button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  border-radius: 10px;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.home-tabs button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.home-panel { display: none; }
.home-panel.active { display: block; }

/* Cards */
.quick-grid, .stack-list { display: flex; flex-direction: column; gap: 10px; }
.quick-card {
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.quick-card:active { transform: scale(0.99); }
.quick-card h3 { margin: 7px 0 3px; font-size: 15px; color: var(--text); }
.quick-card p { margin: 0; font-size: 12px; color: var(--text-sub); }
.qc-top { display: flex; justify-content: space-between; align-items: center; }
.qc-tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--primary-soft); color: var(--primary);
}
.quick-card.danger .qc-tag { background: var(--danger-soft); color: var(--danger); }
.quick-card.warn .qc-tag { background: var(--warn-soft); color: var(--warn); }
.quick-card.info .qc-tag { background: var(--ok-soft); color: var(--ok); }
.quick-card.accent .qc-tag { background: var(--accent-soft); color: var(--accent); }
.qc-count { font-size: 12px; font-weight: 600; color: var(--text-sub); }

.cat-card, .paper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cat-title, .paper-title { font-weight: 700; font-size: 14px; }
.cat-meta, .paper-meta { font-size: 12px; color: var(--text-sub); display: flex; justify-content: space-between; }

.progress-bar { height: 6px; background: var(--surface-alt); border-radius: 99px; overflow: hidden; }
.progress-bar.lg { height: 7px; }
.progress-fill { height: 100%; background: var(--danger); border-radius: 99px; transition: width 0.25s; }
.progress-fill.ok { background: var(--ok); }
.progress-fill.primary { background: var(--primary); }
.dual-bar-wrap { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-sub); }
.bar-row span { min-width: 52px; }
.bar-row .progress-bar { flex: 1; }

.card-btn-row { display: flex; gap: 6px; }
.mini-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
}
.mini-btn:disabled { opacity: 0.45; }
.mini-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.mini-btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* Practice view */
.practice-toolbar {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 13px;
  margin-bottom: 11px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pt-row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pt-left { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; }
.pt-left strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-prog { font-size: 12px; color: var(--text-sub); font-weight: 700; white-space: nowrap; }
.acc-pill { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.pt-modes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.session-track { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--surface-alt); }
.session-track-fill { height: 100%; background: var(--primary); width: 0; transition: width 0.2s; }

.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid var(--border);
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--text-sub);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
}
.segmented button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.timer-pill {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}

.question-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 14px;
  box-shadow: var(--shadow);
  touch-action: pan-y;
}
.q-meta-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.q-badges, .q-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.badge.type { background: var(--primary-soft); color: var(--primary); }
.badge.cat { background: var(--surface-alt); color: var(--text-sub); }
.badge.hist-wrong { background: var(--danger-soft); color: var(--danger); }
.badge.hist-right { background: var(--ok-soft); color: var(--ok); }
.badge.streak { background: var(--accent-soft); color: var(--accent); }

.tool-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-sub);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.tool-chip.active, .tool-chip.unsure { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.tool-chip.mastered { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }

.q-source { font-size: 11px; color: var(--text-sub); margin-bottom: 8px; }
.q-stem { font-size: var(--q-font); font-weight: 600; margin-bottom: 14px; white-space: pre-wrap; }

.q-options { display: flex; flex-direction: column; gap: 10px; }
.opt-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  width: 100%;
  min-height: 48px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 12px 13px;
  border-radius: 11px;
  font-size: calc(var(--q-font) - 1px);
}
.opt-key {
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.opt-btn.selected { border-color: var(--primary); background: var(--primary-soft); }
.opt-btn.selected .opt-key { background: var(--primary); color: #fff; border-color: var(--primary); }
.opt-btn.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt-btn.correct .opt-key { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt-btn.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt-btn.wrong .opt-key { background: var(--danger); color: #fff; border-color: var(--danger); }

.q-action-row { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.primary-btn, .danger-btn {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}
.danger-btn { background: var(--danger); }
.full-btn { width: 100%; height: 46px; font-size: 15px; }
.hint-text { font-size: 12px; color: var(--text-sub); }

.analysis-box {
  margin-top: 16px;
  padding: 13px;
  border-radius: 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.analysis-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.analysis-head.ok { color: var(--ok); }
.analysis-head.wrong { color: var(--danger); }
.diag-tip {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}
.analysis-answers { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; margin-bottom: 8px; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.memory-tip-box {
  background: var(--warn-soft);
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-left: 4px solid var(--warn);
  border-radius: 9px;
  padding: 9px 11px;
  margin-bottom: 9px;
}
.memory-tip-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--warn);
  margin-bottom: 3px;
}
.memory-tip-body {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.55;
}
.wb-memory-line {
  margin: 6px 0;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  color: var(--text);
}
.analysis-text { font-size: 13px; color: var(--text); white-space: pre-wrap; border-top: 1px dashed var(--border); padding-top: 8px; }
mark.kw-num { background: rgba(37, 99, 235, 0.14); color: var(--primary); padding: 0 3px; border-radius: 4px; font-weight: 700; }
mark.kw-trap { background: rgba(220, 38, 38, 0.14); color: var(--danger); padding: 0 3px; border-radius: 4px; font-weight: 700; }

.note-area { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.note-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-sub); margin-bottom: 5px; }
.note-saved { color: var(--ok); font-weight: 600; }
.note-area textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

/* Fixed mobile bottom practice footer */
.nav-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  z-index: 46;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);
}
.nav-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.nav-btn:disabled { opacity: 0.4; }
.nav-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Slide-over answer sheet drawer */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: rgba(15, 23, 42, 0.45);
}
.answer-sheet {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 86vw;
  max-width: 340px;
  z-index: 90;
  background: var(--surface);
  padding: 14px;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
}
.answer-sheet.open { display: flex; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-header h3 { margin: 0; font-size: 15px; }
.sheet-filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.sheet-filters button {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-sub);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
}
.sheet-filters button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.sheet-stats { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.sheet-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; overflow-y: auto; }
.sheet-cell {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.sheet-cell.current { outline: 2px solid var(--primary); }
.sheet-cell.right { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.sheet-cell.wrong { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.sheet-cell.answered { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.sheet-cell.hist-dot::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--danger);
}

/* Wrong-book & Search */
.wb-header-card, .search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wb-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wb-title-row h2 { margin: 0; font-size: 16px; }
.wb-actions { display: flex; gap: 5px; }
.wb-filters { display: flex; flex-direction: column; gap: 8px; }
.wb-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.wb-tabs button {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-sub);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}
.wb-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.wb-search {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 14px;
}
.wb-selects { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wb-selects select {
  flex: 1;
  min-width: 100px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
}
.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 5px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: nowrap;
}
.wb-list, .search-results { display: flex; flex-direction: column; gap: 10px; }
.wb-card, .search-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  box-shadow: var(--shadow);
}
.wb-card-top, .search-item-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.wb-card-actions { display: flex; gap: 5px; flex-shrink: 0; }
.wb-note-line { margin-top: 6px; font-size: 12px; padding: 5px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.load-more-wrap { text-align: center; margin-top: 12px; }
.print-only-header { display: none; }

.hot-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.hot-tags button {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 12px;
}
.search-meta { font-size: 12px; color: var(--text-sub); }

/* Guide */
.guide-container { display: flex; flex-direction: column; gap: 12px; }
.guide-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
}
.guide-toolbar > div { display: flex; flex-direction: column; }
.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.guide-card h2 { margin: 0 0 10px; font-size: 15px; }
.alert-card { border-left: 4px solid var(--danger); }
.alert-card ul, .cheat-ul { margin: 0; padding-left: 18px; font-size: 13px; }
.alert-card li, .cheat-ul li { margin-bottom: 6px; }
.compare-list { display: flex; flex-direction: column; gap: 10px; }
.cmp-item {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.guide-masked .maskable {
  filter: blur(6px);
  background: var(--surface);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s;
}
body.guide-masked .maskable.unmasked { filter: none; user-select: auto; }

/* Rank & History */
.rank-list, .history-list { display: flex; flex-direction: column; gap: 9px; }
.rank-row { display: flex; flex-direction: column; gap: 4px; }
.rank-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; gap: 6px; }
.rank-btn { border: none; background: transparent; color: var(--primary); font-size: 12px; font-weight: 700; padding: 0; white-space: nowrap; }
.history-row {
  background: var(--surface-alt);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Mobile bottom nav */
.mobile-bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}
.mobile-bottom-nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 18px;
  padding: 3px 0;
}
.mobile-bottom-nav button small { font-size: 11px; font-weight: 600; }
.mobile-bottom-nav button.active { color: var(--primary); }
.tab-dot {
  position: absolute;
  top: 0;
  right: 18%;
  font-style: normal;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 99px;
  line-height: 1.5;
}

/* Modal & Exam Report */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.modal-opt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.modal-opt-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 8px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
}
.modal-opt-btn:disabled { opacity: 0.45; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.report-score-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface-alt);
  border-left: 5px solid var(--ok);
}
.report-score-box.fail { border-left-color: var(--danger); }
.report-big-score { font-size: 28px; font-weight: 800; line-height: 1.1; }
.report-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.report-mini { background: var(--surface-alt); border-radius: 8px; padding: 8px 6px; text-align: center; font-size: 11px; }
.report-mini strong { display: block; font-size: 13px; margin-top: 2px; }
.report-weak-list { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }

/* Toast */
.toast-root {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  pointer-events: none;
}
.toast-item {
  background: #111827;
  color: #fff;
  padding: 8px 15px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.toast-item.ok { background: #15803d; }
.toast-item.warn { background: #b45309; }

@media print {
  html, body, .mobile-frame { background: #fff; color: #000; max-width: none; box-shadow: none; }
  .no-print, .topbar, .wb-card-actions, .mobile-bottom-nav, .nav-footer { display: none !important; }
  .print-only-header { display: block; margin-bottom: 12px; border-bottom: 2px solid #000; padding-bottom: 6px; }
  .view { padding: 0; }
  .wb-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; page-break-inside: avoid; margin-bottom: 8px; }
}
