@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
  --ink: #1a1410;
  --paper: #f9f5ef;
  --paper-deep: #f0e9df;
  --accent: #8b4513;
  --accent-light: #c4915e;
  --accent-pale: #f5ece2;
  --red: #b84233;
  --blue: #2d5a7b;
  --green: #3a6b4f;
  --gray: #7a7268;
  --border: #d4c9b8;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(26,20,16,.08);
  --transition: .25s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ===== Views ===== */
.view { display: none; min-height: 100dvh; }
.view.active { display: block; }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #1a1410, #2d2117);
  color: var(--paper);
  padding: 0 20px;
  height: 56px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}
.app-header .back-btn {
  width: 36px; height: 36px;
  border: none; background: rgba(255,255,255,.1);
  color: var(--accent-light);
  border-radius: 8px; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.app-header .back-btn:hover { background: rgba(255,255,255,.2); }
.app-header .back-btn.hidden { display: none; }
.app-header h1 {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px; font-weight: 700;
  letter-spacing: 2px; flex: 1;
}
.header-progress {
  font-size: 12px; color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}

/* ===== Home View ===== */
.hero {
  text-align: center;
  padding: 48px 24px 36px;
  background: linear-gradient(180deg, #2d2117 0%, var(--paper) 100%);
}
.hero-icon {
  width: 80px; height: 80px; margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.hero-icon img { width: 56px; height: 56px; }
.hero h2 {
  font-family: 'Noto Serif SC', serif;
  font-size: 28px; font-weight: 900;
  color: #fff; letter-spacing: 6px;
  margin-bottom: 8px;
}
.hero p { font-size: 14px; color: var(--accent-light); }

/* Progress ring */
.progress-ring-wrap {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 24px 20px;
}
.progress-ring { position: relative; width: 100px; height: 100px; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring circle {
  fill: none; stroke-width: 8; stroke-linecap: round;
}
.progress-ring .bg { stroke: var(--border); }
.progress-ring .fg { stroke: var(--accent); transition: stroke-dashoffset .6s ease; }
.progress-ring .label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.progress-ring .pct {
  font-family: 'Noto Serif SC', serif;
  font-size: 24px; font-weight: 900; color: var(--accent);
}
.progress-ring .sub { font-size: 11px; color: var(--gray); }
.progress-stats {
  display: flex; flex-direction: column; gap: 8px;
}
.stat-item { font-size: 13px; color: var(--gray); }
.stat-item strong { color: var(--ink); font-size: 18px; display: block; }

/* Phase cards */
.phase-list { padding: 8px 16px 32px; }
.phase-card {
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.phase-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,.12); }
.phase-header {
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
}
.phase-num {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Serif SC', serif;
  font-size: 18px; font-weight: 900; color: #fff;
  flex-shrink: 0;
}
.phase-num.p1 { background: linear-gradient(135deg, #4a7c59, #6a9c79); }
.phase-num.p2 { background: linear-gradient(135deg, #c0392b, #e06050); }
.phase-num.p3 { background: linear-gradient(135deg, #8b4513, #c4915e); }
.phase-num.p4 { background: linear-gradient(135deg, #2471a3, #4a8ab5); }
.phase-info { flex: 1; }
.phase-info h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px; font-weight: 700;
  margin-bottom: 2px;
}
.phase-info .phase-sub { font-size: 12px; color: var(--gray); }
.phase-progress {
  padding: 0 18px 14px;
}
.phase-bar {
  height: 6px; background: var(--paper-deep);
  border-radius: 3px; overflow: hidden;
}
.phase-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width .4s ease;
}
.phase-bar-fill.p1 { background: #4a7c59; }
.phase-bar-fill.p2 { background: #c0392b; }
.phase-bar-fill.p3 { background: #8b4513; }
.phase-bar-fill.p4 { background: #2471a3; }
.phase-bar-text {
  font-size: 11px; color: var(--gray);
  margin-top: 4px; text-align: right;
}

/* ===== Phase Detail View ===== */
.phase-detail-header {
  padding: 24px 20px 16px;
  text-align: center;
}
.phase-detail-header h2 {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px; font-weight: 700;
  margin-bottom: 4px;
}
.phase-detail-header p { font-size: 13px; color: var(--gray); }

.week-section { padding: 0 16px 24px; }
.week-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px; font-weight: 700;
  color: var(--accent);
  padding: 10px 4px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.week-title .week-badge {
  font-size: 11px; background: var(--accent-pale);
  color: var(--accent); padding: 2px 8px;
  border-radius: 10px; font-weight: 600;
}

/* Day items */
.day-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}
.day-item:hover { border-color: var(--accent-light); background: var(--accent-pale); }
.day-item.completed { opacity: .75; }
.day-check {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px; color: transparent;
  transition: var(--transition);
  cursor: pointer;
}
.day-check:hover { border-color: var(--accent); }
.day-item.completed .day-check {
  background: var(--green); border-color: var(--green);
  color: #fff;
}
.day-item.review .day-num { background: var(--accent); color: #fff; }
.day-num {
  width: 32px; height: 24px;
  border-radius: 6px;
  background: var(--paper-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--gray);
  flex-shrink: 0;
}
.day-info { flex: 1; min-width: 0; }
.day-info .day-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-info .day-desc {
  font-size: 11px; color: var(--gray);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-arrow { color: var(--border); font-size: 16px; flex-shrink: 0; }

/* ===== Lecture View ===== */
.lecture-frame {
  width: 100%; border: none;
  height: calc(100dvh - 112px); /* header 56px + bottom nav 56px */
}

/* ===== Footer nav ===== */
.lecture-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 56px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.lecture-nav button {
  flex: 1; border: none; background: none;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: var(--transition);
}
.lecture-nav button:hover { background: var(--accent-pale); }
.lecture-nav button:disabled { color: var(--border); cursor: default; }
.lecture-nav button:disabled:hover { background: none; }
.lecture-nav .nav-complete {
  background: var(--green); color: #fff;
  font-size: 14px;
}
.lecture-nav .nav-complete:hover { background: #2e7d42; }
.lecture-nav .nav-complete.done { background: var(--gray); }

/* ===== Continue Learning Button ===== */
.continue-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; padding: 16px;
  background: linear-gradient(135deg, #8b4513, #c4915e);
  border: none; border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(139,69,19,.3);
  transition: var(--transition);
}
.continue-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(139,69,19,.4); }
.continue-btn:active { transform: translateY(0); }
.continue-label {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px; font-weight: 700;
  color: #fff; letter-spacing: 3px;
  margin-bottom: 4px;
}
.continue-day {
  font-size: 13px; color: rgba(255,255,255,.8);
}
.continue-done {
  text-align: center; padding: 16px;
  background: #e8f5e9; border-radius: var(--radius);
  color: var(--green); font-weight: 600;
  margin-bottom: 20px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.continue-done-icon { font-size: 24px; }

/* ===== Next Day Highlight ===== */
.day-item.next-day {
  border-color: var(--accent) !important;
  background: var(--accent-pale) !important;
  box-shadow: 0 0 0 2px rgba(139,69,19,.15);
}
.day-item.next-day .day-num {
  background: var(--accent); color: #fff;
}

/* ===== Quiz Button Passed State ===== */
.nav-quiz.quiz-passed {
  background: var(--gray) !important;
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .hero h2 { font-size: 36px; }
  .phase-list, .week-section, #continue-wrap { max-width: 640px; margin-left: auto; margin-right: auto; }
  .progress-ring-wrap { max-width: 640px; margin: 0 auto; }
}

/* 小屏手机 (<=414px, iPhone SE / 普通安卓) */
@media (max-width: 414px) {
  .app-header { padding: 0 12px; gap: 8px; height: 48px; }
  .app-header h1 { font-size: 15px; letter-spacing: 1px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .app-header .back-btn, .settings-btn { width: 32px; height: 32px; font-size: 15px; }
  .header-progress { font-size: 11px; }

  .hero { padding: 32px 16px 24px; }
  .hero-icon { width: 60px; height: 60px; margin-bottom: 12px; }
  .hero-icon img { width: 42px; height: 42px; }
  .hero h2 { font-size: 22px; letter-spacing: 3px; margin-bottom: 4px; }
  .hero p { font-size: 12px; }

  .progress-ring-wrap { gap: 16px; padding: 16px 12px; }
  .progress-ring { width: 80px; height: 80px; }
  .progress-ring svg { width: 80px; height: 80px; }
  .progress-ring circle { stroke-width: 6; }
  .progress-ring .pct { font-size: 20px; }
  .progress-ring .sub { font-size: 10px; }
  .stat-item { font-size: 12px; }
  .stat-item strong { font-size: 16px; }

  .continue-btn { padding: 12px; }
  .continue-label { font-size: 16px; letter-spacing: 2px; }
  .continue-day { font-size: 12px; }

  .phase-list { padding: 6px 12px 24px; }
  .phase-card { margin-bottom: 10px; }
  .phase-header { padding: 12px 14px; gap: 10px; }
  .phase-num { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
  .phase-info h3 { font-size: 14px; }
  .phase-info .phase-sub { font-size: 11px; }
  .phase-progress { padding: 0 14px 10px; }

  .phase-detail-header { padding: 16px 14px 10px; }
  .phase-detail-header h2 { font-size: 18px; }

  .week-section { padding: 0 12px 16px; }
  .week-title { font-size: 13px; padding: 8px 2px 6px; }
  .week-title .week-badge { font-size: 10px; padding: 1px 6px; }

  .day-item { padding: 10px 10px; gap: 8px; }
  .day-check { width: 24px; height: 24px; font-size: 12px; }
  .day-num { width: 28px; height: 22px; font-size: 11px; }
  .day-info .day-title { font-size: 13px; }
  .day-info .day-desc { font-size: 10px; }
  .day-arrow { font-size: 14px; }

  .lecture-frame { height: calc(100dvh - 96px); }
  .lecture-nav { height: 48px; }
  .lecture-nav button { font-size: 12px; gap: 3px; }
}

/* 极小屏 (<=340px, iPhone SE 1代等) */
@media (max-width: 340px) {
  .app-header h1 { font-size: 13px; }
  .hero h2 { font-size: 18px; letter-spacing: 2px; }
  .phase-info h3 { font-size: 12px; }
  .day-info .day-title { font-size: 12px; }
  .continue-label { font-size: 14px; }
}