/* ===== 基础变量 ===== */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e6e8ec;
  --border-strong: #d6dae1;
  --text: #1f2328;
  --text-2: #4b5563;
  --muted: #8a919b;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-hover: 0 6px 16px rgba(16, 24, 40, .1);
  --header-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

.container { width: min(1200px, 100% - 40px); margin-inline: auto; }
.container.narrow { width: min(760px, 100% - 40px); }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ===== 头部 ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 7px 12px; border-radius: var(--radius-sm); color: var(--text-2);
  font-size: 14px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--accent-soft); color: var(--accent); }
.nav-link.is-active { color: var(--accent); font-weight: 600; }
.menu-toggle {
  display: none; margin-left: auto; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer;
}

/* ===== 首页 hero ===== */
.hero {
  position: relative;
  overflow: hidden;
  padding: 52px 0 44px;
  background:
    radial-gradient(60% 120% at 50% -10%, rgba(37, 99, 235, .14) 0%, rgba(37, 99, 235, 0) 60%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}
.hero::before {
  width: 380px; height: 380px; top: -160px; left: -80px;
  background: radial-gradient(circle, rgba(37, 99, 235, .28), transparent 70%);
}
.hero::after {
  width: 420px; height: 420px; top: -200px; right: -120px;
  background: radial-gradient(circle, rgba(139, 92, 246, .22), transparent 70%);
}
.hero > .container { position: relative; z-index: 1; }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 20px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: rgba(255, 255, 255, .7); backdrop-filter: blur(6px);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow);
}
.hero-eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}
.hero-title {
  margin: 0 0 28px;
  font-size: clamp(36px, 6vw, 60px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.08;
  background: linear-gradient(135deg, #1f2328 0%, #2563eb 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero-tagline {
  margin: 18px auto 34px; max-width: 620px;
  color: var(--text-2); font-size: clamp(16px, 2vw, 19px); line-height: 1.6;
}
.hero-stats {
  display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px 10px; margin: 24px 0 0; color: var(--muted); font-size: 13px;
}
.hero-stats strong { color: var(--text); font-size: 15px; }

.search-box { position: relative; max-width: 620px; margin: 0 auto; }
.search-box-sm { margin: 16px 0 0; max-width: 420px; }
.search-box input {
  width: 100%; height: 56px; padding: 0 48px 0 22px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 28px; background: var(--surface);
  color: var(--text); box-shadow: 0 4px 20px rgba(16, 24, 40, .08); outline: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.search-box-sm input { height: 40px; border-radius: 20px; font-size: 14px; box-shadow: var(--shadow); }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, .14), 0 6px 24px rgba(37, 99, 235, .12); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; display: none;
}
.search-clear:hover { background: var(--bg); color: var(--text); }
.search-box.has-value .search-clear { display: block; }
.search-status { margin: 12px 0 0; font-size: 13px; color: var(--muted); }

/* ===== 主布局 ===== */
.layout {
  display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 32px;
  padding: 32px 0 64px; align-items: start;
}
.layout > * { min-width: 0; }
.content { min-width: 0; }
.sidebar { position: sticky; top: calc(var(--header-h) + 24px); }
.sidebar-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.cat-nav { display: flex; flex-direction: column; gap: 2px; }
.cat-nav-link {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-2); transition: background .15s, color .15s;
}
.cat-nav-link:hover { background: var(--surface); color: var(--text); }
.cat-nav-link.is-active, .cat-nav-link.is-current {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.cat-nav-icon { width: 18px; text-align: center; font-size: 14px; }
.cat-nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-nav-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== 分类与卡片 ===== */
.cat { margin-bottom: 40px; scroll-margin-top: calc(var(--header-h) + 20px); }
.cat-head { display: flex; align-items: baseline; gap: 12px; }
.cat-title { margin: 0; font-size: 19px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.cat-icon { font-size: 18px; }
.cat-count {
  font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; margin-left: 2px;
}
.cat-more { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.cat-more:hover { color: var(--accent); }
.cat-desc { margin: 6px 0 16px; color: var(--text-2); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 12px; }

.card {
  position: relative; display: flex; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-strong);
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-icon {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font-size: 16px; font-weight: 700;
  background: hsl(var(--h, 220) 70% 95%); color: hsl(var(--h, 220) 55% 42%);
}
/* 有真实 logo 时：中性底色，让深浅色图标都能看清 */
.card-icon.has-logo {
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-icon.has-logo img {
  width: 24px; height: 24px; object-fit: contain; display: block;
}
/* 图标加载失败时隐藏，只留下中性底色，不出现裂图 */
.card-icon.has-logo img:not([src]) { display: none; }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-title {
  font-size: 14.5px; font-weight: 600; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-desc {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-host {
  position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: var(--muted);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
  background: linear-gradient(90deg, transparent, var(--surface) 24%); padding-left: 20px;
}
.card:hover .card-host { opacity: 1; transform: translateY(0); }

/* ===== 页头 / 面包屑 / 芯片 ===== */
.breadcrumb { display: flex; gap: 8px; padding: 18px 0 0; font-size: 13px; color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); display: flex; align-items: center; gap: 10px; }
.page-lead { margin: 10px 0 0; color: var(--text-2); font-size: 15px; }
.page-meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.related { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border); }
.related h2 { margin: 0 0 14px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); font-size: 13px; color: var(--text-2); transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn {
  display: inline-block; padding: 9px 18px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
}
.btn:hover { filter: brightness(1.06); }

/* ===== 文章列表 ===== */
.post-list { display: flex; flex-direction: column; gap: 14px; padding-bottom: 60px; }
.post-card {
  padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.post-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-strong);
}
.post-card-title { margin: 0; font-size: 20px; line-height: 1.4; letter-spacing: -.01em; }
.post-card-title a { transition: color .15s; }
.post-card:hover .post-card-title a { color: var(--accent); }
.post-card-desc { margin: 9px 0 0; color: var(--text-2); font-size: 14.5px; line-height: 1.7; }
.post-card-meta, .post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.post-card-meta span, .post-meta span { position: relative; padding-left: 10px; }
.post-card-meta span::before, .post-meta span::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5;
}

/* ===== 文章详情 ===== */
.post { padding: 36px 0 40px; }
.post-head { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.post-head h1 {
  margin: 0; font-size: clamp(28px, 3.8vw, 40px); line-height: 1.28;
  letter-spacing: -.025em; font-weight: 800;
}
.post-head .post-meta { margin-top: 16px; font-size: 13px; }
.post-head .post-meta time { color: var(--text-2); font-weight: 500; }

/* 阅读进度条 */
.read-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  transform: scaleX(0); transform-origin: 0 50%; will-change: transform;
}

/* Cookie 同意横幅 */
.consent-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 80;
  max-width: 620px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px;
  padding: 16px 20px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(16, 24, 40, .16);
}
.consent-text { margin: 0; flex: 1 1 280px; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.consent-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.consent-actions { display: flex; gap: 10px; margin-left: auto; }
.consent-btn {
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-strong); transition: all .15s;
}
.consent-reject { background: var(--surface); color: var(--text-2); }
.consent-reject:hover { background: var(--bg); }
.consent-accept { background: var(--accent); color: #fff; border-color: var(--accent); }
.consent-accept:hover { filter: brightness(1.06); }

.toc {
  margin: 28px 0; padding: 18px 22px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.toc-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.toc ol { margin: 0; padding-left: 18px; font-size: 14px; }
.toc li { margin: 5px 0; color: var(--text-2); }
.toc li.toc-l3 { margin-left: 14px; font-size: 13px; }
.toc a { transition: color .15s; }
.toc a:hover { color: var(--accent); }

.prose { font-size: 17px; line-height: 1.85; color: #2a2f37; }
.prose > p:first-of-type {
  font-size: 19px; line-height: 1.7; color: var(--text);
}
.prose h2 {
  margin: 44px 0 16px; font-size: 24px; font-weight: 750; padding-bottom: 10px;
  letter-spacing: -.01em; border-bottom: 2px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.prose h3 { margin: 32px 0 12px; font-size: 19px; font-weight: 700; scroll-margin-top: calc(var(--header-h) + 16px); }
.prose p { margin: 18px 0; }
.prose ul, .prose ol { margin: 18px 0; padding-left: 26px; }
.prose li { margin: 8px 0; }
.prose li::marker { color: var(--accent); }
.prose a {
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-thickness: 1px; text-decoration-color: rgba(37, 99, 235, .35);
  transition: text-decoration-color .15s;
}
.prose a:hover { text-decoration-color: var(--accent); }
.prose blockquote {
  margin: 24px 0; padding: 14px 22px; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-2); font-size: 16px;
}
.prose blockquote p { margin: 6px 0; }
.prose code {
  background: #f1f3f6; border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 5px; font-size: .88em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.prose pre {
  margin: 20px 0; padding: 16px 18px; background: #1f2430; color: #e5e9f0;
  border-radius: var(--radius); overflow-x: auto; font-size: 13.5px; line-height: 1.7;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; }
.prose hr { margin: 32px 0; border: 0; border-top: 1px solid var(--border); }
.table-wrap { overflow-x: auto; margin: 20px 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th, .prose td { padding: 9px 12px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--surface-2); font-weight: 600; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 0 60px; }
.post-nav-item {
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; transition: border-color .15s;
}
.post-nav-item:hover { border-color: var(--accent); color: var(--accent); }
.post-nav-item span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.post-nav-item.is-next { text-align: right; }
.empty { color: var(--muted); }

/* ===== 广告位 ===== */
.ad {
  display: block; margin: 24px 0; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); min-height: 90px;
}
.ad-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.ad-sidebar { margin-top: 24px; }

/* ===== 页脚 ===== */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 40px 0 24px; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-col a { display: block; font-size: 13.5px; color: var(--text-2); padding: 3px 0; }
.footer-col a:hover { color: var(--accent); }
.footer-brand { margin: 0 0 8px; font-weight: 650; }
.footer-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.footer-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.7; max-width: 46ch; }
.copyright {
  display: flex; gap: 16px; margin-top: 28px; padding-top: 16px;
  border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted);
}
.copyright a:hover { color: var(--accent); }

/* ===== 回到顶部 ===== */
.to-top {
  position: fixed; right: 24px; bottom: 24px; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: 16px; cursor: pointer; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 40;
}
.to-top.is-visible { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }

/* ===== 响应式 ===== */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .sidebar { position: static; max-width: 100%; overflow: hidden; }
  .sidebar-title, .ad-sidebar { display: none; }
  .cat-nav {
    flex-direction: row; gap: 8px; overflow-x: auto; padding-bottom: 6px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .cat-nav::-webkit-scrollbar { display: none; }
  .cat-nav-link {
    flex: none; border: 1px solid var(--border); background: var(--surface); white-space: nowrap;
  }
  .cat-nav-count { display: none; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 640px) {
  .container, .container.narrow { width: calc(100% - 32px); }
  .site-nav {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 8px 16px 12px; box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; }
  .menu-toggle { display: block; }
  .hero { padding: 56px 0 40px; }
  .grid { grid-template-columns: 1fr; }
  .post-nav { grid-template-columns: 1fr; }
  .to-top { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
