/* 颜色变量全部由 themes.css 按 [data-theme] 提供；这里只保留与主题无关的结构常量 */
:root {
  --radius: 12px;
  --sidebar-w: 220px;
  --aside-w: 260px;
}

* { box-sizing: border-box; }
img { max-width: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-family, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  background-color: var(--bg);
  /* 随主题变化的深空辉光 */
  background-image: var(--bg-glow);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }

/* ================= 三栏 ================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--aside-w);
  min-height: 100vh;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 18px;
}

/* ================= 左侧栏 ================= */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.side-mark {
  width: 34px; height: 34px; border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(2, 6, 23, .25);
}
.side-name { font-weight: 700; font-size: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-group { color: var(--muted); font-size: 12px; letter-spacing: 1px; padding: 12px 10px 4px; margin: 0; text-transform: uppercase; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--muted);
  transition: .18s; position: relative;
}
.side-item:hover { background: var(--hover-bg); color: var(--text); }
.side-active {
  background: var(--active-bg);
  color: var(--primary-dark);
  box-shadow: inset 2px 0 0 var(--primary);
}
.side-dot { width: 18px; text-align: center; font-size: 14px; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }

/* ================= 中间 ================= */
.content { padding: 22px 24px 40px; min-width: 0; }

.search-box {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden;
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
  transition: .2s;
}
.search-box:focus-within { box-shadow: var(--glow); border-color: var(--primary); }
.search-box input { flex: 1; border: 0; outline: 0; padding: 12px 22px; font-size: 15px; background: transparent; color: var(--text); }
.search-box input::placeholder { color: var(--muted); }
.search-box button {
  border: 0; background: var(--gradient); color: #fff;
  padding: 0 26px; cursor: pointer; font-weight: 600;
}
.search-box button:hover { filter: brightness(1.1); }

.block { margin-bottom: 30px; scroll-margin-top: 18px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.block-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.block-icon { font-size: 18px; }
.more { color: var(--muted); font-size: 13px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.site-card {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.site-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--glow);
}
.site-icon {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px;
  object-fit: cover; display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; overflow: hidden;
}
.site-icon.emoji { background: var(--icon-soft); }
.site-icon.letter { color: #fff; font-weight: 700; font-size: 18px; box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.site-body { min-width: 0; display: flex; flex-direction: column; }
.site-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-desc { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.page-footer { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 20px; text-align: center; }
.page-footer p { margin: 3px 0; color: var(--muted); font-size: 13px; }
.page-footer a:hover { color: var(--primary); }

/* ================= 右侧栏 ================= */
.aside { padding: 22px 18px 40px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; min-width: 0; }
.brand-card {
  background: var(--gradient);
  color: #fff; border-radius: var(--radius); padding: 18px;
  box-shadow: var(--glow);
  position: relative; overflow: hidden;
}
.brand-card::after {
  content: ""; position: absolute; top: -26px; right: -26px;
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(255,255,255,.14);
  pointer-events: none;
}
.brand-card-name { margin: 0; font-weight: 800; font-size: 17px; position: relative; z-index: 1; overflow-wrap: anywhere; text-align: center; }
.brand-card-slogan { margin: 4px 0 14px; font-size: 12.5px; opacity: .92; position: relative; z-index: 1; text-align: center; }
.brand-stats { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; position: relative; z-index: 1; }
.brand-stats div { display: flex; flex-direction: column; align-items: center; background: rgba(255,255,255,.16); border-radius: 9px; padding: 8px 4px; flex: 1; }
.brand-stats b { font-size: 18px; }
.brand-stats span { font-size: 11px; opacity: .92; }

.aside-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(8px);
}
.aside-block h3 { margin: 0 0 10px; font-size: 15px; color: var(--text); text-align: center; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.rank-list li { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; }
.rank-num {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 6px;
  background: var(--icon-soft); color: var(--muted); font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.rank-top { background: var(--gradient); color: #fff; }
.rank-list a { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.rank-list a:hover { color: var(--primary); }
.rank-visit { font-style: normal; font-size: 12px; color: var(--muted); }

/* ================= 顶部主题切换菜单 ================= */
.top-menu {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.top-menu-label {
  font-size: 13px; font-weight: 700; color: var(--muted);
  white-space: nowrap; flex: 0 0 auto;
}
.top-menu-items { display: flex; gap: 8px; overflow-x: auto; flex: 1; padding: 2px; }
.top-theme-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: .16s;
}
.top-theme-btn:hover { color: var(--text); border-color: var(--primary); }
.top-theme-btn.active {
  background: var(--gradient); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(2, 6, 23, .18);
}
.top-theme-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gradient);
}
.top-theme-btn.active .top-theme-dot {
  background: rgba(255, 255, 255, .85);
}

/* ================= 分类内子分组 ================= */
.sub-group { margin-bottom: 16px; }
.sub-group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
  margin: 12px 0 10px;
}
.sub-group-title::before {
  content: ""; width: 4px; height: 14px; border-radius: 2px;
  background: var(--gradient);
}
.sub-count {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--icon-soft); border-radius: 999px; padding: 1px 9px;
}

/* ================= 右侧访问统计 ================= */
.visit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.visit-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--icon-soft);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 4px;
}
.visit-item b {
  font-size: 20px; font-weight: 700; color: var(--primary);
  line-height: 1.2;
}
.visit-item span {
  font-size: 11.5px; color: var(--muted); margin-top: 3px;
}

