:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #fafaf7;
  --text: #222222;
  --muted: #666666;
  --line: #e5e5e0;
  --link: #3377aa;
  --link-hover-bg: #3377aa;
  --link-hover-text: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.08);
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"]:root {
  --bg: #111418;
  --surface: #181c21;
  --surface-muted: #1f252c;
  --text: #e7ebef;
  --muted: #a7b0ba;
  --line: #303844;
  --link: #8fb9de;
  --link-hover-bg: #8fb9de;
  --link-hover-text: #0f1418;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.85;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.zh-shell {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
}

.zh-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.zh-header-shell {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.zh-brand {
  color: var(--muted);
  font-size: clamp(1.32rem, 2.4vw, 1.58rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  line-height: 1;
}

.zh-brand:hover,
.zh-brand:focus,
.zh-brand:active {
  text-decoration: none;
}

.zh-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.zh-nav a {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.2rem 0;
  text-decoration: none;
}

.zh-nav a[aria-current="page"] {
  color: var(--muted);
  font-weight: 500;
}

.zh-nav a:hover {
  text-decoration: none;
}

.zh-header-actions {
  display: flex;
  align-items: center;
}

.zh-theme-toggle,
.zh-lang-toggle {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zh-theme-toggle {
  cursor: pointer;
  padding: 0;
}

.zh-lang-toggle {
  text-decoration: none;
}

.zh-theme-toggle svg,
.zh-lang-toggle svg {
  width: 1.08rem;
  height: 1.08rem;
  fill: currentColor;
  display: block;
}

.zh-theme-toggle:hover,
.zh-lang-toggle:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--line), var(--link) 30%);
  background: var(--surface-muted);
  text-decoration: none;
}

.zh-theme-toggle .theme-icon {
  display: none;
}

html[data-theme="dark"] .zh-theme-toggle .theme-sun {
  display: block;
}

html[data-theme="dark"] .zh-theme-toggle .theme-moon {
  display: none;
}

html:not([data-theme="dark"]) .zh-theme-toggle .theme-moon {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.zh-main {
  padding-block: 1.4rem 2.2rem;
}

.zh-headline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.zh-headline-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem 1rem;
  padding: 0.92rem 1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.zh-headline-item.click-card {
  cursor: pointer;
}

.zh-headline-item:hover {
  background: var(--surface-muted);
  border-color: color-mix(in srgb, var(--line), var(--link) 24%);
  box-shadow: var(--shadow);
}

.zh-headline-main,
.zh-headline-date {
  position: relative;
  z-index: 1;
}

.zh-headline-main {
  min-width: 0;
}

.zh-headline-link {
  display: inline;
  color: var(--link);
  font-size: clamp(1.02rem, 2.05vw, 1.16rem);
  line-height: 1.5;
  padding: 0 0.14em;
  border-radius: 2px;
  transition: color 180ms ease;
}

.zh-headline-content {
  margin-top: 0.45rem;
  color: var(--muted);
}

.zh-headline-content p {
  margin: 0.74rem 0 0;
}

.zh-headline-content p:first-child {
  margin-top: 0;
}

.zh-headline-ellipsis {
  margin-top: 0.24rem;
  color: var(--muted);
}

.zh-headline-date {
  align-self: start;
  padding-top: 0.16rem;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.click-card .card-link {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 4px;
}

.zh-archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.2rem;
  align-items: start;
}

.zh-archive-main,
.zh-archive-side {
  min-width: 0;
}

.zh-archive-side .zh-calendar-section {
  position: sticky;
  top: 1rem;
}

.zh-archive-item .zh-headline-link {
  font-size: clamp(0.99rem, 1.9vw, 1.08rem);
}

.zh-calendar-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.9rem;
}

.zh-calendar-controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.62rem;
}

.zh-calendar-control {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.zh-calendar-control span {
  white-space: nowrap;
}

.zh-calendar-select {
  min-height: 1.9rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  padding: 0 0.45rem;
  font-size: 0.82rem;
}

.zh-calendar-months {
  display: grid;
  gap: 0.62rem;
}

.zh-calendar-month {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-muted);
  padding: 0.62rem;
}

.zh-calendar-month h2 {
  margin: 0 0 0.38rem;
  font-size: 0.96rem;
  color: var(--text);
}

.zh-calendar-month[hidden] {
  display: none;
}

.zh-calendar-weekdays,
.zh-calendar-days {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.2rem;
}

.zh-calendar-weekdays {
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.67rem;
}

.zh-calendar-weekdays li {
  text-align: center;
}

.zh-calendar-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 1.62rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
}

.zh-calendar-day.has-post {
  background: color-mix(in srgb, var(--link) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--line), var(--link) 32%);
  color: var(--link);
}

.zh-calendar-day.has-post:hover {
  background: var(--link-hover-bg);
  border-color: var(--link-hover-bg);
  color: var(--link-hover-text);
  text-decoration: none;
}

.zh-calendar-day.is-empty {
  border: 0;
  background: transparent;
}

