/* ============================================================================
   猫窝博客（miao-blog）设计系统
   ----------------------------------------------------------------------------
   方向：可爱为壳，阅读为核。
   - 「可爱」靠形状与动效表达（大圆角、2px 描边、实色偏移阴影、猫 mascot），
     不靠插画堆砌 —— 首屏没有大图，LCP 只有文字。
   - 「阅读」优先：正文 17.5px / 1.9，中文行宽 720px（每行 40 字左右），
     代码块与正文同级对待。
   - 两套形态：data-style="cute"（默认）/ "minimal"（给技术博主，一键极简）。
   - 两色模式：data-theme="light" / "dark"，由 <head> 内联脚本在首屏前决定。
   ========================================================================== */

/* ── tokens：亮色为基准 ─────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --canvas: #fdf9f3;
  --surface: #ffffff;
  --surface-soft: #f7f1e8;
  --surface-sink: #f2ebdf;

  --ink: #2c2a26;
  --ink-soft: #6b6357;
  --ink-muted: #948b7d;

  --accent: #e8836b;
  --accent-deep: #d2664c;
  --accent-soft: #fcebe5;
  --accent-ink: #ffffff;

  --mascot-fill: #fff3e9;
  --mascot-stroke: #2c2a26;

  --hairline: #e8dfd2;
  --hairline-strong: #d8ccb9;

  --code-bg: #2b2a2e;
  --code-ink: #ece9e4;
  --code-comment: #8b8578;
  --code-keyword: #f0a6a6;
  --code-string: #a8d8a0;
  --code-number: #f2c48a;
  --code-function: #9cc9f0;
  --code-type: #e8d59a;
  --code-tag: #f0a6a6;

  --ok: #5f9e7f;
  --warn: #c98a3c;
  --danger: #c65a4a;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-card: 0 2px 0 var(--hairline);
  --shadow-lift: 0 6px 0 var(--hairline);
  --shadow-float: 0 12px 32px rgb(44 42 38 / 10%);

  --font-sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --reading-width: 720px;
  --shell-width: 1080px;
}

/* ── 暗色：暖调深灰，不是纯黑 ───────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;

  --canvas: #17161a;
  --surface: #1e1d22;
  --surface-soft: #242329;
  --surface-sink: #2a2830;

  --ink: #ede9e3;
  --ink-soft: #b5aea4;
  --ink-muted: #8a8378;

  --accent: #f09a82;
  --accent-deep: #e8836b;
  --accent-soft: #33251f;
  --accent-ink: #1a1512;

  --mascot-fill: #2a2521;
  --mascot-stroke: #ede9e3;

  --hairline: #2e2c33;
  --hairline-strong: #3d3a44;

  --code-bg: #111014;
  --code-ink: #e6e2dc;
  --code-comment: #7d776c;
  --code-keyword: #f0a6a6;
  --code-string: #a8d8a0;
  --code-number: #f2c48a;
  --code-function: #9cc9f0;
  --code-type: #e8d59a;
  --code-tag: #f0a6a6;

  --ok: #7fbd9b;
  --warn: #e0a95c;
  --danger: #e07b6a;

  --shadow-card: 0 2px 0 #26242b;
  --shadow-lift: 0 6px 0 #2c2a32;
  --shadow-float: 0 12px 32px rgb(0 0 0 / 45%);
}

/* JS 未执行时的兜底：跟随系统，且只覆盖「没被脚本写过 data-theme」的情况 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --canvas: #17161a;
    --surface: #1e1d22;
    --surface-soft: #242329;
    --surface-sink: #2a2830;
    --ink: #ede9e3;
    --ink-soft: #b5aea4;
    --ink-muted: #8a8378;
    --accent: #f09a82;
    --accent-deep: #e8836b;
    --accent-soft: #33251f;
    --accent-ink: #1a1512;
    --mascot-fill: #2a2521;
    --mascot-stroke: #ede9e3;
    --hairline: #2e2c33;
    --hairline-strong: #3d3a44;
    --code-bg: #111014;
    --code-ink: #e6e2dc;
    --shadow-card: 0 2px 0 #26242b;
    --shadow-lift: 0 6px 0 #2c2a32;
  }
}

/* ── 极简形态：同一套结构，去掉「可爱」的装饰性 token ──────────────────── */
[data-style="minimal"] {
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow-card: none;
  --shadow-lift: none;
}
[data-style="minimal"] .mascot,
[data-style="minimal"] .hero__art {
  display: none;
}
[data-style="minimal"] .post-card {
  border-width: 1px;
}
[data-style="minimal"] .btn {
  border-width: 1px;
}

