/* ===== 上海高中知识体系 · 样式 ===== */
:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6270;
  --ink-3: #8a91a0;
  --line: #e7e9f0;
  --brand: #1d4ed8;
  --brand-soft: #eef2ff;
  --accent: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .14);
  --sidebar-w: 288px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 15px;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--ink-3); font-size: 12.5px; }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1d4ed8, #4f46e5);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.brand-text h1 { font-size: 16px; margin: 0; letter-spacing: .5px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }

.search-box { position: relative; padding: 14px 16px 8px; }
.search-box input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }
.search-results {
  position: absolute;
  top: 56px; left: 16px; right: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 60vh;
  overflow: auto;
  z-index: 30;
}
.search-item {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--brand-soft); }
.search-item .si-title { font-weight: 600; font-size: 14px; }
.search-item .si-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.search-empty { padding: 16px; color: var(--ink-3); text-align: center; font-size: 13px; }

.subject-nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-group-title {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 1px;
  margin: 14px 6px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background .12s;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--brand-soft); border-color: #dbe3ff; }
.nav-item .dot {
  width: 28px; height: 28px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.nav-item .ni-name { font-weight: 600; font-size: 14px; }
.nav-item .ni-tag { margin-left: auto; font-size: 11px; color: var(--ink-3); }

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.ghost-btn {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #dbe3ff;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.ghost-btn:hover { background: #e0e7ff; }

/* ===== 主内容 ===== */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 80px;
  max-width: 1000px;
}
.loading { color: var(--ink-3); padding: 40px; text-align: center; }

.subject-hero {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  margin-bottom: 20px;
  border-left: 5px solid var(--subj-color, var(--brand));
}
.hero-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hero-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--subj-color, var(--brand));
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.hero-title h2 { margin: 0; font-size: 22px; }
.hero-title .sub { font-size: 13px; color: var(--ink-2); }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--badge-bg, var(--brand-soft));
  color: var(--badge-color, var(--brand));
  margin-left: 6px;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px; color: var(--ink-2);
}
.hero-meta b { color: var(--ink); }
.hero-focus {
  margin-top: 12px;
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink-2);
}
.hero-focus b { color: var(--ink); }
.hero-focus.difficulty-focus { background: #f5f3ff; border-color: #e4e0ff; border-left-color: #7c3aed; }

/* 出处与细化要点 */
.point-refs {
  font-size: 12.5px;
  color: #7c3aed;
  background: #f7f5ff;
  border: 1px dashed #d9d2ff;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 8px 0;
}
.details-block {
  margin: 10px 0 4px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
}
.details-title { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.point-details { margin: 0; padding-left: 18px; }
.point-details li { font-size: 13.5px; margin: 3px 0; line-height: 1.65; }
.point-details li b, .point-details li strong { color: var(--ink); }

/* 英语词组·固定搭配（主站内嵌） */
.colloc-banner {
  background: linear-gradient(90deg, #e0f2fe, #eff6ff);
  border: 1px solid #bae6fd;
  border-left: 4px solid #0ea5e9;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.8;
}
.colloc-banner b { color: #0c4a6e; font-size: 15px; }
.colloc-group { margin: 14px 0; }
.colloc-group-title {
  font-weight: 700;
  font-size: 14px;
  color: #0369a1;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.colloc-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2px 18px;
}
.citem { break-inside: avoid; padding: 3px 0; font-size: 13.5px; }
.citem .cph { font-weight: 600; }
.citem .czh { color: var(--ink-2); }
.citem .czh::before { content: "　"; }
.citem .cex { display: block; font-size: 12px; color: var(--ink-3); }
.wy-text { margin: 4px 0 10px; }
.wy-text-title {
  font-weight: 700; font-size: 13.5px; color: #92400e;
  background: #fffbf0; border-left: 3px solid #b45309;
  padding: 4px 10px; border-radius: 4px;
  margin: 10px 0 4px;
}
.ckind {
  display: inline-block; flex: 0 0 auto;
  font-size: 10.5px; font-weight: 700;
  padding: 0 6px; border-radius: 4px;
  margin-right: 2px; height: fit-content;
}
.ck-shi { color: #92400e; background: #fef3c7; }
.ck-xu { color: #6d28d9; background: #ede9fe; }
@media print {
  .colloc-items { grid-template-columns: repeat(2, 1fr); }
}

/* 例题难度标签 */
.q-diff {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 5px;
  height: fit-content;
  margin-left: 4px;
}
.diff-基础 { color: #15803d; background: #ecfdf3; }
.diff-提升 { color: #b45309; background: #fffbeb; }
.diff-拔高 { color: #b91c1c; background: #fef2f2; }

/* 学期标签页 */
.tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 4px 0 18px;
}
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13.5px;
  color: var(--ink-2);
  font-weight: 600;
  transition: all .12s;
}
.tab:hover { border-color: var(--subj-color, var(--brand)); color: var(--subj-color, var(--brand)); }
.tab.active {
  background: var(--subj-color, var(--brand));
  border-color: var(--subj-color, var(--brand));
  color: #fff;
}

/* 单元 */
.unit {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.unit-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}
.unit-head:hover { background: #fafbff; }
.unit-num {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--subj-color, var(--brand));
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.unit-title { font-weight: 700; font-size: 15.5px; flex: 1; }
.unit-count { font-size: 12px; color: var(--ink-3); }
.unit-body { padding: 0 18px 6px; }

/* 知识点卡片 */
.point {
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 12px;
  overflow: hidden;
}
.point-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  background: #fbfbfe;
}
.point-head:hover { background: #f4f6fb; }
.point-name { font-weight: 700; font-size: 14.5px; }
.point-level { margin-left: auto; white-space: nowrap; font-size: 13px; color: var(--accent); letter-spacing: 1px; }
.point-level .off { color: #d5d9e2; }
.point-body { padding: 4px 14px 14px; }
.focus-text {
  font-size: 14px; color: var(--ink-2);
  background: #fffdf5;
  border: 1px solid #f6ecd0;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
}
.focus-text b { color: var(--ink); }

/* 例题 */
.examples-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 14px 0 6px; }
.example {
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 8px;
  overflow: hidden;
}
.example-q {
  padding: 10px 13px;
  font-size: 14px;
  cursor: pointer;
  display: flex; gap: 10px;
}
.example-q:hover { background: #fafbff; }
.example-q .q-tag {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 1px 7px; border-radius: 5px;
  height: fit-content;
}
.example-q .q-text { flex: 1; white-space: pre-wrap; }
.example-ans {
  display: none;
  padding: 0 13px 12px;
  font-size: 14px;
  border-top: 1px dashed var(--line);
}
.example.open .example-ans { display: block; }
.example.open .example-q { background: #fafbff; border-bottom: 1px dashed var(--line); }
.ans-block { margin-top: 8px; }
.ans-block .ans-label { font-weight: 700; color: #0f766e; font-size: 13px; }
.ans-block .ans-content { white-space: pre-wrap; margin-top: 2px; color: var(--ink-2); }
.ana-block { margin-top: 8px; }
.ana-block .ans-label { font-weight: 700; color: #b45309; font-size: 13px; }
.ana-block .ans-content { white-space: pre-wrap; margin-top: 2px; color: var(--ink-2); }

.caret { transition: transform .18s; font-size: 11px; color: var(--ink-3); flex: 0 0 auto; }
.point.open .caret, .unit.open .caret { transform: rotate(90deg); }

/* 工具条 */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .btn {
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.toolbar .btn:hover { border-color: var(--brand); color: var(--brand); }
.stats-line { font-size: 12.5px; color: var(--ink-3); margin-bottom: 14px; }

/* ===== 知识点配图（js/figs/*） ===== */
.point-figs { margin: 12px 0 4px; }
.figs-title { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; }
.fig-card {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.fig-canvas {
  padding: 10px 12px 4px;
  cursor: zoom-in;
  background: #fff;
  border-bottom: 1px dashed var(--line);
}
.fig-canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.fig-canvas .fig-svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.fig-card figcaption {
  padding: 8px 12px 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
}
.fig-card figcaption b { font-size: 13.5px; color: var(--ink); margin-right: 6px; }
.fig-no {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px; font-weight: 700;
  border-radius: 5px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: 1px;
}
.fig-tag {
  display: inline-block;
  background: #f0fdf4; color: #15803d;
  font-size: 11px; font-weight: 700;
  border-radius: 5px; padding: 1px 6px; margin-right: 6px;
}
.fig-note { display: block; margin-top: 4px; color: var(--ink-2); }
.fig-zoom {
  position: fixed; inset: 0;
  background: rgba(15, 20, 30, .72);
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.fig-zoom svg { max-width: 96vw; max-height: 92vh; background: #fff; border-radius: 10px; padding: 12px; }
.fig-zoom-close {
  position: fixed; top: 16px; right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: #fff; color: var(--ink);
  font-size: 22px; line-height: 1;
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 20, 30, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
/* hidden 属性优先于 display:flex，避免页面加载时弹窗自动出现 */
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: 84vh;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close { border: none; background: none; font-size: 26px; color: var(--ink-3); line-height: 1; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px 20px; overflow-y: auto; font-size: 14px; }
.modal-body h3 { font-size: 15px; margin: 16px 0 6px; }
.modal-body pre {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.6;
}
.modal-body ul { padding-left: 20px; }

/* ===== 移动端导航开关 ===== */
.nav-toggle {
  position: fixed;
  top: 12px; left: 12px;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  display: none;
  align-items: center; justify-content: center;
  z-index: 70;
  box-shadow: var(--shadow);
}
.nav-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  border: none;
  background: var(--bg);
  color: var(--ink-2);
  border-radius: 9px;
  font-size: 22px;
  line-height: 1;
  display: none;
  align-items: center; justify-content: center;
  z-index: 3;
}
.scrim {
  position: fixed; inset: 0;
  background: rgba(15, 20, 30, .35);
  z-index: 55;
}

/* ===== 打印 ===== */
@media print {
  .sidebar, .toolbar, .modal-overlay, .tabs, .nav-toggle, .nav-close, .scrim { display: none !important; }
  .app { display: block; }
  .main { max-width: none; padding: 0; }
  .unit-body, .point-body { display: block !important; }
  .example-ans { display: block !important; }
  .unit, .point { box-shadow: none; break-inside: avoid; }
  .fig-zoom { display: none !important; }
  .fig-card { break-inside: avoid; }
  .fig-canvas { cursor: default; }
}

/* ===== 响应式 ===== */
@media (max-width: 860px) {
  .nav-toggle { display: flex; }
  .nav-close { display: flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform .22s;
    z-index: 60;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px 16px 60px; }
}
