:root {
  color-scheme: dark;
  --bg: #080c0a;
  --surface: #101713;
  --ink: #f1efe5;
  --muted: #b0b8aa;
  --line: #27342e;
  --accent: #63d5a1;
  --accent-strong: #84b7ff;
  --warm: #e2b05f;
  --quote-bg: #0d1511;
  --quote-ink: #d9e6d5;
  --shadow: 0 12px 36px rgb(0 0 0 / 32%);
  --max: 1120px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f7f4ed;
  --surface: #fffdf8;
  --ink: #1d1b18;
  --muted: #706a60;
  --line: #ded6c8;
  --accent: #0f6b5f;
  --accent-strong: #164a8b;
  --warm: #ad5b2a;
  --quote-bg: #fff8eb;
  --quote-ink: #3f3a33;
  --shadow: 0 12px 28px rgb(42 35 25 / 10%);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", "Noto Serif TC", "Source Han Serif TC", serif;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 100%;
  height: 3px;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 0.18em;
}

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

img,
iframe,
video {
  max-width: 100%;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: block;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink) 28%, transparent);
  background: #020403;
  box-shadow: var(--shadow);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 58% 50%;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 18px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font: 600 0.9rem ui-sans-serif, system-ui, sans-serif;
}

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

.search-wrap,
.contact-wrap {
  position: relative;
}

.theme-toggle,
.search-toggle,
.contact-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 5px 8px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: none;
  cursor: pointer;
  font: 700 0.78rem ui-sans-serif, system-ui, sans-serif;
}

.search-toggle {
  justify-content: center;
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.search-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.search-toggle:hover,
.search-toggle:focus,
.contact-button:hover,
.contact-button:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
}

.contact-button {
  padding: 6px 12px;
}

.search-panel,
.contact-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 12px;
}

.search-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--bg);
  font: 600 0.95rem ui-sans-serif, system-ui, sans-serif;
}

.search-input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 38%, transparent);
  outline-offset: 2px;
}

.search-results {
  max-height: min(520px, 62vh);
  margin-top: 10px;
  overflow: auto;
}

.search-result {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result img {
  width: 72px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
}

.search-result__placeholder {
  display: block;
  width: 72px;
  height: 54px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
}

.search-result span,
.search-result strong,
.search-result small,
.search-result em {
  display: block;
}

.search-result strong {
  overflow: hidden;
  color: var(--ink);
  font: 800 0.9rem/1.35 ui-sans-serif, system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result small {
  margin-top: 3px;
  color: var(--muted);
  font: 700 0.76rem ui-sans-serif, system-ui, sans-serif;
}

.search-result em {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font: 600 0.78rem/1.45 ui-sans-serif, system-ui, sans-serif;
  font-style: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.search-result mark,
.article-content mark {
  border-radius: 3px;
  color: var(--bg);
  background: var(--accent);
}

.search-empty {
  margin: 8px 0 0;
  color: var(--muted);
  font: 700 0.86rem ui-sans-serif, system-ui, sans-serif;
}

.contact-menu a {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  font: 700 0.86rem ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
}

.contact-menu a:hover,
.contact-menu a:focus {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.theme-toggle__track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 26%, var(--bg));
}

.theme-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 160ms ease, background 160ms ease;
}

:root[data-theme='light'] .theme-toggle__thumb {
  transform: translateX(20px);
  background: var(--warm);
}

.theme-toggle__label {
  min-width: 33px;
  text-align: left;
}

main {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

.home-hero {
  min-height: clamp(320px, 43vh, 520px);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.home-hero div,
.page-heading {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--warm);
  font: 700 0.78rem ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 9vw, 5.8rem);
}

.home-hero h1,
.page-heading h1 {
  max-width: 100%;
  white-space: nowrap;
}

.home-hero h1 {
  font-size: clamp(2.15rem, 7.4vw, 5.8rem);
}

.lede {
  max-width: 720px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 2.4vw, 1.45rem);
}

.hero-quote {
  max-width: 720px;
  margin: 26px 0 0;
  padding: 18px 20px;
  border-left: 4px solid var(--accent);
  background: var(--quote-bg);
  color: var(--quote-ink);
}

.hero-quote blockquote {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.hero-quote figcaption {
  margin-top: 8px;
  color: var(--muted);
  font: 700 0.86rem ui-sans-serif, system-ui, sans-serif;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 56px;
  padding: 56px 0 72px;
}

.post-row {
  border-bottom: 1px solid var(--line);
}

.post-row a {
  display: block;
  padding: 26px 0;
  text-decoration: none;
}

.post-thumb,
.list-thumb {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}

.post-thumb {
  height: clamp(260px, 36vw, 430px);
  object-fit: contain;
}

.list-thumb {
  width: 92px;
  height: 68px;
}

.list-thumb--small {
  width: 76px;
  height: 58px;
}

.post-row time,
.side-list time,
.compact-list time,
.archive-list time,
.article-meta {
  color: var(--muted);
  font: 600 0.84rem ui-sans-serif, system-ui, sans-serif;
}

.post-row h2 {
  margin: 10px 0 8px;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
}

.post-row p {
  margin: 0;
  color: var(--muted);
}

.side-list {
  position: sticky;
  top: 24px;
  align-self: start;
  padding-top: 28px;
}

.home-more {
  margin-top: 32px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
}

.home-more p {
  margin: 0 0 10px;
  color: var(--muted);
  font: 700 0.86rem ui-sans-serif, system-ui, sans-serif;
}

.home-more a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 52%, var(--line));
  border-radius: 999px;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font: 800 0.9rem ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
}

