/* =========================================================
   common.css — 全站通用样式（变量 / 重置 / 顶栏 / 页脚 / 按钮）
   ========================================================= */

:root {
  --bg: #f5f7fb;
  --bg-alt: #eef2f8;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .1);
  --on-accent: #ffffff;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --shadow: 0 20px 40px -24px rgb(15 23 42 / .4);
  --max: 1180px;
  --header-h: 66px;
}

[data-theme="dark"] {
  --bg: #0a0f1c;
  --bg-alt: #0e1526;
  --surface: #121a2c;
  --text: #e8eefb;
  --muted: #93a2b8;
  --line: #1f2b44;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, .15);
  --on-accent: #071022;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .5);
  --shadow: 0 22px 44px -26px rgb(0 0 0 / .95);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
  /* 始终为滚动条留位：内容长短不一时，各页容器的左右边界保持一致 */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p { margin: 0; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 2px;
}

.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 20px;
}

/* ---------- 跳转链接（无障碍） ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .82rem;
  font-weight: 700;
}
.skip-link:focus { left: 8px; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, box-shadow .3s, background-color .3s;
}
.site-header.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 1px 16px rgb(15 23 42 / .08);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -.02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-size: .8rem;
}
.brand-text { display: none; }
@media (min-width: 480px) { .brand-text { display: inline; } }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }

.header-nav a {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: .87rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color .2s, background-color .2s;
}
.header-nav a:hover { color: var(--accent); background: var(--accent-soft); }
.header-nav a.is-current { color: var(--accent); background: var(--accent-soft); }

/* ---------- 顶栏搜索框（所有页面共用） ---------- */
.site-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 420px;
  min-width: 0;
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.site-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-icon { flex: none; font-size: .92rem; color: var(--muted); }

.site-search input {
  flex: 1;
  min-width: 0;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .93rem;
  outline: none;
}
.site-search input::-webkit-search-cancel-button { display: none; }

.search-clear {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--muted);
  font-size: .72rem;
  line-height: 1;
}
.search-clear:hover { color: var(--text); }

.search-submit {
  flex: none;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .85rem;
  font-weight: 600;
  transition: filter .2s, transform .2s;
}
.search-submit:hover { filter: brightness(1.08); transform: translateY(-1px); }

.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  transition: border-color .2s, transform .2s;
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .2s, color .2s, border-color .2s,
              transform .2s, box-shadow .2s;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 20px -10px var(--accent);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ---------- 页脚 ---------- */
.site-footer {
  padding: 36px 0 28px;
  background: var(--bg-alt);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .86rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
}

/* ---------- 滚动入场 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s cubic-bezier(.22, .61, .36, 1);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding-block: 10px;
  }
  .header-nav {
    order: 3;
    flex: 1 1 100%;
  }
  .site-search {
    order: 4;
    flex: 1 1 100%;
  }
  .icon-btn { margin-left: auto; }
  .search-submit { padding: 8px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ================= 登录弹窗 ================= */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  position: relative;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border: none; background: var(--bg-alt); color: var(--muted);
  border-radius: 50%; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
}
.modal-close:hover { background: var(--line); color: var(--text); }

.modal-card h2 { font-size: 1.4rem; margin-bottom: 6px; letter-spacing: -0.02em; }
.modal-desc { font-size: 0.88rem; color: var(--muted); margin-bottom: 24px; }

/* 表单 */
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.input-row input {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-alt); color: var(--text);
  font-size: 0.95rem; outline: none; transition: border 0.2s;
}
.input-row input:focus { border-color: var(--accent); background: var(--surface); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row .btn { padding: 0 16px; font-size: 0.85rem; white-space: nowrap; }
.btn-block { width: 100%; margin-top: 8px; padding: 12px; font-size: 0.95rem; }

.auth-tip {
  font-size: 0.8rem; text-align: center; margin-top: 4px;
  color: #dc2626; min-height: 18px;
}
.auth-tip.success { color: #059669; }

/* 分割线与第三方登录 */
.auth-divider {
  display: flex; align-items: center; text-align: center;
  margin: 24px 0; color: var(--muted); font-size: 0.8rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; border-bottom: 1px solid var(--line);
}
.auth-divider span { padding: 0 12px; }

.btn-oauth {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-alt); color: var(--text);
  font-size: 0.95rem; font-weight: 600;
  transition: all 0.2s;
}
.btn-oauth:hover { background: var(--line); transform: translateY(-1px); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: none; } }