/* ── reset ─────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* 用 :where() 把全局链接色的特异性压到 0，这样 .btn--primary 之类的组件色不会被它盖掉
   （踩过的坑：暗色下按钮文字被染成与背景同色，看不见）。 */
:where(a) {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
:where([data-theme="dark"]) a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
}

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

.muted {
  color: var(--ink-muted);
}

.dot {
  color: var(--hairline-strong);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus {
  left: 16px;
}

/* ── 顶栏 ──────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--hairline);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 66px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.brand__name {
  font-size: 17px;
}

.mascot {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.brand:hover .mascot {
  transform: rotate(-8deg) scale(1.06);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}

.nav__link {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav__link:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.nav__link--active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
[data-theme="dark"] .nav__link--active {
  color: var(--accent);
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.icon-btn__label {
  font-size: 12px;
  font-weight: 700;
}

/* 主题图标：亮色显示月亮（点下去变暗），暗色显示太阳 */
.theme-icon--sun {
  display: none;
}
[data-theme="dark"] .theme-icon--moon {
  display: none;
}
[data-theme="dark"] .theme-icon--sun {
  display: inline-flex;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-icon--moon {
    display: none;
  }
  :root:not([data-theme]) .theme-icon--sun {
    display: inline-flex;
  }
}

/* ── 按钮 ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  box-shadow: var(--shadow-card);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}
.btn:active {
  transform: translateY(0);
  box-shadow: none;
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover {
  background: var(--accent-deep);
}
.btn--ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  color: var(--ink-soft);
}
.btn--ghost:hover {
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}
.btn--danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
  box-shadow: none;
}
.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.btn--github {
  background: #24292f;
  border-color: #24292f;
  color: #fff;
}
[data-theme="dark"] .btn--github {
  background: #f0f0f0;
  border-color: #f0f0f0;
  color: #24292f;
}
.btn--sm {
  padding: 6px 12px;
  font-size: 13px;
}
.btn--full {
  width: 100%;
}

/* ── 首页 ──────────────────────────────────────────────────────────────── */
.main {
  min-height: 62vh;
  padding-bottom: 72px;
}

/* hero 做成一张「卡片」：全宽两列时中间会空出一大片，
   给一个明确的边界比靠留白更稳，也更贴「可爱」的卡片语言。 */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  margin: 34px 0 46px;
  padding: 44px 46px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: 28px;
  box-shadow: var(--shadow-card);
}
[data-style="minimal"] .hero {
  border-width: 1px;
  border-radius: var(--radius);
  box-shadow: none;
}

.hero__copy {
  min-width: 0;
}

.hero__greeting {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-deep);
  text-transform: uppercase;
}
[data-theme="dark"] .hero__greeting {
  color: var(--accent);
}

.hero__title {
  margin: 0 0 14px;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1.12;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero__tagline {
  margin: 0 0 26px;
  font-size: 17.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 30em;
}

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

.hero__stats {
  display: flex;
  gap: 30px;
  margin: 34px 0 0;
  padding: 0;
}

.hero__stat {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  margin: 0;
}
.hero__stat dt {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}
.hero__stat dd {
  margin: 0;
  font-size: 25px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.hero__art {
  display: grid;
  place-items: center;
  width: 236px;
  height: 236px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--accent-soft), transparent 68%);
}
.hero__art .mascot {
  width: 150px;
  height: 150px;
  animation: mascot-bob 5s ease-in-out infinite;
}
@keyframes mascot-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hero__art .mascot {
    animation: none;
  }
}

