:root {
  --brand-primary: #0b1c7e;
  --brand-hover: #183ca8;
  --brand-on-primary: #ffffff;
  --brand-surface: #eef2ff;
  --brand-border: #ccd8f3;
  --page-background: #f4f6fc;
  --page-background-end: #edf2fb;
  --surface: #ffffff;
  --surface-muted: #f6f8fd;
  --surface-raised: #fbfcff;
  --text-main: #34415f;
  --text-strong: #142650;
  --text-muted: #65718c;
  --text-subtle: #68768a;
  --border-color: #dce3f1;
  --border-strong: #c5d1e6;
  --shadow-soft: 0 12px 34px rgba(20, 43, 104, 0.08);
  --shadow-hover: 0 18px 40px rgba(20, 43, 104, 0.14);
  --radius-small: 10px;
  --radius-medium: 16px;
  --radius-large: 22px;
  --content-width: 1080px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC",
    "Microsoft YaHei", sans-serif;
  --font-reading: "Songti SC", STSong, "Noto Serif CJK SC",
    "Source Han Serif SC", Georgia, serif;
  --font-size-xs: 0.8125rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-reading: clamp(1.03rem, 1rem + 0.16vw, 1.1rem);
  --font-size-card-title: clamp(1rem, 0.97rem + 0.24vw, 1.125rem);
  --font-size-page-title: clamp(1.625rem, 2.2vw, 2rem);
  --line-height-tight: 1.25;
  --line-height-ui: 1.65;
  --line-height-reading: 1.85;
  --interaction-duration: 0.2s;
  --focus-ring: 2px solid var(--brand-primary);
}

html.dark-theme {
  --brand-primary: #b5c3ff;
  --brand-hover: #d3dcff;
  --brand-on-primary: #101625;
  --brand-surface: #202b4b;
  --brand-border: #3b4d7b;
  --page-background: #0d1321;
  --page-background-end: #111a2c;
  --surface: #171f31;
  --surface-muted: #1d2840;
  --surface-raised: #222e49;
  --text-main: #d8e0f2;
  --text-strong: #f0f3ff;
  --text-muted: #aeb9d0;
  --text-subtle: #97a4bd;
  --border-color: #2d3b59;
  --border-strong: #435376;
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.26);
  --shadow-hover: 0 18px 42px rgba(0, 0, 0, 0.38);
  --focus-ring: 2px solid #c4ceff;
}

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

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

body {
  min-width: 0;
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-ui);
  font-kerning: normal;
  color: var(--text-main);
  background: linear-gradient(
    180deg,
    var(--page-background) 0%,
    var(--page-background-end) 100%
  );
  overflow-x: clip;
  transition: color var(--interaction-duration) ease,
    background-color var(--interaction-duration) ease;
}

img {
  max-width: 100%;
  height: auto;
}

a,
button {
  transition: color var(--interaction-duration) ease,
    background-color var(--interaction-duration) ease,
    border-color var(--interaction-duration) ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

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

.site-shell-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-shell-brand {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-primary);
  text-decoration: none;
}

.site-shell-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

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

.site-shell-nav a {
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: 999px;
}

.site-shell-nav a:hover {
  color: var(--brand-primary);
  background: var(--brand-surface);
}

.site-shell-nav a.active {
  color: var(--brand-on-primary);
  background: var(--brand-primary);
}

.site-theme-toggle {
  position: relative;
  flex: 0 0 auto;
}

.site-theme-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.site-theme-toggle label {
  width: 46px;
  height: 28px;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-muted);
  cursor: pointer;
  user-select: none;
}

.site-theme-toggle label::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transition: transform 0.25s ease;
}

.site-theme-toggle input:checked + label::after {
  transform: translateX(18px);
}

.site-theme-toggle input:focus-visible + label {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.site-theme-sun,
.site-theme-moon {
  position: relative;
  z-index: 1;
  font-size: 12px;
  line-height: 1;
}

.site-shell-footer {
  margin-top: 40px;
  border-top: 1px solid var(--brand-border);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.6;
  text-align: center;
  padding: 24px 16px;
}

body > main:not(#main-content) {
  width: calc(100% - 32px);
  max-width: var(--content-width);
  margin: 32px auto;
  padding: clamp(22px, 4vw, 40px);
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft);
}

.section-title {
  margin: 0 0 clamp(22px, 4vw, 36px);
  text-align: center;
  line-height: var(--line-height-tight);
  color: var(--brand-primary);
  font-size: var(--font-size-page-title);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.archive-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.archive-section {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  padding: 20px;
}

.archive-subtitle {
  color: var(--text-muted);
  margin-top: 8px;
  max-width: 62ch;
  line-height: 1.7;
}

.archive-title {
  margin: 0;
  color: var(--brand-primary);
  font-size: var(--font-size-page-title);
  font-weight: 600;
  line-height: var(--line-height-tight);
  letter-spacing: -0.01em;
}

.archive-filter {
  margin: 14px 0 20px;
}

.archive-filter select {
  color: var(--text-main);
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: var(--font-size-sm);
}

.timeline-month {
  border-left: 2px solid var(--brand-border);
  padding-left: 14px;
  margin-bottom: 18px;
}

.timeline-month h2 {
  font-size: 1rem;
  margin: 0 0 10px;
}

.timeline-month ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-month li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-color);
}

.timeline-type {
  font-size: var(--font-size-xs);
  color: var(--brand-primary);
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--brand-surface);
  align-self: start;
}

