/* ====== CSS Variables ====== */
:root {
  /* 背景和文字 */
  --bg: #FFF8F0;
  --card-bg: #FFFFFF;
  --text: #2C2C2C;
  --text-light: #888888;

  /* 按钮色 */
  --green: #4CAF50;
  --orange: #FF9800;
  --red: #E74C3C;

  /* 物质颜色 */
  --color-cu: #C44B4B;
  --color-cuo: #2C2C2C;
  --color-cuso4: #2980B9;
  --color-fe: #B0B0B0;
  --color-fe2o3: #A0522D;
  --color-fe3o4: #2C2C2C;
  --color-fe2-plus: #7DCEA0;
  --color-fe3-plus: #D4A017;
  --color-s: #F4D03F;
  --color-p: #C0392B;
  --color-c: #2C2C2C;
  --color-mno2: #2C2C2C;
  --color-kmno4: #6C3483;
  --color-white-solid: #E5E5E5;

  /* 条件标签色 */
  --tag-ignite: #E74C3C;
  --tag-heat: #FF9800;
  --tag-high-temp: #2C2C2C;
  --tag-catalyst: #2980B9;
  --tag-electric: #2980B9;

  /* 其他 */
  --shadow-card: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 16px;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ====== Page System ====== */
.page,
[id^="page-"] {
  display: none;
}

.page.active,
[id^="page-"].active {
  display: flex;
  flex-direction: column;
}

/* ====== Card Generic ====== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin: 16px;
}

/* ====== Card Flip Animation ====== */
.card-inner {
  position: relative;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  backface-visibility: hidden;
}

.card-front {
  cursor: pointer;
}

.card-back {
  transform: rotateY(180deg);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ====== Card Layers ====== */
.card-layer-1 {
  /* 默认可见 */
}

.card-layer-2,
.card-layer-3 {
  display: none;
}

.card-layer-2.show,
.card-layer-3.show {
  display: block;
}

/* ====== Bottom Tab Bar ====== */
.tab-bar {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 500px;
  height: 60px;
  display: flex;
  background: white;
  border-top: 1px solid #eee;
  z-index: 100;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.tab-item.active {
  color: var(--green);
  border-bottom: 3px solid var(--green);
}

/* ====== Button Styles ====== */
.btn-remember {
  background: var(--green);
  color: white;
  padding: 16px 32px;
  border-radius: 30px;
  font-size: 1.1rem;
  border: none;
  flex: 1;
  cursor: pointer;
  min-height: 44px;
}

.btn-remember:active {
  opacity: 0.85;
}

.btn-forget {
  background: var(--orange);
  color: white;
  padding: 16px 32px;
  border-radius: 30px;
  font-size: 1.1rem;
  border: none;
  flex: 1;
  cursor: pointer;
  min-height: 44px;
}

.btn-forget:active {
  opacity: 0.85;
}

.btn-row {
  display: flex;
  gap: 16px;
  padding: 16px;
}

/* ====== Condition Tags ====== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  margin: 0 2px;
}

.tag-ignite {
  background: var(--tag-ignite);
  color: white;
}

.tag-heat {
  background: var(--tag-heat);
  color: white;
}

.tag-high-temp {
  background: var(--tag-high-temp);
  color: white;
}

.tag-catalyst {
  background: var(--tag-catalyst);
  color: white;
}

.tag-electric {
  background: var(--tag-electric);
  color: white;
}

/* ====== Chemical Formula Colors ====== */
.chem-cu {
  color: var(--color-cu);
  font-weight: bold;
}

.chem-cuo {
  color: var(--color-cuo);
  font-weight: bold;
}

.chem-cuso4 {
  color: var(--color-cuso4);
  font-weight: bold;
}

.chem-fe {
  color: var(--color-fe);
  font-weight: bold;
}

.chem-fe2o3 {
  color: var(--color-fe2o3);
  font-weight: bold;
}

.chem-fe3o4 {
  color: var(--color-fe3o4);
  font-weight: bold;
}

.chem-fe2-plus {
  color: var(--color-fe2-plus);
  font-weight: bold;
}

.chem-fe3-plus {
  color: var(--color-fe3-plus);
  font-weight: bold;
}

.chem-s {
  color: var(--color-s);
  font-weight: bold;
}

.chem-p {
  color: var(--color-p);
  font-weight: bold;
}

.chem-c {
  color: var(--color-c);
  font-weight: bold;
}

.chem-mno2 {
  color: var(--color-mno2);
  font-weight: bold;
}

.chem-kmno4 {
  color: var(--color-kmno4);
  font-weight: bold;
}

.chem-white-solid {
  background: var(--color-white-solid);
  color: #555;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: bold;
}

/* ====== Mobile Responsive ====== */
@media (max-width: 500px) {
  .card {
    padding: 16px;
  }

  .btn-remember,
  .btn-forget {
    padding: 14px 24px;
  }
}

/* ====== Touch Target ====== */
button,
input,
select,
textarea,
a,
.tab-item,
[role="button"],
[onclick] {
  min-height: 44px;
}

/* ====== Toast Animation ====== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 200;
  animation: fadeInOut 1.5s;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  15% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ====== Guide Page ====== */
.guide-page {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: #FFF8F0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
}
.guide-container {
  text-align: center; max-width: 350px; padding: 20px;
  width: 100%; min-height: 400px; position: relative;
}
.guide-slide { display: none; }
.guide-slide.active { display: block; animation: fadeIn 0.3s; }
.guide-emoji { font-size: 4rem; margin-bottom: 20px; }
.guide-slide h2 { font-size: 1.3rem; margin-bottom: 8px; color: #2C2C2C; }
.guide-slide p { font-size: 1rem; color: #888; line-height: 1.6; }
.guide-dots { margin-top: 30px; }
.dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; background: #ccc; margin: 0 5px;
  cursor: pointer; padding: 5px;
}
.dot.active { background: #4CAF50; width: 24px; border-radius: 5px; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== Invite Page ====== */
/* ====== Complete Animation ====== */
.complete-animation {
  text-align: center;
  padding: 40px 20px;
  animation: scaleIn 0.5s;
}

@keyframes scaleIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ====== 方程式课本标准格式 ====== */
.equation-wrapper {
  display: block;
  text-align: center;
  font-weight: bold;
  font-size: 1.8rem;
  padding: 20px 0;
  line-height: 2;
  white-space: nowrap;
}
@media (max-width: 380px) {
  .equation-wrapper { font-size: 1.4rem; }
}
.equation-mid {
  display: inline-block;
  position: relative;
  vertical-align: middle;
  margin: 0 4px;
}
.equation-condition {
  display: block;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: bold;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 3px;
  color: white;
  line-height: 1.4;
  min-width: max-content;
}
.equation-equals {
  display: inline-block;
  font-size: 1.2rem;
  letter-spacing: 2px;
}
.equation-left,
.equation-right {
  display: inline-block;
  vertical-align: middle;
}

/* 归类卡纯文本答案 */
.category-answer {
  font-size: 1.05rem;
  line-height: 1.8;
  text-align: left;
  padding: 8px 4px;
}

/* ====== Body padding (为底部Tab留空间) ====== */
body {
  padding-bottom: 70px;
}

/* ====== Main Page Container Styles ====== */
#page-review {
  padding: 12px;
}

/* ====== 顶部信息栏 ====== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: white;
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.countdown-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.countdown {
  font-size: 1rem;
  font-weight: bold;
  color: #2C2C2C;
}
.countdown.warning {
  color: #FF9800;
}
.countdown.urgent {
  color: #E74C3C;
}
.countdown.exam-over {
  color: #888;
  font-weight: normal;
  font-size: 0.85rem;
}
.daily-goal {
  font-size: 0.8rem;
  color: #888;
}
.progress-text {
  color: #888;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ====== 筛选栏 ====== */
.filter-bar {
  position: relative;
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.module-panel {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 50;
  min-width: 200px;
  max-width: 92vw;
  max-height: 65vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
  margin-top: 4px;
}
.module-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}
.module-item:hover {
  background: #f5f5f5;
}
.module-item input {
  margin-right: 8px;
}
/* 进阶面板分区标题 */
.module-section-title {
  font-size: 0.72rem;
  color: #aaa;
  padding: 8px 16px 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.module-item.module-item-card {
  padding-left: 24px;
  font-size: 0.82rem;
}
.module-item.module-item-sub {
  padding-left: 36px;
  font-size: 0.78rem;
  color: #666;
}
.filter-btn {
  padding: 8px 14px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #555;
}

/* ====== 交错练习标识栏 ====== */
.interleave-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 8px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.interleave-tag {
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.interleave-progress {
  flex: 1;
  font-size: 0.85rem;
  color: #555;
  text-align: center;
}
.interleave-exit-btn {
  background: none;
  border: 1px solid #ccc;
  color: #888;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
.interleave-exit-btn:active {
  background: #f5f5f5;
}

/* ====== 卡片容器与翻面 ====== */
.card-container {
  perspective: 1000px;
  margin: 8px 0;
  width: 100%;
}
.card-inner {
  position: relative;
  width: 100%;
  min-height: 350px;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  cursor: pointer;
}
.card-inner.flipped {
  transform: rotateY(180deg);
}
.card-front,
.card-back {
  backface-visibility: hidden;
  background: white;
  border-radius: 16px;
  padding: 28px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 100%;
  box-sizing: border-box;
}
.card-front {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  font-size: 1.3rem;
  font-weight: bold;
  text-align: center;
  color: #2C2C2C;
}
.card-back {
  position: absolute;
  top: 0;
  left: 0;
  min-height: 350px;
  transform: rotateY(180deg);
  overflow-y: auto;
}
.card-hint {
  color: #888;
  font-size: 16px;
}

/* ====== 卡片分层内容 ====== */
.card-layer-1 {
  font-size: 1.3rem;
  font-weight: bold;
  text-align: center;
  padding: 16px 0;
  margin-bottom: 16px;
}
.card-layer-2 {
  display: none;
  margin-top: 12px;
}
.card-layer-3 {
  display: none;
  margin-top: 12px;
}
.card-layer-2.show,
.card-layer-3.show {
  display: block;
}
.layer-label {
  font-size: 12px;
  color: #4CAF50;
  font-weight: 600;
  margin-bottom: 6px;
}
.layer-content {
  font-size: 15px;
  line-height: 1.6;
}

/* ====== 考点表格 ====== */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.85rem;
}
.breakdown-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}
.breakdown-table td:first-child {
  color: #888;
  white-space: nowrap;
  width: 25%;
  font-weight: bold;
}

/* ====== 条件标签 ====== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  margin: 0 2px;
  color: white;
}
.tag-ignite { background: #E74C3C; }
.tag-heat { background: #FF9800; }
.tag-high-temp { background: #2C2C2C; }
.tag-catalyst { background: #2980B9; }
.tag-electric { background: #2980B9; }

/* ====== 按钮行 ====== */
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* 记住了 / 没记住 按钮 */
.btn-forgot,
.btn-remembered,
.btn-forget,
.btn-remember {
  flex: 1;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: normal;
  min-height: 32px;
  background: transparent;
}
.btn-forgot,
.btn-forget {
  color: #FF9800;
  border: 1px solid #FF9800;
}
.btn-remembered,
.btn-remember {
  color: #4CAF50;
  border: 1px solid #4CAF50;
}
.btn-forgot:active,
.btn-forget:active {
  background: rgba(255,152,0,0.1);
}
.btn-remembered:active,
.btn-remember:active {
  background: rgba(76,175,80,0.1);
}
.review-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  padding: 0 16px;
}

/* ====== 展开联想按钮 ====== */
.expand-btn {
  display: block;
  width: 100%;
  padding: 6px;
  background: none;
  border: 1px dashed #ddd;
  border-radius: 6px;
  color: #999;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 8px;
}

/* ====== 卡片区域布局 ====== */
.card-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ====== 底部Tab栏 (HTML用.bottom-nav/.nav-btn) ====== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  height: 60px;
  display: flex;
  background: white;
  border-top: 1px solid #eee;
  z-index: 100;
}
.nav-btn {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  cursor: pointer;
  color: #888;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  min-height: 44px;
}
.nav-btn .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.nav-btn.active {
  color: #4CAF50;
  border-bottom: 3px solid #4CAF50;
}
.nav-label {
  font-size: 11px;
}

/* ====== 错题本页 ====== */
.page-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 16px;
  text-align: center;
}
.sub-tabs {
  display: flex;
  margin-bottom: 12px;
}
.sub-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  border-bottom: 2px solid #ddd;
  font-size: 0.9rem;
  color: #888;
  background: none;
}
.sub-tab.active {
  border-bottom-color: #4CAF50;
  color: #4CAF50;
  font-weight: bold;
}
.sub-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.placeholder-text {
  color: #888;
  font-size: 15px;
}
.hidden {
  display: none;
}

/* ====== 错题本/收藏列表 ====== */
.error-item, .fav-item {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.error-item .card-title, .fav-item .card-title {
  flex: 1;
  font-size: 0.85rem;
  padding-right: 8px;
}
.review-one-btn {
  background: none;
  border: 1px solid #FF9800;
  color: #FF9800;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  margin-left: 4px;
}
.unfav-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  margin-left: 4px;
}
.review-all-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: #FF9800;
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  cursor: pointer;
}