/* ── 文章列表 ──────────────────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--hairline);
}
.section-head__title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.section-head__count {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--surface-soft);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card {
  padding: 22px 24px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--hairline-strong);
}

.post-card__title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.post-card__title a {
  color: var(--ink);
  text-decoration: none;
}
.post-card__title a:hover {
  color: var(--accent-deep);
}
[data-theme="dark"] .post-card__title a:hover {
  color: var(--accent);
}

.post-card__excerpt {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.post-card__tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 2px;
}

.tag-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.tag-chip:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
[data-theme="dark"] .tag-chip:hover {
  color: var(--accent);
}

/* ── 空状态 / 404 ──────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 20px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--hairline-strong);
  border-radius: var(--radius-lg);
}
.empty-state__title {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 800;
}
.empty-state__desc {
  margin: 0 0 10px;
  color: var(--ink-soft);
}

.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 96px 20px;
  text-align: center;
}
.not-found__title {
  margin: 0;
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 900;
}
.not-found__desc {
  margin: 0 0 8px;
  color: var(--ink-soft);
}

/* ── 分页 ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 30px;
}
.pagination__btn {
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
}
.pagination__btn:hover {
  border-color: var(--hairline-strong);
  color: var(--ink);
}
.pagination__btn--disabled {
  opacity: 0.4;
}
.pagination__pages {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
}
.pagination__page {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pagination__page:hover {
  background: var(--surface-soft);
}
.pagination__page--current {
  background: var(--accent);
  color: var(--accent-ink);
}
.pagination__gap {
  color: var(--ink-muted);
  padding: 0 2px;
}

/* ── 文章详情 ──────────────────────────────────────────────────────────── */
.post {
  padding-top: 48px;
}

.post__head {
  max-width: var(--reading-width);
  margin: 0 auto 34px;
}

.post__breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}
.post__breadcrumb a {
  color: var(--ink-muted);
  text-decoration: none;
}
.post__breadcrumb a:hover {
  color: var(--accent-deep);
}

.post__title {
  margin: 0 0 16px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.24;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.post__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.post__tags {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.post__cover {
  width: 100%;
  margin-top: 26px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--hairline);
  object-fit: cover;
  max-height: 420px;
}

.post__layout {
  display: grid;
  grid-template-columns: minmax(0, var(--reading-width)) 220px;
  gap: 48px;
  justify-content: center;
  align-items: start;
}

.post__body {
  min-width: 0;
}

/* ── 目录 ──────────────────────────────────────────────────────────────── */
.toc {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-left: 16px;
  border-left: 2px solid var(--hairline);
  font-size: 13.5px;
}
.toc__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.toc__item--h3 {
  padding-left: 12px;
}
.toc__item a {
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.45;
  display: block;
}
.toc__item a:hover {
  color: var(--accent-deep);
}
[data-theme="dark"] .toc__item a:hover {
  color: var(--accent);
}

/* ── 正文排版（prose）─────────────────────────────────────────────────── */
.prose {
  font-size: 17.5px;
  line-height: 1.9;
  color: var(--ink);
  overflow-wrap: break-word;
}

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

.prose p {
  margin: 0 0 1.35em;
}

.prose h2,
.prose h3,
.prose h4 {
  margin: 2.1em 0 0.7em;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: -0.01em;
  scroll-margin-top: 92px;
}
.prose h1 {
  font-size: 1.7em;
  padding-bottom: 0.24em;
  border-bottom: 2px solid var(--hairline);
}
.prose h2 {
  font-size: 1.48em;
  padding-bottom: 0.28em;
  border-bottom: 2px solid var(--hairline);
}
.prose h3 {
  font-size: 1.24em;
}
.prose h4 {
  font-size: 1.08em;
}

.prose a {
  color: var(--accent-deep);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}
[data-theme="dark"] .prose a {
  color: var(--accent);
}
.prose a:hover {
  text-decoration-color: currentColor;
}

.prose strong {
  font-weight: 800;
}

.prose ul,
.prose ol {
  margin: 0 0 1.35em;
  padding-left: 1.4em;
}
.prose li {
  margin: 0.32em 0;
}
.prose li > ul,
.prose li > ol {
  margin: 0.32em 0;
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 2px 0 2px 18px;
  border-left: 4px solid var(--accent);
  color: var(--ink-soft);
}
.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
}

