/* ==========================================================================
   Gitfire 统一设计系统
   所有页面共用：设计令牌 / 顶栏 / 按钮 / 卡片 / 芯片 / 骨架屏 / 动效
   ========================================================================== */

:root {
  /* 品牌 */
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --brand-soft-2: #e0e7ff;
  --brand-ink: #a5b4fc;

  /* 深色（顶栏 / Hero / 品牌面） */
  --ink: #0b1120;
  --ink-2: #131c33;
  --ink-3: #1b2545;

  /* 中性 */
  --bg: #f5f7fb;
  --bg-dot: #e9edf6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f9;
  --border: #e6eaf2;
  --border-strong: #d6dceb;
  --track: #edf1f8;

  /* 文本 */
  --text: #16203a;
  --text-soft: #475569;
  --muted: #6b7891;
  --on-dark: #ffffff;
  --on-dark-soft: #cbd5e1;

  /* 语义 */
  --good: #059669;
  --good-soft: #ecfdf5;
  --good-border: #a7f3d0;
  --good-ink: #047857;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;
  --warn-ink: #b45309;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --bad-border: #fecaca;
  --bad-ink: #b91c1c;
  --info: #2563eb;

  /* 圆角 */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* 阴影 */
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 4px 14px rgba(16, 24, 40, .07);
  --sh-3: 0 14px 34px rgba(16, 24, 40, .10);
  --sh-4: 0 26px 60px rgba(16, 24, 40, .16);
  --sh-brand: 0 10px 26px rgba(79, 70, 229, .28);

  /* 顶栏（深色玻璃，两种主题下都是深色，仅细节微调） */
  --topbar-bg: rgba(11, 17, 32, .82);
  --topbar-border: rgba(255, 255, 255, .08);
  --topbar-fg: #b9c4d8;
  --topbar-fg-strong: #ffffff;
  --topbar-hover: rgba(255, 255, 255, .08);
  --topbar-active-bg: rgba(99, 102, 241, .22);
  --topbar-active-border: rgba(129, 140, 248, .45);
  --topbar-chip: rgba(255, 255, 255, .07);
  --topbar-sep: rgba(255, 255, 255, .14);

  /* 代码 / 骨架屏 */
  --code-ink: #b91c6c;
  --skel-1: #eef1f7;
  --skel-2: #f7f9fc;
  --scrollbar: #cbd5e1;
  --scrollbar-hover: #94a3b8;

  /* 尺寸 / 动效 */
  --nav-h: 62px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --t-fast: .16s;
  --t: .24s;
  --t-slow: .42s;
}

/* ==========================================================================
   深色模式
   data-theme 由 site.js 依据 localStorage / 系统偏好写入；
   head 中的内联脚本会在首屏绘制前完成设置，因此不会出现白屏闪烁。
   ========================================================================== */
[data-theme="dark"] {
  /* 品牌：深色底上需要提亮，否则对比度不足 */
  --brand: #818cf8;
  --brand-2: #a78bfa;
  --brand-hover: #6366f1;
  --brand-soft: rgba(99, 102, 241, .16);
  --brand-soft-2: rgba(129, 140, 248, .26);
  --brand-ink: #a5b4fc;

  /* 深色面 */
  --ink: #070b16;
  --ink-2: #0c1322;
  --ink-3: #121a2e;

  /* 中性：整体降低亮度并提高边框可见度 */
  --bg: #080c17;
  --bg-dot: #1a2338;
  --surface: #0f1524;
  --surface-2: #141c2e;
  --surface-3: #1a2338;
  --border: #232d45;
  --border-strong: #313c58;
  --track: #1b2539;

  /* 文本 */
  --text: #e8edf7;
  --text-soft: #b3bfd4;
  --muted: #7f8ca6;

  /* 语义 */
  --good: #34d399;
  --good-soft: rgba(16, 185, 129, .14);
  --good-border: rgba(52, 211, 153, .3);
  --good-ink: #6ee7b7;
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, .14);
  --warn-border: rgba(251, 191, 36, .3);
  --warn-ink: #fcd34d;
  --bad: #f87171;
  --bad-soft: rgba(239, 68, 68, .14);
  --bad-border: rgba(248, 113, 113, .3);
  --bad-ink: #fca5a5;
  --info: #60a5fa;

  /* 阴影：深色底上需要更重才能看出层次 */
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 4px 14px rgba(0, 0, 0, .45);
  --sh-3: 0 14px 34px rgba(0, 0, 0, .5);
  --sh-4: 0 26px 60px rgba(0, 0, 0, .6);
  --sh-brand: 0 10px 26px rgba(99, 102, 241, .34);

  /* 顶栏 */
  --topbar-bg: rgba(6, 10, 20, .86);
  --topbar-border: rgba(255, 255, 255, .07);
  --topbar-fg: #98a5bd;
  --topbar-hover: rgba(255, 255, 255, .07);
  --topbar-active-bg: rgba(99, 102, 241, .26);
  --topbar-chip: rgba(255, 255, 255, .06);

  /* 代码 / 骨架屏 */
  --code-ink: #f9a8d4;
  --skel-1: #161f33;
  --skel-2: #1f2a42;
  --scrollbar: #33415c;
  --scrollbar-hover: #4a5b7d;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  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: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
