/* ============================================================
   设计令牌
   ============================================================ */
:root {
  --bg: #080a10;
  --bg-soft: #0d1017;
  --surface: #11151f;
  --surface-2: #161b27;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9edf6;
  --text-muted: #98a3b8;
  --text-dim: #6b768c;
  --accent: #5b8cff;
  --accent-2: #22d3ee;
  --accent-3: #a78bfa;
  --gradient: linear-gradient(100deg, #5b8cff 0%, #22d3ee 55%, #a78bfa 100%);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --max: 1120px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f7f8fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: rgba(16, 24, 40, 0.1);
  --border-strong: rgba(16, 24, 40, 0.18);
  --text: #12172a;
  --text-muted: #55617a;
  --text-dim: #8b95ab;
  --accent: #2f5fe0;
  --accent-2: #0e9bb5;
  --accent-3: #7c5cf0;
  --shadow: 0 24px 50px -34px rgba(16, 24, 40, 0.4);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60rem 40rem at 12% -10%, rgba(91, 140, 255, 0.16), transparent 60%),
    radial-gradient(50rem 34rem at 90% 0%, rgba(167, 139, 250, 0.12), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
}

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

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  font-weight: 650;
}

p {
  margin: 0 0 1em;
}

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ============================================================
   页头
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 66px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--gradient);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px -10px rgba(91, 140, 255, 0.9);
}

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

.nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.92rem;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}

