:root {
  --bg: #0e1117;
  --bg-soft: #161b24;
  --bg-card: #1a2130;
  --line: #2a3347;
  --text: #e8e4da;
  --text-dim: #8b93a5;
  --gold: #d4a94e;
  --gold-soft: rgba(212, 169, 78, .15);
  --green: #4caf7d;
  --red-soft: rgba(214, 106, 90, .12);
  --red: #d66a5a;
  --radius: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 14px 28px;
  background: linear-gradient(180deg, #171d29, #12161f);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #1a1405;
  background: linear-gradient(135deg, #e8c876, var(--gold));
  box-shadow: 0 2px 10px rgba(212,169,78,.35);
}
.topbar h1 { font-size: 18px; letter-spacing: 1px; }
.topbar p { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.overall { min-width: 220px; text-align: right; }
.overall-text { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.overall-text #overall-pct { color: var(--gold); font-weight: 600; }
.overall-bar { height: 6px; border-radius: 3px; background: var(--bg-card); overflow: hidden; }
#overall-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #a07c2c, var(--gold));
  border-radius: 3px; transition: width .4s ease;
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: calc(100vh - 73px); }

.sidebar {
  width: 300px; flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex; flex-direction: column;
  position: sticky; top: 73px; height: calc(100vh - 73px);
}
.side-head { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
#filter {
  flex: 1; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font-size: 13px; outline: none;
}
#filter:focus { border-color: var(--gold); }
#btn-home {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-card); color: var(--text-dim);
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
#btn-home:hover { color: var(--gold); border-color: var(--gold); }

#lesson-list { overflow-y: auto; flex: 1; padding: 8px; }

.side-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px;
  transition: background .15s;
}
.side-item:hover { background: var(--bg-card); }
.side-item.active { background: var(--gold-soft); border-color: rgba(212,169,78,.4); }
.side-item .num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12px; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--line);
}
.side-item.done .num { background: var(--green); border-color: var(--green); color: #fff; }
.side-item .meta { flex: 1; min-width: 0; }
.side-item .t { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item .d { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.side-item .prog { height: 3px; background: var(--bg); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.side-item .prog i { display: block; height: 100%; background: var(--gold); }

/* ---------- 主区 ---------- */
.main { flex: 1; padding: 26px 32px 60px; min-width: 0; }
.hidden { display: none !important; }

/* ---------- 总览 ---------- */
.home-hero { margin-bottom: 22px; }
.home-hero h2 { font-size: 24px; }
.home-hero p { color: var(--text-dim); font-size: 13px; margin-top: 6px; }

.card-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: transform .15s, border-color .15s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--gold); }
.card .thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .dur {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.75); padding: 2px 8px; border-radius: 6px; font-size: 11px;
}
.card .thumb .done-badge {
  position: absolute; left: 8px; top: 8px;
  background: var(--green); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 11px;
}
.card .body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; }
.card .tag { font-size: 11px; color: var(--gold); background: var(--gold-soft); padding: 2px 8px; border-radius: 4px; align-self: flex-start; }
.card h3 { font-size: 14px; margin-top: 8px; line-height: 1.5; }
.card .hl {
  font-size: 12px; color: var(--text-dim); line-height: 1.6; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .prog { height: 4px; background: var(--bg); border-radius: 2px; margin-top: auto; padding-top: 0; overflow: hidden; }
.card .prog-wrap { margin-top: 10px; }
.card .prog-wrap .prog { margin-top: 0; }
.card .prog i { display: block; height: 100%; background: var(--gold); }

/* ---------- 讲义页 ---------- */
.lesson-head { margin-bottom: 20px; }
.lesson-head .tag {
  font-size: 12px; color: var(--gold);
  background: var(--gold-soft); padding: 3px 10px; border-radius: 5px;
}
.lesson-head h2 { font-size: 24px; margin-top: 10px; }
.lesson-head .headline { color: var(--gold); font-size: 14px; margin-top: 8px; letter-spacing: .5px; }

.lesson-cols { display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: 28px; align-items: start; }

/* 讲义正文 */
.notes-col { min-width: 0; }

.intro-card {
  background: linear-gradient(135deg, rgba(212,169,78,.10), rgba(212,169,78,.03));
  border: 1px solid rgba(212,169,78,.35);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 22px;
}
.ic-label { font-size: 12px; color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; }
.intro-card p { font-size: 14px; line-height: 1.9; }

.sec {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px;
}
.sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sec-head .idx {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px;
  background: var(--gold-soft); color: var(--gold);
}
.sec-head h3 { font-size: 16px; }
.sec-head .ts {
  margin-left: auto; flex-shrink: 0;
  font-size: 12px; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px;
  cursor: pointer; background: var(--bg);
  font-variant-numeric: tabular-nums;
}
.sec-head .ts:hover { color: var(--gold); border-color: var(--gold); }
.sec-head .ts::before { content: "▶ "; font-size: 10px; }

.sec ul { list-style: none; }
.sec li {
  position: relative; padding-left: 18px;
  font-size: 14px; line-height: 1.9; color: #cfd4de;
  margin-bottom: 6px;
}
.sec li::before {
  content: ""; position: absolute; left: 2px; top: 13px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--gold); opacity: .55;
}

