:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1d2129;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --hot: #ef4444;
  --gold: #f59e0b;
  --silver: #94a3b8;
  --bronze: #c2703d;
  --ok-bg: #ecfdf3; --ok: #067647;
  --err-bg: #fef3f2; --err: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-hover: 0 6px 18px rgba(16, 24, 40, .10);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --text: #e6e8ec; --muted: #9aa3b2;
    --border: #2a2f3a; --accent: #6b9bff; --accent-soft: #1d2a45;
    --ok-bg: #0d2a1c; --ok: #6ce9a6; --err-bg: #2d1414; --err: #fda29b;
    --shadow: none; --shadow-hover: 0 6px 18px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --text: #e6e8ec; --muted: #9aa3b2;
  --border: #2a2f3a; --accent: #6b9bff; --accent-soft: #1d2a45;
  --ok-bg: #0d2a1c; --ok: #6ce9a6; --err-bg: #2d1414; --err: #fda29b;
  --shadow: none; --shadow-hover: 0 6px 18px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 120px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-size: 17px; font-weight: 600; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 16px; }
.search { flex: 1; max-width: 600px; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search input {
  flex: 1; min-width: 0; width: 100%; height: 38px; padding: 0 14px; border: 1px solid var(--border); border-radius: 19px;
  background: var(--surface-2); color: var(--text); font: inherit; outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
.search-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 19px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: filter .15s ease, box-shadow .15s ease;
}
.topbar-inner .btn { height: 38px; }
.search-btn:hover { filter: brightness(1.08); box-shadow: 0 2px 8px rgba(37, 99, 235, .25); }
.search-btn:active { filter: brightness(.95); }
.search-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn {
  flex: none; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 16px; cursor: pointer;
}
.catnav { border-top: 1px solid var(--border); }
.catnav-inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-top: 6px; padding-bottom: 6px; }
.catnav-inner::-webkit-scrollbar { display: none; }
.catnav a { flex: none; padding: 5px 12px; border-radius: 8px; color: var(--text); white-space: nowrap; }
.catnav a:hover { background: var(--surface-2); text-decoration: none; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn.disabled { opacity: .45; pointer-events: none; }

/* 区块 */
.main { padding-top: 20px; padding-bottom: 40px; }
.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.block.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.block-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.block-head h1, .block-head h2 { display: flex; align-items: center; gap: 6px; }
.cat-icon { font-size: 18px; }
.heat { color: var(--hot); font-size: 12px; background: color-mix(in srgb, var(--hot) 10%, transparent); padding: 1px 8px; border-radius: 10px; }
.block-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; }
.block-actions a { color: var(--muted); }
.block-actions a:hover { color: var(--accent); }
.empty { color: var(--muted); margin: 8px 0; }

/* 卡片网格 */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; height: 100%;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.rank {
  flex: none; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2);
}
.rank-top { color: #fff; }
.rank-1 { background: var(--gold); }
.rank-2 { background: var(--silver); }
.rank-3 { background: var(--bronze); }
.ico { flex: none; width: 36px; height: 36px; border-radius: 9px; object-fit: cover; background: var(--surface-2); }
.ico-letter {
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
  background: hsl(var(--h) 60% 52%);
}
.card-body { min-width: 0; display: flex; flex-direction: column; }
.card-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-pin { font-style: normal; font-size: 11px; color: var(--hot); border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; margin-right: 4px; }

/* 最近点入 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 20px; color: var(--text); }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip .ico { width: 22px; height: 22px; border-radius: 50%; font-size: 11px; }

/* 标签页、分页 */
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.tabs a { padding: 3px 10px; border-radius: 6px; color: var(--muted); }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.pager-info { color: var(--muted); }

/* 表单 */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 500; }
.form input, .form select, .form textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form .btn { justify-self: start; }
.req { color: var(--hot); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.notice ul { margin: 0; padding-left: 18px; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-err { background: var(--err-bg); color: var(--err); }

.footer { color: var(--muted); font-size: 12px; padding: 20px 0 30px; text-align: center; }
.footer a { color: var(--muted); }

.show-sm { display: none !important; }
@media (max-width: 720px) {
  .hide-sm { display: none !important; }
  .search { gap: 6px; }
  .search-btn { width: 38px; padding: 0; }
  .search-btn-text { display: none; }
  .show-sm { display: inline-flex !important; }
  .catnav { display: none; }
  .catnav.open { display: block; }
  .catnav-inner { flex-wrap: wrap; }
  .topbar-inner { gap: 8px; }
  .logo { font-size: 0; gap: 0; }
  .logo-mark { font-size: 16px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 8px; gap: 8px; }
  .card .rank { position: absolute; top: -6px; left: -6px; width: 18px; height: 18px; }
  .ico { width: 30px; height: 30px; }
  .block { padding: 12px; }
  .block-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } }

/* 首页公告、页脚附加文字（后台"网站设置"） */
.notice-bar {
  background: color-mix(in srgb, var(--gold) 14%, var(--surface)); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--border));
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; white-space: pre-line;
}
.footer-text { margin: 0 0 6px; white-space: pre-line; }

/* 右下角悬浮联系按钮 */
.contact-float { position: fixed; right: 20px; bottom: 24px; z-index: 20; display: flex; flex-direction: column; gap: 10px; }
.cf-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .18); transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.cf-btn:hover { text-decoration: none; transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 6px 18px rgba(15, 23, 42, .26); }
.cf-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cf-tg { background: #229ed9; }
.cf-mail { background: var(--accent); }
.cf-tg svg { margin-left: -2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cf-btn { box-shadow: 0 4px 14px rgba(0, 0, 0, .5); } }
:root[data-theme="dark"] .cf-btn { box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
@media (max-width: 640px) {
  .contact-float { right: 14px; bottom: 14px; gap: 8px; }
  .cf-btn { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) { .cf-btn { transition: none; } .cf-btn:hover { transform: none; } }

/* 广告位：导航栏下方的正方形图片网格 */
.ads { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 16px; }
.ads + .main { padding-top: 14px; }
.ad {
  display: block; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ad img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ad:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .12); }
@media (max-width: 720px) { .ads { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; } }
@media (prefers-reduced-motion: reduce) { .ad { transition: none; } .ad:hover { transform: none; } }
