:root {
  /* ... (颜色变量保持不变) ... */
  --bg: #0f1720;
  --surface: #111318;
  --muted: #9aa4b2;
  --text: #e6eef6;
  --accent: #4aa3ff;
  --glass: rgba(255, 255, 255, 0.03);
  --radius: 12px;
  --shadow: 0 6px 20px rgba(2, 6, 23, 0.6);
  --font: "Noto Sans SC", system-ui, sans-serif;
}
body.light-theme {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --muted: #6b7280;
  --text: #111827;
  --accent: #1e6fd8;
  --glass: rgba(0, 0, 0, 0.02);
  --shadow: 0 6px 14px rgba(9, 30, 66, 0.06);
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.app.loading {
  visibility: hidden;
}

/* ... (登录部分不变) ... */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(6px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.overlay.visible {
  opacity: 1;
  visibility: visible;
}
.login-card {
  width: 420px;
  background: var(--surface);
  padding: 28px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.brand i {
  color: var(--accent);
}
.brand h1 {
  font-size: 20px;
  margin: 0;
}
.hint {
  color: var(--muted);
  margin: 12px 0 18px;
}
#username-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: transparent;
  color: var(--text);
  font-size: 14px;
}
.row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #2b8cff);
  color: white;
  box-shadow: 0 6px 18px rgba(74, 163, 255, 0.12);
}
.btn.subtle {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* ... (App & Topbar 部分不变) ... */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 560px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}
.topbar .left,
.topbar .center,
.topbar .right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar button {
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}
.topbar button:hover {
  background: var(--glass);
}
.brand.small span {
  margin-left: 6px;
  font-size: 14px;
}
.progress-controls button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
}
.seek {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 360px;
}
.seek input[type="range"] {
  flex: 1;
}
.now-playing {
  min-width: 180px;
  text-align: center;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- 🐞 侧边栏布局终极修复 --- */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.sidebar {
  width: 300px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-right: 1px solid rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.3s ease;
}
.sidebar.collapsed {
  margin-left: -300px;
}

.section {
  flex: 1; /* 平分空间 */
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.section:first-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.section h3 {
  padding: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* 滚动容器样式 */
.list-container {
  flex-grow: 1; /* 关键：让这个容器填满 section 里的剩余空间 */
  overflow-y: auto; /* 关键：让这个容器负责滚动 */
  padding: 0 10px 10px; /* 内边距 */
}

/* 列表样式 */
.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-list li {
  padding: 12px 15px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: normal;
  word-break: break-all;
  line-height: 1.5;
  transition: background-color 0.2s ease;
}
.item-list li:hover {
  background: var(--glass);
}
.item-list li.active {
  background: linear-gradient(90deg, var(--accent), #2b8cff);
  color: white;
  box-shadow: 0 8px 20px rgba(46, 117, 255, 0.12);
}

/* ... (viewer 和 responsive 样式保持不变) ... */
.viewer {
  flex: 1;
  padding: 28px;
  overflow: auto;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.02));
}
.markdown-body {
  max-width: 900px;
}
.markdown-body h1,
.markdown-body h2 {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 8px;
  margin-top: 24px;
}
.markdown-body p {
  line-height: 1.8;
  color: var(--muted);
}
@media (max-width: 900px) {
  .sidebar {
    width: 260px;
  }
  .sidebar.collapsed {
    margin-left: -260px;
  }
  .seek {
    min-width: 180px;
  }
}
@media (max-width: 700px) {
  .sidebar {
    display: none;
  }
  .sidebar.collapsed {
    display: none;
  }
  .topbar .center {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
}