p { margin: 0; }
img, svg, video { max-width: 100%; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* 统一键盘焦点样式（无障碍） */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: var(--brand-soft-2); color: var(--brand-hover); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); background-clip: content-box; }

/* ---------- 布局容器 ---------- */
.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 20px;
}
.container-sm { max-width: 860px; }
.container-xs { max-width: 720px; }

/* ==========================================================================
   顶栏
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  background: var(--topbar-bg);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  color: var(--topbar-fg-strong);
  border-bottom: 1px solid var(--topbar-border);
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}
/* 品牌标识（由 site.js 注入 logo 图片） */
.topbar .brand .gf-mark {
  width: 28px; height: 28px;
  flex: none;
  display: block;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(59, 130, 246, .25);
}
.topbar .brand em {
  font-style: normal;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-ink);
  letter-spacing: 0;
}

.topbar .nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar .nav a,
.topbar .nav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--topbar-fg);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.topbar .nav a:hover,
.topbar .nav button:hover {
  color: var(--topbar-fg-strong);
  background: var(--topbar-hover);
  border-color: var(--topbar-border);
}
.topbar .nav a.active {
  color: var(--topbar-fg-strong);
  background: var(--topbar-active-bg);
  border-color: var(--topbar-active-border);
}
.topbar .nav .user {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--topbar-fg-strong);
  font-weight: 600;
  padding: 5px 12px 5px 6px;
  background: var(--topbar-chip);
  border: 1px solid var(--topbar-border);
}
.topbar .nav .user .avatar {
  width: 24px; height: 24px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.topbar .nav .sep { width: 1px; height: 20px; background: var(--topbar-sep); margin: 0 4px; }

.topbar.solid { background: var(--ink); backdrop-filter: none; }

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  padding: 0;
  border: 1px solid var(--topbar-border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--topbar-fg);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.theme-toggle:hover {
  color: var(--topbar-fg-strong);
  background: var(--topbar-hover);
  border-color: rgba(255, 255, 255, .2);
  transform: rotate(-12deg);
}
/* 两个图标都渲染，由主题决定显示哪一个（声明式，避免首屏闪烁） */
.theme-toggle .i-sun, .theme-toggle .i-moon {
  display: grid;
  place-items: center;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
[data-theme="light"] .theme-toggle .i-sun,
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* 无顶栏页面（认证页）的右上角悬浮切换 */
.theme-float { position: fixed; right: 18px; top: 16px; z-index: 70; }
.theme-float .theme-toggle {
  width: 38px; height: 38px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-soft);
  box-shadow: var(--sh-2);
}
.theme-float .theme-toggle:hover {
  color: var(--brand);
  background: var(--surface-2);
  border-color: var(--brand);
}

@media (max-width: 720px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .brand em { display: none; }
  .topbar .nav a, .topbar .nav button { padding: 6px 10px; font-size: 13px; }
  .topbar .nav .user span.name { display: none; }
}

/* ==========================================================================
   按钮
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { border-color: var(--brand); color: var(--brand); box-shadow: var(--sh-1); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--sh-brand);
}
.btn.primary:hover { color: #fff; filter: brightness(1.07); box-shadow: 0 14px 30px rgba(79, 70, 229, .34); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad-border); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-xs); }
.btn.block { width: 100%; }

.btn.loading { pointer-events: none; opacity: .8; }
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: gf-spin .7s linear infinite;
  opacity: .7;
}

/* ==========================================================================
   卡片 / 芯片 / 徽章
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 700; }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.hot { background: var(--warn-soft); color: var(--warn-ink); }
.chip.on-dark { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: #e2e8f0; }
.chip.on-dark b { color: #fff; }

.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: var(--r-pill);
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: 11px;
  font-weight: 700;
}

/* 区块标题 */
.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.sec-title { display: flex; align-items: center; gap: 10px; }
.sec-title h2 { font-size: 20px; }
.sec-head .sub { color: var(--muted); font-size: 13px; }
.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 8px;
  border-radius: var(--r-xs);
}

