:root {
  color-scheme: light dark;
  --bg: #f4f2ef;
  --bg-elevated: #fffcf7;
  --fg: #14120f;
  --muted: #5c5852;
  --accent: #0d5c63;
  --accent-hover: #0a4a50;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --border: rgba(20, 18, 15, 0.08);
  --shadow: 0 1px 2px rgba(20, 18, 15, 0.04), 0 12px 40px -16px rgba(20, 18, 15, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --content-max: 40rem;
  --prose-max: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0b0a;
    --bg-elevated: #161412;
    --fg: #f2ede6;
    --muted: #9a948b;
    --accent: #5eead4;
    --accent-hover: #7ff5e1;
    --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
    --border: rgba(242, 237, 230, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 16px 48px -20px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 100% 80% at 50% -30%, var(--accent-soft), transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 45%),
    radial-gradient(ellipse 50% 40% at 0% 20%, color-mix(in srgb, var(--fg) 4%, transparent), transparent 40%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: min(76rem, calc(100% - 2.4rem));
  margin: 0 auto;
  padding: 0.9rem 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--fg);
}

.brand__mark {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--fg)));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

.brand:hover .brand__mark {
  transform: scale(1.03);
  transition: transform 0.2s ease;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav__link {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.site-nav__link:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.site-nav__link--muted {
  color: var(--muted);
  font-weight: 400;
}

.site-nav__link--muted:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.site-main {
  max-width: min(76rem, calc(100% - 2.4rem));
  margin: 0 auto;
  padding: 2.25rem 1.35rem 4rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: color-mix(in srgb, var(--bg-elevated) 70%, var(--bg));
}

.site-footer__inner {
  max-width: min(76rem, calc(100% - 2.4rem));
  margin: 0 auto;
  padding: 2rem 1.35rem;
}

.site-footer__copy {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* —— 首页 —— */
.page-hero {
  margin-bottom: 2.25rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.page-hero__title {
  margin: 0 0 0.65rem;
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.post-list__item--empty .post-card--empty {
  text-align: center;
  color: var(--muted);
}

.post-card {
  position: relative;
  padding: 1.35rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.post-card:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  box-shadow:
    0 1px 2px rgba(20, 18, 15, 0.06),
    0 20px 50px -18px color-mix(in srgb, var(--accent) 22%, rgba(20, 18, 15, 0.15));
  transform: translateY(-2px);
}

.post-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.post-card__date {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.post-card__arrow {
  font-size: 1.1rem;
  color: var(--accent);
  opacity: 0.35;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.post-card:hover .post-card__arrow {
  opacity: 1;
  transform: translateX(3px);
}

.post-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.post-card__title a {
  color: inherit;
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size 0.2s ease;
}

.post-card__title a:hover {
  color: var(--accent);
  background-size: 0% 1px;
}

.post-card__excerpt {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.post-card__cta::after {
  content: "→";
  transition: transform 0.2s ease;
}

.post-card__cta:hover::after {
  transform: translateX(4px);
}

/* —— 文章页 —— */
.breadcrumb {
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.breadcrumb__sep {
  margin: 0 0.4rem;
  opacity: 0.45;
}

.breadcrumb__current {
  color: var(--fg);
  font-weight: 500;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  display: inline-block;
}

.post__header {
  margin-bottom: 2.25rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post__title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.post__meta {
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.post__meta time {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.post__lede {
  margin: 0;
  max-width: var(--prose-max);
  font-size: 1.1rem;
  color: var(--muted);
  line-height: 1.6;
}

.post-body {
  max-width: var(--prose-max);
}

.post__footer {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.post__back {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.post__back:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* —— 正文排版 —— */
.prose {
  font-size: 1.05rem;
}

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

.prose :where(h2) {
  margin-top: 2.25rem;
  margin-bottom: 0.65rem;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.prose :where(h3) {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-size: 1.12rem;
  font-weight: 700;
}

.prose :where(p, ul, ol) {
  margin: 0.85rem 0;
}

.prose :where(ul, ol) {
  padding-left: 1.35rem;
}

.prose :where(li) {
  margin: 0.35rem 0;
}

.prose :where(strong) {
  font-weight: 700;
  color: var(--fg);
}

.prose :where(a) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose :where(a):hover {
  color: var(--accent-hover);
}

.prose :where(blockquote) {
  margin: 1.25rem 0;
  padding: 0.65rem 0 0.65rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
  font-style: normal;
}

.prose :where(hr) {
  margin: 2rem 0;
  border: none;
  height: 1px;
  background: var(--border);
}

.prose :where(table) {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 1.25rem 0;
}

.prose :where(th, td) {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
}

.prose :where(th) {
  background: color-mix(in srgb, var(--fg) 5%, transparent);
  font-weight: 600;
}

.prose pre {
  overflow: auto;
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  background: color-mix(in srgb, var(--fg) 6%, var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* —— 首页双栏 + 分类 —— */
.layout-cols--index {
  display: grid;
  gap: 2.25rem;
  align-items: start;
}

@media (min-width: 960px) {
  .layout-cols--index {
    grid-template-columns: minmax(0, 1fr) 15.5rem;
    gap: 2.75rem;
  }
}

.aside-panel {
  position: relative;
  padding: 1.25rem 1.2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

@media (min-width: 960px) {
  .aside-panel--sticky {
    position: sticky;
    top: 5.25rem;
  }
}

.aside-panel__title {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.aside-panel__hint {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.aside-panel__hint code {
  font-size: 0.72rem;
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.aside-panel__decor {
  position: absolute;
  right: -2rem;
  bottom: -2.5rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 65%);
  opacity: 0.55;
  pointer-events: none;
}

.cat-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 1;
}

.cat-nav li + li {
  margin-top: 0.35rem;
}

.cat-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--fg);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.cat-nav__link:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.cat-nav__link--active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.cat-nav__count {
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 1.5rem;
  text-align: right;
}

.cat-nav__link--active .cat-nav__count {
  color: var(--accent);
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.cat-chip:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.cat-chip--sm {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}

.post-card__cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.page-hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.35rem;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-elevated));
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--fg) 4%, transparent);
}

.stat-pill__value {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.stat-pill__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.stat-pill--accent {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}

.stat-pill--accent .stat-pill__value {
  color: var(--fg);
}

.post__meta-sep {
  color: var(--muted);
  opacity: 0.5;
}

.post__cats-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* —— 动效（尊重系统减少动效） —— */
@keyframes fade-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hero-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.post-list__item--enter {
  animation: fade-rise 0.58s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(0.07s * (var(--stagger, 0) + 1));
}

.page-hero--animate .page-hero__title {
  animation: hero-pop 0.6s ease backwards;
}

.page-hero--animate .page-hero__stats {
  animation: hero-pop 0.6s 0.08s ease backwards;
}

.breadcrumb--enter {
  animation: fade-rise 0.45s ease backwards;
}

.post--enter .post__header {
  animation: fade-rise 0.52s 0.04s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.prose--enter {
  animation: fade-rise 0.55s 0.1s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .post-list__item--enter,
  .page-hero--animate .page-hero__title,
  .page-hero--animate .page-hero__stats,
  .breadcrumb--enter,
  .post--enter .post__header,
  .prose--enter {
    animation: none !important;
  }

  .cat-chip:hover,
  .cat-nav__link:hover {
    transform: none;
  }
}

@media (max-width: 520px) {
  .site-header__inner { padding-inline: 1rem; }
  .site-main { padding-inline: 1rem; }
  .post-card { padding: 1.15rem 1.2rem; }
  .breadcrumb__current { max-width: 9rem; }
}
