/* ====== 语文桥 · 侧栏导航共用样式 ======
 * 所有频道首页（index-*.html）和课文页（kewen/*.html）共享此文件
 * 改一个，全站联动
 * ============================================ */

/* ====== 左列：深色导航 ====== */
.sidebar {
  width: var(--sidebar-w, 240px);
  background: var(--sidebar-bg, #1a1a2e);
  color: var(--sidebar-text, #b0b0c8);
  flex-shrink: 0;
  position: sticky;
  top: 50px;
  height: calc(100vh - 50px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
/* 侧栏滚动条：必须用 !important —— 每个课文页的内联 <style> 里都有一条
   `.sidebar::-webkit-scrollbar-thumb { background:#d9d2c2 }`（浅米白），
   内联样式在外部 CSS 之后，优先级相同者后者胜，故必须提升。
   —— 2026-09-23 桥哥：教材库滚动条不要白底色 */
.sidebar::-webkit-scrollbar { width: 6px !important; }
.sidebar::-webkit-scrollbar-track { background: transparent !important; }
.sidebar::-webkit-scrollbar-track-piece { background: transparent !important; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--sidebar-scroll, #4a4a6e) !important;
  border-radius: 3px !important;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--sidebar-scroll-hover, #6a6a92) !important; }
/* 浅色侧栏通道（课文页：html.channel-lessons body）——配浅金滑块 */
html.channel-lessons body .sidebar::-webkit-scrollbar { width: 6px !important; }
html.channel-lessons body .sidebar::-webkit-scrollbar-track { background: transparent !important; }
html.channel-lessons body .sidebar::-webkit-scrollbar-thumb { background: #c9b98a !important; border-radius: 3px !important; }
html.channel-lessons body .sidebar::-webkit-scrollbar-thumb:hover { background: #b8922e !important; }

/* TGB跳转导航 · 小灯笼 */
.tgb-nav {
  display: flex;
  border-bottom: 1px solid var(--sidebar-border, #2a2a4a);
  padding: 5px 8px;
  gap: 2px;
}
.tgb-nav a, .tgb-nav button {
  flex: 1;
  text-align: center;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--sidebar-dim, #8888aa);
  letter-spacing: 2px;
  transition: all 0.2s;
  text-decoration: none;
  cursor: pointer;
  border-radius: 14px;
  margin: 0 2px;
}
.tgb-nav a:hover, .tgb-nav button:hover {
  color: var(--sidebar-hover-text, #cccce0);
  background: var(--sidebar-hover-bg, rgba(255,255,255,0.04));
}
.tgb-nav a.active, .tgb-nav button.active {
  background: rgba(212, 175, 55, 0.15);
  color: #e8c56a;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.12), inset 0 0 2px rgba(212, 175, 55, 0.06);
}

/* 搜索框 */
.search-box { padding: 8px; }
.search-box input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--sidebar-border, #5a5a8a);
  border-radius: 4px;
  background: var(--sidebar-input-bg, #1a1a3a);
  color: var(--sidebar-input-text, #d0d0e8);
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

/* 导航树滚动区 */
.nav-links { flex: 1; padding: 4px 0 20px; overflow-y: auto;
             scrollbar-width: thin; scrollbar-color: var(--sidebar-scroll, #3a3a5a) transparent; }
.nav-links::-webkit-scrollbar { width: 5px; }
.nav-links::-webkit-scrollbar-track { background: transparent; }
.nav-links::-webkit-scrollbar-thumb { background: var(--sidebar-scroll, #3a3a5a); border-radius: 3px; }
.nav-links::-webkit-scrollbar-thumb:hover { background: var(--sidebar-scroll-hover, #5a5a8a); }

/* 册标题 */
.tree-header {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
  color: var(--sidebar-header-text, #c8c8e0);
}
.tree-header:hover { background: var(--sidebar-hover, #252545); }
.tree-header .arrow {
  font-size: 9px;
  transition: transform 0.2s;
  color: var(--sidebar-dim, #555577);
}
.tree-header .arrow.open { transform: rotate(90deg); }
.tree-header.collapsed .arrow { transform: rotate(-90deg); }

/* 课文列表容器 */
.tree-items { list-style: none; }
.tree-items.hidden { display: none; }

/* 单元分隔条 */
.unit-separator {
  padding: 5px 18px 3px 28px;
  font-size: 10px;
  color: var(--sidebar-dim, #7878a0);
  background: var(--sidebar-unit-bg, #16162e);
  border-bottom: 1px solid var(--sidebar-border, #2a2a4a);
  margin: 3px 0;
  letter-spacing: 1px;
  font-weight: 600;
  cursor: default;
  user-select: none;
}
.unit-sep-gaozhong {
  color: var(--sidebar-gold, #ffd700);
  background: var(--sidebar-unit-gold-bg, #1c1c2e);
  font-weight: 700;
  letter-spacing: 2px;
  padding: 6px 18px 6px 26px;
  margin: 6px 0;
}

.stage-header { font-size: 13px !important; color: var(--gold-light, #e8c56a) !important; }
.stage-grades { }

/* 课文条目 */
.tree-item {
  display: block;
  padding: 5px 18px 5px 32px;
  font-size: 12px;
  color: var(--sidebar-text, #b0b0c8);
  border-left: 2px solid transparent;
  transition: all 0.12s;
  cursor: pointer;
}
.tree-item:hover { background: var(--sidebar-hover, #252545); color: var(--sidebar-hover-text, #d0d0e8); }
.tree-item.active { border-left-color: var(--sidebar-active, #e8c56a); color: var(--sidebar-active-text, #e0e0f0); background: var(--sidebar-hover, #252545); }
.tree-item a { color: inherit; display: block; }
.tree-item a:hover { text-decoration: none; color: var(--sidebar-hover-text, #d0d0e8); }

/* 父标题（不可点击） */
.tree-item-parent {
  padding: 8px 18px 8px 28px;
  font-size: 12px;
  color: var(--sidebar-parent, #666688);
  cursor: default;
  border-left: 2px solid transparent;
}
.tree-item-parent:hover { background: transparent; color: #666688; }
.tree-item-parent span { display: block; }

/* 子课文条目 */
.tree-item-sub {
  display: block;
  padding: 6px 18px 6px 32px;
  font-size: 11px;
  color: var(--sidebar-dim, #8888aa);
  border-left: 2px solid transparent;
}
.tree-item-sub:hover { background: transparent; color: #8888aa; }
.tree-item-sub a { color: inherit; display: block; }
.tree-item-sub a:hover { text-decoration: none; color: var(--sidebar-sub-hover, #b0b0d0); }
.tree-item-sub span { display: block; }

.unit-header { padding-left: 28px !important; }

/* 侧栏底部 */
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--sidebar-border, #2a2a4a);
  font-size: 11px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-title {
  padding: 14px 18px 6px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--sidebar-dim, #555577);
  font-weight: 600;
}
.sidebar-nav { flex: 1; padding: 4px 0 20px; }


/* ===== 侧栏配色变量（默认深色；html.channel-lessons body 覆盖为浅色） =====
 * 2026-08-16：kewen 频道对齐课标页导航标杆（浅色侧栏），yuedu/mingshipu 保持深色 */
:root {
  --sidebar-scroll: #3a3a5a;
  --sidebar-border: #2a2a4a;
  --sidebar-dim: #8888aa;
  --sidebar-hover-text: #d0d0e8;
  --sidebar-hover-bg: rgba(255,255,255,0.04);
  --sidebar-input-bg: #1a1a3a;
  --sidebar-input-text: #d0d0e8;
  --sidebar-header-text: #c8c8e0;
  --sidebar-unit-bg: #16162e;
  --sidebar-gold: #ffd700;
  --sidebar-unit-gold-bg: #1c1c2e;
  --sidebar-active-text: #e0e0f0;
  --sidebar-parent: #666688;
  --sidebar-sub-hover: #b0b0d0;
}

/* 课文频道（lessons）：课标同款深色侧栏（2026-08-16 重做，参考 kebiao 树）
 * 一级(册)=三角▶；二级(单元)=尖括号>；当前项金色左边线；级间细分隔线。
 * 注：kewen 各页 <head> 内联 <style> 对 .tree-item/.tree-header/.sidebar 写死浅色，
 *     且不走变量，故必须用 !important 覆盖；并限定 html.channel-lessons body，
 *     以免误伤 yuedu / mingshipu（它们不加载 JS 生成的树、应保持原深色）。 */
html.channel-lessons body {
  --sidebar-bg: #faf8f5;
  --sidebar-hover: #f0ece2;
  --sidebar-text: #5c5344;
  --sidebar-active: #b8922e;
  --sidebar-scroll: #d9d2c2;
  --sidebar-border: #e3ddd0;
  --sidebar-dim: #8a7d66;
  --sidebar-hover-text: #3a3226;
  --sidebar-hover-bg: rgba(184,146,46,0.10);
  --sidebar-input-bg: #ffffff;
  --sidebar-input-text: #3a3226;
  --sidebar-header-text: #5c5344;
  --sidebar-unit-bg: #f4f0e7;
  --sidebar-gold: #b8922e;
  --sidebar-unit-gold-bg: #efe8d8;
  --sidebar-active-text: #6b5d44;
  --sidebar-parent: #9a8d75;
  --sidebar-sub-hover: #4a3f2e;
}

/* ---- 强制覆盖内联（仅 kewen） ---- */
html.channel-lessons body .sidebar {
  background: #faf8f5 !important;
  border-right: 1px solid #e3ddd0 !important;
  color: #5c5344 !important;
}
/* 课文页侧栏滚动条：米白轨道 + 金色滑块（原先只覆盖 .sidebar，而真正滚动的是 .nav-links，等于没生效） */
html.channel-lessons body .nav-links { scrollbar-width: thin; scrollbar-color: #c9b98a #f2ede3; }
html.channel-lessons body .nav-links::-webkit-scrollbar { width: 6px !important; }
html.channel-lessons body .nav-links::-webkit-scrollbar-track { background: #f2ede3 !important; }
html.channel-lessons body .nav-links::-webkit-scrollbar-thumb { background: #c9b98a !important; border-radius: 3px !important; }
html.channel-lessons body .nav-links::-webkit-scrollbar-thumb:hover { background: #b8922e !important; }
html.channel-lessons body .tgb-nav { border-bottom: 1px solid #e3ddd0 !important; background: #f4f0e7 !important; }
html.channel-lessons body .tgb-nav a { color: #8a7d66 !important; background: transparent !important; }
html.channel-lessons body .tgb-nav a:hover { color: #6b5d44 !important; background: rgba(184,146,46,0.08) !important; }
html.channel-lessons body .tgb-nav a.active { background: rgba(184,146,46,0.16) !important; color: #8a6d2e !important; box-shadow: 0 0 8px rgba(184,146,46,0.18) !important; }
html.channel-lessons body .search-box { margin: 2px !important; }
html.channel-lessons body .search-box input,
html.channel-lessons body #searchInput { border: 1px solid #e3ddd0 !important; background: #ffffff !important; color: #3a3226 !important; }
html.channel-lessons body .search-box input:focus,
html.channel-lessons body #searchInput:focus { border-color: #b8922e !important; box-shadow: 0 0 0 3px rgba(184,146,46,0.15) !important; }

/* ---- 一级（册）：三角 ▶，展开旋转 90°（向下=放） ---- */
html.channel-lessons body .tree-group.level1 + .tree-group.level1 { border-top: 1px solid #e3ddd0 !important; margin-top: 4px !important; padding-top: 4px !important; }
html.channel-lessons body .tree-header { color: #5c5344 !important; }
html.channel-lessons body .tree-header:hover { background: rgba(184,146,46,0.08) !important; color: #3a3226 !important; }
html.channel-lessons body .tree-header .arrow { color: #b8922e !important; }
/* 图标方向：尖向右=收（0deg），向下=放（90deg） */
html.channel-lessons body .tree-header.collapsed .arrow { transform: rotate(0deg) !important; }
html.channel-lessons body .tree-group.level2 .tree-header.collapsed .arrow::before { transform: rotate(0deg) !important; }
html.channel-lessons body .tree-header.level1 { padding: 8px 14px !important; font-size: 13px !important; font-weight: 700 !important; color: #6b5d44 !important; border-radius: 4px !important; letter-spacing: 1px !important; }
html.channel-lessons body .tree-header.level1:hover { background: rgba(184,146,46,0.14) !important; color: #4a3f2e !important; }
html.channel-lessons body .tree-header.level1 .arrow { font-size: 10px !important; margin-right: 4px !important; color: #b8922e !important; }
html.channel-lessons body .tree-header.level1.active { background: rgba(184,146,46,0.12) !important; border-left: 3px solid #b8922e !important; color: #8a6d2e !important; }

/* ---- 二级（单元）：尖括号 > ，展开旋转 90°（向下=放） ---- */
html.channel-lessons body .tree-group.level2 + .tree-group.level2 { border-top: 1px solid #e8e2d5 !important; }
html.channel-lessons body .tree-group.level2 .tree-header { padding: 5px 12px 5px 16px !important; font-size: 12px !important; font-weight: 500 !important; color: #8a7d66 !important; border-radius: 3px !important; letter-spacing: 0 !important; }
html.channel-lessons body .tree-group.level2 .tree-header:hover { background: rgba(184,146,46,0.07) !important; color: #3a3226 !important; }
html.channel-lessons body .tree-group.level2 .tree-items { padding-left: 4px !important; }
html.channel-lessons body .tree-group.level2 .tree-header .arrow { font-size: 0 !important; margin-right: 5px !important; width: 12px !important; text-align: center !important; transform: none !important; }
/* 尖括号 > ：收(右=0deg) / 放(下=90deg)，由 ::before 单独控制，屏蔽通用 .arrow 元素旋转叠加 */
html.channel-lessons body .tree-group.level2 .tree-header .arrow::before { content: '>' !important; font-size: 12px !important; line-height: 1 !important; display: inline-block !important; color: #b8922e !important; transform: rotate(0deg) !important; transition: transform 0.2s !important; }
html.channel-lessons body .tree-group.level2 .tree-header .arrow.open::before,
html.channel-lessons body .tree-group.level2 .tree-header:not(.collapsed) .arrow::before { transform: rotate(90deg) !important; }

/* ---- 课文条目：左边线 + 悬停/当前金色 ---- */
html.channel-lessons body .tree-item { color: #5c5344 !important; }
html.channel-lessons body .tree-item:hover { background: rgba(184,146,46,0.07) !important; color: #3a3226 !important; }
html.channel-lessons body .tree-item.active { color: #8a6d2e !important; border-left-color: #b8922e !important; background: rgba(184,146,46,0.12) !important; }
html.channel-lessons body .tree-item-sub,
html.channel-lessons body .tree-item.sub-item { color: #9a8d75 !important; }
html.channel-lessons body .tree-item-sub:hover,
html.channel-lessons body .tree-item.sub-item:hover { background: rgba(184,146,46,0.07) !important; color: #3a3226 !important; }
html.channel-lessons body .tree-item-sub.active,
html.channel-lessons body .tree-item.sub-item.active { color: #8a6d2e !important; border-left-color: #b8922e !important; background: rgba(184,146,46,0.12) !important; }
html.channel-lessons body .tree-item-parent { color: #9a8d75 !important; }
html.channel-lessons body .tree-item-parent:hover { background: transparent !important; color: #9a8d75 !important; }

/* ---- 分隔线 / 旧 unit-separator 兼容 ---- */
html.channel-lessons body .tree-section-divider { height: 1px !important; background: #e3ddd0 !important; margin: 4px 16px !important; border: none !important; }
html.channel-lessons body .unit-separator { color: #8a7d66 !important; background: #f4f0e7 !important; border-bottom: 1px solid #e3ddd0 !important; }
html.channel-lessons body .unit-sep-gaozhong { color: #b8922e !important; background: #efe8d8 !important; }

/* ===== 小/初/高 学段 TAB（搜索框上方 .tgb-nav） ===== */
html.channel-lessons body .tgb-nav a.stage-tab { letter-spacing: 1px; font-weight: 600; font-size: 12px; }
html.channel-lessons body .tgb-nav a.stage-tab:hover { color: #6b5d44 !important; }
html.channel-lessons body .sidebar-footer { border: 1px solid #e3ddd0 !important; color: #8a7d66 !important; background: #faf8f5 !important; }
html.channel-lessons body .sidebar-footer a { color: #9a8d75 !important; }
