/* ===== 基础 ===== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e6e8ec;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --brand: #2f6bff;
  --brand-soft: #eaf0ff;
  --red: #d83931;
  --red-soft: #fdeceb;
  --orange: #d97b00;
  --orange-soft: #fff4e0;
  --green: #1f8a4c;
  --green-soft: #e8f6ee;
  --purple: #6b45c9;
  --purple-soft: #f0ebfd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 6px;
}

.brand-mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.brand-text { font-weight: 650; font-size: 16px; letter-spacing: .3px; }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 6px;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.tabs a:hover { background: #f0f1f3; }
.tabs a.active { background: var(--brand); color: #fff; }

/* ===== 主区 ===== */
.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 14px 40px;
}

.loading, .empty {
  color: var(--text-3);
  text-align: center;
  padding: 42px 16px;
  font-size: 14px;
}

.page-head { margin: 2px 0 14px; }
.page-title { font-size: 20px; font-weight: 650; margin: 0 0 4px; letter-spacing: .2px; }
.page-sub { color: var(--text-3); font-size: 13px; margin: 0; }

.section-title {
  font-size: 15px;
  font-weight: 620;
  margin: 22px 0 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.section-title .count { color: var(--text-3); font-size: 12px; font-weight: 400; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card + .card { margin-top: 10px; }

.card-link {
  display: block;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.card-link:active { background: #fafbfc; }

@media (hover: hover) {
  .card-link:hover {
    border-color: #c9d4f5;
    box-shadow: 0 3px 12px rgba(47, 107, 255, .08);
  }
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title { font-weight: 620; font-size: 15.5px; margin: 0 0 3px; }
.card-meta { color: var(--text-3); font-size: 12.5px; }

.score-big {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--brand);
  white-space: nowrap;
}
.score-big small { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* ===== 统计卡 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.stat-label { color: var(--text-3); font-size: 12.5px; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
.stat-value.warn { color: var(--orange); }
.stat-value.danger { color: var(--red); }

/* ===== 筛选区 ===== */
.filter-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.filter-summary::-webkit-details-marker { display: none; }
.filter-summary .arrow { color: var(--text-3); transition: transform .2s; font-size: 12px; }
.filter-panel[open] .filter-summary .arrow { transform: rotate(180deg); }

.filter-body {
  padding: 0 14px 12px;
  display: grid;
  gap: 10px;
  border-top: 1px solid #f0f1f3;
  padding-top: 12px;
}

.field { display: grid; gap: 5px; }
.field label { font-size: 12px; color: var(--text-3); }

select, input[type="search"], input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  appearance: none;
  min-height: 42px;
}
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%238f959e' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select:focus, input:focus { outline: 2px solid var(--brand-soft); border-color: #b9cbff; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line);
  background: #f7f8fa;
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  min-height: 34px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:active { transform: scale(.97); }

.filter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-3);
}
.btn-reset {
  font: inherit;
  font-size: 13px;
  color: var(--brand);
  background: none;
  border: none;
  padding: 6px 2px;
  cursor: pointer;
}

/* ===== 徽标 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f0f1f3;
  color: var(--text-2);
  white-space: nowrap;
}
.badge.sev-高 { background: var(--red-soft); color: var(--red); }
.badge.sev-中 { background: var(--orange-soft); color: var(--orange); }
.badge.sev-低 { background: var(--green-soft); color: var(--green); }
.badge.st-未掌握 { background: var(--red-soft); color: var(--red); }
.badge.st-模糊 { background: var(--orange-soft); color: var(--orange); }
.badge.st-基本掌握 { background: var(--brand-soft); color: var(--brand); }
.badge.st-已掌握 { background: var(--green-soft); color: var(--green); }
.badge.st-待复习 { background: var(--purple-soft); color: var(--purple); }
.badge.tag { background: #f5f6f8; color: var(--text-3); }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.kv {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 3px 10px;
  font-size: 13.5px;
  margin-top: 8px;
}
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

.wp-desc {
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 13.5px;
  word-break: break-word;
}

.badge-late { color: var(--red); font-weight: 600; }

/* ===== 时间线 ===== */
.timeline { position: relative; margin: 4px 0 0; padding-left: 18px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 2px;
  background: #eef0f3;
}
.timeline-item { position: relative; padding: 0 0 14px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -17px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--brand);
}
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-no { font-weight: 620; font-size: 14.5px; }
.timeline-date { color: var(--text-3); font-size: 12.5px; }
.timeline-body { color: var(--text-2); font-size: 13.5px; margin-top: 3px; }

/* ===== 图表 ===== */
.chart-card { padding: 12px 12px 6px; }
.chart-title { font-size: 13.5px; font-weight: 600; margin: 0 0 8px; }
.chart-box { position: relative; height: 220px; width: 100%; }
.chart-box.tall { height: 260px; }
.chart-grid { display: grid; gap: 10px; }

/* ===== 桌面表格 ===== */
.table-wrap { display: none; }
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}
.table-wrap th, .table-wrap td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f1f3;
  white-space: nowrap;
}
.table-wrap th { background: #fafbfc; color: var(--text-3); font-weight: 550; font-size: 12.5px; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tbody tr { cursor: pointer; }
.table-wrap tbody tr:hover { background: #fafbff; }
.table-wrap td.num { font-variant-numeric: tabular-nums; }

/* ===== 空状态 / 错误 ===== */
.banner {
  max-width: 1080px;
  margin: 10px auto 0;
  padding: 0 14px;
}
.banner-inner {
  background: var(--red-soft);
  border: 1px solid #f7cfcc;
  color: #8f2b25;
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 13px;
}
.banner-inner strong { display: block; margin-bottom: 4px; }
.banner-inner ul { margin: 6px 0 0; padding-left: 18px; }
.banner-inner li { margin: 2px 0; }

/* ===== 页脚 ===== */
.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 14px 30px;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}
.footer-dot { margin: 0 6px; }

/* ===== 数学公式 & 文本 ===== */
.katex { font-size: 1em; }
.katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; }

.link-plain { color: inherit; }

/* ===== 桌面适配 ===== */
@media (min-width: 720px) {
  body { font-size: 15px; }
  .topbar-inner { padding: 10px 20px 0; }
  .brand { display: none; }
  .tabs { padding-bottom: 8px; }
  .app { padding: 20px 20px 50px; }
  .page-title { font-size: 22px; }

  .stat-grid { grid-template-columns: repeat(4, 1fr); }

  .filter-panel { margin-bottom: 14px; }
  .filter-summary { display: none; }
  .filter-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    border-top: none;
    padding: 12px 14px;
    align-items: end;
  }
  details.filter-panel > .filter-body { display: grid !important; }

  .cards-mobile { display: none; }
  .table-wrap { display: block; }

  .chart-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-box { height: 260px; }
  .split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
}

@media (max-width: 719px) {
  .filter-panel > .filter-body { display: none; }
  .filter-panel[open] > .filter-body { display: grid; }
}
