/* boxs.top — modern minimal theme (light + dark) */
:root {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: #e4e8ef;
  --border-strong: #cbd5e1;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #4338ca;
  --code-bg: #f1f5f9;
  --code-text: #334155;
  --quote-bar: #c7d2fe;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 760px;
  --maxw-wide: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0a0c10;
  --bg-elev: #11151c;
  --surface: #12161f;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --border: #1f2733;
  --border-strong: #334155;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: #1e1b4b;
  --accent-ink: #a5b4fc;
  --code-bg: #0f172a;
  --code-text: #cbd5e1;
  --quote-bar: #4338ca;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}
a { color: var(--accent-strong); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw-wide); margin: 0 auto;
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; display: block; }
.brand-word { font-size: 19px; letter-spacing: -.02em; }
.brand-sub { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 1px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav a {
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px;
}
.nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav a.active { color: var(--accent-strong); }
.nav-toggle { display: none; flex-direction: column; gap: 4px; background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 8px 9px; cursor: pointer; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text-muted); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.spacer { flex: 1; }
.theme-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); font: inherit; font-size: 13px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  transition: all .15s ease;
}
.theme-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.theme-btn svg { width: 15px; height: 15px; }
[data-theme="light"] .i-moon { display: inline; }
[data-theme="light"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: none; }
[data-theme="dark"] .i-sun { display: inline; }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: var(--maxw-wide); margin: 0 auto; padding: 0 24px; }

/* ---------- Hero (home) ---------- */
.hero { padding: 72px 0 40px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-strong); background: var(--accent-soft);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(30px, 5vw, 46px); line-height: 1.15; letter-spacing: -.03em;
  margin: 0 0 14px; font-weight: 800;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent-strong), #7c3aed 60%, #db2777);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: 17px; color: var(--text-muted); max-width: 560px; margin: 0 0 8px; }
.hero-meta { display: flex; gap: 18px; margin-top: 22px; font-size: 14px; color: var(--text-muted); }
.hero-meta b { color: var(--text); font-weight: 700; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 20px 0 18px;
}
.section-title h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.section-title a { font-size: 13px; color: var(--text-muted); }

/* ---------- Post cards ---------- */
.post-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 56px; }
.post-card {
  display: block; padding: 24px 22px; border-radius: var(--radius);
  border: 1px solid transparent; transition: all .18s ease;
  color: var(--text);
}
.post-card:hover { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); text-decoration: none; transform: translateY(-1px); }
.post-card h3 { font-size: 19px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; line-height: 1.35; }
.post-card:hover h3 { color: var(--accent-strong); }
.post-card .excerpt { font-size: 14.5px; color: var(--text-muted); margin: 0; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .meta { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--text-faint); }
.post-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px; font-weight: 600; color: var(--accent-strong);
  background: var(--accent-soft); padding: 2px 9px; border-radius: 999px;
}
.tag:hover { text-decoration: none; }

/* ---------- Article ---------- */
.article { padding: 48px 0 64px; }
.article-head { margin-bottom: 32px; }
.article-head .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.article h1 {
  font-size: clamp(26px, 4vw, 36px); line-height: 1.25; letter-spacing: -.02em;
  font-weight: 800; margin: 0 0 14px;
}
.article .byline { font-size: 14px; color: var(--text-muted); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.article .byline .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-faint); }
.prose { font-size: 16.5px; line-height: 1.85; color: var(--text); }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-weight: 700; line-height: 1.35; letter-spacing: -.01em; margin: 28px 0 12px;
}
.prose h2 { font-size: 22px; padding-top: 8px; }
.prose h3 { font-size: 18px; }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin: 4px 0; }
.prose blockquote {
  margin: 18px 0; padding: 10px 18px; border-left: 3px solid var(--quote-bar);
  background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}
.prose hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.prose a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }
.prose a:hover { text-decoration-color: var(--accent); }
.prose table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--bg-elev); font-weight: 600; }

/* Hexo highlight tables -> clean code blocks */
.prose figure.highlight { margin: 16px 0; }
.prose figure.highlight table { width: 100%; border: none; display: table; }
.prose figure.highlight td { border: none; padding: 0; vertical-align: top; }
.prose figure.highlight .gutter { display: none; }
.prose pre, .prose .highlight pre {
  background: var(--code-bg); color: var(--code-text);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  padding: 16px 18px; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 0; white-space: pre;
}
.prose code { font-family: var(--mono); font-size: .92em; background: var(--code-bg); color: var(--code-text); padding: 2px 6px; border-radius: 5px; }
.prose pre code { background: transparent; padding: 0; }
.prose .headerlink { opacity: 0; margin-left: 6px; font-size: .8em; color: var(--text-faint); text-decoration: none; }
.prose h2:hover .headerlink, .prose h3:hover .headerlink { opacity: 1; }
.prose center { text-align: center; color: var(--text-muted); margin: 2px 0; }