/* 规则 / 金句 / 误区 */
.block { border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px; border: 1px solid var(--line); }
.block h3 { font-size: 16px; margin-bottom: 12px; }

.rules-block { background: rgba(76,175,125,.07); border-color: rgba(76,175,125,.3); }
.rules-block ul { list-style: none; }
.rules-block li {
  position: relative; padding-left: 26px;
  font-size: 14px; line-height: 1.9; margin-bottom: 8px;
}
.rules-block li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  color: var(--green); font-weight: 700;
}

.quotes-block { background: var(--bg-card); }
#n-quotes { display: grid; gap: 10px; }
.quote {
  border-left: 3px solid var(--gold);
  padding: 10px 14px; background: rgba(212,169,78,.06);
  border-radius: 0 8px 8px 0;
  font-size: 14px; line-height: 1.8; font-style: italic;
}

.pitfalls-block { background: var(--red-soft); border-color: rgba(214,106,90,.3); }
.pitfalls-block ul { list-style: none; }
.pitfalls-block li {
  position: relative; padding-left: 24px;
  font-size: 14px; line-height: 1.9; margin-bottom: 6px;
}
.pitfalls-block li::before { content: "✗"; position: absolute; left: 0; color: var(--red); font-weight: 700; }

.lesson-foot { display: flex; gap: 10px; margin-top: 8px; }
.lesson-foot button {
  padding: 10px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-card);
  color: var(--text); font-size: 13px;
}
.lesson-foot button:hover { border-color: var(--gold); color: var(--gold); }
.lesson-foot button:disabled { opacity: .35; cursor: default; }
.lesson-foot button:disabled:hover { border-color: var(--line); color: var(--text); }
.complete-btn { margin-left: auto; margin-right: auto; }
.complete-btn.done { background: var(--green); border-color: var(--green); color: #fff; }

/* 右侧媒体列 */
.media-col { position: sticky; top: 93px; }
.video-wrap { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.video-wrap video { width: 100%; display: block; }
.media-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin: 10px 2px 16px; font-size: 12px; color: var(--text-dim);
}
.speed-btns { display: flex; gap: 5px; }
.speed-btns button {
  padding: 4px 9px; border-radius: 6px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--line); background: var(--bg-card); color: var(--text-dim);
}
.speed-btns button:hover { border-color: var(--gold); color: var(--gold); }
.speed-btns button.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }

.notes { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.notes-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.notes-head h3 { font-size: 14px; }
.note-status { font-size: 11px; color: var(--text-dim); }
#note-editor {
  width: 100%; min-height: 150px; resize: vertical;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.7;
  font-family: inherit; outline: none;
}
#note-editor:focus { border-color: var(--gold); }

/* 窄屏 */
@media (max-width: 1100px) {
  .lesson-cols { grid-template-columns: 1fr; }
  .media-col { position: static; order: -1; }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; max-height: 40vh; }
  .main { padding: 18px; }
}
