/* ===== 上海高中知识体系 · 样式 ===== */
: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); }

/* 例题难度标签 */
.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; }

/* ===== 弹窗 ===== */
.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; }
}

/* ===== 响应式 ===== */
@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; }
}

/* ===== v1.2 快捷入口 ===== */
.quick-links {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 10px;
}
.quick-links a {
  font-size: 12.5px; line-height: 1;
  padding: 7px 11px; border-radius: 999px;
  background: #f1f5ff; border: 1px solid #d7e2fb; color: #1d4ed8;
  text-decoration: none; white-space: nowrap;
}
.quick-links a:hover { background: #e3ecff; border-color: #b9ccf5; }

/* ===== 返回顶部 ===== */
.back-top {
  position: fixed; right: 20px; bottom: 24px; z-index: 40;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid #d7e2fb; background: #fff; color: #1d4ed8;
  font-size: 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(16,24,40,.14);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s, transform .2s, visibility .2s;
}
.back-top.show { opacity: 1; visibility: visible; transform: translateY(0); }

@media print {
  .quick-links, .back-top { display: none !important; }
}

/* ===== v1.4 分组快捷入口 ===== */
.quick-groups { display:flex; flex-direction:column; gap:7px; margin:0 0 12px; }
.qg-row { display:flex; flex-wrap:wrap; align-items:center; gap:7px; }
.qg-label {
  flex:none; font-size:11.5px; font-weight:800; letter-spacing:.5px;
  color:#64748b; background:#f1f5f9; border:1px solid #e2e8f0;
  border-radius:6px; padding:4px 8px; margin-right:2px;
}
.qg-row a {
  font-size:12.5px; line-height:1; padding:7px 11px; border-radius:999px;
  background:#f1f5ff; border:1px solid #d7e2fb; color:#1d4ed8;
  text-decoration:none; white-space:nowrap;
}
.qg-row a:hover { background:#e3ecff; border-color:#b9ccf5; }
@media print { .quick-groups { display:none !important; } }
