:root {
  --bg: #f5f2eb;
  --bg-subtle: #eae4d8;
  --surface: #ffffff;
  --surface-elevated: #fdfcf9;
  --border: #e5dfd3;
  --text: #1c2229;
  --text-muted: #5f6975;
  --text-light: #8e97a3;

  --accent: #2b4c7e;
  --accent-hover: #203b64;
  --accent-soft: #e9f0fa;

  --red-ink: #c62828;
  --red-bg: #fff0f0;
  --red-border: #f7c7c7;

  --amber-ink: #9c5300;
  --amber-bg: #fffbeb;
  --amber-border: #fce08b;

  --green-ink: #17723d;
  --green-bg: #eafbf0;
  --green-border: #9de5b9;

  --purple-ink: #6d28d9;

  --shadow-card: 0 12px 32px rgba(28, 34, 41, 0.09), 0 2px 6px rgba(28, 34, 41, 0.04);
  --shadow-stack: 0 4px 12px rgba(28, 34, 41, 0.05);
  --shadow-btn: 0 6px 18px rgba(43, 76, 126, 0.24);
  --radius-card: 22px;
  --radius-sheet: 22px;
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark {
  --bg: #111419;
  --bg-subtle: #1a1f27;
  --surface: #1d232c;
  --surface-elevated: #232a35;
  --border: #2c3543;
  --text: #edf1f7;
  --text-muted: #9eaab8;
  --text-light: #6e7a89;

  --accent: #6ea0f5;
  --accent-hover: #8bb4f8;
  --accent-soft: rgba(110, 160, 245, 0.15);

  --red-ink: #ff7b7b;
  --red-bg: rgba(255, 107, 107, 0.14);
  --red-border: rgba(255, 107, 107, 0.34);

  --amber-ink: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.12);
  --amber-border: rgba(251, 191, 36, 0.3);

  --green-ink: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.13);
  --green-border: rgba(74, 222, 128, 0.3);

  --purple-ink: #c4b5fd;

  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-stack: 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-btn: 0 8px 20px rgba(0, 0, 0, 0.35);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

.hidden {
  display: none !important;
}

/* ==================== 外壳与顶栏 ==================== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}

.scope-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 62%;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}

.scope-pill:active {
  transform: scale(0.96);
}

.scope-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.scope-dot.xianfa {
  background: var(--red-ink);
}

.scope-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 1px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.scope-chevron {
  font-size: 11px;
  color: var(--text-light);
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-ink);
  font-size: 12px;
  font-weight: 800;
  animation: streakPop 0.35s var(--ease-spring);
}

@keyframes streakPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.16); }
  100% { transform: scale(1); opacity: 1; }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.icon-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 纤细进度条 */
.progress-track {
  flex-shrink: 0;
  height: 3px;
  margin: 0 16px;
  border-radius: 99px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #4f86d6);
  transition: width 0.35s var(--ease-out);
}

/* ==================== 主舞台 ==================== */
.main-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.study-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 0;
}

/* ==================== 堆叠卡组舞台 ==================== */
.deck-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: 14px;
  perspective: 1200px;
}

.stack-card {
  position: absolute;
  inset: 0 0 14px 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  pointer-events: none;
  transition: transform 0.35s var(--ease-spring), opacity 0.35s ease;
}

.stack-card-1 {
  transform: translateY(10px) scale(0.96);
  opacity: 0.72;
  box-shadow: var(--shadow-stack);
  z-index: 1;
}

.stack-card-2 {
  transform: translateY(19px) scale(0.92);
  opacity: 0.42;
  z-index: 0;
}