/* code copy */
.code-wrap { position: relative; }
.code-wrap .copy-btn {
  position: absolute; top: 8px; right: 8px; opacity: 0;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 11px; padding: 3px 9px; border-radius: 6px; cursor: pointer; transition: opacity .15s;
}
.code-wrap:hover .copy-btn { opacity: 1; }
.copy-btn.copied { color: var(--accent-strong); border-color: var(--accent); }

/* ---------- Article TOC ---------- */
.prose h2, .prose h3 { scroll-margin-top: 84px; }
.toc {
  margin: 0 0 28px; padding: 14px 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.toc summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "展开"; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-faint); }
.toc details[open] > summary::after { content: "收起"; }
.toc-list { list-style: none; margin: 10px 0 0; padding: 0; }
.toc-list li { margin: 0; }
.toc-list a {
  display: block; padding: 5px 10px; font-size: 13.5px; line-height: 1.5;
  color: var(--text-muted); border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toc-list a:hover { color: var(--accent-strong); background: var(--accent-soft); text-decoration: none; }
.toc-list a.active { color: var(--accent-strong); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.toc-list .lvl-3 a { padding-left: 24px; font-size: 13px; }

@media (min-width: 1120px) {
  .article.has-toc { max-width: var(--maxw-wide); }
  .article.has-toc .article-head,
  .article.has-toc .pager { max-width: var(--maxw); }
  .article.has-toc .article-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) 224px;
    gap: 44px; align-items: start;
  }
  .article.has-toc .article-grid > .prose { min-width: 0; grid-column: 1; grid-row: 1; }
  .article.has-toc .toc {
    grid-column: 2; grid-row: 1;
    margin: 0; position: sticky; top: 84px;
    max-height: calc(100vh - 116px); overflow-y: auto;
    padding: 4px 2px 8px 14px; border: none; background: transparent;
  }
  .article.has-toc .toc summary { display: none; }
  .article.has-toc .toc-list { margin: 0; }
}

/* prev/next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.pager a {
  display: block; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); background: var(--surface); transition: all .15s;
}
.pager a:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); text-decoration: none; }
.pager .label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.pager .title { font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.pager .next { text-align: right; }

/* ---------- Archive / tag listings ---------- */
.page-head { padding: 56px 0 8px; }
.page-head h1 { font-size: clamp(24px, 3.5vw, 32px); font-weight: 800; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-muted); font-size: 14.5px; margin-top: 8px; }

.year-block { margin: 28px 0; }
.year-block .year { font-size: 13px; font-weight: 700; color: var(--accent-strong); letter-spacing: .05em; margin: 0 0 4px; }
.year-block ul { list-style: none; margin: 0; padding: 0; }
.year-block li { display: flex; gap: 14px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border); }
.year-block li:last-child { border-bottom: none; }
.year-block .date { font-size: 13px; color: var(--text-faint); min-width: 76px; font-variant-numeric: tabular-nums; }
.year-block li a { color: var(--text); font-weight: 500; flex: 1; }
.year-block li a:hover { color: var(--accent-strong); text-decoration: none; }
.year-block .tags-mini { font-size: 11px; color: var(--text-faint); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 40px; }
.tag-cloud a { font-size: 14px; padding: 7px 16px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); background: var(--surface); font-weight: 500; }
.tag-cloud a:hover { color: var(--accent-strong); border-color: var(--accent); text-decoration: none; }
.tag-cloud a .cnt { font-size: 11px; color: var(--text-faint); margin-left: 4px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 36px 0 48px; color: var(--text-muted); font-size: 13.5px; }
.footer-inner { max-width: var(--maxw-wide); margin: 0 auto; padding: 0 24px; display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; align-items: center; }
.footer .links a { color: var(--text-muted); margin-right: 14px; }
.footer .links a:hover { color: var(--accent-strong); }
.footer .beian { color: var(--text-faint); }

/* ---------- 404 ---------- */
.error-page { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 24px; }
.error-page .code { font-size: 72px; font-weight: 800; letter-spacing: -.04em; background: linear-gradient(120deg, var(--accent-strong), #7c3aed); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-page h1 { margin: 8px 0; font-size: 24px; }
.error-page p { color: var(--text-muted); margin: 0 0 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar-inner { padding: 0 16px; height: 54px; gap: 12px; }
  .brand-sub { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: 54px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px; margin: 0;
    background: var(--bg-elev); border-bottom: 1px solid var(--border);
    padding: 8px 16px 12px; box-shadow: var(--shadow-md);
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; }
  .hero { padding: 44px 0 24px; }
  .container, .container-wide { padding: 0 18px; }
  .post-card { padding: 18px 16px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

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