:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --text: #151515;
  --muted: #5f5a53;
  --line: #d9d2c7;
  --accent: #0d4b73;
  --accent-soft: #edf4fa;
  --gh-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

html {
  color-scheme: light;
}

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

html[data-theme="dark"]:root {
  --bg: #111519;
  --surface: #1a2129;
  --text: #e9eef5;
  --muted: #b4beca;
  --line: #313c49;
  --accent: #9ad0ff;
  --accent-soft: #203449;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top right, #efe8dc 0%, var(--bg) 48%), var(--bg);
  font-family: "Newsreader", "Source Serif 4", "Georgia", serif;
  line-height: 1.7;
}

html[data-theme="dark"] body {
  background: var(--bg);
}

html[data-theme="dark"] .site-header {
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg), #fff 35%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-shell {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-family: var(--gh-font);
  font-size: 1.32rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

.main-nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
}

.sub-nav {
  display: flex;
  gap: 1rem;
}

.main-nav a,
.sub-nav a {
  text-decoration: none;
  color: var(--muted);
  font-family: var(--gh-font);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.main-nav a[aria-current="page"],
.sub-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.footer-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.lang-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lang-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
  display: block;
}

.theme-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.theme-sun {
  display: none;
}

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

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

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

.site-main {
  padding-block: 2.8rem 3rem;
}

.about-main {
  width: min(900px, calc(100% - 2.4rem));
}

.about-main p {
  max-width: 72ch;
  font-family: var(--gh-font);
  font-size: clamp(1.12rem, 1.45vw, 1.26rem);
  line-height: 1.75;
  font-weight: 400;
}

.list-page-header h1,
.post-header h1 {
  margin: 0;
  line-height: 1.2;
  font-size: clamp(1.8rem, 3.8vw, 2.45rem);
}

.eyebrow {
  margin: 0 0 0.55rem;
  font-family: var(--gh-font);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
  color: var(--muted);
}

.lede {
  color: var(--muted);
  max-width: 66ch;
}

.list-section,
.entry-list,
.post-single {
  margin-top: 2rem;
}

.entry-item,
.post-single {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 8px 24px rgba(16, 20, 22, 0.06);
}

.post-single {
  max-width: min(72ch, 100%);
  margin: 1.25rem auto 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.entry-item.click-card {
  transition:
    background-color 260ms ease,
    border-color 260ms ease,
    box-shadow 260ms ease,
    transform 260ms ease;
}

.entry-item.click-card:hover {
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 38%);
  border-color: color-mix(in srgb, var(--line), var(--accent) 35%);
  box-shadow: 0 14px 28px rgba(16, 20, 22, 0.14);
  transform: translateY(-2px);
}

html[data-theme="dark"] .entry-item.click-card:hover {
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 22%);
  border-color: color-mix(in srgb, var(--line), var(--accent) 40%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.entry-item h2,
.entry-item h3 {
  margin: 0.2rem 0 0.45rem;
  line-height: 1.3;
}

.latest-section {
  margin-top: 0.4rem;
}

.latest-lead {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 0 1.25rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.latest-lead-title {
  margin: 0.3rem 0 0.75rem;
  line-height: 1.12;
  font-size: clamp(1.85rem, 4.2vw, 2.7rem);
}

.latest-lead-title a {
  color: var(--text);
  text-decoration: none;
}

.latest-lead-title a:hover {
  text-decoration: underline;
}

.latest-cover {
  margin: 0.35rem auto 0.95rem;
  max-width: 70ch;
}

.latest-cover a {
  display: block;
}

.latest-cover img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.lead-excerpt {
  max-width: 70ch;
  margin: 0 auto;
  font-family: var(--gh-font);
  font-size: clamp(1.08rem, 1.3vw, 1.18rem);
  line-height: 1.76;
  font-weight: 400;
  text-align: left;
}

.latest-lead .tag-row {
  justify-content: center;
}

.click-card {
  position: relative;
}

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

.click-card .card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.entry-list {
  list-style: none;
  padding: 0;
  margin-left: 0;
  display: grid;
  gap: 0.9rem;
}

.tag-row {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  position: relative;
  z-index: 3;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-family: var(--gh-font);
  font-size: 0.78rem;
  line-height: 1.2;
  position: relative;
  z-index: 3;
}

.tag-pill:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tag-group-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.62rem;
}

.tag-group-row {
  display: block;
}

.tag-group-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag-group-values .tag-pill {
  padding: 0.3rem 0.82rem;
  font-size: 0.92rem;
}

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

.pagination-nav a {
  text-decoration: none;
}

.post-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-family: var(--gh-font);
}

