/* ========== 主题变量（与笔记站同一套） ========== */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-elev: #ffffff;
  --border: #d8dee4;
  --border-soft: #eaeef2;
  --text: #1f2328;
  --text-dim: #656d76;
  --text-faint: #8c959f;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --ok: #1a7f37;
  --ok-soft: #dafbe1;
  --warn: #9a6700;
  --warn-soft: #fff8c5;
  --mark-bg: #fff3a3;
  --shadow: 0 1px 3px rgba(27, 31, 36, .12), 0 8px 24px rgba(66, 74, 83, .12);
  --radius: 8px;
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "微软雅黑", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-elev: #161b22;
    --border: #30363d;
    --border-soft: #21262d;
    --text: #e6edf3;
    --text-dim: #9198a1;
    --text-faint: #6e7681;
    --accent: #4493f8;
    --accent-soft: #0c2d6b;
    --ok: #3fb950;
    --ok-soft: #12261e;
    --warn: #d29922;
    --warn-soft: #2e2408;
    --mark-bg: #6b5900;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-elev: #161b22;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-dim: #9198a1;
  --text-faint: #6e7681;
  --accent: #4493f8;
  --accent-soft: #0c2d6b;
  --ok: #3fb950;
  --ok-soft: #12261e;
  --warn: #d29922;
  --warn-soft: #2e2408;
  --mark-bg: #6b5900;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .4);
}

/* ========== 基础 ========== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: 64px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 0;
}

.loading { color: var(--text-dim); text-align: center; padding: 48px 0; }

/* ========== 顶栏 ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 18px; }

.course-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  scrollbar-width: none;
}
.course-tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
.tab:hover { color: var(--text); border-color: var(--text-faint); text-decoration: none; }
.tab[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.search-wrap { position: relative; display: flex; align-items: center; flex-shrink: 0; }
.search-icon { position: absolute; left: 9px; color: var(--text-faint); pointer-events: none; }

#searchInput {
  width: 190px;
  padding: 6px 30px 6px 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
#searchInput:focus { border-color: var(--accent); background: var(--bg); }

.search-kbd {
  position: absolute;
  right: 9px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  pointer-events: none;
}
#searchInput:focus + .search-kbd { display: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { display: none; }
:root[data-theme-mode="auto"] .ico-auto,
:root[data-theme-mode="light"] .ico-sun,
:root[data-theme-mode="dark"] .ico-moon { display: block; }

/* ========== 课程头部 ========== */
.hero { margin-bottom: 28px; }

.hero-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-emoji { font-size: 34px; line-height: 1.1; }

.hero-title { margin: 0; font-size: 24px; line-height: 1.3; }
.hero-title .code { font-family: var(--mono); font-size: 20px; }

.hero-meta {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

.hero-note {
  margin: 12px 0 0;
  padding: 10px 13px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
  font-size: 13.5px;
}

.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  transition: border-color .12s, background .12s;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.chip .ic { font-size: 14px; }

/* ========== 统计条 ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 10px;
  margin: 22px 0 4px;
}

.stat {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 10px 12px;
  text-align: center;
}
.stat b { display: block; font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--text-dim); }

/* ========== 区块 ========== */
.section { margin-top: 34px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .02em;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

.section-title .count {
  font-weight: 400;
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ========== 筛选 ========== */
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }

.filter {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.filter:hover { color: var(--text); }
.filter[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ========== 讲次卡片 ========== */
.module { margin-bottom: 26px; }

.module-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.lec {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-elev);
  margin-bottom: 8px;
  overflow: hidden;
}
.lec:hover { border-color: var(--border); }
.lec.is-break { opacity: .58; background: transparent; border-style: dashed; }
.lec.is-hidden { display: none; }

.lec-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
}

.lec-code {
  flex-shrink: 0;
  min-width: 34px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
}

.lec-body { flex: 1; min-width: 0; }

.lec-title { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.lec-title mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }

.lec-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.lec-sub .lecturer { color: var(--text-dim); }

.lec-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.mini:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.mini.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mini.off { opacity: .45; cursor: default; }
.mini.off:hover { border-color: var(--border); color: var(--text-dim); }
.mini .n { font-variant-numeric: tabular-nums; opacity: .8; }

/* 阅读清单抽屉 */
.drawer { border-top: 1px solid var(--border-soft); background: var(--bg-soft); padding: 11px 13px; }
.drawer[hidden] { display: none; }

.drawer h4 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.drawer h4:not(:first-child) { margin-top: 14px; }

.refs { margin: 0; padding: 0; list-style: none; }
.refs li { margin: 0 0 3px; font-size: 13px; line-height: 1.5; }
.refs a { color: var(--text); }
.refs a:hover { color: var(--accent); }
.refs mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }

.refs-cols { columns: 2; column-gap: 24px; }
.refs-cols li { break-inside: avoid; }

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10.5px;
  vertical-align: 1px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}

/* ========== 作业 / 评分 ========== */
.cards { display: grid; gap: 10px; }

.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 13px 15px;
}
.card:hover { border-color: var(--border); }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}
.card-head h4 { margin: 0; font-size: 14.5px; }

.due {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 4px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.due.past { color: var(--text-faint); background: var(--bg-soft); }

.card p { margin: 7px 0 0; font-size: 13px; color: var(--text-dim); }
.card .links-row { margin-top: 10px; }

.grade-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grade-table th, .grade-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.grade-table th { color: var(--text-dim); font-weight: 600; font-size: 12.5px; }
.grade-table td:first-child { color: var(--text); }
.grade-table td.w, .grade-table th.w { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grade-table tbody tr:last-child td { border-bottom: none; }
.grade-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--bg-elev);
}

/* ========== 空状态 ========== */
.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty b { display: block; margin-bottom: 6px; color: var(--text); }

/* ========== 页脚 ========== */
.foot {
  margin-top: 46px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.8;
}

/* ========== 移动端 ========== */
@media (max-width: 720px) {
  .brand-text { display: none; }
  .topbar { gap: 8px; padding: 0 12px; }
  #searchInput { width: 128px; }
  .search-kbd { display: none; }
  .wrap { padding: 18px 14px 0; }
  .hero-title { font-size: 20px; }
  .hero-emoji { font-size: 28px; }
  .refs-cols { columns: 1; }
}
