/* ============================================================
   此木暖通研究室 · cimu-kb 主题
   品牌色: #FF9D33(主) / #6C4941(暗) / #FF6500(强调)
   字体: 宋体(中文) / Times New Roman(英文)
   ============================================================ */

:root {
  --primary: #FF9D33;
  --primary-light: #FFB366;
  --primary-bg: #FFF5EB;
  --primary-dark: #E68A00;
  --accent: #FF6500;
  --dark: #6C4941;
  --dark-light: #8B6B63;
  --text: #1a1a1a;
  --text-secondary: #666;
  --border: #e0ddd8;
  --bg: #fcfaf7;
  --card-bg: #fff;
  --radius: 3px;
}

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

body {
  font-family: 'SimSun','宋体','Times New Roman',serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,h2,h3,h4,h5,h6 {
  font-family: 'Times New Roman','SimSun','宋体',serif;
  color: var(--dark);
  line-height: 1.3;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }

/* ====== 导航栏 ====== */
.navbar {
  display: flex; align-items: center;
  background: linear-gradient(135deg, #C56B3E 0%, #B06E47 100%);
  padding: 0 24px; height: 56px;
  position: sticky; top: 0; z-index: 1000;
}
.navbar .logo {
  color: #fff; font-size: 19px; font-weight: 700;
  letter-spacing: 1px; margin-right: auto;
  font-family: 'Times New Roman','SimSun','宋体',serif;
}
.navbar .logo:hover { color: rgba(255,255,255,0.8); }

.nav-links { display: flex; list-style: none; gap: 4px; margin-right: 12px; align-items: center; }
.nav-links > li > a, .nav-links .dropdown-toggle {
  display: flex; align-items: center; gap: 3px;
  color: #fff; padding: 8px 14px; border-radius: var(--radius);
  font-size: 15px; font-weight: 600;
  transition: all 0.2s; white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.nav-links a:hover, .nav-links a.active {
  color: #fff; background: rgba(0,0,0,0.15);
}

/* 下拉菜单 */
.nav-dropdown { position: relative; }
.dropdown-toggle {
  cursor: pointer; display: flex; align-items: center; gap: 3px;
}
.dropdown-toggle .arrow {
  font-size: 8px; margin-left: 1px; transition: transform 0.2s;
}
.nav-dropdown.open .dropdown-toggle .arrow { transform: rotate(180deg); }

.dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  min-width: 210px; background: #fff;
  border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 6px 0; z-index: 1002; list-style: none;
}
.dropdown-menu a {
  display: block; padding: 8px 16px; color: var(--text);
  font-size: 14px; white-space: nowrap; border-radius: 0;
  transition: background 0.15s;
}
.dropdown-menu a:hover { background: var(--primary-bg); color: var(--accent); }
.dropdown-menu a.disabled { color: #bbb; pointer-events: none; cursor: default; }

.dropdown-section {
  border-top: 1px solid var(--border); padding-top: 4px; margin-top: 4px;
}
.dropdown-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.dropdown-label {
  display: block; padding: 6px 16px 2px; font-size: 11px;
  color: var(--text-secondary); letter-spacing: 0.5px;
}

/* 桌面端：hover展开下拉 */
@media (min-width: 769px) {
  .nav-dropdown:hover .dropdown-menu { display: block; }
  .dropdown-menu a { padding: 8px 16px; }
}

/* 搜索 */
.nav-search { position: relative; }
.nav-search input {
  padding: 6px 12px; border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius); background: rgba(255,255,255,0.1);
  color: #fff; font-size: 14px; width: 160px;
  font-family: inherit;
}
.nav-search input::placeholder { color: rgba(255,255,255,0.4); }
.nav-search input:focus { outline: none; border-color: var(--primary); background: rgba(255,255,255,0.15); }

.search-results {
  display: none; position: absolute; top: 100%; right: 0;
  width: 320px; max-height: 400px; overflow-y: auto;
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); margin-top: 4px;
}
.search-results.show { display: block; }
.search-results .result-item {
  display: block; padding: 10px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 14px;
}
.search-results .result-item:hover { background: var(--primary-bg); }
.search-results .result-item .result-title { font-weight: 600; color: var(--dark); }
.search-results .no-results { padding: 16px; text-align: center; color: var(--text-secondary); }

/* 汉堡菜单 */
.hamburger { display: none; flex-direction: column; gap: 5px;
  width: 36px; height: 36px; background: none; border: none;
  cursor: pointer; padding: 6px; margin-left: auto; z-index: 1001; }
.hamburger span {
  display: block; width: 100%; height: 2px;
  background: #fff; border-radius: 2px; transition: all 0.3s;
}
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

/* ====== 首页 Hero ====== */
.hero {
  text-align: center; padding: 48px 20px 32px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary-bg) 100%);
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 34px; margin-bottom: 8px; }
.hero-subtitle { color: var(--text-secondary); font-size: 15px; margin-bottom: 12px; }
.hero-desc { color: var(--dark-light); font-size: 16px; max-width: 600px; margin: 0 auto; }

