* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #1a1a2e; --bg2: #16213e; --bg3: #0f3460;
  --fg: #e0e0e0; --fg2: #a0a0b0; --accent: #e94560;
  --link: #64b5f6; --border: #2a2a4a;
  --radius: 8px; --shadow: 0 2px 8px rgba(0,0,0,0.3);
}


[data-theme="default"] {
  --accent: #e94560; --link: #64b5f6; --bg3: #0f3460;
}
[data-theme="ink-gold"] {
  --accent: #c9a94e; --link: #7ab0c0; --bg3: #1a2640;
}
[data-theme="sky-blue"] {
  --accent: #6ba4b8; --link: #8bb8d0; --bg3: #0a2a3a;
}
[data-theme="bamboo"] {
  --accent: #8aaa70; --link: #a0c090; --bg3: #0a2a1a;
  --bg: #1a2a1a; --bg2: #162316; --border: #2a3a2a;
}
[data-theme="sandalwood"] {
  --accent: #d4a843; --link: #c4955a; --bg3: #2a1f14;
  --bg: #2a1f14; --bg2: #221810; --border: #3a2a1a;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.7;
}
#app {
  display: flex; flex-direction: column; height: 100vh;
  position: relative; overflow: hidden;
}

/* 顶栏 */
#topbar {
  display: flex; align-items: center; height: 48px; padding: 0 12px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  gap: 8px; flex-shrink: 0; z-index: 100;
}
#breadcrumb {
  flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 14px; color: var(--fg2);
}
#breadcrumb span { color: var(--fg); }
.icon-btn {
  width: 36px; height: 36px; border: none; border-radius: var(--radius);
  background: transparent; color: var(--fg); font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: var(--bg3); }
.icon-btn:disabled { opacity: 0.3; }

/* 侧边栏 */
#sidebar {
  position: fixed; top: 0; left: -300px; width: 300px; height: 100%;
  background: var(--bg2); z-index: 200; transition: left 0.3s ease;
  display: flex; flex-direction: column; box-shadow: 2px 0 12px rgba(0,0,0,0.5);
}
#sidebar.open { left: 0; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 18px; }
.sidebar-search { padding: 8px 12px; }
.sidebar-search input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--fg);
  font-size: 14px; outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }
#sidebarTree {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.tree-item {
  display: flex; align-items: center; padding: 6px 16px; cursor: pointer;
  color: var(--fg2); font-size: 14px; gap: 6px; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tree-item:active { background: var(--bg3); }
.tree-item .icon { width: 20px; text-align: center; flex-shrink: 0; }
.tree-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item.dir { color: var(--fg); font-weight: 500; }
.tree-item.file { padding-left: 42px; }
.tree-item.highlight { background: var(--bg3); color: var(--accent); }
.tree-loader, .tree-empty { padding: 20px; text-align: center; color: var(--fg2); }
#sidebarOverlay {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.5);
}
#sidebarOverlay.show { display: block; }

/* 主内容 */
#content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 0; gap: 12px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { 
  padding: 20px; text-align: center; color: var(--accent); 
  background: rgba(233,69,96,0.1); border-radius: var(--radius);
  margin: 20px 0;
}

/* 目录列表 */
.dir-list { display: flex; flex-direction: column; gap: 4px; }
.dir-item {
  display: flex; align-items: center; padding: 10px 12px; gap: 10px;
  cursor: pointer; border-radius: var(--radius); user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dir-item:active { background: var(--bg2); }
.dir-item .icon { font-size: 20px; }
.dir-item .name { font-size: 15px; }
.dir-item .desc { font-size: 12px; color: var(--fg2); margin-left: auto; }

/* Markdown 渲染 */
.markdown-body { padding-bottom: 40px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin: 24px 0 12px; color: var(--fg); line-height: 1.4;
}
.markdown-body h1 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 16px; }
.markdown-body p { margin: 8px 0 12px; }
.markdown-body a { color: var(--link); text-decoration: none; }
.markdown-body a:active { opacity: 0.8; }
.markdown-body img {
  max-width: 100%; height: auto; border-radius: var(--radius);
  margin: 8px 0;
}
.markdown-body blockquote {
  border-left: 3px solid var(--accent); padding: 8px 12px; margin: 12px 0;
  background: rgba(233,69,96,0.05); border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown-body code {
  background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-size: 14px;
}
.markdown-body pre {
  background: var(--bg2); padding: 12px; border-radius: var(--radius);
  overflow-x: auto; margin: 12px 0;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
  font-size: 14px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.markdown-body th { background: var(--bg2); font-weight: 600; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin: 8px 0; }
.markdown-body li { margin: 4px 0; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown-body .internal-link {
  color: var(--accent); text-decoration: underline; text-decoration-style: dotted;
}

/* 底栏 */
#bottombar {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; padding: 0 12px; background: var(--bg2);
  border-top: 1px solid var(--border); flex-shrink: 0;
  font-size: 12px; color: var(--fg2);
}

/* 空状态 */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--fg2);
}
.empty-state .big-icon { font-size: 48px; margin-bottom: 12px; }

/* 桌面端 */
@media (min-width: 768px) {
  #sidebar { left: 0; position: relative; width: 320px; }
  #sidebarOverlay { display: none !important; }
  #app { flex-direction: row; }
  #menuBtn, #closeSidebar { display: none; }
  .sidebar-header h2 { font-size: 20px; }
}
@media (max-width: 767px) {
  .markdown-body table { display: block; overflow-x: auto; }
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f5; --bg2: #ffffff; --bg3: #e8e8e8;
    --fg: #333333; --fg2: #888888; --accent: #d6336c;
    --link: #1976d2; --border: #dddddd;
  }
}
.icon-btn:disabled { opacity: 0.3; }



.theme-selector { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.theme-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: all 0.15s;
}
.theme-btn .dot { width: 24px; height: 24px; border-radius: 50%; background: var(--btn-c); }
.theme-btn.active { border-color: var(--btn-c); box-shadow: 0 0 6px var(--btn-c); }
.theme-option { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.theme-option .name { font-size: 11px; color: var(--fg2); }
.theme-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }

/* 设置弹窗 */
.config-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.6); align-items: center; justify-content: center;
}
.config-dialog {
  background: var(--bg2); border-radius: 12px; width: 85%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.config-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.config-header h3 { font-size: 16px; }
.config-body { padding: 16px; }
.config-body label { font-size: 13px; color: var(--fg2); display: block; margin-bottom: 6px; }
.config-body input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--fg);
  font-size: 14px; outline: none;
}
.config-body input:focus { border-color: var(--accent); }
.config-hint { font-size: 12px; color: var(--fg2); margin: 8px 0 16px; }
.config-actions { display: flex; gap: 8px; }
.btn {
  flex: 1; padding: 10px; border: none; border-radius: var(--radius);
  font-size: 14px; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--bg3); color: var(--fg); }
.btn:active { opacity: 0.8; }

/* 侧边栏 */