.zh-pagination-nav {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.zh-pagination-status {
  flex: 1;
  text-align: center;
}

.zh-page-link {
  min-width: 4.6rem;
  min-height: 1.95rem;
  padding: 0.2rem 0.68rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.zh-page-link:hover {
  color: var(--link-hover-text);
  background: var(--link-hover-bg);
  border-color: var(--link-hover-bg);
  text-decoration: none;
}

.zh-page-link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.zh-post-single {
  max-width: min(760px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.35rem 1.45rem;
  box-shadow: var(--shadow);
}

.zh-post-header {
  margin-bottom: 1rem;
}

.zh-post-header h1 {
  margin: 0;
  color: var(--text);
  line-height: 1.35;
  font-size: clamp(1.52rem, 2.6vw, 1.95rem);
}

.zh-post-date {
  margin: 0.22rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.zh-post-content {
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.9;
}

.zh-post-content p,
.zh-post-content li {
  margin-top: 1.02rem;
  margin-bottom: 0;
}

.zh-post-content p:first-child {
  margin-top: 0;
}

.zh-post-content h2,
.zh-post-content h3 {
  margin-top: 1.6rem;
  margin-bottom: 0.48rem;
  line-height: 1.35;
}

.zh-post-content blockquote {
  margin: 1rem 0 0;
  padding: 0.06rem 0 0.06rem 0.85rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.zh-post-content code,
.zh-headline-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--surface), var(--link) 9%);
  border: 1px solid color-mix(in srgb, var(--line), var(--link) 18%);
  border-radius: 4px;
  padding: 0.1em 0.32em;
}

.zh-post-content pre,
.zh-headline-content pre {
  margin: 1rem 0 0;
  padding: 0.7rem 0.78rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  overflow-x: auto;
}

.zh-post-content pre code,
.zh-headline-content pre code {
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.zh-post-content ul,
.zh-post-content ol {
  padding-left: 1.25rem;
}

.zh-post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.zh-post-content a,
.zh-headline-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.zh-post-content a:hover,
.zh-headline-content a:hover {
  color: var(--link-hover-text);
  background: var(--link-hover-bg);
  text-decoration: none;
}

.zh-post-content .katex-display,
.zh-headline-content .katex-display {
  display: block;
  overflow-x: visible;
  overflow-y: visible;
  padding: 0.28rem 0;
}

.katex,
.katex * {
  box-sizing: content-box;
}

.katex *::before,
.katex *::after {
  box-sizing: content-box;
}

.zh-post-content .mermaid,
.zh-headline-content .mermaid {
  margin-top: 0.86rem;
  margin-bottom: 0.32rem;
  overflow-x: auto;
  text-align: center;
}

.zh-post-content .mermaid svg,
.zh-headline-content .mermaid svg {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.zh-post-nav {
  margin-top: 1.35rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.66rem;
}

.zh-post-nav-link {
  min-height: 3.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  padding: 0.58rem 0.7rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
  text-decoration: none;
  color: var(--text);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.zh-post-nav-link:hover {
  background: color-mix(in srgb, var(--surface-muted), var(--link) 12%);
  border-color: color-mix(in srgb, var(--line), var(--link) 34%);
  text-decoration: none;
}

.zh-post-nav-link.is-older {
  align-items: flex-end;
  text-align: right;
}

.zh-post-nav-link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.zh-post-nav-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.zh-post-nav-title {
  font-size: 0.93rem;
  line-height: 1.45;
}

.zh-lang-toggle:focus-visible,
.zh-theme-toggle:focus-visible,
.zh-page-link:focus-visible,
.zh-post-nav-link:focus-visible,
.zh-calendar-day.has-post:focus-visible,
.click-card .card-link:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 4px;
}

.zh-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.zh-footer-shell {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

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

  .zh-archive-side {
    order: 2;
  }

  .zh-archive-side .zh-calendar-section {
    position: static;
  }
}

@media (max-width: 760px) {
  .zh-header-shell {
    min-height: 60px;
    gap: 0.58rem;
    flex-wrap: nowrap;
    padding-block: 0.45rem;
  }

  .zh-brand {
    font-size: 1.34rem;
  }

  .zh-nav {
    margin-left: auto;
    margin-right: 0.42rem;
  }

  .zh-main {
    padding-top: 1.05rem;
  }

  .zh-headline-item {
    grid-template-columns: 1fr;
    gap: 0.52rem;
    padding: 0.82rem 0.86rem;
  }

  .zh-headline-date {
    white-space: normal;
    padding-top: 0;
  }

  .zh-pagination-nav {
    flex-wrap: wrap;
  }

  .zh-pagination-status {
    order: 3;
    width: 100%;
    text-align: left;
  }

  .zh-calendar-controls {
    justify-content: flex-start;
  }

  .zh-post-single {
    padding: 1.1rem 1rem;
  }

  .zh-post-nav {
    grid-template-columns: 1fr;
  }

  .zh-post-nav-link.is-older {
    align-items: flex-start;
    text-align: left;
  }
}

@media (max-width: 900px) {
  .zh-post-content .katex-display,
  .zh-headline-content .katex-display {
    overflow-x: auto;
    padding: 0.28rem 0.04rem 0.44rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zh-headline-item,
  .zh-theme-toggle,
  .zh-lang-toggle,
  .zh-page-link,
  .zh-post-nav-link,
  .zh-calendar-day.has-post,
  .zh-headline-link {
    transition: none;
  }
}
