:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f1fa;
  --ink: #111113;
  --muted: #66646c;
  --line: #e7dff0;
  --accent: #58427d;
  --accent-2: #9a5f42;
  --focus: #4f63c6;
  --shadow: 0 8px 24px rgb(88 66 125 / 8%);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: var(--font-sans);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

html {
  scroll-behavior: smooth;
}

a {
  color: inherit;
}

input {
  font: inherit;
}

a:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 70%);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(220px, 320px);
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 0 max(32px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(14px);
}

.brand,
.site-nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.94rem;
  font-weight: 700;
}

.site-nav {
  justify-content: flex-end;
  gap: 4px;
}

.site-nav a {
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.site-nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-search {
  position: relative;
  min-width: 0;
}

.site-search label {
  display: block;
}

.site-search input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
}

.site-search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  width: min(380px, calc(100vw - 32px));
  max-height: min(420px, calc(100vh - 96px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px;
  box-shadow: var(--shadow);
}

.site-search-results[hidden] {
  display: none;
}

.site-search-result {
  display: grid;
  gap: 3px;
  border-radius: 6px;
  padding: 11px 12px;
  text-decoration: none;
}

.site-search-result:hover,
.site-search-result:focus-visible,
.site-search-result[aria-selected="true"] {
  background: var(--surface-2);
}

.site-search-result span {
  font-weight: 700;
}

.site-search-result small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-search-message {
  margin: 0;
  padding: 12px;
  color: var(--muted);
}

.page-shell {
  width: min(100% - 64px, 1240px);
  margin: 0 auto;
  padding: 48px 0 88px;
}

.intro {
  padding: 0 0 32px;
  border-bottom: 1px solid var(--line);
}

.profile-intro {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 64px;
}

.profile-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 200px;
  height: 200px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--ink);
  color: white;
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
}

.profile-copy {
  min-width: 0;
  max-width: 780px;
  padding-top: 6px;
}

.profile-bio {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.profile-links a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  padding: 5px 10px;
  text-decoration: none;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.profile-actions:first-child {
  margin-top: 0;
}

.profile-actions a {
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  padding: 7px 12px;
  text-decoration: none;
}

.eyebrow,
.post-date {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
}

.intro h1,
.post-header h1 {
  max-width: 920px;
  margin: 0;
  font-size: 2.35rem;
  line-height: 1.12;
  letter-spacing: 0;
}

.intro p:last-child {
  max-width: 820px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.post-list {
  display: grid;
  gap: 0;
  padding-top: 18px;
}

.post-card,
.tag-link,
.search-result {
  background: transparent;
}

.post-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  border-bottom: 1px dashed var(--line);
  padding: 18px 0;
}

.post-card:first-child {
  padding-top: 0;
}

.post-card h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.32;
  letter-spacing: 0;
}

.post-card h2 a {
  text-decoration: none;
}

.post-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.collection-header {
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.collection-header h1 {
  max-width: 920px;
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.collection-header p:last-child {
  max-width: 820px;
  margin: 16px 0 0;
  color: var(--muted);
}

.tag-cloud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding-top: 24px;
}

.tag-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tag-link strong {
  display: grid;
  place-items: center;
  min-width: 32px;
  min-height: 32px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
}

.archive-list {
  display: grid;
  gap: 26px;
  padding-top: 24px;
}

.archive-year {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.archive-year:first-child {
  border-top: 0;
  padding-top: 0;
}

.archive-year h2 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0;
}

.archive-year ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-year li {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
}

.archive-year time {
  color: var(--muted);
}

.archive-year a {
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
}

.archive-year a:hover,
.archive-year a:focus-visible {
  background: var(--surface-2);
  color: var(--accent);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 6px;
}

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

.post-page {
  display: grid;
  gap: 36px;
}

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 900px) 240px;
  align-items: start;
  gap: 48px;
}

.post {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 40px;
}

