/* ===== 暗色模式（默认） ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #0f1118;
  --bg-card: #151a25;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #00ffff;
  --accent2: #ff0080;
  --accent-glow: rgba(0, 255, 255, 0.25);
  --border: rgba(0, 255, 255, 0.12);
  --sidebar-width: 280px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --code-bg: rgba(0, 255, 255, 0.08);
  --pre-bg: #0a0a0f;
  --table-header-bg: #151a25;
}

/* ===== 亮色模式 ===== */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent: #0891b2;
  --accent2: #db2777;
  --accent-glow: rgba(8, 145, 178, 0.15);
  --border: rgba(8, 145, 178, 0.15);
  --code-bg: rgba(8, 145, 178, 0.08);
  --pre-bg: #f1f5f9;
  --table-header-bg: #e2e8f0;
}

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

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  transition: background 0.4s, color 0.4s;
}

/* ===== 鼠标光效 ===== */
.cursor-glow {
  position: fixed;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s;
  opacity: 0;
}

.cursor-glow.active {
  opacity: 1;
}

[data-theme="light"] .cursor-glow {
  display: none;
}

/* ===== 粒子背景 ===== */
.particles-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.2;
  animation: float linear infinite;
}

[data-theme="light"] .particle {
  opacity: 0.1;
}

@keyframes float {
  0% {
    transform: translateY(100vh);
    opacity: 0;
  }

  10% {
    opacity: 0.2;
  }

  90% {
    opacity: 0.2;
  }

  100% {
    transform: translateY(-10vh);
    opacity: 0;
  }
}

/* ===== 布局 ===== */
.app-container {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== 侧边栏遮罩 ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: var(--transition);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent-glow);
  font-family: 'Orbitron', sans-serif;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  transition: var(--transition);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.sidebar-close:hover {
  color: var(--accent);
  background: rgba(0, 255, 255, 0.08);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.sidebar-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ===== 目录树 ===== */
.tree-item {
  margin: 1px 0;
}

.tree-folder,
.tree-file {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.84rem;
  color: var(--text-secondary);
  user-select: none;
}

.tree-folder:hover,
.tree-file:hover {
  background: rgba(0, 255, 255, 0.06);
  color: var(--text-primary);
}

.tree-file.active {
  background: rgba(0, 255, 255, 0.12);
  color: var(--accent);
}

.tree-folder .icon {
  margin-right: 6px;
  transition: var(--transition);
  font-size: 0.65rem;
}

.tree-folder.expanded .icon {
  transform: rotate(90deg);
}

.tree-file .icon {
  margin-right: 6px;
  font-size: 0.55rem;
  color: var(--accent);
}

.tree-children {
  margin-left: 12px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.tree-children.expanded {
  max-height: 5000px;
}

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin-left: 0;
  transition: var(--transition);
}

.main-content.shifted {
  margin-left: var(--sidebar-width);
}

/* ===== 顶部栏 ===== */
.top-bar {
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.menu-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1rem;
}

.menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.top-bar-title {
  margin-left: 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1.1rem;
  margin-left: 8px;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ===== 内容区 ===== */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.content-area::-webkit-scrollbar {
  width: 5px;
}

.content-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===== 欢迎页 ===== */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  text-align: center;
}

.welcome h1 {
  font-size: 2.6rem;
  font-family: 'Orbitron', sans-serif;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.welcome p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 460px;
  line-height: 1.7;
}

.welcome .hint {
  margin-top: 18px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

/* ===== Markdown 渲染 ===== */
.markdown-body {
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.8;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.markdown-body h1 {
  font-size: 1.8rem;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
  font-size: 1.35rem;
  margin-top: 26px;
  margin-bottom: 10px;
}

.markdown-body h3 {
  font-size: 1.1rem;
  margin-top: 18px;
  margin-bottom: 6px;
}

.markdown-body p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.markdown-body a:hover {
  border-bottom-color: var(--accent);
}

.markdown-body code {
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.84em;
  color: var(--accent);
}

.markdown-body pre {
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent2);
  padding-left: 14px;
  margin: 14px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 12px;
  padding-left: 22px;
}

.markdown-body li {
  margin-bottom: 5px;
  color: var(--text-secondary);
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 12px 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--table-header-bg);
  color: var(--accent);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 75vw;
  }

  .sidebar-overlay {
    display: block;
  }

  .main-content.shifted {
    margin-left: 0;
  }

  .content-area {
    padding: 18px 14px;
  }

  .welcome h1 {
    font-size: 1.8rem;
  }

  .markdown-body {
    font-size: 0.9rem;
  }

  .markdown-body h1 {
    font-size: 1.4rem;
  }

  .cursor-glow {
    display: none;
  }
}

@media (max-width: 480px) {
  :root {
    --sidebar-width: 85vw;
  }

  .top-bar {
    padding: 0 10px;
    height: 46px;
  }

  .content-area {
    padding: 14px 10px;
  }

  .welcome h1 {
    font-size: 1.5rem;
  }
}