/* ====== 配平页 ====== */
#page-balance.active {
  height: calc(100vh - 70px);
  padding: 0;
}
#page-balance .balance-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 8px;
}
#page-balance .balance-card {
  width: 100%;
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  box-sizing: border-box;
}
#page-balance .balance-question-text {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.7;
  margin-bottom: 12px;
  text-align: left;
}
#page-balance .balance-reactants {
  font-size: 1.4rem;
  font-weight: bold;
  color: #2C2C2C;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 1px;
  line-height: 1.6;
}
#page-balance .balance-reactants .highlight-blank {
  background: #FFF9C4;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
  color: #E65100;
}
#page-balance .balance-condition-wrap {
  text-align: center;
  min-height: 24px;
}
#page-balance .balance-condition-wrap .tag {
  font-size: 0.75rem;
  padding: 2px 10px;
}
/* 固定底部输入行 */
#page-balance .balance-input-row {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-top: 1px solid #eee;
  align-items: center;
  flex-shrink: 0;
}
#page-balance .balance-input {
  flex: 3;
  height: 48px;
  padding: 0 16px;
  border: 2px solid #ddd;
  border-radius: 12px;
  font-size: 1.05rem;
  outline: none;
  text-align: center;
  box-sizing: border-box;
  min-width: 0;
}
#page-balance .balance-input:focus {
  border-color: #4CAF50;
}
#page-balance .balance-submit-btn {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: #4CAF50;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#page-balance .balance-submit-btn:active {
  opacity: 0.85;
}
#page-balance .balance-next-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 8px;
  padding: 10px 0;
  border: 1px solid #4CAF50;
  border-radius: 10px;
  background: none;
  color: #4CAF50;
  font-size: 15px;
  cursor: pointer;
}
#page-balance .balance-feedback {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
}
#page-balance .balance-feedback.correct {
  background: #E8F5E9;
  color: #2E7D32;
}
#page-balance .balance-feedback.wrong {
  background: #FFEBEE;
  color: #C62828;
}
#page-balance .balance-feedback .correct-answer {
  display: block;
  margin-top: 6px;
  padding: 8px 12px;
  background: #FFF3E0;
  border-radius: 4px;
  font-weight: bold;
  color: #E65100;
  font-size: 1.05rem;
}
#page-balance .balance-feedback .user-answer {
  display: block;
  margin-top: 4px;
  color: #888;
  font-size: 0.85rem;
}