/* ====== 卡片 ====== */
.card-section { margin: 32px 0; }
.section-title {
  font-size: 22px; color: var(--dark); margin-bottom: 8px;
  border-left: 4px solid var(--primary); padding-left: 12px;
}
.section-desc { color: var(--text-secondary); font-size: 15px; margin-bottom: 16px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  display: block; background: var(--card-bg); padding: 20px 24px;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: all 0.2s;
}
.card:hover {
  border-color: var(--primary); box-shadow: 0 2px 12px rgba(255,157,51,0.12);
  transform: translateY(-2px);
}
.card h3 { font-size: 18px; margin-bottom: 6px; color: var(--dark); }
.card p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }

/* ====== 知识库三栏布局 ====== */
.breadcrumb {
  padding: 10px 24px; font-size: 14px; color: var(--text-secondary);
  background: #fff; border-bottom: 1px solid var(--border);
}
.breadcrumb a { color: var(--dark-light); }

.sidebar-toggle {
  display: none; position: fixed; bottom: 20px; left: 20px; z-index: 999;
  width: 44px; height: 44px; border: 1px solid var(--border);
  background: var(--card-bg); border-radius: 50%; font-size: 20px;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.kb-layout {
  display: flex; flex: 1; max-width: 1400px;
  margin: 0 auto; width: 100%;
}

/* 左侧导航树 */
.kb-sidebar {
  width: 260px; min-width: 260px;
  background: #fff; border-right: 1px solid var(--border);
  padding: 16px 0; position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
}
.sidebar-nav { padding: 0 16px; }
.sidebar-nav h3 {
  font-size: 15px; color: var(--dark); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 2px solid var(--primary);
}
.tree { list-style: none; font-size: 14px; }
.tree li { margin: 2px 0; }
.tree a {
  display: block; padding: 4px 8px; border-radius: var(--radius);
  color: var(--dark-light); transition: all 0.15s;
}
.tree a:hover { background: var(--primary-bg); color: var(--dark); }
.tree a.current { background: var(--primary-bg); color: var(--accent); font-weight: 600; }

.tree-toggle {
  display: inline-block; width: 16px; cursor: pointer;
  color: var(--text-secondary); font-size: 10px; text-align: center;
  user-select: none; transition: transform 0.2s;
}
.tree-toggle.collapsed { transform: rotate(-90deg); }

.tree-label {
  color: var(--dark); font-weight: 600; font-size: 14px; cursor: pointer;
}
.tree-children { margin-left: 16px; }

.tree-section { margin-top: 8px; }

/* 中间主内容 */
.kb-main {
  flex: 1; min-width: 0; padding: 32px 40px; max-width: 800px;
}
.kb-main article { }
.kb-main article h1 {
  font-size: 28px; margin-bottom: 24px; padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}
.kb-main article h2 {
  font-size: 22px; margin: 28px 0 12px; padding-left: 10px;
  border-left: 4px solid var(--primary); color: var(--dark);
}
.kb-main article h3 { font-size: 18px; margin: 20px 0 8px; color: var(--dark); }
.kb-main article p { margin: 10px 0; }
.kb-main article ul, .kb-main article ol { padding-left: 24px; margin: 8px 0; }
.kb-main article li { margin: 4px 0; }
.kb-main article table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
  font-size: 14px;
}
.kb-main article th {
  background: var(--primary-bg); color: var(--dark);
  padding: 8px 12px; text-align: left; border: 1px solid var(--border);
  font-weight: 600;
}
.kb-main article td {
  padding: 6px 12px; border: 1px solid var(--border);
}
.kb-main article tr:nth-child(2n) { background: #fafaf8; }
.kb-main article code {
  background: #f0f0f0; padding: 2px 6px; border-radius: 2px;
  font-family: 'Consolas','Courier New',monospace; font-size: 14px;
}
.kb-main article pre {
  background: #2d2d2d; color: #f8f8f2; padding: 16px;
  border-radius: var(--radius); overflow-x: auto; font-size: 14px;
  line-height: 1.5; margin: 12px 0;
}
.kb-main article pre code { background: none; padding: 0; color: inherit; }

/* 右侧目录 */
.kb-toc {
  width: 220px; min-width: 220px;
  padding: 24px 16px; position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
  border-left: 1px solid var(--border); background: #fff;
}
.kb-toc h4 { font-size: 14px; color: var(--text-secondary); margin-bottom: 10px; }
.kb-toc nav a {
  display: block; padding: 3px 0; font-size: 13px; color: var(--text-secondary);
  border-left: 2px solid transparent; padding-left: 8px; transition: all 0.15s;
}
.kb-toc nav a:hover, .kb-toc nav a.active {
  color: var(--accent); border-left-color: var(--primary);
}
.kb-toc nav a.toc-h2 { font-weight: 600; color: var(--dark); }
.kb-toc nav a.toc-h3 { padding-left: 20px; }

/* ====== 工具全屏页面 ====== */
.tools-fullscreen {
  flex: 1; background: #f0f4f8; min-height: calc(100vh - 56px);
}

/* ====== 普通页面 ====== */
body.page .container article { max-width: 800px; margin: 0 auto; padding: 32px 0; }
body.page .container article h1 { font-size: 28px; margin-bottom: 20px; }
body.page .container article h2 {
  font-size: 22px; margin: 24px 0 10px; border-left: 4px solid var(--primary); padding-left: 10px;
}

/* ====== 页脚 ====== */
.footer {
  text-align: center; padding: 24px; color: var(--dark-light);
  font-size: 14px; border-top: 1px solid var(--border);
  background: var(--card-bg); margin-top: auto;
}
.footer p { margin: 4px 0; }

/* ====== 响应式 ====== */
@media (max-width: 1024px) {
  .kb-toc { display: none; }
  .kb-sidebar { width: 240px; min-width: 240px; }
}

@media (max-width: 768px) {
  .container { padding: 12px; }
  .hero { padding: 32px 16px 24px; }
  .hero h1 { font-size: 24px; }
  .cards { grid-template-columns: 1fr; }
  .nav-links {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    background: #E68A00; flex-direction: column; padding: 4px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-height: calc(100vh - 56px); overflow-y: auto;
  }
  .nav-links.show { display: flex; }
  .nav-links > li > a, .nav-links > li > .dropdown-toggle {
    padding: 12px 24px; border-radius: 0; font-size: 15px; color: #fff;
    display: block; font-weight: 600;
  }
  .nav-links a:hover { background: rgba(0,0,0,0.12); }

  /* 移动端下拉菜单 */
  .nav-dropdown .dropdown-menu {
    display: none; position: static;
    background: rgba(0,0,0,0.12); box-shadow: none;
    border-radius: 0; padding: 2px 0; min-width: auto;
  }
  .nav-dropdown.open .dropdown-menu { display: block; }
  .dropdown-menu a { padding: 10px 24px 10px 36px; font-size: 14px; color: rgba(255,255,255,0.85); }
  .dropdown-menu a:hover { background: rgba(0,0,0,0.12); color: #fff; }
  .dropdown-menu a.disabled { color: rgba(255,255,255,0.45); }
  .dropdown-label { padding: 8px 24px 2px 36px; font-size: 11px; color: rgba(255,255,255,0.55); }
  .dropdown-section { border-top-color: rgba(255,255,255,0.15); }

  .hamburger { display: flex; }
  .nav-search { display: none; }
  .nav-search.show { display: block; position: absolute; top: 56px; left: 0; right: 0; padding: 8px 16px; background: #E68A00; }
  .nav-search input { width: 100%; }
  .search-results { width: calc(100vw - 32px); right: auto; left: 16px; }

  .kb-layout { flex-direction: column; }
  .kb-sidebar {
    display: none; position: fixed; top: 56px; left: 0;
    width: 260px; height: calc(100vh - 56px);
    z-index: 900; box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }
  .kb-sidebar.open { display: block; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .kb-main { padding: 20px 16px; }
  .breadcrumb { padding: 8px 16px; font-size: 12px; }
}

@media (prefers-color-scheme: dark) {
  /* 后续扩展暗色模式 */
}
