:root {
  --bg: #f5f6f8;
  --bg-soft: #f8f9fb;
  --card: #ffffff;
  --card-2: #f3f4f6;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --mark: #a16207;
  --mark-soft: #fff7d6;
  --ok: #15803d;
  --bad: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body.gate-open { overflow: hidden; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.gate-card {
  width: min(360px, 100%);
  padding: 28px 26px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-logo {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 19px;
}
.gate-card h2 { margin: 0 0 8px; font-size: 18px; }
.gate-tip { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.gate-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  letter-spacing: 1px;
  text-align: center;
  outline: none;
}
.gate-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.gate-error { min-height: 18px; margin: 8px 0 0; color: var(--bad); font-size: 12.5px; }
.gate-btn {
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.gate-btn:hover { filter: brightness(1.06); }
.gate-btn:disabled { opacity: 0.65; cursor: default; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
body.drawer-open, body.vocab-open { overflow: hidden; }

/* ---------- 顶栏与课程抽屉 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 190px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.brand:hover h1 { color: var(--primary); }

.logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary);
}

.brand-text { display: block; }
.brand-text h1 { font-size: 17px; letter-spacing: 0.3px; transition: color 0.16s; }
.brand-text p { font-size: 12px; color: var(--muted); }

.vocab-top-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.vocab-top-btn:hover { border-color: #bfdbfe; background: var(--primary-soft); }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.24);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }

.lesson-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 32px rgba(15, 23, 42, 0.1);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.22s ease, visibility 0.22s;
}
.lesson-drawer.open { transform: translateX(0); visibility: visible; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.drawer-head h2 { font-size: 18px; }
.drawer-head p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.drawer-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.drawer-close:hover { background: var(--card-2); color: var(--text); }

.vocab-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.24);
}
.vocab-modal-card {
  width: min(560px, 100%);
  max-height: min(70vh, 600px);
  overflow-y: auto;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
}
.vocab-modal-card .card-head { align-items: flex-start; }
.vocab-modal-subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; }
.global-vocab-list { padding-top: 4px; }

.lesson-tabs { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding-right: 2px; }

.tab {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}
.tab:hover { color: var(--text); border-color: #bfdbfe; background: var(--bg-soft); }
.tab.active { color: var(--text); border-color: #93c5fd; background: var(--primary-soft); }
.tab-title { display: block; font-size: 14px; font-weight: 600; }
.tab-num { margin-right: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tab.active .tab-num { color: var(--primary); }
.tab-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11px; color: var(--muted); }
.tab-score { color: var(--ok); }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.col-left, .col-right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

@media (min-width: 1025px) {
  .col-left {
    position: sticky;
    top: 91px;
    max-height: calc(100vh - 115px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 15px; letter-spacing: 0.2px; }

.lesson-head .tags { display: flex; gap: 8px; margin-bottom: 10px; }
.tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.tag.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.lesson-head h2 { font-size: 22px; letter-spacing: 0.2px; }
.muted { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- 播放器 ---------- */
.player { margin-top: 18px; }

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

.icon-btn, .play-btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.18s, transform 0.12s, background 0.18s;
}
.icon-btn { font-size: 16px; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: #cbd5e1; }

.play-btn {
  width: 52px;
  height: 52px;
  font-size: 19px;
  color: #ffffff;
  background: var(--primary);
  border-color: transparent;
  box-shadow: none;
}
.play-btn:hover { transform: translateY(-1px); }
.play-btn:active, .icon-btn:active { transform: scale(0.97); }

.pill {
  margin-left: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
}
.pill:hover { color: var(--text); border-color: #cbd5e1; }
.pill.active {
  color: #92400e;
  border-color: rgba(255, 215, 106, 0.5);
  background: var(--mark-soft);
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 10px;
}
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 40px; }

.seek {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) var(--fill, 0%), #d1d5db var(--fill, 0%), #d1d5db 100%);
  outline: none;
  cursor: pointer;
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.16);
}
.seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--primary);
}

.player-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.now-playing { font-size: 12px; color: var(--muted); }

.speeds { display: flex; gap: 4px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.speed {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.speed.active { background: var(--primary-soft); color: #1d4ed8; }
.speed:hover { color: var(--text); }

.status { min-height: 18px; margin-top: 8px; font-size: 12px; color: var(--bad); }

/* ---------- 原文 ---------- */
.head-actions { display: flex; gap: 6px; }
.text-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.16s;
}
.text-btn:hover { color: var(--text); background: var(--card-2); }
.text-btn.danger:hover { color: var(--bad); }
.count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--mark-soft);
  color: #92400e;
  font-size: 11px;
  text-align: center;
}

.transcript { max-height: 48vh; overflow-y: auto; padding-right: 4px; scroll-behavior: smooth; }
.transcript::-webkit-scrollbar { width: 8px; }
.transcript::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }

.line {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 9px 12px 9px 10px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  transition: background 0.16s, border-color 0.16s;
  cursor: default;
}
.line + .line { margin-top: 2px; }
.line:hover { background: var(--bg-soft); }
.line.current { background: var(--primary-soft); border-left-color: var(--primary); }

