:root {
  --bg: #f6f3ea;
  --panel: #fffdf7;
  --text: #33312b;
  --muted: #8a8475;
  --border: #e4ddcb;
  --accent: #4a7c6f;
  --accent-soft: #e3efe9;
  --danger: #b4624f;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
}

[data-theme="green"] {
  --bg: #e8f0e3;
  --panel: #f3f8ef;
  --text: #2f3a2e;
  --muted: #6f7d6b;
  --border: #d3e0cb;
  --accent: #4f7a4a;
  --accent-soft: #e2efe0;
}

[data-theme="dark"] {
  --bg: #1f2120;
  --panel: #272a28;
  --text: #d9d9d4;
  --muted: #9a9c95;
  --border: #353934;
  --accent: #7bb6a4;
  --accent-soft: #2c3a36;
  --danger: #d98c79;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; letter-spacing: .5px; }
.top-actions { display: flex; gap: 8px; }

.layout { display: flex; height: calc(100vh - 53px); }
.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar-head { padding: 14px 18px 6px; color: var(--muted); font-size: 13px; }
.lesson-list { list-style: none; margin: 0; padding: 0 8px 16px; }
.lesson-list li {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 2px;
}
.lesson-list li:hover { background: var(--accent-soft); }
.lesson-list li.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lesson-list .l-title { font-size: 14px; }
.lesson-list .l-no { color: var(--muted); font-size: 12px; margin-right: 8px; }
.lesson-list .badge { font-size: 11px; color: var(--muted); }
.lesson-list .badge.ready { color: var(--accent); }

.content { flex: 1; overflow-y: auto; padding: 24px 32px; }
.welcome { max-width: 640px; margin: 8vh auto; }
.welcome h1 { font-weight: 600; }
.muted { color: var(--muted); font-size: 14px; }

.lesson-view { max-width: 820px; margin: 0 auto; }
.lesson-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.lesson-head h2 { margin: 0 0 4px; font-weight: 600; }
.lesson-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toggle { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.text-block { margin: 20px 0; }
.sentence {
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: 19px; line-height: 2;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  border-left: 3px solid transparent;
}
.sentence:hover { background: var(--accent-soft); border-left-color: var(--accent); }
.sentence .zh { display: block; font-family: inherit; font-size: 15px; color: var(--muted); margin-top: 2px; line-height: 1.7; }
.sentence.hide-zh .zh { display: none; }
.sentence .word { cursor: pointer; }
.sentence .word:hover { text-decoration: underline; text-decoration-style: dotted; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin: 18px 0; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.keypoints { margin: 0; padding-left: 20px; }
.keypoints li { margin-bottom: 6px; }

.vocab-block { display: flex; flex-wrap: wrap; gap: 8px; }
.vocab-chip {
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 14px;
  display: flex; gap: 8px; align-items: baseline;
}
.vocab-chip .pos { color: var(--muted); font-size: 12px; }
.vocab-chip .ipa { color: var(--accent); font-size: 12px; font-family: "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", "Noto Sans", serif; }
.vocab-chip .zh { color: var(--muted); }
.vocab-chip button { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 13px; }

.quiz-block .q { margin-bottom: 14px; }
.quiz-block .q-text { font-weight: 500; margin-bottom: 6px; }
.quiz-block .opt {
  display: block; width: 100%; text-align: left; padding: 8px 12px; margin: 4px 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); cursor: pointer;
}
.quiz-block .opt.correct { border-color: var(--accent); background: var(--accent-soft); }
.quiz-block .opt.wrong { border-color: var(--danger); }
.quiz-result { margin-top: 10px; font-weight: 600; }

.lesson-footer { margin: 24px 0 60px; text-align: right; }

.primary-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; cursor: pointer;
}
.primary-btn:hover { opacity: .92; }
.ghost-btn {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.ghost-btn:hover { background: var(--accent-soft); }

.word-pop {
  position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 280px;
}
.word-pop .wp-word { font-weight: 600; }
.word-pop .wp-pos { color: var(--muted); font-size: 12px; margin: 0 6px; }
.word-pop .wp-ipa { color: var(--accent); font-size: 13px; font-family: "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", "Noto Sans", serif; }
.word-pop .wp-zh { color: var(--text); margin-top: 4px; }
.word-pop button { margin-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal-card { background: var(--panel); border-radius: 12px; width: min(640px, 92vw); max-height: 84vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }

.flashcard { text-align: center; padding: 24px; }
.flashcard .fc-word { font-size: 30px; font-weight: 600; }
.flashcard .fc-pos { color: var(--muted); margin: 6px 0; }
.flashcard .fc-ipa { color: var(--accent); font-size: 18px; font-family: "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", "Noto Sans", serif; }
.flashcard .fc-zh { font-size: 20px; margin: 10px 0 20px; }
.flashcard .fc-actions { display: flex; gap: 10px; justify-content: center; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; }
.stat { background: var(--accent-soft); border-radius: 10px; padding: 14px; text-align: center; }
.stat .num { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat .lbl { font-size: 13px; color: var(--muted); }

.hidden { display: none !important; }

/* ===== AI 复习教练 ===== */
.coach-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.coach-tab {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 7px 14px; font-size: 14px; cursor: pointer;
}
.coach-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.coach-body { min-height: 60px; }
.coach-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: var(--bg); }
.coach-prompt { font-size: 16px; margin-bottom: 8px; }
.coach-input {
  width: 100%; min-height: 80px; resize: vertical; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-family: inherit; font-size: 15px; line-height: 1.6;
}
.coach-input.inline { min-height: auto; flex: 1; }
.coach-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.coach-result { margin-top: 10px; }
.cues { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.cue-row { font-size: 14px; margin: 2px 0; }

.diag-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.diag-score {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700;
}
.diag-mode { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.diag-point { border-left: 3px solid var(--accent); padding: 6px 10px; margin: 6px 0; background: var(--accent-soft); border-radius: 0 6px 6px 0; font-size: 14px; }

.rp-info { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.chat { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg); max-height: 320px; overflow-y: auto; margin-bottom: 8px; }
.msg { padding: 8px 12px; border-radius: 10px; margin: 6px 0; max-width: 85%; line-height: 1.6; }
.msg.user { background: var(--accent); color: #fff; margin-left: auto; }
.msg.assistant { background: var(--panel); border: 1px solid var(--border); }

.primary-btn.recording { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* ===== 登录 / 同步弹层 ===== */
.auth-box { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 2px; }
.auth-tab { flex: 1; padding: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 14px; }
.auth-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.auth-box .coach-input { min-height: auto; }
.auth-err { color: var(--danger); font-size: 13px; min-height: 16px; }