.prose pre {
  margin: 1.6em 0;
  padding: 18px 20px;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.72;
  border: 2px solid color-mix(in srgb, var(--code-bg) 70%, #000);
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* 代码块外壳：语言名头部条 */
.code-block {
  margin: 1.6em 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--code-bg) 70%, #000);
  background: var(--code-bg);
}
.code-block__head {
  display: flex;
  align-items: center;
  padding: 7px 16px;
  background: color-mix(in srgb, var(--code-bg) 88%, #fff);
  border-bottom: 1px solid color-mix(in srgb, var(--code-bg) 60%, #fff);
}
.code-block__lang {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--code-comment);
}
.prose .code-block > .code-block__pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--code-bg);
}

/* highlight.js token 配色（两种主题共用深色代码面） */
.prose .hljs-comment,
.prose .hljs-quote {
  color: var(--code-comment);
}
.prose .hljs-keyword,
.prose .hljs-selector-tag,
.prose .hljs-literal {
  color: var(--code-keyword);
}
.prose .hljs-string,
.prose .hljs-attr,
.prose .hljs-template-variable {
  color: var(--code-string);
}
.prose .hljs-number,
.prose .hljs-symbol {
  color: var(--code-number);
}
.prose .hljs-title,
.prose .hljs-function .hljs-title,
.prose .hljs-title.function_ {
  color: var(--code-function);
}
.prose .hljs-type,
.prose .hljs-class .hljs-title {
  color: var(--code-type);
}
.prose .hljs-tag,
.prose .hljs-name {
  color: var(--code-tag);
}
.prose .hljs-built_in,
.prose .hljs-meta {
  color: var(--code-comment);
}

.prose table {
  width: 100%;
  margin: 1.6em 0;
  border-collapse: collapse;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}
.prose th,
.prose td {
  padding: 9px 14px;
  border: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}
.prose th {
  background: var(--surface-soft);
  font-weight: 800;
}

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

.prose img {
  border-radius: var(--radius);
  border: 2px solid var(--hairline);
  margin: 1.6em auto;
}
.prose p > img:only-child {
  display: block;
}

/* mermaid 占位：未渲染时显示源码，不套代码块外壳 */
.diagram {
  margin: 1.6em 0;
}
.diagram--ready pre {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--hairline);
}
.diagram pre {
  margin: 0;
}

/* ── 文章尾部：作者卡 / 上下篇 / 评论 ─────────────────────────────────── */
.post__foot {
  max-width: var(--reading-width);
  margin: 56px auto 0;
}

.post__author {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 20px 22px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
}
.post__author-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--hairline);
  flex-shrink: 0;
}
.post__author-name {
  margin: 0 0 3px;
  font-weight: 800;
  font-size: 16px;
}
.post__author-bio {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0 0;
}
.post-nav__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 18px;
  border: 2px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.post-nav__item:hover {
  border-color: var(--hairline-strong);
  transform: translateY(-1px);
}
.post-nav__item--next {
  text-align: right;
  grid-column: 2;
}
.post-nav__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}
.post-nav__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── 评论 ──────────────────────────────────────────────────────────────── */
.comments {
  margin-top: 54px;
  padding-top: 32px;
  border-top: 2px solid var(--hairline);
}

.comments__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 22px;
  font-size: 22px;
  font-weight: 800;
}
.comments__count {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}
.comments__empty {
  color: var(--ink-muted);
  font-size: 14.5px;
}

