:root {
  --bg: #fbf8ff;
  --bg-2: #f4edff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-soft: #f5efff;
  --text: #2d2438;
  --heading: #21182d;
  --muted: #776a86;
  --line: #e6daf3;
  --accent: #9d68d8;
  --accent-strong: #7542b7;
  --accent-soft: #efe2ff;
  --accent-faint: rgba(157, 104, 216, 0.12);
  --rose: #d870a9;
  --code-bg: #292238;
  --code-line: #3b314d;
  --code-text: #eee8f7;
  --lightbox-backdrop: rgba(246, 238, 255, 0.84);
  --lightbox-panel: rgba(255, 255, 255, 0.78);
  --shadow: 0 18px 48px rgba(83, 48, 124, 0.12);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #14111b;
  --bg-2: #1d1629;
  --surface: rgba(31, 25, 42, 0.88);
  --surface-solid: #211a2d;
  --surface-soft: #2a2138;
  --text: #eee9f5;
  --heading: #fff9ff;
  --muted: #b8aacb;
  --line: #40334f;
  --accent: #c59aff;
  --accent-strong: #d8bcff;
  --accent-soft: #3a2852;
  --accent-faint: rgba(197, 154, 255, 0.15);
  --rose: #f0a2cf;
  --code-bg: #17121f;
  --code-line: #332842;
  --code-text: #f1ecf8;
  --lightbox-backdrop: rgba(23, 16, 34, 0.84);
  --lightbox-panel: rgba(38, 28, 52, 0.82);
  --shadow: 0 20px 60px rgba(4, 2, 9, 0.36);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 8%, rgba(216, 112, 169, 0.16), transparent 28rem),
    radial-gradient(circle at 86% 16%, rgba(157, 104, 216, 0.18), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.75;
}

body::selection {
  background: var(--accent-soft);
  color: var(--heading);
}

body.lightbox-open {
  overflow: hidden;
}

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

img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}

.site-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--surface-solid), var(--accent-soft));
  color: var(--accent-strong);
  font-family: "Noto Serif SC", serif;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(117, 66, 183, 0.14);
}

.site-title {
  display: block;
  color: var(--heading);
  font-family: "Noto Serif SC", serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.site-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.site-nav a,
.theme-toggle {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
}

.site-nav a {
  padding: 7px 13px;
}

.theme-toggle {
  display: inline-grid;
  width: 38px;
  place-items: center;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.theme-toggle-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-faint);
}

:root[data-theme="dark"] .theme-toggle-icon {
  background: transparent;
  box-shadow: inset -5px -3px 0 0 var(--accent-strong), 0 0 0 4px var(--accent-faint);
}

.site-nav a:hover,
.theme-toggle:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--accent-strong);
}

.site-main {
  padding: 18px 0 52px;
}

.hero {
  margin: 24px 0 30px;
  padding: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--surface), var(--accent-soft)),
    repeating-linear-gradient(90deg, var(--accent-faint) 0 1px, transparent 1px 34px);
  box-shadow: var(--shadow);
}

.hero-kicker,
.page-title p {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1,
.page-title h1,
.article-header h1 {
  margin: 0;
  color: var(--heading);
  font-family: "Noto Serif SC", serif;
  font-weight: 700;
  line-height: 1.2;
}

.hero h1 {
  font-size: 44px;
}

.hero p:last-child {
  max-width: 640px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 820px);
  justify-content: center;
  gap: 28px;
  align-items: start;
}

.post-list {
  display: grid;
  width: 100%;
  gap: 18px;
}

.post-list.narrow {
  max-width: 820px;
  margin: 0 auto;
}

.post-card,
.article-page,
.side-panel,
.taxonomy-card,
.archive-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.post-card {
  position: relative;
  padding: 28px;
  overflow: hidden;
}

.post-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--rose));
}

.post-card-head,
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--rose);
}

.category-link,
.article-meta a {
  color: var(--accent-strong);
  font-weight: 600;
}

.post-card-title {
  margin: 10px 0 14px;
  font-family: "Noto Serif SC", serif;
  font-size: 26px;
  line-height: 1.35;
}

.post-card-title a:hover,
.archive-item a:hover {
  color: var(--accent-strong);
}

.post-card-excerpt {
  color: var(--text);
}

.post-card-excerpt > :first-child,
.markdown-body > :first-child {
  margin-top: 0;
}