/* ====== 统计页 ====== */
.stat-cards {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  padding: 0 12px;
}
.stat-card {
  flex: 1;
  background: white;
  padding: 16px 8px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.stat-num {
  font-size: 1.6rem;
  font-weight: bold;
  color: #2C2C2C;
}
.stat-label {
  font-size: 0.75rem;
  color: #888;
  margin-top: 4px;
}

.today-summary {
  padding: 0 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: #555;
}

/* 7天趋势柱状图 */
.trend-section {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin: 0 12px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.trend-section h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-top: 8px;
}
.trend-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.trend-bar {
  width: 100%;
  max-width: 30px;
  background: #4CAF50;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}
.trend-date {
  font-size: 0.65rem;
  color: #888;
  margin-top: 4px;
}
.trend-count {
  font-size: 0.7rem;
  color: #4CAF50;
  font-weight: bold;
  margin-bottom: 2px;
}

/* 薄弱模块 */
.weak-section {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin: 0 12px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.weak-section h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.weak-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.weak-item:last-child {
  border-bottom: none;
}
.weak-name {
  font-size: 0.85rem;
  color: #2C2C2C;
}
.weak-count {
  font-size: 0.8rem;
  color: #E74C3C;
  font-weight: bold;
}
.weak-review-btn {
  background: none;
  border: 1px solid #FF9800;
  color: #FF9800;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
}

/* 重置按钮 */
#resetProgressBtn {
  display: block;
  width: calc(100% - 24px);
  padding: 12px;
  margin: 0 12px 20px;
  background: none;
  border: 1px solid #E74C3C;
  color: #E74C3C;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* 已掌握列表项（保留在统计页内） */
.mastered-item {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.mastered-item .card-title {
  flex: 1;
  font-size: 0.9rem;
}
.mastered-item .re-review-btn {
  background: none;
  border: 1px solid #4CAF50;
  color: #4CAF50;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ====== 横屏适配 ====== */
@media (orientation: landscape) {
  .card-inner { min-height: 280px; }
  .card-front, .card-back { min-height: 280px; padding: 20px 32px; }
  .equation-wrapper { font-size: 2.2rem; }

/* ====== 移动端响应式 ====== */
@media (max-width: 500px) {
  .card-front,
  .card-back {
    padding: 16px;
    min-height: 260px;
  }
  .btn-forgot,
  .btn-remembered,
  .btn-forget,
  .btn-remember {
    padding: 8px 12px;
    font-size: 0.78rem;
  }
}

/* ====== 配平模式切换（prac-balance 命名空间） ====== */
#page-balance .prac-balance-mode-switch {
  display: flex;
  gap: 8px;
  margin: 8px 12px;
}
#page-balance .prac-balance-mode-btn {
  flex: 1;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.85rem;
  background: white;
  color: #888;
}
#page-balance .prac-balance-mode-active {
  background: #4CAF50;
  color: white;
  border-color: #4CAF50;
}

/* ====== 物质颜色扩展 ====== */
/* 金属单质 */
.chem-mg { color: #B0B0B0; font-weight: bold; }
.chem-al { color: #B0B0B0; font-weight: bold; }
.chem-zn { color: #8A8AAD; font-weight: bold; }
.chem-ag { color: #C0C0C0; font-weight: bold; }
.chem-hg { color: #A0A0A0; font-weight: bold; }
.chem-fe-powder { color: #555555; font-weight: bold; }

/* 氧化物 */
.chem-mgo { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-al2o3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-p2o5 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }

/* 碱类 */
.chem-ca-oh2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-mg-oh2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }

/* 盐类 */
.chem-na2co3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-nahco3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-nacl { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-cuso4-anhydrous { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-cuso4-5h2o { color: #2980B9; font-weight: bold; }
.chem-baco3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }

/* 沉淀 */
.chem-fe-oh3 { color: #A0522D; font-weight: bold; }
.chem-cu-oh2 { color: #5DADE2; font-weight: bold; }
.chem-cu2-oh-2co3 { color: #5D8C5A; font-weight: bold; }

/* 气体 */
.chem-no2 { color: #A0522D; font-weight: bold; }
.chem-so2 { color: #888888; font-weight: bold; }
.chem-nh3 { color: #888888; font-weight: bold; }
.chem-hcl { color: #888888; font-weight: bold; }

/* 其他重要物质 */
.chem-cao { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-naoh { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-h2o2 { color: #888888; font-weight: bold; }
.chem-h2so4 { color: #888888; font-weight: bold; }
.chem-i2 { color: #4A235A; font-weight: bold; }
.chem-k2mno4 { color: #1E5128; font-weight: bold; }
.chem-na2o2 { background: #F9E79F; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }

/* 气体箭头 & 沉淀箭头 */
.arrow-gas, .arrow-ppt {
  color: #2E7D32;
  font-weight: bold;
  font-size: 1.2em;
}

/* 缺失的物质颜色（按类别） */
/* 气体 */
.chem-o2 { color: #888888; font-weight: bold; }
.chem-h2 { color: #888888; font-weight: bold; }
.chem-co { color: #888888; font-weight: bold; }
.chem-co2 { color: #888888; font-weight: bold; }
.chem-br2 { color: #A0522D; font-weight: bold; }

/* 水 */
.chem-h2o { color: #1565C0; font-weight: bold; }

/* 盐类 — 白色固体 */
.chem-caco3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-mgco3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-kcl { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-kclo3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-naclo3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-znso4 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-mgcl2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-agno3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-al2-so4-3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-nh4hco3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }

/* 盐类 — 有色 */
.chem-feso4 { color: #7DCEA0; font-weight: bold; }
.chem-fecl2 { color: #7DCEA0; font-weight: bold; }
.chem-cu-no3-2 { color: #2980B9; font-weight: bold; }

/* 沉淀 */
.chem-agbr { background: #F9E79F; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-al-oh-3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-cacl2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-na2so4 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-alcl3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
/* 沉淀专项 */
.chem-agcl { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-nano3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-bacl2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-baso4 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-fecl3 { color: #D4A017; font-weight: bold; }
.chem-cucl2 { color: #2980B9; font-weight: bold; }
.chem-nh4cl { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-ba-oh2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-n2 { color: #888888; font-weight: bold; }
.chem-h2co3 { color: #888888; font-weight: bold; }
.chem-h2so3 { color: #888888; font-weight: bold; }
.chem-h2s { color: #888888; font-weight: bold; }
.chem-no { color: #888888; font-weight: bold; }
.chem-ch4o { color: #888888; font-weight: bold; }
.chem-si { color: #555555; font-weight: bold; }
.chem-na2sio3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-caso4 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-ca-hco3-2 { color: #888888; font-weight: bold; }
.chem-nano2 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-c6h12o6 { color: #888888; font-weight: bold; }
.chem-casio3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-h2sio3 { background: #E5E5E5; color: #555; padding: 0 4px; border-radius: 3px; font-weight: bold; }
.chem-hno3 { color: #888888; font-weight: bold; }
.chem-ch4 { color: #888888; font-weight: bold; }
.chem-c2h5oh { color: #888888; font-weight: bold; }

/* ====== 实验流程图页 ====== */
#page-flows,
#page-structures,
#page-decision-trees,
#page-equations,
#page-calculations,
#page-experiments,
#page-chemistry-life,
#page-question-types {
  padding: 0;
  background: #F5F5F5;
  overflow-x: hidden;
  max-width: 100vw;
}
#page-flows *,
#page-structures *,
#page-decision-trees *,
#page-equations *,
#page-calculations *,
#page-experiments *,
#page-chemistry-life *,
#page-question-types * {
  box-sizing: border-box;
}

#page-flows.active,
#page-structures.active,
#page-decision-trees.active,
#page-equations.active,
#page-calculations.active,
#page-experiments.active,
#page-chemistry-life.active,
#page-question-types.active {
  height: calc(100vh - 70px);
}

/* 顶部栏 */
.flow-top-bar {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  gap: 10px;
}
.flow-top-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: #2C2C2C;
  flex: 1;
  text-align: center;
  margin-right: 50px; /* offset to center the title */
}
.page-subtitle {
  text-align: center;
  font-size: 0.8rem;
  color: #888;
  padding: 8px;
  background: #fff;
  margin: 0;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}
.flow-back-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  background: none;
  color: #4CAF50;
  border: 1px solid #4CAF50;
  border-radius: 18px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.flow-back-btn:active {
  background: #E8F5E9;
}

/* 滚动区 */
#page-flows .flow-scroll-area,
#page-structures .flow-scroll-area,
#page-decision-trees .flow-scroll-area,
#page-equations .flow-scroll-area,
#page-calculations .flow-scroll-area,
#page-experiments .flow-scroll-area,
#page-chemistry-life .flow-scroll-area,
#page-question-types .flow-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 4px;
  max-width: 100%;
}

/* 分类卡片 */
.flow-category {
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  max-width: 100%;
}
.flow-cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.flow-cat-title {
  font-size: 1rem;
  font-weight: bold;
  color: #2C2C2C;
}
.flow-cat-arrow {
  font-size: 0.75rem;
  color: #888;
  transition: transform 0.25s;
  flex-shrink: 0;
  margin-left: 8px;
}
.flow-cat-body {
  background: #fff;
  max-width: 100%;
  overflow: hidden;
}

/* 中考用途标签 */
.flow-exam-use {
  margin: 0 6px 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: #8D6E00;
  background: #FFF8E1;
  border-left: 3px solid #FFC107;
  border-radius: 4px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* 实验子项 */
.flow-exp {
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  margin: 0 2px;
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}
.flow-exp:last-child {
  border-bottom: none;
}
.flow-exp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 10px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.flow-exp-title {
  font-size: 0.9rem;
  color: #2C2C2C;
  flex: 1;
}
.flow-exp-arrow {
  font-size: 0.7rem;
  color: #aaa;
  flex-shrink: 0;
  margin-left: 8px;
  transition: transform 0.25s;
}
.flow-exp-body {
  padding: 0 6px 10px;
}

/* SVG 容器 */
.flow-svg-wrap {
  text-align: center;
  margin: 2px 0 6px;
  background: #fff;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #eee;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.flow-svg-wrap svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.flow-svg-placeholder {
  text-align: center;
  padding: 24px;
  color: #aaa;
  font-size: 0.85rem;
  border: 1px dashed #ddd;
  border-radius: 8px;
  margin: 8px 0;
}

/* 考点列表 */
.flow-keypoints {
  padding-left: 18px;
  margin: 8px 0;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.8;
  word-break: break-word;
  overflow-wrap: break-word;
}
.flow-keypoints li {
  margin-bottom: 2px;
}
.flow-keypoints li::marker {
  color: #4CAF50;
}

/* ====== Dark Mode ====== */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --card-bg: #1e2a3a;
  --text: #e0e0e0;
  --text-light: #999;
  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
  color-scheme: dark;
}
[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] .guide-page { background: var(--bg); }
[data-theme="dark"] .card-front { background: linear-gradient(135deg, #2a3a4a, #1e2a3a); color: #e0e0e0; }
[data-theme="dark"] .card-front .card-hint { color: #888; }
[data-theme="dark"] .card-back { background: #1e2a3a; }
[data-theme="dark"] .layer-label { color: #aaa; }
[data-theme="dark"] .layer-content { color: #ccc; }
[data-theme="dark"] .btn-forgot { background: #b53a3a; color: #fff; }
[data-theme="dark"] .btn-remembered { background: #3a8a40; color: #fff; }
[data-theme="dark"] .filter-btn { background: #2a3a4a; color: #ccc; border-color: #444; }
[data-theme="dark"] .top-bar { background: #1a1a2e; border-color: #333; }
[data-theme="dark"] .bottom-nav { background: #1a1a2e; border-color: #333; }
[data-theme="dark"] .bottom-nav .nav-btn { color: #999; }
[data-theme="dark"] .bottom-nav .nav-btn.active { color: #e0e0e0; }
[data-theme="dark"] .countdown { color: #e0e0e0; }
[data-theme="dark"] .countdown.urgent { color: #ff6b6b; }
[data-theme="dark"] .countdown.warning { color: #ffa726; }
[data-theme="dark"] .interleave-bar { background: #2a3a4a; border-color: #444; }
[data-theme="dark"] .interleave-tag { color: #ccc; }
[data-theme="dark"] .module-panel { background: #1e2a3a; border-color: #444; box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
[data-theme="dark"] .module-item { color: #ccc; }
[data-theme="dark"] .module-item:hover { background: #2a3a4a; }
[data-theme="dark"] .page-title { color: #e0e0e0; }
[data-theme="dark"] .stat-card { background: #1e2a3a; box-shadow: var(--shadow-card); }
[data-theme="dark"] .stat-num { color: #e0e0e0; }
[data-theme="dark"] .stat-label { color: #999; }
[data-theme="dark"] .trend-bar { background: #5c8a5c; }
[data-theme="dark"] .error-item { background: #1e2a3a; border-color: #333; }
[data-theme="dark"] .sub-tab { background: #2a3a4a; }
[data-theme="dark"] .sub-tab.active { background: #4CAF50; color: #fff; }
[data-theme="dark"] .placeholder-text { color: #666; }
[data-theme="dark"] .weak-item { background: #2a2a3a; }
[data-theme="dark"] .balance-card { background: #1e2a3a; border-color: #333; }
[data-theme="dark"] .balance-input { background: #2a3a4a; color: #e0e0e0; border-color: #444; }
[data-theme="dark"] .balance-submit-btn { background: #4CAF50; }
[data-theme="dark"] .balance-feedback.correct { background: #2e4a2e; }
[data-theme="dark"] .balance-feedback.wrong { background: #4a2e2e; }
[data-theme="dark"] .flow-top-bar { background: #1a1a2e; border-color: #333; }
[data-theme="dark"] .flow-back-btn { color: #ccc; }
[data-theme="dark"] .flow-top-title { color: #e0e0e0; }
[data-theme="dark"] .accordion-header { background: #1e2a3a; border-color: #444; color: #e0e0e0; }
[data-theme="dark"] .accordion-content { background: #1a2a3a; color: #ccc; }
[data-theme="dark"] .flow-svg-wrap svg text { fill: #ccc !important; }
[data-theme="dark"] .flow-svg-wrap svg rect[fill="#FAFAFA"],
[data-theme="dark"] .flow-svg-wrap svg rect[fill="#fafafa"],
[data-theme="dark"] .flow-svg-wrap svg rect[fill="#FFFFFF"],
[data-theme="dark"] .flow-svg-wrap svg rect[fill="#ffffff"] { fill: #1e2a3a !important; }
[data-theme="dark"] .flow-svg-wrap svg text[fill="#444"] { fill: #bbb !important; }
[data-theme="dark"] .flow-svg-wrap svg text[fill="#333"] { fill: #ddd !important; }
[data-theme="dark"] .flow-svg-wrap svg text[fill="#888"] { fill: #999 !important; }
[data-theme="dark"] .flow-svg-wrap svg line[stroke="#E0E0E0"] { stroke: #444 !important; }
[data-theme="dark"] .expand-btn { background: #2a3a4a; color: #ccc; border-color: #555; }

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: calc(50% - 250px + 12px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
@media (max-width: 520px) {
  .theme-toggle { right: 8px; }
}
.theme-toggle:active { transform: scale(0.9); }

/* Search modal */
.search-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}
.search-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 90%;
  max-width: 460px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.search-input-row {
  display: flex;
  padding: 12px;
  gap: 8px;
  border-bottom: 1px solid #eee;
}
[data-theme="dark"] .search-input-row { border-color: #333; }
.search-input-row input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
[data-theme="dark"] .search-input-row input { border-color: #444; }
.search-input-row input:focus { border-color: #4CAF50; }
.search-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 0 8px;
}
.search-results {
  overflow-y: auto;
  max-height: 60vh;
  padding: 8px;
}
.search-result-item {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}
[data-theme="dark"] .search-result-item { border-color: #2a2a2a; }
.search-result-item:hover { background: #f5f5f5; }
[data-theme="dark"] .search-result-item:hover { background: #2a3a4a; }
.search-result-item .sr-question {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-item .sr-module {
  font-size: 0.75rem;
  color: var(--text-light);
}
.search-result-item .sr-tag {
  display: inline-block;
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}
[data-theme="dark"] .search-result-item .sr-tag { background: #2e4a2e; }

/* Undo button */
.btn-undo {
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  background: #78909C;
  color: white;
  opacity: 0.7;
  transition: opacity 0.2s;
  min-width: 80px;
}
.btn-undo:hover { opacity: 1; }
.btn-undo:disabled { opacity: 0.3; cursor: not-allowed; }

/* Module stats */
.module-stats-section { margin-top: 20px; }
.module-stat-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card-bg);
  margin-bottom: 8px;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
[data-theme="dark"] .module-stat-row { box-shadow: none; border: 1px solid #333; }
.module-stat-name {
  flex: 0 0 100px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-stat-bar-wrap {
  flex: 1;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}
[data-theme="dark"] .module-stat-bar-wrap { background: #333; }
.module-stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
  border-radius: 4px;
  transition: width 0.5s ease;
}
.module-stat-pct {
  flex: 0 0 40px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}
.module-stat-info {
  flex: 0 0 60px;
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: right;
  line-height: 1.3;
}

/* Export/Import buttons */
.data-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.data-btn {
  flex: 1;
  padding: 10px;
  border-radius: 20px;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}
.data-btn.export-btn { background: #4CAF50; color: white; }
.data-btn.import-btn { background: #FF9800; color: white; }
.data-btn:hover { opacity: 0.85; }

/* Streak badge */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #FF9800, #F44336);
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Cram mode banner */
.cram-banner {
  background: linear-gradient(135deg, #FF6B6B, #E74C3C);
  color: white;
  text-align: center;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.cram-banner button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Error book improvements */
.error-meta {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.error-module {
  font-size: 0.7rem;
  background: #E3F2FD;
  color: #1565C0;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
[data-theme="dark"] .error-module { background: #1a3a5a; color: #90CAF9; }
.error-diff {
  font-size: 0.7rem;
}
.card-answer-preview {
  display: block;
  font-size: 0.78rem;
  color: var(--text-light);
  margin: 4px 0;
  line-height: 1.4;
}
.error-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* Balance stats */
.balance-stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  text-align: center;
}
.balance-stat-item {
  flex: 1;
  background: var(--card-bg);
  padding: 10px 6px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
[data-theme="dark"] .balance-stat-item { border: 1px solid #333; box-shadow: none; }
.balance-stat-num { font-size: 1.3rem; font-weight: 700; color: #4CAF50; }
.balance-stat-num.wrong { color: #E74C3C; }
.balance-stat-label { font-size: 0.7rem; color: var(--text-light); margin-top: 2px; }

/* ====== 邀请码验证页 ====== */
.invite-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.invite-card { text-align: center; padding: 40px 30px; max-width: 360px; width: 85%; }
.invite-emoji { font-size: 3rem; margin-bottom: 12px; }
.invite-card h2 { font-size: 1.3rem; color: var(--text); margin-bottom: 6px; }
.invite-input {
  width: 100%; padding: 14px 16px; border: 2px solid #ddd;
  border-radius: 12px; font-size: 1.05rem; text-align: center;
  letter-spacing: 2px; background: var(--card-bg); color: var(--text);
  box-sizing: border-box; outline: none; transition: border-color 0.2s;
}
.invite-input:focus { border-color: #4CAF50; }
.invite-submit {
  width: 100%; margin-top: 14px; padding: 14px; background: #4CAF50;
  color: #fff; border: none; border-radius: 12px; font-size: 1.05rem;
  cursor: pointer; letter-spacing: 2px; transition: background 0.2s;
}
.invite-submit:hover { background: #43A047; }
.invite-submit:active { background: #388E3C; }
.invite-error {
  margin-top: 14px; padding: 10px 14px; background: #FFF0F0;
  color: #E74C3C; border-radius: 8px; font-size: 0.9rem;
}
[data-theme="dark"] .invite-input { border-color: #444; }
[data-theme="dark"] .invite-error { background: #3C1A1A; }
