/* ========== LegalByte · 样式 ========== */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #1d4ed8;
  --accent-soft: #eff4ff;
  --badge-dead: #b91c1c;
  --badge-dead-bg: #fef2f2;
  --badge-warn: #92400e;
  --badge-warn-bg: #fffbeb;
  --shadow: 0 1px 2px rgba(16,24,40,.06);
  --shadow-hover: 0 4px 12px rgba(16,24,40,.12);
  --radius: 10px;
}
[data-theme="dark"] {
  --bg: #12151c;
  --panel: #1a1f29;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #2a3140;
  --accent: #60a5fa;
  --accent-soft: #1e293b;
  --badge-dead: #f87171;
  --badge-dead-bg: #2a1518;
  --badge-warn: #fbbf24;
  --badge-warn-bg: #29200e;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-hover: 0 4px 14px rgba(0,0,0,.5);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand-logo { width: 28px; height: 28px; border-radius: 6px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--muted); border-left: 1px solid var(--border); padding-left: 10px; }
.search-box {
  flex: 1; max-width: 460px; position: relative; display: flex; align-items: center;
}
.search-ico { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
#search {
  width: 100%; height: 36px; padding: 0 30px 0 32px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
#search:focus { border-color: var(--accent); background: var(--panel); }
#search-clear {
  position: absolute; right: 6px; width: 22px; height: 22px; border: none; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; display: none;
}
#search-clear:hover { background: var(--border); }
#theme-toggle, .menu-toggle {
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#theme-toggle:hover, .menu-toggle:hover { border-color: var(--accent); color: var(--accent); }
#theme-toggle svg, .menu-toggle svg { width: 18px; height: 18px; }
[data-theme="light"] .ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
.menu-toggle { display: none; }

/* ---------- 布局 ---------- */
.layout { max-width: 1440px; margin: 0 auto; padding-top: 56px; display: flex; align-items: flex-start; }
.sidebar {
  width: 228px; flex-shrink: 0; position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
  border-right: 1px solid var(--border); padding: 16px 12px 8px;
  background: var(--bg);
}
.side-group { margin-bottom: 4px; }
.side-group-title {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px 10px; border: none; border-radius: 8px; background: transparent;
  color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left;
}
.side-group-title:hover { background: var(--accent-soft); color: var(--accent); }
.side-group-title .count { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 400; }
.side-group-title .arrow { width: 12px; height: 12px; transition: transform .15s; flex-shrink: 0; }
.side-group.open .side-group-title .arrow { transform: rotate(90deg); }
.side-children { display: none; padding: 2px 0 6px; }
.side-group.open .side-children { display: block; }
.side-child {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 26px;
  border-radius: 7px; color: var(--muted); font-size: 13px; text-decoration: none;
}
.side-child:hover { background: var(--accent-soft); color: var(--accent); }
.side-child .count { margin-left: auto; font-size: 11px; opacity: .75; }
.side-footer { padding: 12px 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 8px; }

.sidebar-mask { display: none; }

/* ---------- 内容区 ---------- */
.content { flex: 1; min-width: 0; padding: 20px 28px 40px; }
.notice {
  background: var(--badge-warn-bg); color: var(--badge-warn);
  border: 1px solid var(--badge-warn); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}
.result-info { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.group-section { margin-bottom: 30px; }
.group-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.group-header h2 { font-size: 19px; font-weight: 700; }
.group-header .group-count { font-size: 12.5px; color: var(--muted); }

.cat-section { margin-bottom: 20px; scroll-margin-top: 70px; }
.cat-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-left: 10px; border-left: 3px solid var(--accent); }
.cat-header h3 { font-size: 15px; font-weight: 600; }
.cat-header .cat-count { font-size: 12px; color: var(--muted); }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px;
}
.site-card {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; text-decoration: none; color: var(--text);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.site-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); border-color: var(--accent); }
.site-card img { width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; }
.site-info { min-width: 0; flex: 1; }
.site-name {
  font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-desc {
  font-size: 12.5px; color: var(--muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.site-domain { font-size: 11.5px; color: var(--muted); opacity: .8; margin-top: 4px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 10.5px; font-weight: 500; padding: 1px 6px; border-radius: 4px; flex-shrink: 0;
}
.badge-dead { color: var(--badge-dead); background: var(--badge-dead-bg); border: 1px solid var(--badge-dead); }
.badge-warn { color: var(--badge-warn); background: var(--badge-warn-bg); border: 1px solid var(--badge-warn); }
.site-card.is-dead { opacity: .62; }

.footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: 12.5px; }
.footer p + p { margin-top: 4px; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent); }

/* ---------- 关于本站等文章页 ---------- */
.article-wrap { max-width: 780px; margin: 0 auto; padding: 28px 22px 40px; }
.article { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 34px; }
.article h1 { font-size: 22px; margin-bottom: 18px; }
.article h2 { font-size: 16.5px; margin: 26px 0 10px; padding-left: 10px; border-left: 3px solid var(--accent); }
.article p { margin: 10px 0; color: var(--text); }
.article a { color: var(--accent); }
@media (max-width: 520px) {
  .article { padding: 20px 16px; }
  .article-wrap { padding: 16px 12px 32px; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .brand-sub { display: none; }
  .menu-toggle { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 56px; z-index: 90; height: calc(100vh - 56px);
    background: var(--panel); transform: translateX(-100%); transition: transform .2s;
  }
  .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-hover); }
  .sidebar-mask.show { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.35); z-index: 80; }
  .content { padding: 16px 14px 32px; }
}
@media (max-width: 520px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
  .site-card { padding: 10px; }
  .site-card img { width: 32px; height: 32px; }
  .site-name { font-size: 13px; }
  .site-desc { display: none; }
  .brand-name { font-size: 15px; }
}

.site-avatar {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  color: #fff; font-size: 17px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
@media (max-width: 520px) {
  .site-avatar { width: 32px; height: 32px; font-size: 14px; }
}
