:root {
  --bg: #f7f6f3;
  --bg-glow: #eceae4;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --rule: #d8d5cf;
  --measure: 38rem;
  --font: Palatino, "Palatino Linotype", "Book Antiqua", "Noto Serif SC", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --bg-glow: #1e1d1a;
    --text: #eceae4;
    --muted: #a8a59c;
    --rule: #2e2c28;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141412;
  --bg-glow: #1e1d1a;
  --text: #eceae4;
  --muted: #a8a59c;
  --rule: #2e2c28;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f7f6f3;
  --bg-glow: #eceae4;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --rule: #d8d5cf;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-glow) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.75;
}

.page {
  width: min(100% - 2.5rem, var(--measure));
  margin: 0 auto;
  padding: 2.5rem 0 5rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 2.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.theme-icon {
  display: none;
}

/* Show moon in light (click → dark); sun in dark (click → light) */
html:not([data-theme="dark"]) .theme-icon-moon {
  display: block;
}

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

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) .theme-icon-moon {
    display: none;
  }

  html:not([data-theme="light"]):not([data-theme="dark"]) .theme-icon-sun {
    display: block;
  }
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.lang-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.is-active {
  color: var(--text);
  font-weight: 600;
}

.lang-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.lang-sep {
  color: var(--rule);
  user-select: none;
}

.article[hidden] {
  display: none;
}

.title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.author {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.epigraph {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.article p {
  margin: 0 0 1.15em;
  max-width: 70ch;
}

.article p:last-child {
  margin-bottom: 0;
}

.article em {
  font-style: italic;
}

.article[lang="zh-Hans"] {
  line-height: 1.9;
}

@media (max-width: 480px) {
  body {
    font-size: 1.05rem;
  }

  .page {
    width: min(100% - 1.5rem, var(--measure));
    padding-top: 1.75rem;
  }

  .site-header {
    margin-bottom: 2rem;
  }
}