.deck-stage.promoting .stack-card-1 {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.deck-stage.promoting .stack-card-2 {
  transform: translateY(10px) scale(0.96);
  opacity: 0.72;
}

/* 主闪卡 */
.flashcard {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  touch-action: pan-y;
  will-change: transform, opacity;
  transition: transform 0.32s var(--ease-spring), opacity 0.25s ease;
}

.flashcard.dragging {
  transition: none !important;
  cursor: grabbing;
}

.flashcard.fly-right {
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.26s ease !important;
  transform: translate3d(125%, -20px, 0) rotate(16deg) !important;
  opacity: 0 !important;
}

.flashcard.fly-left {
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.26s ease !important;
  transform: translate3d(-125%, -20px, 0) rotate(-16deg) !important;
  opacity: 0 !important;
}

.flashcard.fly-up {
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.24s ease !important;
  transform: translate3d(0, -60px, 0) scale(0.94) !important;
  opacity: 0 !important;
}

.flashcard.card-enter {
  animation: cardEnter 0.34s var(--ease-spring) forwards;
}

@keyframes cardEnter {
  0% {
    transform: translateY(14px) scale(0.96);
    opacity: 0.55;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* 拖拽印章 */
.swipe-stamp {
  position: absolute;
  top: 22px;
  z-index: 10;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0;
  border: 2.5px solid currentColor;
  backdrop-filter: blur(4px);
}

.stamp-right {
  left: 18px;
  color: var(--green-ink);
  background: var(--green-bg);
  transform: rotate(-10deg);
}

.stamp-left {
  right: 18px;
  color: var(--red-ink);
  background: var(--red-bg);
  transform: rotate(10deg);
}

/* 卡片顶栏 */
.card-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px 10px;
  border-bottom: 1px dashed var(--border);
}

.card-path {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.subject-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.subject-tag.xianfa {
  background: var(--red-bg);
  color: var(--red-ink);
}

.chapter-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.diff-stars {
  font-size: 11px;
  color: var(--amber-ink);
  letter-spacing: -1px;
}

.page-tag {
  font-size: 11.5px;
  color: var(--text-light);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-new { background: var(--bg-subtle); color: var(--text-muted); }
.status-forgot { background: var(--red-bg); color: var(--red-ink); }
.status-fuzzy { background: var(--amber-bg); color: var(--amber-ink); }
.status-mastered { background: var(--green-bg); color: var(--green-ink); }

/* 卡片内部滚动体 */
.card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
}

/* 正面：居中专注 */
.card-front {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 6px;
  cursor: pointer;
  user-select: none;
}

.type-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 3px 11px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.front-question {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.55;
  color: var(--text);
  max-width: 30em;
}

.front-cue {
  margin-top: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-light);
}

.cue-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulseDot 1.8s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(0.85); opacity: 0.4; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* 背面解析 */
.card-back {
  animation: backReveal 0.28s var(--ease-out);
}

@keyframes backReveal {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.back-question-summary {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.back-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-light);
  margin-bottom: 10px;
}

.mask-hint {
  color: var(--accent);
  font-weight: 700;
}

.answer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 14px;
}

.answer-list li {
  padding: 10px 13px;
  background: var(--bg);
  border-radius: 12px;
  border-left: 3px solid var(--accent);
  font-size: 15px;
  line-height: 1.68;
  opacity: 0;
  animation: staggerIn 0.3s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 42ms);
}

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

/* 红字高亮与弹性遮罩 */
.hl-red {
  color: var(--red-ink);
  font-weight: 700;
  background: var(--red-bg);
  padding: 1px 5px;
  border-radius: 5px;
}

.hl-masked {
  display: inline-block;
  background: var(--accent);
  color: transparent !important;
  border-radius: 5px;
  padding: 0 6px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.16s var(--ease-spring), background 0.18s ease, color 0.18s ease;
}

.hl-masked:active {
  transform: scale(0.94);
}

.hl-masked.revealed {
  background: var(--red-bg);
  color: var(--red-ink) !important;
  font-weight: 700;
  animation: maskPop 0.25s var(--ease-spring);
}

@keyframes maskPop {
  0% { transform: scale(0.92); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* 避坑框 & 谐音口诀框 */
.callout {
  border-radius: 13px;
  padding: 12px 14px;
  margin-bottom: 11px;
  border: 1px solid transparent;
  animation: staggerIn 0.32s var(--ease-out) 0.12s both;
}

.callout-trap {
  background: var(--red-bg);
  border-color: var(--red-border);
}

.callout-trap .callout-title {
  color: var(--red-ink);
}

.callout-mnemonic {
  background: var(--amber-bg);
  border-color: var(--amber-border);
}

.callout-mnemonic .callout-title {
  color: var(--amber-ink);
}

.callout-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
}

.callout-body {
  font-size: 14px;
  line-height: 1.62;
  color: var(--text);
}

/* 按需折叠个人笔记 */
.note-section {
  margin-top: 6px;
}

.note-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.note-toggle-btn.has-note {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.note-saved {
  color: var(--green-ink);
  font-size: 12px;
}

.note-wrap {
  margin-top: 8px;
}

.note-wrap textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  resize: none;
  outline: none;
}

.note-wrap textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.swipe-hint-inline {
  margin-top: 14px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-light);
}

/* ==================== 底部固定拇指区 ==================== */
.thumb-bar {
  flex-shrink: 0;
  padding: 8px 0 calc(14px + env(safe-area-inset-bottom, 0px));
}

.thumb-reveal {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-circle {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.14s ease, opacity 0.15s ease;
}

.nav-circle:active {
  transform: scale(0.92);
}

.nav-circle:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-reveal-main {
  flex: 1;
  height: 50px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #3a63a0);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-btn);
  transition: transform 0.15s var(--ease-spring), filter 0.15s ease;
  font-family: inherit;
}

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

.key-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.2);
}