.comment-login {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface-soft);
  border: 2px dashed var(--hairline-strong);
  border-radius: var(--radius);
  margin-bottom: 26px;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.comment-login p {
  margin: 0;
}

.comment-form {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  margin-bottom: 30px;
}
.comment-form__who {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.comment-form__who strong {
  color: var(--ink);
}
.comment-form__logout {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--ink-muted);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
}
.comment-form__body {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
}
.comment-form__body:focus,
.comment-form__website:focus {
  outline: none;
  border-color: var(--accent);
}
.comment-form__website {
  width: 100%;
  padding: 9px 14px;
  border: 2px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.comment-form__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.comment-form__status {
  font-size: 13px;
  color: var(--ink-muted);
}
.comment-form__status--error {
  color: var(--danger);
}
.comment-form__status--ok {
  color: var(--ok);
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.comment {
  padding: 16px 0 0;
  border-top: 1px solid var(--hairline);
}
.comment-list > .comment:first-child {
  border-top: none;
  padding-top: 0;
}
.comment-children {
  list-style: none;
  margin: 14px 0 0 20px;
  padding: 0 0 0 16px;
  border-left: 2px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.comment--reply {
  padding-top: 0;
}

.comment__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}
.comment__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}
.comment__avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 800;
  font-size: 13px;
}
.comment__who {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.comment__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.comment__name a {
  color: inherit;
  text-decoration: none;
}
.comment__name a:hover {
  text-decoration: underline;
}
.comment__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
}
.comment__owner-badge {
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 11px;
}

.comment__body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.comment__actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.comment__reply-btn,
.comment__admin-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  text-decoration: none;
}
.comment__reply-btn:hover,
.comment__admin-btn:hover {
  color: var(--accent-deep);
}
.comment__admin-btn--danger:hover {
  color: var(--danger);
}

/* ── 归档 / 标签 / 关于 ────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 52px 0 26px;
  border-bottom: 2px solid var(--hairline);
  margin-bottom: 30px;
}
.page-head__title {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: -0.02em;
}
.page-head__meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.archive {
  display: flex;
  flex-direction: column;
  gap: 34px;
}
.archive__year {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-deep);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .archive__year {
  color: var(--accent);
}
.archive__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.archive__item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
}
.archive__link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 15.5px;
}
.archive__link:hover {
  color: var(--accent-deep);
}
.archive__date {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tag-cloud__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 2px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 700;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.tag-cloud__item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tag-cloud__count {
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.about {
  max-width: var(--reading-width);
  margin: 0 auto;
}
.about__avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--hairline);
  object-fit: cover;
  margin-bottom: 16px;
}
.about__name {
  margin: 0 0 18px;
  font-size: 28px;
  font-weight: 900;
}
.about__bio {
  margin-bottom: 30px;
}
.about__links-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 12px;
}
.link-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.link-list__item {
  display: inline-block;
  padding: 8px 15px;
  border: 2px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.link-list__item:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}
.about__contact {
  font-size: 14.5px;
  color: var(--ink-soft);
}

/* ── 页脚 ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 2px solid var(--hairline);
  padding: 26px 0 34px;
  margin-top: 40px;
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-muted);
}
.site-footer__copy,
.site-footer__meta {
  margin: 0;
}
.site-footer a {
  color: var(--ink-soft);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--accent-deep);
}

/* ── 后台 ──────────────────────────────────────────────────────────────── */
.admin-body {
  background: var(--canvas);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  height: 60px;
  border-bottom: 2px solid var(--hairline);
  background: var(--surface);
}
.admin-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-header__user {
  font-size: 12.5px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.admin-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 30px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}
