/* ============================================================
   上海高考数学知识点在线查询 -- 霆的欢享时光
   纯前端样式：深蓝学术风，层次清晰
   ============================================================ */

:root {
  --dark: #1f4e79;
  --mid: #2e75b6;
  --pale: #deebf7;
  --concept-bg: #eaf1f8;
  --method-bg: #edf3ec;
  --warn-bg: #fdf2e9;
  --formula-bg: #f4f7fb;
  --row-alt: #f2f6fb;
  --red: #c55a11;
  --green: #548235;
  --gray: #595959;
  --line: #d9e2ec;
  --header-h: 64px;
  --footer-h: 52px;
  --sidebar-w: 288px;
  --shadow: 0 2px 10px rgba(31, 78, 121, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #243b53;
  font-size: 15px;
  line-height: 1.75;
  background: #f5f8fb;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; }

sup, sub { font-size: 0.72em; }
sup { line-height: 0; }
sub { line-height: 0; }

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: linear-gradient(120deg, #1f4e79 0%, #2e75b6 100%);
  box-shadow: 0 2px 12px rgba(15, 40, 70, 0.25);
}

.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand h1 {
  color: #fff;
  font-size: 19px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.site-sub {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  letter-spacing: 2px;
}

.search-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-box input {
  width: 300px;
  max-width: 38vw;
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 19px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: #1f3a57;
  outline: none;
  transition: box-shadow 0.2s, width 0.2s;
}
.search-box input:focus { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }
.search-box button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 19px;
  background: transparent;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.search-box button:hover { background: rgba(255, 255, 255, 0.18); }

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 38px;
  padding: 0 9px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}
.menu-toggle span { display: block; height: 2px; background: #fff; border-radius: 2px; }

/* ---------------- 布局 ---------------- */
.layout {
  position: fixed;
  top: var(--header-h);
  bottom: var(--footer-h);
  left: 0; right: 0;
  display: flex;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #c3d2e0; border-radius: 3px; }

/* 导航树 */
.nav-tree { padding: 10px 0 24px; }
.nav-node { user-select: none; }
.nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  cursor: pointer;
  color: #334e68;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-row:hover { background: #f0f5fa; }
.nav-row.active {
  background: var(--pale);
  border-left-color: var(--mid);
  color: var(--dark);
  font-weight: 700;
}
.nav-caret {
  width: 10px;
  flex: 0 0 10px;
  font-size: 10px;
  color: #93a9bd;
  transition: transform 0.18s;
}
.nav-node.collapsed > .nav-children { display: none; }
.nav-node.collapsed > .nav-row .nav-caret { transform: rotate(-90deg); }
.nav-leaf .nav-caret { visibility: hidden; }

.nav-lvl-1 > .nav-row { font-size: 15px; font-weight: 700; color: var(--dark); padding-top: 9px; padding-bottom: 9px; }
.nav-lvl-2 > .nav-row { padding-left: 26px; font-weight: 600; }
.nav-lvl-3 > .nav-row { padding-left: 44px; }
.nav-lvl-4 > .nav-row { padding-left: 62px; font-size: 13.5px; color: #486581; }
.nav-children { }

/* 内容区 */
.content {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 30px 38px 60px;
}
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: #c3d2e0; border-radius: 4px; }

.content-inner { max-width: 920px; margin: 0 auto; }

/* 内容标题 */
.book-title {
  font-size: 27px;
  color: var(--dark);
  padding-bottom: 10px;
  margin-bottom: 6px;
  border-bottom: 3px solid var(--mid);
}
.book-subtitle {
  color: var(--gray);
  font-size: 14px;
  font-style: italic;
  margin-bottom: 18px;
}
.chapter-title {
  font-size: 22px;
  color: var(--dark);
  margin: 30px 0 12px;
  padding-left: 12px;
  border-left: 5px solid var(--mid);
}
.section-title {
  font-size: 18px;
  color: var(--mid);
  margin: 24px 0 10px;
}
.lesson-title {
  font-size: 16px;
  color: var(--mid);
  margin: 20px 0 8px;
  font-weight: 700;
}

/* 正文段落 */
.content p { margin: 8px 0; }
.para { text-indent: 2em; }

/* 列表 */
.block-list { margin: 8px 0; padding-left: 8px; list-style: none; }
.block-list li {
  position: relative;
  padding-left: 18px;
  margin: 6px 0;
}
.block-list.bullet li::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--dark);
  font-weight: 700;
}
.block-list.numbered { counter-reset: li; }
.block-list.numbered li { counter-increment: li; }
.block-list.numbered li::before {
  content: counter(li) ". ";
  position: absolute;
  left: 0;
  color: var(--dark);
  font-weight: 700;
}

/* 色块框 */
.box {
  margin: 12px 0;
  padding: 11px 16px;
  border-radius: 6px;
  border-left: 4px solid var(--dark);
  background: var(--concept-bg);
  box-shadow: var(--shadow);
}
.box .box-label { font-weight: 700; }
.box.method { border-left-color: var(--green); background: var(--method-bg); }
.box.method .box-label { color: var(--green); }
.box.warn { border-left-color: var(--red); background: var(--warn-bg); }
.box.warn .box-label { color: var(--red); }
.box .box-label { color: var(--dark); }

/* 公式块 */
.formula {
  margin: 14px 0;
  padding: 12px 18px;
  text-align: center;
  font-weight: 700;
  color: var(--dark);
  background: var(--formula-bg);
  border-left: 3px solid #afc4dd;
  border-right: 3px solid #afc4dd;
  border-radius: 6px;
}

/* 表格 */
.table-caption {
  font-weight: 700;
  color: var(--dark);
  margin: 16px 0 6px;
  font-size: 14.5px;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
}
table.data-table th {
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  padding: 9px 12px;
  text-align: center;
  white-space: nowrap;
}
table.data-table td {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
}
table.data-table tbody tr:nth-child(even) { background: var(--row-alt); }
table.data-table tbody tr:hover { background: var(--pale); }

/* 图片 */
.figure { margin: 18px 0; text-align: center; }
.figure img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 3px 14px rgba(31, 78, 121, 0.14);
  background: #fff;
}
.figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--gray);
}