.post-card-excerpt > :last-child,
.markdown-body > :last-child {
  margin-bottom: 0;
}

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

.tag-list {
  margin-top: 18px;
}

.tag-list a,
.tag-cloud a,
.pill-list a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
}

.tag-list a:hover,
.tag-cloud a:hover,
.pill-list a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pill-list a {
  justify-content: space-between;
  width: 100%;
}

.pill-list span {
  color: var(--muted);
}

.read-more {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-top: 20px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.read-more:hover {
  background: var(--rose);
}

.sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 18px;
}

.side-panel {
  padding: 22px;
}

.side-panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.page-title {
  max-width: 820px;
  margin: 24px auto 28px;
}

.page-title h1 {
  font-size: 36px;
}

.article-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 880px);
  justify-content: center;
  align-items: start;
  gap: 28px;
  margin-top: 24px;
}

.article-layout.no-toc {
  grid-template-columns: minmax(0, 880px);
}

.article-page {
  width: 100%;
  max-width: 880px;
  margin: 0;
  padding: 42px;
}

.article-toc {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.article-toc-inner {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(83, 48, 124, 0.09);
  backdrop-filter: blur(14px);
}

.article-toc p {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.article-toc nav {
  display: grid;
  gap: 4px;
}

.article-toc a {
  display: block;
  padding: 6px 8px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.article-toc a:hover {
  border-left-color: var(--accent);
  background: var(--accent-faint);
  color: var(--accent-strong);
}

.article-toc a.is-active {
  border-left-color: var(--rose);
  background: linear-gradient(90deg, var(--accent-faint), transparent);
  color: var(--accent-strong);
  font-weight: 700;
}

.article-toc .toc-level-3 {
  padding-left: 20px;
}

.article-toc .toc-level-4 {
  padding-left: 32px;
  font-size: 12px;
}

.article-header {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.article-header.compact {
  margin-bottom: 22px;
}

.article-header h1 {
  margin-top: 10px;
  font-size: 38px;
}

.markdown-body {
  max-width: 760px;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.article-page .markdown-body {
  margin-right: auto;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  scroll-margin-top: 96px;
  margin: 1.7em 0 0.65em;
  color: var(--heading);
  font-family: "Noto Serif SC", serif;
  line-height: 1.35;
}

.markdown-body h1 {
  font-size: 30px;
}

.markdown-body h2 {
  position: relative;
  padding-left: 14px;
  border-bottom: 0;
  font-size: 24px;
}

.markdown-body h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.28em;
  width: 4px;
  height: 1.05em;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--rose));
}

.markdown-body h3 {
  font-size: 20px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body figure,
.markdown-body table {
  margin: 1em 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.35em;
}

.markdown-body li + li {
  margin-top: 0.38em;
}

.markdown-body li::marker {
  color: var(--accent-strong);
  font-weight: 700;
}

.markdown-body a {
  color: var(--accent-strong);
  border-bottom: 1px solid rgba(157, 104, 216, 0.35);
}

.markdown-body blockquote {
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface-soft);
  color: var(--muted);
}

.markdown-body code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-body img.is-lightboxable {
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.markdown-body img.is-lightboxable:hover {
  box-shadow: 0 16px 36px rgba(83, 48, 124, 0.16);
  transform: translateY(-2px);
}

.markdown-body img.is-lightboxable:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 64px 28px 34px;
  background:
    radial-gradient(circle at 18% 12%, rgba(216, 112, 169, 0.2), transparent 24rem),
    var(--lightbox-backdrop);
  backdrop-filter: blur(18px);
}

.image-lightbox.is-open {
  display: grid;
}

.image-lightbox figure {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: min(1180px, 94vw);
  margin: 0;
}

.image-lightbox-img {
  max-width: min(1180px, 94vw);
  max-height: 82vh;
  border-radius: 8px;
  background: var(--lightbox-panel);
  box-shadow: 0 28px 80px rgba(48, 29, 74, 0.24);
  cursor: zoom-out;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  user-select: none;
  touch-action: none;
}

.image-lightbox.is-zoomed .image-lightbox-img {
  cursor: zoom-out;
}

.image-lightbox-caption {
  max-width: min(760px, 88vw);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--lightbox-panel);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.image-lightbox-close {
  position: fixed;
  top: 22px;
  right: 22px;
  min-width: 48px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--lightbox-panel);
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(83, 48, 124, 0.12);
}

.image-lightbox-close:hover,
.image-lightbox-close:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.markdown-body pre,
.markdown-body figure.highlight {
  overflow-x: auto;
  padding: 16px;
  border: 0;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  box-shadow: inset 0 0 0 1px var(--code-line);
}

.markdown-body pre code,
.markdown-body figure.highlight code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1.75;
}