.post-header {
  display: grid;
  gap: 12px;
  margin-bottom: 34px;
}

.post-body {
  max-width: 900px;
  font-size: 1.08rem;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  scroll-margin-top: 92px;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  margin: 2rem 0 0.7rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.post-body h2 {
  font-size: 1.65rem;
}

.post-body h3 {
  font-size: 1.35rem;
}

.post-body h4 {
  font-size: 1.12rem;
}

.post-body p,
.post-body ul,
.post-body ol {
  margin: 0.9rem 0;
}

.post-body code,
.empty-state code {
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.93em;
  padding: 0.12em 0.28em;
}

.code-fold,
.math-fold {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin: 1rem 0;
  overflow: hidden;
}

.code-fold summary,
.math-fold summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 8px 12px;
  user-select: none;
}

.code-fold[open] summary,
.math-fold[open] summary {
  border-bottom-color: var(--line);
}

.code-fold-label,
.math-fold-label {
  color: var(--accent);
  font-weight: 700;
}

.code-fold pre {
  margin: 0;
  overflow-x: auto;
  background: var(--surface);
  padding: 14px 16px;
}

.code-fold code {
  background: transparent;
  border-radius: 0;
  display: block;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0;
  tab-size: 2;
}

.math-fold-body {
  overflow-x: auto;
  padding: 14px 16px;
}

.math-fold math {
  min-width: max-content;
}

.post-toc {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  border-left: 1px solid var(--line);
  padding-left: 16px;
  font-size: 0.88rem;
}

.post-toc-title {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.post-toc nav {
  display: grid;
  gap: 2px;
}

.post-toc-link {
  display: block;
  border-radius: 4px;
  color: var(--muted);
  line-height: 1.35;
  padding: 4px 6px;
  text-decoration: none;
}

.post-toc-level-3 {
  margin-left: 12px;
}

.post-toc-level-4 {
  margin-left: 24px;
}

.post-toc-link:hover,
.post-toc-link:focus-visible,
.post-toc-link[aria-current="true"] {
  background: var(--surface-2);
  color: var(--accent);
}

.post-toc-link[aria-current="true"] {
  font-weight: 700;
}

.post-pagination {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.post-pagination a {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  background: transparent;
  padding: 14px 0;
  text-decoration: none;
}

.post-pagination span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-box {
  display: grid;
  gap: 18px;
  padding-top: 24px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
}

.search-results {
  display: grid;
  gap: 0;
}

.search-result {
  display: grid;
  gap: 8px;
  border-bottom: 1px dashed var(--line);
  padding: 16px 0;
}

.search-result:first-child {
  padding-top: 0;
}

.search-result h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.search-result h2 a {
  text-decoration: none;
}

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

.comments {
  display: grid;
  gap: 14px;
  padding-top: 4px;
}

.comments .giscus,
.comments iframe {
  width: 100%;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-title h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 16px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .post-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .post-toc {
    order: -1;
    position: static;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }
}

@media (max-width: 760px) {
  .site-header {
    position: static;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
    padding: 14px 20px;
  }

  .site-nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .site-search {
    width: 100%;
  }

  .site-search-results {
    left: 0;
    right: auto;
    width: 100%;
  }

  .page-shell {
    width: min(100% - 28px, 1240px);
    padding-top: 28px;
  }

  .intro h1,
  .post-header h1 {
    font-size: 2.2rem;
    line-height: 1.1;
  }

  .collection-header h1 {
    font-size: 2rem;
    line-height: 1.1;
  }

  .profile-intro {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 22px;
  }

  .profile-avatar {
    width: 128px;
    height: 128px;
  }

  .profile-avatar-fallback {
    font-size: 2.75rem;
  }

  .profile-copy {
    padding-top: 0;
  }

  .post-card,
  .archive-year,
  .archive-year li,
  .post-pagination {
    grid-template-columns: 1fr;
  }

  .section-title {
    align-items: start;
    flex-direction: column;
  }
}
