:root {
  --bg: #f5f6f8;
  --sidebar-bg: #1f2430;
  --sidebar-text: #c7cdd8;
  --sidebar-hover: #2c3342;
  --accent: #3b82f6;
  --accent-soft: #e8f0fe;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --card: #ffffff;
  --good: #10b981;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .25s ease;
}
.brand {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  z-index: 2;
}
.brand-title { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--sidebar-text); margin-top: 3px; }

.nav { padding: 10px 0 30px; }
.nav-cat { margin-top: 8px; }
.nav-cat-head {
  padding: 10px 20px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #8b93a3;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.nav-cat-head .arrow { transition: transform .2s; font-size: 10px; }
.nav-cat.collapsed .arrow { transform: rotate(-90deg); }
.nav-cat.collapsed .nav-list { display: none; }

.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 8px 26px;
  font-size: 14px;
  cursor: pointer;
  color: var(--sidebar-text);
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--accent); }
.nav-item .en { font-size: 11px; color: #8b93a3; }
.nav-item.active .en { color: #b8c2d4; }
.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.nav-item .dot.available { background: var(--good); }
.nav-item .dot.planned { background: #4b5563; }

/* ---------- 内容区 ---------- */
.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-spacer { flex: 1; }
.user-name { font-size: 13px; color: var(--muted); white-space: nowrap; }
.admin-link { font-size: 13px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.admin-link:hover { text-decoration: underline; }
.logout-btn {
  background: none; border: 1px solid #d1d5db; border-radius: 7px;
  padding: 5px 12px; font-size: 13px; cursor: pointer; color: #374151; white-space: nowrap;
}
.logout-btn:hover { background: #f3f4f6; }
.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}

.markdown { flex: 1; overflow-y: auto; padding: 28px 36px 60px; }
.home { max-width: 860px; }
.home h1 { font-size: 26px; margin: 0 0 6px; }
.lead { color: var(--muted); font-size: 15px; margin: 0 0 16px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
}
.badge.available { background: #d1fae5; color: #047857; }
.badge.planned { background: #e5e7eb; color: #4b5563; }

/* 首页卡片 */
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 20px; }
.home-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.home-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-1px); }
.home-card .cat-name { font-weight: 700; font-size: 15px; }
.home-card .cat-en { font-size: 12px; color: var(--muted); margin-top: 2px; }
.home-card .count { font-size: 12px; color: var(--accent); margin-top: 8px; }

/* Markdown 渲染样式 */
.md { max-width: 860px; }
.md h1 { font-size: 24px; border-bottom: 2px solid var(--border); padding-bottom: 8px; margin-top: 8px; }
.md h2 { font-size: 20px; margin-top: 28px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md h3 { font-size: 16px; margin-top: 22px; color: #374151; }
.md h4 { font-size: 14px; margin-top: 16px; color: #4b5563; }
.md p { line-height: 1.7; margin: 10px 0; }
.md ul, .md ol { line-height: 1.7; padding-left: 24px; }
.md li { margin: 4px 0; }
.md blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  color: #374151;
}
.md code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
}
.md pre {
  background: #1f2430;
  color: #e5e7eb;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
}
.md pre code { background: none; color: inherit; padding: 0; }
.md table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md th { background: #f9fafb; font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.md strong { font-weight: 600; }
.md a { color: var(--accent); }

/* 元信息标签 */
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.toggle-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.toggle-btn:hover { text-decoration: underline; }
.meta-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.meta-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: #eef2f7;
  color: #374151;
}
.meta-chip.difficulty-SUPPORT { background: #d1fae5; color: #047857; }
.meta-chip.difficulty-STANDARD { background: #fef3c7; color: #b45309; }
.meta-chip.difficulty-CHALLENGE { background: #fee2e2; color: #b91c1c; }

/* 空状态 */
.empty {
  max-width: 760px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
}
.empty h2 { border: none; font-size: 18px; color: var(--text); }
.empty .big { font-size: 48px; margin: 10px 0; }

/* 场景图 */
.scene-img-wrap { margin: 0 0 18px; }
.scene-img { max-width: 100%; height: auto; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.08); display: block; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 50;
    box-shadow: 0 0 30px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .markdown { padding: 20px 18px 50px; }
  .home-cards { grid-template-columns: 1fr; }
}