.markdown-body figure.highlight table,
.markdown-body figure.highlight tbody,
.markdown-body figure.highlight tr,
.markdown-body figure.highlight td {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.markdown-body figure.highlight .gutter {
  display: none;
}

.markdown-body figure.highlight .code,
.markdown-body figure.highlight .line,
.markdown-body figure.highlight pre {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.markdown-body figure.highlight figcaption {
  margin: -2px 0 10px;
  color: #bcaee0;
  font-size: 13px;
}

.markdown-body .comment,
.markdown-body .quote {
  color: #a99abb;
  font-style: italic;
}

.markdown-body .keyword,
.markdown-body .selector-tag,
.markdown-body .subst {
  color: #d8a8ff;
}

.markdown-body .number,
.markdown-body .literal,
.markdown-body .variable,
.markdown-body .template-variable,
.markdown-body .attr,
.markdown-body .tag .attr {
  color: #ffb86c;
}

.markdown-body .string,
.markdown-body .doctag {
  color: #b9f18d;
}

.markdown-body .title,
.markdown-body .section,
.markdown-body .selector-id {
  color: #8fd3ff;
}

.markdown-body .type,
.markdown-body .class .title {
  color: #ffd479;
}

.markdown-body .tag,
.markdown-body .name,
.markdown-body .attribute {
  color: #ff9ccc;
}

.markdown-body .regexp,
.markdown-body .link {
  color: #9ee6d8;
}

.markdown-body .punctuation,
.markdown-body .operator {
  color: #d6c9e8;
}

.markdown-body .property,
.markdown-body .params {
  color: #f1ecf8;
}

.markdown-body .symbol,
.markdown-body .bullet {
  color: #c9a7ff;
}

.markdown-body .built_in,
.markdown-body .builtin-name {
  color: #8fd3ff;
}

.markdown-body .meta {
  color: #c9a7ff;
}

.markdown-body .deletion {
  color: #ff8c9a;
}

.markdown-body .addition {
  color: #b9f18d;
}

.markdown-body > table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.markdown-body th {
  background: var(--surface-soft);
}

.archive-list {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px;
}

.archive-list h2 {
  margin: 10px 0 12px;
  color: var(--accent-strong);
  font-family: "Noto Serif SC", serif;
}

.archive-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.archive-item time {
  color: var(--muted);
  font-size: 14px;
}

.archive-item a {
  font-weight: 700;
}

.taxonomy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.taxonomy-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 92px;
  padding: 22px;
}

.taxonomy-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.taxonomy-card strong {
  font-size: 20px;
}

.taxonomy-card span {
  color: var(--muted);
  font-size: 14px;
}

.tag-card strong {
  color: var(--accent-strong);
}

.pagination {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.pagination .page-number,
.pagination .extend,
.pagination .space {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  margin: 0 4px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--muted);
  font-weight: 700;
}

.pagination .current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 860px) {
  .site-shell {
    width: min(100% - 28px, 1180px);
  }

  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .hero {
    padding: 32px 24px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .article-layout,
  .article-layout.no-toc {
    display: block;
    margin-top: 16px;
  }

  .article-toc {
    display: none;
  }

  .article-page {
    margin: 0 auto;
    padding: 28px 22px;
  }

  .article-header h1,
  .page-title h1 {
    font-size: 30px;
  }
}

@media (max-width: 540px) {
  .brand {
    align-items: flex-start;
  }

  .site-nav a {
    padding-inline: 10px;
  }

  .hero {
    margin-top: 10px;
  }

  .post-card {
    padding: 24px 20px;
  }

  .post-card-title {
    font-size: 23px;
  }

  .article-page {
    padding: 24px 18px;
  }

  .archive-item {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .taxonomy-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .image-lightbox {
    padding: 58px 14px 24px;
  }

  .image-lightbox-img {
    max-width: 94vw;
    max-height: 78vh;
  }

  .image-lightbox-close {
    top: 14px;
    right: 14px;
  }
}