.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 24px;
  align-self: start;
}
.admin-nav__link {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.admin-nav__link:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.admin-nav__link--active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
[data-theme="dark"] .admin-nav__link--active {
  color: var(--accent);
}

.admin-main {
  min-width: 0;
}

.admin-login {
  max-width: 380px;
  margin: 80px auto;
  padding: 30px 28px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.admin-login__title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 900;
}
.admin-login__hint {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.6;
}
.admin-login__form {
  display: grid;
  gap: 14px;
}

.admin-title {
  margin: 0 0 22px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.admin-section-head .admin-title {
  margin-bottom: 0;
}
.admin-section-head__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-posts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-post {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 15px 18px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius);
}
.admin-post__main {
  min-width: 0;
  flex: 1;
}
.admin-post__title {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 5px;
}
.admin-post__title:hover {
  color: var(--accent-deep);
}
.admin-post__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.admin-post__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.status-badge {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
}
.status-badge--published {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
}
.status-badge--draft {
  background: var(--surface-soft);
  color: var(--ink-muted);
}

/* 编辑器 */
.editor__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.editor__main {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.editor__side {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius);
  position: sticky;
  top: 24px;
}
.editor__preview {
  margin-top: 6px;
  padding: 20px 22px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius);
}
.editor__preview-title {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.editor__status {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}
.editor__status--error {
  color: var(--danger);
}
.editor__status--ok {
  color: var(--ok);
}

.field {
  display: grid;
  gap: 6px;
}
.field--row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field__label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.field__input {
  width: 100%;
  padding: 10px 13px;
  border: 2px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
}
.field__input:focus {
  outline: none;
  border-color: var(--accent);
}
.field__input--title {
  font-size: 20px;
  font-weight: 800;
  padding: 12px 15px;
}
.field__input--code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  min-height: 460px;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.form-error {
  margin: 0;
  min-height: 1em;
  font-size: 13px;
  color: var(--danger);
}

.admin-form {
  display: grid;
  gap: 16px;
  max-width: 860px;
}
.admin-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.admin-form__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 6px;
}

/* 评论管理 */
.admin-comments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-comment {
  padding: 15px 18px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--radius);
}
.admin-comment--hidden {
  opacity: 0.55;
  border-style: dashed;
}
.admin-comment__head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 13.5px;
  margin-bottom: 8px;
}
.admin-comment__body {
  margin: 0 0 10px;
  font-size: 14.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.admin-comment__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

/* 迁移页：Agent 提示词面板 */
.admin-migrate__hint {
  max-width: 62ch;
  line-height: 1.75;
  margin: 0 0 20px;
}
.agent-prompt {
  border: 2px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  max-width: 900px;
}
.agent-prompt__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-soft);
  border-bottom: 2px solid var(--hairline);
}
.agent-prompt__label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.agent-prompt__body {
  margin: 0;
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.admin-migrate__foot {
  max-width: 62ch;
  line-height: 1.7;
  margin: 18px 0 14px;
}

/* ── 响应式 ────────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .post__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .toc {
    display: none;
  }
  .editor__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .editor__side {
    position: static;
  }
}

@media (max-width: 820px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    padding: 30px 24px;
    gap: 6px;
  }
  .hero__art {
    display: none;
  }
  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    position: static;
    padding-bottom: 4px;
  }
  .admin-form__grid {
    grid-template-columns: 1fr;
  }
  .post-nav {
    grid-template-columns: 1fr;
  }
  .post-nav__item--next {
    grid-column: 1;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 0 16px;
  }
  .site-header__inner {
    height: 58px;
    gap: 10px;
  }
  .brand__name {
    font-size: 15.5px;
  }
  .nav__link {
    padding: 6px 10px;
    font-size: 13.5px;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
  }
  .prose {
    font-size: 16.5px;
    line-height: 1.88;
  }
  .post-card {
    padding: 18px 18px;
  }
  .post-card__title {
    font-size: 19px;
  }
  .hero__stats {
    gap: 22px;
  }
  .hero__stat dd {
    font-size: 21px;
  }
  .comment-children {
    margin-left: 8px;
    padding-left: 10px;
  }
}

/* 打印：去掉一切装饰，只留正文 */
@media print {
  .site-header,
  .site-footer,
  .toc,
  .comments,
  .post-nav,
  .hero__art,
  .header-actions {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .post__layout {
    display: block;
  }
  .prose {
    font-size: 12pt;
  }
}
