:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --text: #24231f;
  --muted: #6e6a61;
  --line: #d9d4ca;
  --accent: #8b3a62;
  --accent-soft: #f1e3ea;
  --shadow: 0 14px 40px rgb(41 34 28 / 0.08);
  --max-width: 76rem;
  --reading-width: 44rem;
  --radius: 1rem;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Iowan Old Style", "Palatino Linotype", "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

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

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171615;
  --surface: #201f1d;
  --text: #f2eee7;
  --muted: #b9b2a8;
  --line: #3a3834;
  --accent: #e0a5c1;
  --accent-soft: #352731;
  --shadow: 0 14px 44px rgb(0 0 0 / 0.3);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #171615;
    --surface: #201f1d;
    --text: #f2eee7;
    --muted: #b9b2a8;
    --line: #3a3834;
    --accent: #e0a5c1;
    --accent-soft: #352731;
    --shadow: 0 14px 44px rgb(0 0 0 / 0.3);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.82;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.13em;
}

button,
input,
select {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  transform: translateY(-160%);
  padding: 0.65rem 0.9rem;
  border-radius: 0.6rem;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-ui);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(calc(100% - 2rem), var(--max-width));
  min-height: 4rem;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
}

.ui-link,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.45rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.ui-link:hover,
.theme-toggle:hover {
  border-color: var(--accent);
}

.page-shell {
  width: min(calc(100% - 2rem), var(--max-width));
  margin-inline: auto;
  padding: clamp(2.5rem, 6vw, 5.5rem) 0 4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}

.article {
  min-width: 0;
  max-width: var(--reading-width);
}

.kicker {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.22;
  text-wrap: balance;
}

h1 {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(2.45rem, 7vw, 5rem);
  font-weight: 650;
  letter-spacing: -0.035em;
}

.dek {
  max-width: 40rem;
  margin: 1.35rem 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  line-height: 1.7;
}

.article-meta {
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.lead-card {
  margin: 2.4rem 0 0;
  padding: clamp(1.2rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lead-card p:first-child {
  margin-top: 0;
}

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

.article-section {
  padding-top: 3.3rem;
  scroll-margin-top: 5.5rem;
}

.article-section h2 {
  margin: 0 0 1.25rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.55rem, 3vw, 2rem);
}

.article p {
  margin: 1.05rem 0;
}

.term {
  font-weight: 700;
}

.toc {
  position: sticky;
  top: 6rem;
  padding: 1rem 0 0.25rem;
  font-family: var(--font-ui);
}

.toc-title {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding-left: 1.15rem;
}

.toc li {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.toc a {
  color: inherit;
  text-decoration: none;
}

.toc a:hover,
.toc a[aria-current="true"] {
  color: var(--accent);
}


.related-reading {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.related-reading h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
}

.related-label {
  margin: 0 0 0.8rem;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.related-grid {
  display: grid;
  gap: 0.9rem;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.8rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.55;
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.related-grid .related-card {
  margin-top: 0;
}

.related-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.related-title,
.related-card-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
}

.related-card-description,
.related-card > span:not(.related-title):not(.related-card-title):not(.related-card-action) {
  color: var(--muted);
  font-size: 0.88rem;
}

.related-card-action {
  margin-top: 0.25rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.source-link {
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 0.82em;
}

.site-footer {
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
}

.footer-inner {
  width: min(calc(100% - 2rem), var(--max-width));
  margin-inline: auto;
  padding: 1.5rem 0 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .article {
    max-width: none;
  }

  .toc {
    position: static;
    order: -1;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    background: var(--surface);
  }
}

@media (max-width: 560px) {
  .header-inner {
    min-height: 3.65rem;
  }

  .site-brand {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-link,
  .theme-toggle {
    min-height: 2.15rem;
    padding-inline: 0.58rem;
    font-size: 0.78rem;
  }

  .page-shell {
    width: min(calc(100% - 1.25rem), var(--max-width));
    padding-top: 2rem;
  }

  .footer-inner {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
