/* ===== 主题变量 ===== */
:root {
  --primary: #FF8C42;
  --primary-light: #FFB37A;
  --primary-dark: #E07330;
  --primary-bg: #FFF4ED;
  --secondary: #4ECDC4;
  --accent: #FFD93D;
  --success: #6BCB77;
  --danger: #FF6B6B;
  --bg: #FAFAFA;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --text-lighter: #BDC3C7;
  --border: #ECEEF0;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --header-h: 56px;
  --nav-h: 60px;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== 头部 ===== */
#appHeader {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(255,140,66,0.3);
}

#appHeader h1 {
  font-size: 1.15rem;
  font-weight: 700;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s;
}

.back-btn:active { background: rgba(255,255,255,0.35); }

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  display: flex;
  height: var(--nav-h);
  border-top: 1px solid var(--border);
  z-index: 99;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-lighter);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: color 0.2s;
}

.nav-btn i { font-size: 1.2rem; }
.nav-btn.active { color: var(--primary); }

/* ===== 主内容 ===== */
#mainContent {
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 20px);
}

/* ===== 首页 ===== */
.hero-banner {
  background: linear-gradient(135deg, var(--primary), #FFA751);
  border-radius: var(--radius);
  padding: 28px 22px;
  color: #fff;
  margin-bottom: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-banner::before {
  content: "☀️";
  position: absolute;
  top: -10px;
  right: 16px;
  font-size: 4rem;
  opacity: 0.2;
}

.hero-banner h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.hero-banner p {
  font-size: 0.85rem;
  opacity: 0.9;
}

.edition-pill {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 10px;
  backdrop-filter: blur(2px);
}

.topic-visual {
  background: #FFF7ED;
  border: 1px solid #FFD8B0;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  text-align: center;
}

.topic-visual .visual-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 14px;
}

.hero-stat { text-align: center; }
.hero-stat .num { font-size: 1.5rem; font-weight: 700; }
.hero-stat .label { font-size: 0.7rem; opacity: 0.85; }

/* 年级卡片 */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i { color: var(--primary); }

.grade-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  border: 2px solid transparent;
}

.grade-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-hover);
}

.grade-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.grade-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.grade-info { flex: 1; }
.grade-info .name { font-size: 1.1rem; font-weight: 700; }
.grade-info .desc { font-size: 0.78rem; color: var(--text-light); margin-top: 2px; }

.grade-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.grade-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.grade-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.grade-progress-text {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  font-weight: 600;
}

/* 学期选择 */
.semester-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.semester-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  text-align: center;
  border: 2px solid transparent;
}

.semester-card:active { transform: scale(0.97); }

.semester-card .icon { font-size: 2rem; margin-bottom: 8px; }
.semester-card .name { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.semester-card .info { font-size: 0.72rem; color: var(--text-light); }
.semester-card .mini-bar {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
}
.semester-card .mini-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s;
}

/* 知识点列表 */
.topic-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topic-item:active { transform: scale(0.98); }