.speak {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.16s, color 0.16s;
}
.line:hover .speak, .line.current .speak { opacity: 1; }
.speak:hover { color: var(--primary); border-color: rgba(79, 140, 255, 0.5); }

.line-body { min-width: 0; }
.speaker {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  margin-right: 6px;
  letter-spacing: 0.3px;
}
.line-text { font-size: 15.5px; line-height: 1.85; color: var(--text); }
.line-zh { display: block; margin-top: 2px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.transcript.zh-off .line-zh { display: none; }

.w {
  border-radius: 4px;
  padding: 1px 1px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.w:hover { background: #dbeafe; }
.w.marked {
  color: #92400e;
  background: var(--mark-soft);
  border-bottom: 1px dashed var(--mark);
}

.hidden { display: none !important; }
.hidden-hint { padding: 18px 8px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- 生词本 ---------- */
.vocab-panel {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.vocab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--mark-soft);
  border: 1px solid rgba(255, 215, 106, 0.36);
  border-radius: 999px;
  padding: 3px 4px 3px 11px;
  font-size: 13px;
}
.chip a { color: #92400e; text-decoration: none; }
.chip a:hover { text-decoration: underline; }
.chip .remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
}
.chip .remove:hover { color: var(--bad); background: rgba(255, 107, 107, 0.12); }
.empty { color: var(--muted); font-size: 12px; }

/* ---------- 题目 ---------- */
.score-line { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.score-line strong { color: var(--text); }

.quiz-section + .quiz-section { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.section-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; letter-spacing: 0.4px; }

.q { padding: 12px 0; }
.q + .q { border-top: 1px solid var(--line); }
.q-title { display: flex; gap: 8px; font-size: 14.5px; line-height: 1.6; margin-bottom: 10px; }
.q-index {
  flex: 0 0 auto;
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  padding-top: 1px;
}

.options { display: grid; gap: 8px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, transform 0.12s;
}
.option:hover { border-color: #cbd5e1; transform: translateX(2px); }
.option .letter {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--line);
}
.option.selected { border-color: rgba(79, 140, 255, 0.65); background: var(--primary-soft); }
.option.selected .letter { color: #ffffff; background: var(--primary); border-color: var(--primary); }
.option.correct { border-color: rgba(61, 220, 151, 0.6); background: rgba(61, 220, 151, 0.1); }
.option.correct .letter { color: #ffffff; background: var(--ok); border-color: var(--ok); }
.option.wrong { border-color: rgba(255, 107, 107, 0.55); background: rgba(255, 107, 107, 0.09); }
.option.wrong .letter { color: #ffffff; background: var(--bad); border-color: var(--bad); }
.option:disabled { cursor: default; transform: none; }

.cloze-sentence { font-size: 15px; line-height: 2.1; color: var(--text); }
.blank {
  width: 108px;
  margin: 0 3px;
  padding: 3px 8px;
  border: 0;
  border-bottom: 2px solid #cbd5e1;
  background: transparent;
  color: #92400e;
  font-size: 14.5px;
  text-align: center;
  outline: none;
  transition: border-color 0.16s;
}
.blank:focus { border-bottom-color: var(--primary); }
.blank.correct { border-bottom-color: var(--ok); color: var(--ok); }
.blank.wrong { border-bottom-color: var(--bad); color: var(--bad); }
.blank:disabled { opacity: 1; }

.blank-tools { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint-btn {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.hint-btn:hover { color: var(--text); border-color: #cbd5e1; }
.hint-text { font-size: 12px; color: var(--muted); }
.hint-text strong { color: var(--mark); }

.explain {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #4b5563;
  background: var(--bg-soft);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
.explain .answer-text { color: var(--ok); }

.quiz-actions { display: flex; gap: 10px; margin-top: 18px; }
.primary, .ghost-btn {
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: transform 0.12s, background 0.16s, border-color 0.16s;
}
.primary {
  color: #ffffff;
  background: var(--primary);
  box-shadow: none;
}
.primary:hover { transform: translateY(-1px); }
.primary:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }
.ghost-btn { background: transparent; border-color: var(--line); color: var(--muted); }
.ghost-btn:hover { color: var(--text); border-color: #cbd5e1; }

.foot { text-align: center; color: #9ca3af; font-size: 12px; padding: 22px 20px 30px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 18px 18px 8px; }
  .transcript { max-height: 42vh; }
}
@media (max-width: 640px) {
  .topbar { flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px; }
  .brand { min-width: 0; }
  .vocab-top-btn { padding: 6px 10px; }
  .vocab-modal-card { padding: 16px; }
  .layout { padding: 14px 12px 8px; gap: 14px; }
  .card { padding: 15px; }
  .lesson-head h2 { font-size: 19px; }
  .player-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }
  .controls { gap: 8px; }
  .play-btn { width: 48px; height: 48px; }
  .line { padding: 8px; }
  .line-text { font-size: 15px; }
  .blank { width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