/* ================= 页脚运行天数 ================= */
.footer-run { font-size: 14px; color: var(--text); }
.footer-run b { color: var(--primary); font-size: 16px; }
.footer-tech { color: var(--muted); }

/* ================= 响应式（电脑 / 平板 / 手机） ================= */

/* ---- 中等屏幕：收窄两侧栏，避免右栏品牌卡片拥挤 ---- */
@media (max-width: 1280px) {
  :root { --sidebar-w: 210px; --aside-w: 250px; }
}

/* ---- 平板：隐藏右侧栏，保留左侧分类 + 内容 ---- */
@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  .app-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .aside { display: none; }
}

/* ---- 大手机 / 小平板：单栏，侧边栏变顶部横滑分类条 ---- */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; padding: 0 12px; }

  .sidebar {
    position: static;
    height: auto;
    display: block;
    padding: 12px 0 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .side-brand { padding: 0 16px 10px; }
  .side-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding: 0 16px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-group { display: none; }
  .side-item { flex: 0 0 auto; white-space: nowrap; padding: 7px 12px; }
  .side-foot {
    flex-direction: row;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    overflow-x: auto;
  }
  .side-foot .side-item { flex: 0 0 auto; }

  .content { padding: 16px 14px 32px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .site-card { padding: 11px; gap: 10px; }
  .top-menu { flex-wrap: nowrap; padding: 8px 10px; gap: 8px; }
  .top-menu-label { display: none; }
  .block-head h2 { font-size: 16px; }
}

/* ---- 小手机：进一步紧凑，保证不横向溢出 ---- */
@media (max-width: 420px) {
  .app-shell { padding: 0 10px; }
  .content { padding: 14px 10px 28px; }
  .card-grid { gap: 8px; }
  .site-card { padding: 9px; gap: 8px; flex-direction: row; }
  .site-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 17px; }
  .site-title { font-size: 14px; }
  .site-desc { font-size: 12px; }
  .top-theme-btn { padding: 5px 10px; font-size: 12.5px; }
  .search-box input { padding: 11px 16px; font-size: 14px; }
  .search-box button { padding: 0 18px; }
  .visit-grid { gap: 8px; }
  .visit-item { padding: 10px 2px; }
  .visit-item b { font-size: 18px; }
  .page-footer p { font-size: 12.5px; }
}

/* ---- 触屏设备默认，避免 hover 卡片粘滞 ---- */
@media (hover: none) {
  .site-card:hover { transform: none; }
}