.thumb-rating {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  animation: backReveal 0.2s var(--ease-out);
}

.rate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  height: 58px;
  border-radius: 16px;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.14s var(--ease-spring), box-shadow 0.15s ease;
}

.rate-btn:active {
  transform: scale(0.93);
}

.rate-emoji {
  font-size: 16px;
  line-height: 1.1;
}

.rate-text {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.rate-hint {
  font-size: 10.5px;
  opacity: 0.8;
}

.rate-forgot {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red-ink);
}

.rate-fuzzy {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-ink);
}

.rate-mastered {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green-ink);
}

/* ==================== 空状态 ==================== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 14px;
}

.empty-icon { font-size: 46px; margin-bottom: 10px; }
.empty-state h2 { font-size: 18px; margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; }

/* ==================== 谐音口诀手册视图 ==================== */
.mnemonics-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 0;
}

.mn-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.mn-topbar h2 { font-size: 17px; }
.mn-topbar p { font-size: 12px; color: var(--text-muted); }

.mn-topbar-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.mnemonics-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.mn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mn-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mn-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--amber-ink);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  padding: 7px 11px;
  border-radius: 10px;
}

.mn-content { font-size: 13.5px; line-height: 1.62; color: var(--text); }
.mn-front { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }

.mn-answer {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  line-height: 1.65;
}

.mn-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2px;
}

/* ==================== 底部抽屉 Bottom Sheet ==================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 16, 23, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeBackdrop 0.2s ease;
}

@keyframes fadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bottom-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 84dvh;
  background: var(--surface);
  border-top-left-radius: var(--radius-sheet);
  border-top-right-radius: var(--radius-sheet);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.22);
  animation: sheetSlideUp 0.28s var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-sheet-compact {
  max-height: 75dvh;
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle-wrap {
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.sheet-header h3 { font-size: 16px; font-weight: 800; }

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* 抽屉内统计条 */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-stat {
  background: var(--bg);
  border-radius: 12px;
  padding: 9px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.mini-stat strong { font-size: 17px; font-weight: 800; color: var(--text); line-height: 1.2; }
.mini-stat span { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.mini-stat.is-green strong { color: var(--green-ink); }
.mini-stat.is-red strong { color: var(--red-ink); }

.subject-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 11px;
  gap: 3px;
}

.subject-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 0;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
}

.subject-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.search-box input {
  width: 100%;
  padding: 10px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.search-box input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-red.active { background: var(--red-ink); border-color: var(--red-ink); }
.chip-amber.active { background: #d97706; border-color: #d97706; }
.chip-green.active { background: var(--green-ink); border-color: var(--green-ink); }
.chip-purple.active { background: var(--purple-ink); border-color: var(--purple-ink); }
.chip-gold.active { background: #b45309; border-color: #b45309; }

.chapter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-light);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chapter-group-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 6px;
}

.chapter-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}

.chapter-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.chapter-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.chapter-count { font-size: 12px; color: var(--text-muted); }

.chapter-bar {
  margin-top: 6px;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.chapter-bar-fill {
  height: 100%;
  background: var(--green-ink);
  border-radius: 99px;
  transition: width 0.25s ease;
}

/* 设置抽屉磁贴 */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.quick-tile:active { transform: scale(0.97); }
.tile-icon { font-size: 18px; }

.sheet-divider { height: 1px; background: var(--border); }
.sheet-sublabel { font-size: 12px; font-weight: 700; color: var(--text-light); }

.backup-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 通用小按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--red-ink); color: #fff; }
.btn-danger-outline { background: transparent; border-color: var(--red-border); color: var(--red-ink); }
.link-btn { border: none; background: none; color: var(--accent); font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit; }

/* ==================== 纸屑微粒子 ==================== */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  overflow: hidden;
}

.confetti-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiBurst 0.72s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes confettiBurst {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.35) rotate(var(--rot));
    opacity: 0;
  }
}

/* Toast */
.toast {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--text);
  color: var(--surface);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  animation: toastIn 0.22s var(--ease-spring);
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ==================== 桌面宽屏微调 ==================== */
@media (min-width: 680px) {
  .study-view {
    padding: 18px 24px 0;
  }
  .front-question {
    font-size: 24px;
  }
  .card-body {
    padding: 22px 28px 26px;
  }
  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }
  .bottom-sheet {
    border-radius: 22px;
    max-height: 82vh;
  }
  .mnemonics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
  }
}

@media (max-width: 679px) {
  .key-badge {
    display: none;
  }
}
