/* =========================================================
   主题变量：浅色为默认，body.dark 切换为深色
   ========================================================= */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sidebar-bg: #ffffff;
  --text: #1f2329;
  --text-muted: #8a9099;
  --border: #e6e8eb;
  --accent: #3b82f6;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --topbar-h: 56px;
  --sidebar-w: 240px;
}

body.dark {
  --bg: #15171a;
  --surface: #1e2125;
  --sidebar-bg: #1b1e22;
  --text: #e6e8eb;
  --text-muted: #9aa0a8;
  --border: #2c3035;
  --accent: #5b9bff;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

/* =========================================================
   基础重置
   ========================================================= */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* =========================================================
   顶部栏
   ========================================================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  color: var(--accent);
}
.brand i { margin-right: 6px; }
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
  padding: 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.search-box i { color: var(--text-muted); }
.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}
.engine-select {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  max-width: 88px;
  outline: 0;
  cursor: pointer;
  border-right: 1px solid var(--border);
  padding-right: 6px;
  margin-right: 4px;
}
.engine-select option { color: #000; }
.search-go { font-size: 14px; }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--bg); }
.menu-toggle { display: none; }

/* =========================================================
   布局：侧边栏 + 内容
   ========================================================= */
.layout { display: flex; }

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
  z-index: 90;
}
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-group > .nav-group-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-weight: 600;
  color: var(--text);
}
.nav-group-link i { width: 20px; text-align: center; color: var(--accent); }
.nav-group-link:hover { background: var(--bg); }
.nav-sub { list-style: none; margin: 0; padding: 0 0 6px; }
.nav-sub a {
  display: block;
  padding: 7px 16px 7px 46px;
  font-size: 14px;
  color: var(--text-muted);
}
.nav-sub a:hover { color: var(--text); background: var(--bg); }

.content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px;
  flex: 1;
  min-width: 0;
}

/* =========================================================
   内容区标题与卡片网格
   ========================================================= */
.tax-section { scroll-margin-top: calc(var(--topbar-h) + 12px); margin-bottom: 36px; }
.tax-title {
  font-size: 20px;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tax-title i { color: var(--accent); }
.term-block { scroll-margin-top: calc(var(--topbar-h) + 12px); margin-bottom: 24px; }
.term-title {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.card-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}
.card-logo {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}
.card-logo img { width: 32px; height: 32px; object-fit: contain; }
.card-info { min-width: 0; flex: 1; }
.card-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-go {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity .15s;
}
.card-item:hover .card-go { opacity: 1; }

/* 链接有效性指示 */
.link-badge {
  position: absolute;
  left: 10px; bottom: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  z-index: 2;
}
.link-badge-ok { background: #2ecc71; }
.link-badge-dead { background: #e74c3c; }
.link-badge-unknown { background: #f1c40f; }
.link-dead { opacity: .55; }
.link-dead .card-title { text-decoration: line-through; }
.link-unknown { opacity: .85; }

/* =========================================================
   页脚
   ========================================================= */
.site-footer {
  margin-left: var(--sidebar-w);
  padding: 20px 24px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* =========================================================
   响应式：移动端侧边栏变为抽屉
   ========================================================= */
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .brand { font-size: 16px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s;
    box-shadow: 2px 0 12px rgba(0, 0, 0, .25);
  }
  .sidebar.open { transform: translateX(0); }
  .content, .site-footer { margin-left: 0; }
  /* 移动端遮罩 */
  .sidebar::after { content: none; }
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, .4);
    z-index: 80;
  }
}

@media (max-width: 480px) {
  .content { padding: 16px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .brand span, .brand { font-size: 15px; }
}