/* ==========================================================================
   页脚
   ========================================================================== */
.foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 40px;
  padding: 26px 20px 34px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.foot .links { display: flex; gap: 18px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.foot .beian { margin-top: 10px; }
.foot a { color: var(--muted); transition: color var(--t-fast); }
.foot a:hover { color: var(--brand); }

/* ==========================================================================
   骨架屏 / 状态
   ========================================================================== */
.skel {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--skel-1) 25%, var(--skel-2) 37%, var(--skel-1) 63%);
  background-size: 400% 100%;
  animation: gf-shimmer 1.3s ease-in-out infinite;
}
@keyframes gf-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: gf-spin 1s linear infinite;
  vertical-align: middle;
}
@keyframes gf-spin { to { transform: rotate(360deg); } }

.state { text-align: center; padding: 56px 20px; color: var(--muted); }
.state p { margin: 10px 0 18px; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}
.empty h3 { font-size: 17px; margin-bottom: 8px; color: var(--text); }

/* ==========================================================================
   Toast（site.js 使用）
   ========================================================================== */
.gf-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 200;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  background: rgba(20, 28, 48, .95);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--sh-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.gf-toast.show { opacity: 1; transform: translate(-50%, 0); }
.gf-toast.err { background: var(--bad); }
.gf-toast.ok { background: var(--good); }

/* ==========================================================================
   阅读进度条
   ========================================================================== */
.gf-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  z-index: 120;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), #c084fc);
  transition: width .1s linear;
}

/* ==========================================================================
   入场动画（reveal）
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

/* 通用卡片悬浮 */
.hover-lift { transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease); }
.hover-lift:hover { transform: translateY(-4px); box-shadow: var(--sh-3); border-color: var(--brand-soft-2); }

/* 工具类 */
.muted { color: var(--muted); }
.soft { color: var(--text-soft); }
.err { color: var(--bad); }
.hidden { display: none !important; }
.clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }

/* 跳转到主内容（无障碍） */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 300;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--r-sm);
}
.skip-link:focus { left: 12px; }

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ==========================================================================
   侧边广告（左右侧栏，后台「广告设置」配置）
   ========================================================================== */
.ad-rail {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 132px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.ad-rail.ad-left { left: 14px; }
.ad-rail.ad-right { right: 14px; }
.ad-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2px;
  font-size: 11px; color: var(--muted);
}
.ad-head button {
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 15px; line-height: 1;
  padding: 1px 5px; border-radius: 6px;
}
.ad-head button:hover { color: var(--text); background: var(--surface-2); }
.ad-item {
  display: block; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border);
}
.ad-item img {
  display: block; width: 100%; height: auto;
  transition: transform .25s var(--ease);
}
.ad-item:hover img { transform: scale(1.04); }

/* 窄屏自动隐藏，避免遮挡正文 */
@media (max-width: 1320px) {
  .ad-rail { display: none; }
}
