/* =====================================================
   主题变量：默认暗色，html[data-theme="light"] 时切换亮色
   ===================================================== */
:root {
  --bg: #0e1117;
  --bg-soft: #12161f;
  --card: #171d29;
  --border: #232b3b;
  --border-soft: #1d2432;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #3f8cff;
  --accent-soft: rgba(63, 140, 255, 0.14);
  --header-bg: rgba(14, 17, 23, 0.86);
  --header-h: 56px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-soft: #eef1f6;
  --card: #ffffff;
  --border: #e3e8f0;
  --border-soft: #e9edf4;
  --text: #232a3d;
  --muted: #6b7390;
  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, 0.10);
  --header-bg: rgba(243, 245, 249, 0.86);
  --shadow: 0 6px 24px rgba(31, 45, 80, 0.10);
}

/* ===================== 基础 ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 防止自定义 display 覆盖 hidden 属性 */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  transition: background 0.25s, color 0.25s;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

.icon {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* ===================== 顶部 ===================== */
.site-header {
  position: sticky; top: 0; z-index: 80;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.header-inner {
  display: flex; align-items: center; gap: 8px;
  max-width: 1280px; margin: 0 auto;
  height: var(--header-h); padding: 0 20px;
}

.brand {
  display: flex; align-items: center; gap: 7px;
  font-weight: 700; font-size: 16px;
  white-space: nowrap; flex-shrink: 0;
}
.brand span:first-child { font-size: 18px; }

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-radius: 50%; color: var(--muted);
  flex-shrink: 0; transition: color 0.2s, background 0.2s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-soft); }
.icon-btn .icon { width: 18px; height: 18px; }
.menu-btn { display: none; }

.top-tabs {
  display: flex; flex: 1; min-width: 0;
  justify-content: center;
}

.top-tab {
  position: relative;
  padding: 0 16px; height: var(--header-h);
  display: flex; align-items: center;
  color: var(--muted); font-size: 15px;
  white-space: nowrap;
  transition: color 0.2s;
}
.top-tab:hover { color: var(--text); }
.top-tab.active { color: var(--text); font-weight: 600; }
.top-tab.active::after {
  content: "";
  position: absolute; left: 14px; right: 14px; bottom: 0;
  height: 3px; border-radius: 3px 3px 0 0;
  background: var(--accent);
}

/* ===================== 布局 ===================== */
.layout {
  display: flex; gap: 24px;
  max-width: 1280px; margin: 0 auto;
  padding: 0 20px;
  align-items: flex-start;
}

/* ---------- 左侧子分类 ---------- */
.sidebar {
  width: 176px; flex-shrink: 0;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 0 24px;
}
#sideNav { display: flex; flex-direction: column; gap: 2px; padding-right: 6px; }

.side-item {
  display: flex; align-items: center;
  width: 100%; padding: 9px 14px;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted); font-size: 14px; text-align: left;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.side-item:hover { color: var(--text); }
.side-item.active {
  color: var(--text); background: var(--card);
  border-color: var(--border); font-weight: 500;
}

.sidebar-mask {
  position: fixed; inset: var(--header-h) 0 0 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 65; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.sidebar-mask.show { opacity: 1; pointer-events: auto; }

/* ---------- 内容区 ---------- */
.content { flex: 1; min-width: 0; padding: 20px 0 40px; }

/* 搜索行 + 横幅 */
.toolbar { display: flex; gap: 16px; align-items: stretch; }

.banners { flex: 1; display: flex; gap: 14px; min-width: 0; }
.banner {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 8px 16px; border-radius: 10px;
  color: #fff; overflow: hidden; white-space: nowrap;
  transition: transform 0.2s, box-shadow 0.2s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.banner:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.banner b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.banner span { font-size: 12px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 分组 ---------- */
.section { margin-top: 26px; scroll-margin-top: calc(var(--header-h) + 58px); }

.section-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer; user-select: none;
}
.section-head h2 { font-size: 16.5px; font-weight: 600; transition: color 0.2s; }
.section-head:hover h2 { color: var(--accent); }
.section-head .count { color: var(--accent); font-size: 13.5px; font-weight: 600; }
.section-head .chev { display: flex; color: var(--muted); transition: transform 0.2s; }
.section.collapsed .chev { transform: rotate(-90deg); }
.section.collapsed .grid { display: none; }

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

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-body {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 14px 11px;
  min-height: 66px; cursor: pointer;
}

.card-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 8px; object-fit: contain;
  background: var(--bg-soft); padding: 3px;
}

.card-info { flex: 1; min-width: 0; }
.card-name {
  font-size: 14.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tag {
  flex-shrink: 0;
  font-size: 11px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 4px; padding: 1px 6px;
}
.card-desc {
  margin-top: 5px; font-size: 12.5px; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.card-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border-soft);
}
.card-btn {
  height: 36px; border: none; background: transparent;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.card-btn + .card-btn { border-left: 1px solid var(--border-soft); }
.card-btn:hover { color: var(--accent); background: var(--accent-soft); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 70px 0; color: var(--muted); }
.empty-icon { font-size: 42px; margin-bottom: 12px; }
.empty .btn { margin-top: 16px; }

/* ===================== 页脚 ===================== */
.site-footer {
  border-top: 1px solid var(--border-soft);
  margin-top: 30px; padding: 26px 16px 30px;
  text-align: center; color: var(--muted); font-size: 13px;
  display: flex; flex-direction: column; gap: 6px;
}
.site-footer b { color: var(--accent); }
.site-footer a { color: var(--accent); }
.site-footer a:hover { text-decoration: underline; }

/* ===================== 悬浮按钮 ===================== */
.float-btns {
  position: fixed; right: 18px; bottom: 26px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px;
}
.fbtn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: color 0.2s, border-color 0.2s, opacity 0.25s, transform 0.25s;
}
.fbtn:hover { color: var(--accent); border-color: var(--accent); }
.fbtn .icon { width: 17px; height: 17px; }
#topBtn { opacity: 0; pointer-events: none; transform: translateY(8px); }
#topBtn.show { opacity: 1; pointer-events: auto; transform: none; }

/* ===================== 弹窗 ===================== */
.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

.modal {
  position: relative;
  width: 420px; max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: popIn 0.18s ease;
}
.modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px;
  border: none; background: transparent; border-radius: 50%;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--text); background: var(--bg-soft); }