.lead-excerpt p,
.entry-item p,
.post-content p,
.post-content li {
  margin-top: 0.55rem;
  margin-bottom: 0;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.9rem;
  padding: 0.3rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--gh-font);
  text-decoration: none;
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    color 220ms ease,
    transform 220ms ease;
}

.read-more::after {
  content: "\2192";
  transition: transform 220ms ease;
}

.read-more:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 44%);
  border-color: color-mix(in srgb, var(--line), var(--accent) 36%);
  transform: translateY(-1px);
}

.read-more:hover::after {
  transform: translateX(2px);
}

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

.post-actions {
  max-width: none;
  margin: 2rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-twitter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease,
    transform 200ms ease;
}

.share-twitter svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.share-twitter:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 40%);
  border-color: color-mix(in srgb, var(--line), var(--accent) 35%);
  transform: translateY(-1px);
}

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

.about-links {
  margin: 0.6rem 0 1.1rem;
  display: flex;
  gap: 0.6rem;
}

.about-link {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  transition:
    color 200ms ease,
    border-color 200ms ease,
    background-color 200ms ease,
    transform 200ms ease;
}

.about-link:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--line), var(--accent) 30%);
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 34%);
  transform: translateY(-1px);
}

.about-link svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.post-header {
  margin: 0 0 1.25rem;
  text-align: left;
}

.post-header h1 {
  line-height: 1.14;
  font-size: clamp(1.72rem, 3.6vw, 2.28rem);
  text-align: left;
}

.post-content h2,
.post-content h3 {
  margin-top: 1.7rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.post-content {
  margin: 0;
  font-family: var(--gh-font);
  font-size: clamp(1.08rem, 1.45vw, 1.22rem);
  line-height: 1.82;
  font-weight: 400;
}

.post-content p,
.post-content li {
  margin-top: 0.78rem;
}

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

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

.post-content code,
.lead-excerpt 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(--accent-soft) 28%);
  border: 1px solid color-mix(in srgb, var(--line), var(--accent) 16%);
  border-radius: 4px;
  padding: 0.1em 0.32em;
}

.post-content pre,
.lead-excerpt pre {
  margin: 1rem 0 0;
  padding: 0.72rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 16%);
  overflow-x: auto;
}

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

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

.post-content .katex-display,
.lead-excerpt .katex-display {
  display: block;
  overflow-x: visible;
  overflow-y: visible;
  padding: 0.32rem 0;
}

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

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

.post-content .mermaid,
.lead-excerpt .mermaid {
  margin-top: 0.9rem;
  margin-bottom: 0.4rem;
  overflow-x: auto;
  text-align: center;
}

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.1rem 0 1.7rem;
  color: var(--muted);
  font-size: 0.93rem;
}

@media (max-width: 760px) {
  .header-shell {
    min-height: 68px;
    flex-wrap: wrap;
    padding-block: 0.7rem;
  }

  .main-nav {
    gap: 0.8rem;
  }

  .sub-nav {
    gap: 0.9rem;
  }

  .footer-shell {
    gap: 0.9rem;
  }

  .site-main {
    padding-top: 1.6rem;
  }
}

@media (max-width: 900px) {
  .post-content .katex-display,
  .lead-excerpt .katex-display {
    overflow-x: auto;
    padding: 0.32rem 0.06rem 0.46rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-item.click-card,
  .read-more,
  .read-more::after,
  .share-twitter,
  .about-link {
    transition: none;
  }

  .entry-item.click-card:hover,
  .read-more:hover,
  .read-more:hover::after,
  .share-twitter:hover,
  .about-link:hover {
    transform: none;
  }
}