.side-list h2 {
  margin: 0 0 18px;
  font: 700 1rem ui-sans-serif, system-ui, sans-serif;
}

.side-list a,
.compact-list a,
.archive-list a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px;
  column-gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.side-list span,
.compact-list span,
.archive-list span {
  display: block;
  font-weight: 700;
  line-height: 1.5;
}

.page-heading {
  padding: 64px 0 32px;
}

.page-heading h1 {
  font-size: clamp(1.95rem, 4.8vw, 4.2rem);
}

.archive-list,
.compact-list {
  padding-bottom: 72px;
}

.year-group {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 24px;
  border-top: 1px solid var(--line);
}

.year-group h2 {
  margin: 20px 0 0;
  color: var(--accent);
}

.article-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 64px 0 88px;
}

.article-header {
  margin-bottom: 42px;
}

.article-header h1 {
  font-size: clamp(2.1rem, 6vw, 4.6rem);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 18px;
}

.hero-image {
  display: block;
  width: 100%;
  margin-top: 28px;
  border-radius: 8px;
}

.article-content {
  font-size: 1.12rem;
}

.article-content h2 {
  margin-top: 2.2em;
  font-size: 1.7rem;
}

.article-content h3 {
  margin-top: 2em;
  font-size: 1.28rem;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content figure {
  margin: 1.15em 0;
}

.article-content blockquote {
  padding-left: 22px;
  border-left: 4px solid var(--accent);
  color: var(--quote-ink);
}

.article-content img {
  display: block;
  height: auto;
  margin: 1.8rem auto;
  border-radius: 8px;
}

.article-content iframe {
  display: block;
  width: 100%;
  min-height: 380px;
  margin: 1.8rem 0;
  border: 0;
}

.article-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.article-content th,
.article-content td {
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.toc-box {
  margin: 0 0 36px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.toc-box h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font: 800 0.9rem ui-sans-serif, system-ui, sans-serif;
}

.toc-box ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font: 700 0.9rem/1.45 ui-sans-serif, system-ui, sans-serif;
}

.toc-box a {
  color: var(--ink);
  text-decoration: none;
}

.toc-box a:hover,
.toc-box a:focus {
  color: var(--accent);
}

.toc-depth-3 {
  margin-left: 18px;
  font-weight: 600;
}

.pagefind-taxonomy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.taxonomy-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.taxonomy-footer a {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  font: 700 0.82rem ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
}

.related-section {
  margin-top: 52px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.related-section h2 {
  margin: 0 0 18px;
  font: 800 1.05rem ui-sans-serif, system-ui, sans-serif;
}

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

.related-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 94px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  text-decoration: none;
}

.related-card img {
  width: 92px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
}

.related-card small,
.related-card strong {
  display: block;
}

.related-card small {
  margin-bottom: 3px;
  color: var(--muted);
  font: 700 0.72rem ui-sans-serif, system-ui, sans-serif;
}

.related-card strong {
  color: var(--ink);
  font: 800 0.92rem/1.45 ui-sans-serif, system-ui, sans-serif;
}

.site-footer {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 600 0.86rem ui-sans-serif, system-ui, sans-serif;
}

.license-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 760px;
  margin-top: 12px;
  color: var(--muted);
  text-decoration: none;
}

.license-link img {
  flex: 0 0 auto;
  width: 88px;
  height: 31px;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  font: 900 1rem ui-sans-serif, system-ui, sans-serif;
}

.back-to-top[hidden] {
  display: none;
}

@media (max-width: 820px) {
  .site-header {
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 0;
  }

  .header-actions {
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .header-actions::-webkit-scrollbar {
    display: none;
  }

  .search-panel,
  .contact-menu {
    position: fixed;
    top: 86px;
    right: 16px;
    left: 16px;
    width: auto;
  }

  .site-nav {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .search-wrap,
  .contact-wrap,
  .theme-toggle,
  .search-toggle,
  .contact-button {
    flex: 0 0 auto;
  }

  .contact-button {
    padding: 5px 9px;
    white-space: nowrap;
  }

  .theme-toggle {
    gap: 0;
    min-width: 54px;
    padding: 5px;
  }

  .theme-toggle__label {
    display: none;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 28px;
  }

  .post-thumb {
    height: min(62vw, 320px);
  }

  .side-list {
    position: static;
    padding-top: 0;
  }

  .year-group {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .article-shell {
    padding-top: 42px;
  }

  .article-content {
    font-size: 1.04rem;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand {
    min-width: 0;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand-name {
    overflow: hidden;
    font-size: 0.92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-hero h1 {
    font-size: clamp(1.9rem, 9.8vw, 2.5rem);
  }

  .page-heading h1 {
    font-size: clamp(1.35rem, 6.8vw, 2rem);
  }

  .search-panel {
    width: auto;
  }

  .toc-box {
    padding: 16px;
  }

  .related-card {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .related-card img {
    width: 78px;
    height: 62px;
  }

  .back-to-top {
    right: 14px;
    bottom: 14px;
  }
}