.timeline-month li a {
  color: var(--text-strong);
  text-decoration: none;
}

.timeline-month li a:hover {
  color: var(--brand-primary);
}

.timeline-date {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.timeline-tags {
  grid-column: 2 / -1;
  color: var(--text-subtle);
  font-size: var(--font-size-xs);
}

.archive-empty {
  color: var(--text-muted);
  margin: 8px 0;
}

.content-error,
.content-loading {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 12px;
}

.blog-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 16px;
}

.blog-filter-bar .filter-title {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.filter-chip {
  min-height: 34px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-main);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.filter-chip.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-on-primary);
}

.content-hidden {
  display: none !important;
}

.podcast-toggle-button {
  margin-top: 12px;
  min-height: 40px;
  border: 1px solid var(--brand-primary);
  background: transparent;
  color: var(--brand-primary);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

.scroll-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 999px;
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 30;
}

.scroll-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 25, 0.86);
  z-index: 200;
  padding: 28px;
}

.image-modal.open {
  display: flex;
}

.image-modal-content {
  max-width: min(960px, 92vw);
  max-height: 78vh;
  border-radius: 12px;
  object-fit: contain;
}

.image-modal-caption {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
}

.image-modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.image-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.image-modal-nav.prev {
  left: 18px;
}

.image-modal-nav.next {
  right: 18px;
}

body.modal-open {
  overflow: hidden;
}

/* Shared page language: readable surfaces, links and controls. */
body > main:not(#main-content) a {
  color: var(--brand-primary);
}

body > main:not(#main-content) h1,
body > main:not(#main-content) h2,
body > main:not(#main-content) h3,
body > main:not(#main-content) h4 {
  color: var(--brand-primary);
}

.blog-cover {
  border-radius: inherit;
}

.blog-item {
  position: relative;
  border-color: var(--border-color) !important;
  border-radius: var(--radius-medium) !important;
  background: var(--surface-muted);
  transition: transform var(--interaction-duration) ease,
    box-shadow var(--interaction-duration) ease,
    border-color var(--interaction-duration) ease;
}

.blog-cover-link {
  position: relative;
  z-index: 2;
  display: block;
  flex: 0 0 auto;
}

.blog-item h4 a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.blog-item:has(h4 a:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

.blog-item:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong) !important;
  box-shadow: var(--shadow-hover);
}

.blog-item h4 a,
.title {
  color: var(--brand-primary) !important;
}

.blog-info .date,
.date,
.duration,
.description,
.podcast-loading {
  color: var(--text-muted) !important;
}

.tags-part .tag,
.blog-info .tag {
  position: relative;
  z-index: 2;
  font: inherit;
  cursor: pointer;
  color: var(--text-main) !important;
  background: var(--surface) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 999px !important;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.article-breadcrumb a {
  color: var(--brand-primary);
  text-decoration: none;
}

.article-breadcrumb [aria-current="page"] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-back-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  margin-top: 28px;
  padding: 8px 14px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  color: var(--brand-primary);
  background: var(--brand-surface);
  text-decoration: none;
}

.article-back-link:hover {
  border-color: var(--brand-primary);
}

.timeline-month li {
  position: relative;
}

.timeline-month li > a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.timeline-month li:has(> a:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

.fallback-listen {
  text-decoration: none;
}

.podcast-player-placeholder {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.podcast-player-placeholder .play-button {
  opacity: 0.72;
}

.episode {
  border-color: var(--border-color) !important;
}

.play-button {
  min-width: 32px;
  min-height: 32px;
  color: var(--brand-on-primary) !important;
  background: var(--brand-primary) !important;
}

.more-button,
.podcast-toggle-button {
  color: var(--brand-primary) !important;
}

.more-button {
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  color: var(--brand-primary) !important;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.play-button.loading {
  cursor: progress;
  opacity: 0.8;
}

.article-toc,
blockquote {
  color: var(--text-main);
  background: var(--surface-muted) !important;
  border-color: var(--brand-border) !important;
}

p.date {
  color: var(--text-muted) !important;
  background: transparent !important;
  border-color: transparent !important;
}

.progress-bar,
.reading-progress {
  background: var(--border-color) !important;
}

.progress,
.reading-progress-inner {
  background: var(--brand-primary) !important;
}

.reveal-item {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reveal-item.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 700px) {
  .site-shell-inner {
    align-items: center;
    gap: 8px;
  }

  .site-shell-brand {
    flex: 0 0 auto;
  }

  .site-shell-actions {
    min-width: 0;
    flex: 1;
  }

  .site-shell-nav {
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .site-shell-nav::-webkit-scrollbar {
    display: none;
  }

  .site-shell-nav a {
    flex: 0 0 auto;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    font-size: 0.9rem;
  }

  body > main:not(#main-content) {
    width: calc(100% - 24px);
    margin-top: 16px;
    margin-bottom: 16px;
    padding: 16px;
    border-radius: var(--radius-medium);
  }

  .blog-info {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .timeline-month li {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .timeline-date,
  .timeline-tags {
    grid-column: 2;
  }

  .scroll-to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .site-shell-inner {
    padding: 10px 12px;
  }

  .site-shell-brand {
    font-size: 0.98rem;
  }

  .site-shell-actions {
    gap: 6px;
  }

  .site-shell-nav a {
    font-size: 0.86rem;
  }

  .site-theme-toggle label {
    width: 42px;
  }

  .site-theme-toggle input:checked + label::after {
    transform: translateX(14px);
  }
}
