/* ═══════════════════════════════════════════════════════════════
   高中数学教材知识库 · 样式
   navy + gold 学院典籍气 · 横版 / PC 优先
   ═══════════════════════════════════════════════════════════════ */

:root {
  --navy:        #0f2747;
  --navy-deep:   #0a1c36;
  --navy-soft:   #17335a;
  --gold:        #c8a15a;
  --gold-bright: #e0c079;
  --paper:       #f6f2e9;
  --paper-edge:  #e7ddc9;
  --ink:         #23303f;
  --ink-soft:    #5b6572;
  --line:        #d9cfba;
  --white:       #ffffff;

  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", Georgia, serif;
  --sans:  -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 320px;
  --topbar-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

/* ───────────── 顶栏 ───────────── */
.topbar {
  height: var(--topbar-h);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 2px 14px rgba(10, 28, 54, .35);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 24px;
  color: var(--navy-deep);
  background: linear-gradient(150deg, var(--gold-bright), var(--gold));
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}

.brand-text h1 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 1px;
}
.brand-text p {
  font-size: 11.5px;
  color: var(--gold-bright);
  letter-spacing: .5px;
  margin-top: 1px;
}

.modes { display: flex; gap: 8px; }

.mode-btn {
  font-family: var(--sans);
  font-size: 14px;
  color: rgba(255,255,255,.72);
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .16s;
}
.mode-btn:hover { color: var(--white); background: rgba(255,255,255,.06); }
.mode-btn.active {
  color: var(--navy-deep);
  background: linear-gradient(150deg, var(--gold-bright), var(--gold));
  font-weight: 600;
}

/* ───────────── 主体布局 ───────────── */
.layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;                 /* 内部分区各自滚动 */
}
/* 固定头：版本选择器常驻，不随目录滚动 */
.side-fixed {
  flex-shrink: 0;
  padding: 14px 0 8px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 8px -6px rgba(15,39,71,.18);
  z-index: 2;
}
/* 滚动体：目录 / 统一知识树在这里滚 */
.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 40px;
}

.stage {
  flex: 1;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 0%, rgba(200,161,90,.05), transparent 60%),
    var(--paper);
  display: flex;
  flex-direction: column;
}

/* ───────────── 侧栏：版本选择器 ───────────── */
.side-section-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink-soft);
  padding: 6px 20px;
  text-transform: uppercase;
}

.version-picker { padding: 4px 14px 10px; }

.version-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--white);
  transition: all .15s;
}
.version-card:hover { border-color: var(--gold); background: #fffdf8; }
.version-card.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fffaf0, #fdf4e3);
  box-shadow: inset 3px 0 0 var(--gold);
}
.version-card .vc-pub {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.version-card .vc-book { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.version-card .vc-badge {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* 对比模式：版本多选 chips */
.compare-versions { padding: 6px 16px 12px; display: flex; flex-wrap: wrap; gap: 7px; }
.vchip {
  font-size: 12.5px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-soft);
  background: var(--white);
  transition: all .15s;
  user-select: none;
}
.vchip-book {
  margin-left: 5px;
  padding-left: 5px;
  border-left: 1px solid currentColor;
  opacity: .7;
  font-size: 11.5px;
}
.vchip:hover { border-color: var(--gold); }
.vchip.on {
  color: var(--navy-deep);
  border-color: var(--gold);
  background: linear-gradient(150deg, var(--gold-bright), var(--gold));
  font-weight: 600;
}

/* ───────────── 侧栏：目录树 ───────────── */
.toc { padding: 4px 8px; }

.toc-chapter { margin-bottom: 2px; }

.toc-chapter > .toc-row {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--navy);
}

.toc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.35;
  transition: background .12s;
}
.toc-row:hover { background: #f4efe4; }
.toc-row.active {
  background: linear-gradient(90deg, rgba(200,161,90,.20), rgba(200,161,90,.06));
  color: var(--navy-deep);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--gold);
}

.toc-caret {
  width: 14px; flex-shrink: 0;
  font-size: 10px; color: var(--ink-soft);
  transition: transform .15s;
}
.toc-chapter.collapsed .toc-caret { transform: rotate(-90deg); }
.toc-chapter.collapsed .toc-children { display: none; }

.toc-children { margin-left: 8px; padding-left: 8px; border-left: 1px dashed var(--paper-edge); }
.toc-children .toc-row { padding-left: 14px; }

.toc-page { margin-left: auto; font-size: 11px; color: var(--ink-soft); }