.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav a.active {
  color: var(--text);
  background: var(--surface-2);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ============================================================
   通用区块 / 按钮
   ============================================================ */
.section {
  padding: 64px 0;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.section-head h2 {
  font-size: 1.6rem;
  margin: 0;
}

.section-head .more {
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.section-head .more:hover {
  color: var(--accent-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 550;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.btn-primary {
  background: var(--gradient);
  color: #06080d;
  border: none;
  font-weight: 650;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: 84px 0 56px;
}

.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.16);
}

.hero h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  max-width: 20ch;
  margin-bottom: 18px;
}

.hero h1 .grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .lede {
  font-size: 1.06rem;
  color: var(--text-muted);
  max-width: 58ch;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-stats {
  display: flex;
  gap: 36px;
  margin-top: 44px;
  flex-wrap: wrap;
}

.hero-stats .num {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
}

.hero-stats .lbl {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ============================================================
   卡片网格
   ============================================================ */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.grid-3 {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.card-cover {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(91, 140, 255, 0.22), rgba(167, 139, 250, 0.14)),
    var(--surface-2);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-cover .placeholder {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
}

.card-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card-body h3 {
  font-size: 1.08rem;
  margin: 0;
}

.card-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.chip-accent {
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.3);
  background: rgba(34, 211, 238, 0.08);
}

.card-meta {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.featured-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(6, 8, 13, 0.72);
  color: var(--accent-2);
  border: 1px solid rgba(34, 211, 238, 0.35);
  backdrop-filter: blur(6px);
}

/* ============================================================
   筛选栏
   ============================================================ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filters a {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.filters a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.filters a.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.search {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.search input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  min-width: 200px;
  outline: none;
  transition: border-color 0.18s var(--ease);
}

.search input:focus {
  border-color: var(--accent);
}

/* ============================================================
   详情页
   ============================================================ */
.page-head {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border);
}

.page-head h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.7rem);
  margin-bottom: 12px;
}

.page-head .lede {
  color: var(--text-muted);
  font-size: 1.02rem;
  max-width: 62ch;
  margin: 0;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 48px;
  padding: 44px 0 72px;
  align-items: start;
}

.detail-layout.no-aside {
  grid-template-columns: minmax(0, 1fr);
  max-width: 780px;
}

.aside {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 20px;
}

.panel h4 {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-weight: 500;
}

.panel .kv {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
}

.panel .kv a {
  color: var(--accent-2);
}

.panel .kv a:hover {
  text-decoration: underline;
}

.toc {
  font-size: 0.88rem;
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc ul ul {
  padding-left: 14px;
}

.toc a {
  color: var(--text-muted);
  display: block;
  padding: 3px 0;
  border-left: 2px solid transparent;
  padding-left: 10px;
}

.toc a:hover {
  color: var(--text);
  border-color: var(--accent);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 28px 0;
}

.gallery figure {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.gallery figcaption {
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.changelog {
  margin-top: 36px;
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.changelog-item {
  position: relative;
  padding: 0 0 22px 22px;
  border-left: 1px solid var(--border);
}

.changelog-item::before {
  content: "";
  position: absolute;
  left: -4.5px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.changelog-item .v {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-2);
}

.changelog-item time {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-left: 10px;
  font-family: var(--font-mono);
}

/* ============================================================
   正文排版（Markdown 产物）
   ============================================================ */
.prose {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  font-size: 1.42rem;
  margin: 2em 0 0.7em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 1.16rem;
  margin: 1.8em 0 0.6em;
}

.prose h4 {
  font-size: 1rem;
  margin: 1.5em 0 0.5em;
}

.prose a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(34, 211, 238, 0.4);
}

.prose a:hover {
  text-decoration-color: currentColor;
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
  margin: 0 0 1.1em;
}

.prose li {
  margin: 0.35em 0;
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 1.4em 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.12em 0.42em;
  border-radius: 5px;
}

.prose pre,
.prose .codehilite {
  background: #0b0e16 !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 1.4em 0;
  font-size: 0.87rem;
  line-height: 1.65;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: #d7e0f3;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}

.prose th {
  background: var(--surface-2);
  font-weight: 600;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

/* Pygments 高亮（深色） */
.codehilite .k, .codehilite .kd, .codehilite .kn, .codehilite .kr { color: #c792ea; }
.codehilite .s, .codehilite .s1, .codehilite .s2, .codehilite .sd { color: #a5e1a5; }
.codehilite .c, .codehilite .c1, .codehilite .cm { color: #5f6b85; font-style: italic; }
.codehilite .nf, .codehilite .fm { color: #82aaff; }
.codehilite .nb, .codehilite .bp { color: #7fdbca; }
.codehilite .mi, .codehilite .mf { color: #f78c6c; }
.codehilite .nc, .codehilite .nn { color: #ffcb6b; }
.codehilite .o, .codehilite .ow { color: #89ddff; }
.codehilite .nt { color: #ff6b8a; }
.codehilite .na { color: #ffcb6b; }

/* ============================================================
   文章列表
   ============================================================ */
.post-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 22px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.post-item:last-child {
  border-bottom: none;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  padding-top: 5px;
}

.post-item h3 {
  font-size: 1.14rem;
  margin-bottom: 8px;
}

.post-item h3 a:hover {
  color: var(--accent-2);
}

.post-item p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 0.8rem;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}

.tag:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tag.active {
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.08);
}

.tag .count {
  color: var(--text-dim);
  margin-left: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ============================================================
   分页
   ============================================================ */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 40px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.pagination a,
.pagination span {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pagination a:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.pagination .current {
  color: var(--bg);
  background: var(--text);
  border-color: transparent;
}

/* ============================================================
   空状态
   ============================================================ */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ============================================================
   页脚
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 40px 0 44px;
  margin-top: 40px;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.site-footer .links {
  display: flex;
  gap: 18px;
}

.site-footer a:hover {
  color: var(--text);
}

.site-footer .footer-legal {
  margin-top: 14px;
  justify-content: center;
  font-size: 0.8rem;
  opacity: 0.85;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-top: 32px;
  }

  .aside {
    position: static;
  }

  .nav a {
    padding: 8px 9px;
    font-size: 0.88rem;
  }
}

@media (max-width: 620px) {
  .container {
    padding: 0 18px;
  }

  .site-header .container {
    gap: 10px;
    height: 58px;
  }

  .brand {
    font-size: 0.98rem;
    gap: 8px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
    border-radius: 7px;
  }

  .nav {
    gap: 2px;
  }

  .nav a {
    padding: 6px 7px;
    font-size: 0.84rem;
  }

  .theme-toggle {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  .hero h1,
  .hero .lede {
    max-width: 100%;
  }

  .hero {
    padding: 52px 0 36px;
  }

  .hero-stats {
    gap: 24px;
    margin-top: 32px;
  }

  .section {
    padding: 44px 0;
  }

  .post-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .search {
    margin-left: 0;
    width: 100%;
  }

  .search input {
    min-width: 0;
    flex: 1;
  }

  .toolbar {
    padding: 10px;
  }
}

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