.modal-icon {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 12px; object-fit: contain;
  background: var(--bg-soft); padding: 5px;
}
.modal h3 { font-size: 18px; margin-bottom: 6px; }
.modal-desc { font-size: 13px; color: var(--muted); margin-bottom: 10px; word-break: break-all; }
.modal-url {
  font-size: 12.5px; color: var(--accent);
  background: var(--bg-soft); border-radius: 6px;
  padding: 7px 10px; margin-bottom: 18px;
  word-break: break-all; cursor: pointer;
}
.modal-btns { display: flex; gap: 10px; justify-content: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 18px;
  border-radius: 8px; font-size: 13.5px;
  border: 1px solid transparent;
  transition: opacity 0.2s, border-color 0.2s, background 0.2s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { opacity: 0.88; }
.btn.ghost { border-color: var(--border); color: var(--text); background: transparent; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ===================== Toast ===================== */
.toast {
  position: fixed; left: 50%; bottom: 44px; z-index: 100;
  transform: translate(-50%, 12px);
  background: rgba(22, 26, 36, 0.95);
  border: 1px solid var(--border);
  color: #fff; font-size: 13.5px;
  padding: 9px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
html[data-theme="light"] .toast { background: rgba(35, 42, 61, 0.95); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== 留言板页 ===================== */
.fb-wrap { max-width: 760px; margin: 0 auto; padding: 44px 20px 30px; }
.fb-back { color: var(--muted); font-size: 14px; }
.fb-back:hover { color: var(--accent); }
.fb-wrap h1 { font-size: 24px; margin: 18px 0 8px; }
.fb-sub { color: var(--muted); font-size: 13.5px; }
.fb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; margin-top: 22px;
}
.fb-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px;
  transition: border-color 0.2s, transform 0.2s;
}
.fb-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.fb-icon { font-size: 26px; margin-bottom: 8px; }
.fb-name { font-size: 15px; font-weight: 600; }
.fb-desc { font-size: 12.5px; color: var(--muted); margin: 4px 0 10px; word-break: break-all; }
.fb-link { font-size: 13px; color: var(--accent); background: none; border: none; padding: 0; }
.fb-link:hover { text-decoration: underline; }

/* ===================== 响应式 ===================== */
@media (max-width: 920px) {
  .layout { padding: 0 14px; gap: 0; }
  .content { padding: 16px 0 32px; }

  .menu-btn { display: flex; }
  .top-tabs { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .top-tabs::-webkit-scrollbar { display: none; }

  .sidebar {
    position: fixed; left: 0; top: var(--header-h); bottom: 0;
    width: 224px; height: auto;
    background: var(--bg); z-index: 70;
    transform: translateX(-105%);
    transition: transform 0.25s;
    padding: 12px 10px; border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: none; }
  .sidebar-mask { z-index: 60; }

  .toolbar { flex-direction: column; }
  .banners { min-height: 62px; }
}

@media (min-width: 921px) {
  .sidebar-mask { display: none; }
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .grid { grid-template-columns: 1fr; }
  .float-btns { right: 12px; bottom: 18px; }
}