.topic-num {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.topic-info { flex: 1; min-width: 0; }
.topic-info .title { font-size: 0.95rem; font-weight: 600; }
.topic-info .meta { font-size: 0.72rem; color: var(--text-light); margin-top: 2px; }

.topic-status {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.7rem;
}

.topic-status.done { background: var(--success); color: #fff; }
.topic-status.doing { background: var(--accent); color: #fff; }
.topic-status.todo { background: var(--border); color: var(--text-lighter); }

/* ===== 知识点详情 ===== */
.topic-detail-header {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.topic-detail-header .icon { font-size: 2.2rem; margin-bottom: 8px; }
.topic-detail-header h2 { font-size: 1.2rem; margin-bottom: 4px; }
.topic-detail-header .subtitle { font-size: 0.78rem; color: var(--text-light); }

/* Tab 切换 */
.tab-bar {
  display: flex;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px;
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* 知识回顾 */
.review-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.review-card h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-card h3 i { color: var(--primary); }

.review-card p { font-size: 0.9rem; color: var(--text); margin-bottom: 8px; line-height: 1.7; }
.review-card .formula {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  margin: 10px 0;
  font-size: 0.9rem;
}

.review-card .tip-box {
  background: #FFF8E1;
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  margin: 10px 0;
  font-size: 0.85rem;
}

.review-card .warn-box {
  background: #FFEBEE;
  border-left: 3px solid var(--danger);
  padding: 10px 14px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  margin: 10px 0;
  font-size: 0.85rem;
}

.key-points {
  list-style: none;
  margin-top: 8px;
}

.key-points li {
  padding: 6px 0 6px 24px;
  position: relative;
  font-size: 0.88rem;
}

.key-points li::before {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  left: 0;
  top: 7px;
  color: var(--success);
  font-size: 0.75rem;
}

/* 练习题 */
.practice-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.practice-q {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.6;
}

.practice-q .q-num {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  margin-right: 6px;
  vertical-align: middle;
}

.practice-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.option-btn .opt-label {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.option-btn:active { transform: scale(0.98); }

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.option-btn.selected .opt-label {
  background: var(--primary);
  color: #fff;
}

.option-btn.correct {
  border-color: var(--success);
  background: #E8F8E8;
}

.option-btn.correct .opt-label {
  background: var(--success);
  color: #fff;
}

.option-btn.wrong {
  border-color: var(--danger);
  background: #FFEBEE;
}

.option-btn.wrong .opt-label {
  background: var(--danger);
  color: #fff;
}

.fill-input {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.fill-input:focus { border-color: var(--primary); }

.fill-input.correct { border-color: var(--success); background: #E8F8E8; }
.fill-input.wrong { border-color: var(--danger); background: #FFEBEE; }

.answer-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}

.answer-btn:active { transform: scale(0.97); }
.answer-btn:disabled { opacity: 0.5; }

.feedback {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: none;
}

.feedback.show { display: block; }
.feedback.correct { background: #E8F8E8; color: #2D7D2D; }
.feedback.wrong { background: #FFEBEE; color: #C62828; }

.feedback .answer-text {
  font-weight: 600;
  margin-top: 4px;
}

.feedback .hint-text {
  margin-top: 4px;
  color: var(--text-light);
  font-size: 0.8rem;
}

/* 练习完成 */
.practice-summary {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.practice-summary .emoji { font-size: 3rem; margin-bottom: 12px; }
.practice-summary h3 { font-size: 1.15rem; margin-bottom: 8px; }
.practice-summary .score {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin: 10px 0;
}
.practice-summary .detail { font-size: 0.85rem; color: var(--text-light); margin-bottom: 16px; }

/* 进度页面 */
.progress-overview {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.progress-overview h3 {
  font-size: 1rem;
  margin-bottom: 14px;
  text-align: center;
}

.progress-ring-container {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.progress-detail-list { display: flex; flex-direction: column; gap: 10px; }

.progress-detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.progress-detail-item .label { flex: 1; }
.progress-detail-item .value { font-weight: 600; color: var(--primary); }

/* 工具类 */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.3; }

/* 动画 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease; }

@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.pop-in { animation: pop 0.4s ease; }

/* 署名 */
.author-footer {
  text-align: center;
  padding: 20px 16px 10px;
  color: var(--text-light);
}
.author-footer p {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}
.author-footer p.sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-lighter);
  margin-top: 4px;
}

/* 难度提示 */
.diff-hint {
  background: #FFF8E1;
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  margin: 14px 0;
  font-size: 0.82rem;
  color: #8D6E63;
}
.diff-hint i { color: var(--accent); margin-right: 4px; }

/* 分数竖排显示 */
.frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  line-height: 1.1;
  margin: 0 2px;
  position: relative;
  top: -1px;
}
.frac-num {
  border-bottom: 1.5px solid currentColor;
  padding: 0 4px 1px;
  font-size: 0.82em;
}
.frac-den {
  padding: 1px 4px 0;
  font-size: 0.82em;
}

/* 响应式 */
@media (max-width: 360px) {
  html { font-size: 15px; }
}
