:root {
  --bg: #f2eadf;
  --paper: rgba(255, 251, 245, 0.86);
  --paper-strong: rgba(255, 252, 248, 0.96);
  --ink: #1b1714;
  --muted: #62554a;
  --line: rgba(71, 45, 22, 0.14);
  --line-strong: rgba(71, 45, 22, 0.24);
  --accent: #b75b32;
  --accent-soft: rgba(183, 91, 50, 0.1);
  --accent-gold: #b88827;
  --shadow: 0 30px 80px rgba(58, 35, 18, 0.12);
  --sans: "Avenir Next", "Hiragino Sans", "PingFang TC", "PingFang SC", "Noto Sans JP", sans-serif;
  --sidebar-width: 320px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html.dark {
  --bg: #1a1410;
  --paper: rgba(30, 22, 16, 0.92);
  --paper-strong: rgba(38, 28, 20, 0.98);
  --ink: #f0e8df;
  --muted: #a89080;
  --line: rgba(255, 210, 170, 0.1);
  --line-strong: rgba(255, 210, 170, 0.2);
  --accent: #d4703f;
  --accent-soft: rgba(212, 112, 63, 0.15);
  --accent-gold: #d4a82a;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
body {
  margin: 0; color: var(--ink); font-family: var(--sans);
  background:
    radial-gradient(circle at 10% 10%, rgba(184, 136, 39, 0.16), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(183, 91, 50, 0.16), transparent 24%),
    linear-gradient(180deg, #fbf4eb 0%, #f2eadf 48%, #e8dac9 100%);
  min-height: 100vh;
  transition: background 300ms ease, color 300ms ease;
}
html.dark body {
  background:
    radial-gradient(circle at 10% 10%, rgba(184, 136, 39, 0.08), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(183, 91, 50, 0.08), transparent 24%),
    linear-gradient(180deg, #1f1710 0%, #1a1410 48%, #140f0a 100%);
}
a { color: inherit; }
button { font: inherit; }
.page-shell { position: relative; width: min(100vw - 24px, 1920px); margin: 12px auto 40px; }
.ambient { position: fixed; pointer-events: none; inset: auto; width: 32rem; height: 32rem; border-radius: 999px; filter: blur(24px); opacity: 0.3; z-index: 0; }
.ambient--one { top: -10rem; left: -10rem; background: radial-gradient(circle, rgba(184, 136, 39, 0.6), transparent 62%); }
.ambient--two { right: -10rem; top: 20rem; background: radial-gradient(circle, rgba(183, 91, 50, 0.52), transparent 64%); }
.hero, .sidebar__inner, .article-card, .mobile-toc, .floating-btn, .chapter-card { position: relative; z-index: 1; border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero {
  overflow: hidden; border-radius: 32px; padding: 34px 56px 30px;
  border-bottom: none;
  background:
    linear-gradient(160deg, rgba(255, 253, 249, 0.98), rgba(249, 238, 223, 0.88)),
    linear-gradient(120deg, rgba(184, 136, 39, 0.08), rgba(183, 91, 50, 0.08));
  transition: background 300ms ease;
}
html.dark .hero {
  background:
    linear-gradient(160deg, rgba(38, 28, 20, 0.98), rgba(28, 20, 14, 0.92)),
    linear-gradient(120deg, rgba(184, 136, 39, 0.06), rgba(183, 91, 50, 0.06));
}
html.dark .sidebar__inner, html.dark .article-card, html.dark .mobile-toc, html.dark .chapter-card {
  background: var(--paper);
}
html.dark .stat-card, html.dark .chip, html.dark .language-switch__button, html.dark .mobile-toc__close {
  background: rgba(40, 30, 22, 0.85); color: var(--ink);
}
html.dark .floating-btn {
  background: rgba(40, 30, 22, 0.92); color: var(--ink);
}
html.dark .prose strong { color: #f5e8dc; }
html.dark .prose blockquote { background: rgba(212, 112, 63, 0.08); border-left-color: rgba(212, 112, 63, 0.4); color: #c0a890; }
html.dark .prose code { background: rgba(255, 255, 255, 0.08); }
html.dark .prose pre { background: rgba(10, 7, 5, 0.95); }
.theme-toggle { cursor: pointer; font-size: 1rem; }
.hero::after {
  content: ""; position: absolute; inset: auto -12% -42% auto; width: 44rem; height: 44rem; border-radius: 999px;
  background: radial-gradient(circle, rgba(183, 91, 50, 0.12), transparent 58%); pointer-events: none;
}
.hero__meta, .hero__headline, .hero__rail { position: relative; z-index: 1; width: min(100%, 1120px); margin-inline: auto; }
.hero__meta, .hero__headline { display: flex; justify-content: space-between; gap: 18px; }
.hero__meta { align-items: center; }
.hero__headline { align-items: start; margin-top: 12px; }
.hero__rail { margin-top: 26px; }
.eyebrow, .sidebar__label { margin: 0; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.hero h1, .prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--sans); letter-spacing: -0.03em; }
.hero h1 { margin: 0; max-width: 980px; font-size: clamp(2.1rem, 3.2vw, 3.8rem); line-height: 1.02; }
.hero__lede { max-width: 960px; margin: 18px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.95; }
.hero__controls, .hero__stats, .hero__chips, .language-switch { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__controls { justify-content: flex-end; width: min(100%, 420px); }
.hero__stats { margin-bottom: 18px; }
.stat-card, .chip, .language-switch__button, .mobile-toc__close {
  border: 1px solid var(--line); background: rgba(255, 252, 248, 0.78); backdrop-filter: blur(12px); border-radius: 999px;
  text-decoration: none; color: var(--ink); transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}
.stat-card { min-width: 134px; padding: 14px 16px; border-radius: 18px; }
.stat-card strong { display: block; font-size: 1.3rem; line-height: 1; }
.stat-card span { display: block; margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.chip, .language-switch__button, .mobile-toc__close { padding: 10px 14px; white-space: nowrap; }
.chip:hover, .language-switch__button:hover, .mobile-toc__close:hover, .floating-btn:hover { transform: translateY(-1px); background: rgba(255, 248, 241, 0.98); border-color: rgba(183, 91, 50, 0.34); }
.language-switch__button, .mobile-toc__close, .floating-btn { cursor: pointer; }
.language-switch__button.is-active, .toc__item.is-active { background: linear-gradient(135deg, rgba(183, 91, 50, 0.16), rgba(184, 136, 39, 0.12)); border-color: rgba(183, 91, 50, 0.4); }
.layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 18px; }
.sidebar { position: sticky; top: 16px; }
.sidebar__inner, .article-card, .mobile-toc, .chapter-card { border-radius: 28px; background: var(--paper); }
.sidebar__inner { padding: 24px 18px 18px; overflow-y: auto; max-height: calc(100vh - 32px); scrollbar-width: none; }
.sidebar__inner::-webkit-scrollbar { display: none; }
.toc { display: grid; gap: 8px; margin-top: 16px; }
.toc__item { text-decoration: none; color: var(--muted); font-size: 0.95rem; line-height: 1.5; border-left: 2px solid transparent; border-radius: 12px; padding: 9px 10px 9px 12px; transition: color 160ms ease, border-color 160ms ease, transform 160ms ease, background 160ms ease; }
.toc__item--level-1 { font-weight: 700; color: var(--ink); }
.toc__item--level-3 { padding-left: 20px; font-size: 0.9rem; }
.toc__item:hover, .toc__item.is-active { color: var(--accent); border-left-color: var(--accent); transform: translateX(2px); }
.content { min-width: 0; }
.article-card { padding: 0 0 18px; background: transparent; border: 0; box-shadow: none; position: relative; z-index: 5; }
.prose { font-size: 1.06rem; line-height: 1.9; position: relative; z-index: 6; }
.prose > :first-child { margin-top: 0; }
.chapter-card { padding: 32px 34px 38px; margin-bottom: 18px; }
.chapter-card:last-child { margin-bottom: 0; }
.prose p, .prose li, .prose blockquote { color: var(--ink); }
.prose h1 { margin: 0 0 1rem; font-size: clamp(1.8rem, 2.8vw, 2.6rem); }
.prose h2 { margin: 2.4rem 0 1rem; font-size: clamp(1.35rem, 2vw, 1.8rem); }
.prose h3 { margin: 2rem 0 0.8rem; font-size: 1.18rem; }
.prose h4 { margin: 1.6rem 0 0.6rem; font-size: 1.02rem; }
.prose__chapter-start { margin-top: 0 !important; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table, .prose hr { margin: 1rem 0; }
.prose ul, .prose ol { padding-left: 1.45rem; }
.prose li + li { margin-top: 0.46rem; }
.prose strong { color: #2a1f18; }
.prose a, .chip, .toc__item { position: relative; z-index: 20; pointer-events: auto; }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.prose .is-link-line a { word-break: break-all; }
.prose blockquote { margin-left: 0; padding: 1.1rem 1.2rem; border-left: 4px solid rgba(183, 91, 50, 0.36); background: rgba(183, 91, 50, 0.06); border-radius: 0 18px 18px 0; color: #4e4034; }
.prose hr { border: 0; border-top: 1px solid var(--line); }
.prose code { font-family: "SFMono-Regular", "SF Mono", "Menlo", monospace; font-size: 0.92em; padding: 0.18em 0.38em; background: rgba(31, 22, 15, 0.06); border-radius: 6px; }
.prose pre { padding: 1rem 1.2rem; background: rgba(31, 22, 15, 0.94); color: #f8ede2; border-radius: 18px; overflow: auto; }
.prose pre code { padding: 0; background: transparent; color: inherit; }
.mobile-toc { position: fixed; right: 14px; bottom: 138px; width: min(420px, calc(100vw - 28px)); padding: 18px; background: rgba(255, 251, 246, 0.985); max-height: min(72vh, 640px); overflow: hidden; box-shadow: 0 32px 90px rgba(44, 28, 14, 0.24), 0 10px 30px rgba(44, 28, 14, 0.16); z-index: 60; }
.mobile-toc__header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.toc--mobile { max-height: calc(min(72vh, 640px) - 64px); overflow: auto; }
.floating-btn { position: fixed; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 999px; background: rgba(255, 252, 248, 0.92); backdrop-filter: blur(14px); color: var(--ink); font-size: 1.2rem; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 180ms ease, background 180ms ease, border-color 180ms ease; box-shadow: 0 18px 36px rgba(44, 28, 14, 0.16); z-index: 70; }
.floating-btn.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.floating-btn--top { right: 18px; bottom: 18px; }
.floating-btn--map { right: 18px; bottom: 82px; }
.floating-btn--theme { right: 18px; bottom: 146px; }
@media (min-width: 1025px) {
  .mobile-toc, .floating-btn--map, .floating-btn--theme { display: none; }
  .language-switch { flex-wrap: nowrap; justify-content: flex-end; }
}
@media (max-width: 1024px) {
  .hero__meta .theme-toggle { display: none; }
}
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hero__headline { flex-direction: column; }
  .hero__controls { width: 100%; justify-content: flex-start; }
}
@media (max-width: 720px) {
  .page-shell { width: min(100vw - 26px, 100%); margin-top: 12px; margin-bottom: 28px; }
  .hero { border-radius: 24px; padding: 22px 18px 20px; }
  .hero h1 { font-size: clamp(1.7rem, 7vw, 2.45rem); }
  .article-card, .sidebar__inner, .mobile-toc, .chapter-card { border-radius: 22px; }
  .article-card { padding: 0; background: transparent; }
  .chapter-card { padding: 24px 18px 28px; margin-bottom: 14px; }
  .prose p, .prose li, .prose blockquote { font-size: 0.98rem; line-height: 1.86; }
  .floating-btn { right: 14px; width: 48px; height: 48px; }
  .floating-btn--top { bottom: 14px; }
  .floating-btn--map { bottom: 72px; }
  .floating-btn--theme { bottom: 130px; }
  .mobile-toc { right: 14px; bottom: 190px; width: min(400px, calc(100vw - 28px)); }
}

/* Footer copyright */
.site-footer {
  text-align: center;
  padding: 24px 0 32px;
  border-top: 1px solid var(--line, rgba(255,255,255,0.08));
  color: var(--muted, #888);
  font-size: 0.78rem;
  opacity: 0.7;
}
.site-footer p { margin: 0; }