/* 搜索高亮 */
mark {
  background: #ffe58a;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* ---------------- 欢迎页 ---------------- */
.welcome { max-width: 1000px; margin: 0 auto; }
.welcome-hero {
  text-align: center;
  padding: 26px 20px 30px;
}
.welcome-hero h2 {
  font-size: 30px;
  color: var(--dark);
  margin-bottom: 12px;
}
.welcome-meta { color: var(--gray); font-size: 15px; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 10px 0 26px;
}
.book-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--mid);
  box-shadow: 0 8px 22px rgba(31, 78, 121, 0.16);
}
.book-card .card-key {
  display: inline-block;
  font-size: 12px;
  color: #fff;
  background: var(--mid);
  padding: 2px 10px;
  border-radius: 12px;
  margin-bottom: 10px;
}
.book-card h3 { color: var(--dark); font-size: 17px; margin-bottom: 6px; }
.book-card p { margin: 0; font-size: 13px; color: var(--gray); line-height: 1.6; }

.welcome-tip {
  background: var(--concept-bg);
  border-left: 4px solid var(--mid);
  border-radius: 6px;
  padding: 14px 18px;
  color: #334e68;
}
.welcome-tip p { margin: 0; }

/* 搜索结果 */
.search-head { color: var(--dark); font-size: 18px; margin-bottom: 14px; }
.search-group { margin-bottom: 22px; }
.search-group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--mid);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--line);
}
.search-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.search-item:hover { border-color: var(--mid); background: #f7fafd; }
.search-item .item-path { font-size: 12.5px; color: var(--gray); margin-bottom: 3px; }
.search-item .item-snippet { font-size: 14px; color: #2c4257; }
.no-result { color: var(--gray); text-align: center; padding: 40px 0; }

/* ---------------- 底部备案 ---------------- */
.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.record-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #5a6b7d;
  text-decoration: none;
  transition: color 0.15s;
}
.record-link:hover { color: var(--dark); }
.gongan-icon { width: 16px; height: 16px; object-fit: contain; }
.footer-sep { color: #c2cfdb; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 960px) {
  .menu-toggle { display: flex; }
  .brand h1 { font-size: 16px; }
  .search-box input { width: 42vw; max-width: none; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: var(--footer-h);
    left: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 22px 18px 50px; }
  .sidebar-backdrop {
    position: fixed;
    top: var(--header-h); bottom: var(--footer-h); left: 0; right: 0;
    z-index: 80;
    background: rgba(20, 40, 60, 0.35);
  }
}

@media (max-width: 620px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .brand .site-sub { display: none; }
  .search-box { gap: 6px; }
  .search-box button { padding: 0 12px; }
  .welcome-hero h2 { font-size: 23px; }
  .footer { font-size: 12px; gap: 8px; }
}