/* 下载整本 */
.download-book { padding: 12px 16px 4px; }
.btn-download {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  color: var(--navy-deep);
  background: linear-gradient(150deg, var(--gold-bright), var(--gold));
  border: none; border-radius: 8px;
  padding: 10px; cursor: pointer;
  text-decoration: none;
  transition: filter .15s;
}
.btn-download:hover { filter: brightness(1.05); }
.btn-download.ghost {
  background: transparent; color: var(--navy);
  border: 1px solid var(--gold);
}

/* ───────────── 舞台：浏览模式 ───────────── */
.viewer-bar {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.viewer-title { font-family: var(--serif); font-size: 15px; color: var(--navy); font-weight: 600; }
.viewer-title small { font-family: var(--sans); font-weight: 400; color: var(--ink-soft); margin-left: 8px; font-size: 12px; }

.pager { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager button {
  font-size: 13px; color: var(--navy);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--gold); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .page-input {
  width: 52px; text-align: center; font-size: 13px;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 4px;
}
.pager .page-total { font-size: 12.5px; color: var(--ink-soft); }

.pages-scroll { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* 单页图片 / 占位 */
.page-sheet {
  width: min(920px, 94%);
  background: var(--white);
  border: 1px solid var(--paper-edge);
  box-shadow: 0 6px 22px rgba(15, 39, 71, .10);
  border-radius: 3px;
  position: relative;
}
.page-sheet img { display: block; width: 100%; height: auto; border-radius: 3px; }
.page-sheet .page-num {
  position: absolute; top: 8px; right: 12px;
  font-size: 11px; color: var(--ink-soft);
  background: rgba(255,255,255,.85); padding: 1px 7px; border-radius: 5px;
}
.page-placeholder {
  aspect-ratio: 1 / 1.414;
  display: grid; place-items: center;
  background:
    repeating-linear-gradient(-45deg, #faf7f0, #faf7f0 12px, #f3ecdd 12px, #f3ecdd 24px);
  color: var(--ink-soft);
  text-align: center;
}
.page-placeholder .ph-page { font-family: var(--serif); font-size: 30px; color: var(--navy); opacity: .5; }
.page-placeholder .ph-hint { font-size: 12px; margin-top: 8px; }

/* ───────────── 舞台：对比模式 ───────────── */
.compare-head {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--white); border-bottom: 1px solid var(--line);
}
.compare-head .ch-title { font-family: var(--serif); font-size: 16px; color: var(--navy); font-weight: 600; }
.compare-head .ch-crumb { font-size: 12.5px; color: var(--ink-soft); }

.compare-cols { flex: 1; overflow: hidden; display: flex; gap: 0; }

.ccol {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.ccol:last-child { border-right: none; }

.ccol-head {
  padding: 11px 16px;
  background: linear-gradient(180deg, #fbf7ee, #f4ecdb);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.ccol-head .cc-pub { font-family: var(--serif); font-weight: 600; color: var(--navy); font-size: 14.5px; }
.ccol-head .cc-book { font-size: 11.5px; color: var(--ink-soft); }
.ccol-head .cc-pages { margin-left: auto; font-size: 11px; color: var(--gold); background: rgba(200,161,90,.12); padding: 2px 8px; border-radius: 5px; }

.ccol-scroll { flex: 1; overflow-y: auto; padding: 16px 14px 40px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ccol-scroll .page-sheet { width: 100%; }

.ccol-empty {
  margin: 40px 14px; padding: 24px;
  text-align: center; color: var(--ink-soft); font-size: 13px;
  border: 1px dashed var(--line); border-radius: 10px;
  background: rgba(255,255,255,.5);
}

/* ───────────── 空状态 / 提示 ───────────── */
.empty-hint {
  flex: 1; display: grid; place-items: center;
  color: var(--ink-soft); text-align: center; padding: 40px;
}
.empty-hint .eh-mark { font-family: var(--serif); font-size: 48px; color: var(--gold); opacity: .55; margin-bottom: 14px; }
.empty-hint h3 { font-family: var(--serif); color: var(--navy); font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.empty-hint p { font-size: 13.5px; line-height: 1.7; max-width: 380px; }

.loading {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--paper);
  font-family: var(--serif); color: var(--navy); font-size: 16px; letter-spacing: 2px;
  z-index: 50;
}
.loading.hide { display: none; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cdbf9f; border-radius: 6px; border: 2px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }
