:root {
  color-scheme: dark;
  --bg: #0d0e12;
  --bg-elevated: rgba(24, 25, 31, 0.78);
  --paper: #f1eee7;
  --paper-text: #262522;
  --paper-muted: #6f6a60;
  --text: #f7f4ed;
  --muted: #aaa79f;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #e9bd77;
  --accent-soft: rgba(233, 189, 119, 0.12);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9e5dc;
  --bg-elevated: rgba(245, 242, 235, 0.82);
  --paper: #fffdf8;
  --text: #24231f;
  --muted: #716d64;
  --line: rgba(32, 31, 27, 0.13);
  --accent: #946b2f;
  --accent-soft: rgba(148, 107, 47, 0.1);
  --shadow: 0 28px 70px rgba(62, 54, 40, 0.15);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 112px;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(109, 83, 47, 0.35), transparent 33rem),
    radial-gradient(circle at 95% 20%, rgba(75, 80, 105, 0.2), transparent 30rem),
    var(--bg);
  color: var(--text);
  transition: background-color 180ms ease, color 180ms ease;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 10px;
  background: var(--paper);
  color: var(--paper-text);
}

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

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 78px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  backdrop-filter: blur(22px) saturate(130%);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.22);
  object-fit: cover;
}

.brand strong,
.brand small { display: block; }
.brand strong { letter-spacing: 0.03em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: 0.12em; }

.top-nav {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elevated);
}

.nav-link {
  padding: 8px 15px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }

.theme-toggle {
  justify-self: end;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}

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

.home-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(72px, 11vw, 150px) 0 80px;
}

.hero { max-width: 850px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.24em; }

.hero h1,
.not-found h1 {
  margin: 22px 0 26px;
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(52px, 8vw, 106px);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.hero h1 em { color: var(--accent); font-weight: 400; }

.hero-copy {
  max-width: 650px;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.85;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: clamp(64px, 9vw, 110px);
}

.document-card {
  position: relative;
  min-height: 310px;
  padding: clamp(28px, 4vw, 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, var(--bg-elevated), color-mix(in srgb, var(--bg-elevated) 64%, transparent));
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease;
}

.document-card::after {
  position: absolute;
  right: -80px;
  bottom: -100px;
  width: 230px;
  height: 230px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: 50%;
  content: "";
}

.document-card:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.card-index { color: var(--accent); font-family: Georgia, serif; font-size: 13px; }
.document-card h2 { margin: 48px 0 16px; font-family: Georgia, "Songti SC", serif; font-size: clamp(30px, 4vw, 48px); font-weight: 400; }
.document-card p { max-width: 420px; color: var(--muted); line-height: 1.75; }
.card-action { position: absolute; bottom: 38px; color: var(--accent); font-size: 13px; }

.principle-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 68px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.principle-strip strong,
.principle-strip span { display: block; }
.principle-strip strong { margin-bottom: 8px; font-size: 13px; }
.principle-strip span { color: var(--muted); font-size: 12px; line-height: 1.6; }

.legal-layout {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(0, 820px);
  gap: clamp(24px, 5vw, 76px);
  justify-content: center;
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 100px;
}

.toc-panel {
  position: sticky;
  top: 112px;
  align-self: start;
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding: 18px 6px 18px 0;
}

.toc-title { margin: 0 0 16px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.18em; }
.toc-panel ol { margin: 0; padding: 0; list-style: none; }
.toc-panel li { margin: 3px 0; }
.toc-panel a {
  display: block;
  padding: 7px 11px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
}
.toc-panel a:hover,
.toc-panel a.is-current { border-left-color: var(--accent); color: var(--accent); }

.legal-paper {
  overflow: hidden;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--paper-text);
}

.document-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(26px, 6vw, 68px);
  border-bottom: 1px solid #ded9ce;
  color: var(--paper-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.legal-content { padding: clamp(42px, 7vw, 82px) clamp(26px, 7vw, 76px); }
.legal-content > h1 { margin: 0 0 8px; font-family: Georgia, "Songti SC", serif; font-size: clamp(38px, 6vw, 62px); font-weight: 400; letter-spacing: -0.035em; }
.legal-content > p:nth-of-type(-n + 2) { color: var(--paper-muted); font-size: 12px; }
.legal-content h2 { margin: 58px 0 18px; padding-top: 4px; border-top: 1px solid #ded9ce; font-family: Georgia, "Songti SC", serif; font-size: 25px; font-weight: 500; }
.legal-content h2 .heading-anchor { display: block; padding-top: 26px; }
.legal-content h3 { margin: 35px 0 14px; font-size: 16px; }
.heading-anchor { color: inherit; text-decoration: none; }
.heading-anchor:hover { color: #8a6028; }
.legal-content p,
.legal-content li { font-size: 14px; line-height: 2; }
.legal-content p { margin: 13px 0; }
.legal-content ul,
.legal-content ol { padding-left: 1.35em; }
.legal-content li { margin: 5px 0; padding-left: 0.25em; }
.legal-content a { color: #805821; text-underline-offset: 3px; }
.legal-content blockquote { margin: 22px 0; padding: 15px 20px; border-left: 3px solid #b38242; background: #e8e2d6; color: #504a40; }
.legal-content blockquote p { margin: 0; }

.document-end { padding: 40px; border-top: 1px solid #ded9ce; color: var(--paper-muted); text-align: center; }
.document-end span { color: #b38242; font-size: 10px; }
.document-end p { margin: 12px 0 0; font-size: 12px; }
.document-end a { color: #805821; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 28px clamp(20px, 4vw, 64px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.site-footer p { margin: 0; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

.not-found { width: min(760px, calc(100% - 40px)); margin: 0 auto; padding: 150px 0; text-align: center; }
.not-found h1 { font-size: clamp(42px, 7vw, 76px); }
.not-found > p:not(.eyebrow) { color: var(--muted); }
.primary-link { display: inline-block; margin-top: 22px; padding: 12px 20px; border-radius: 999px; background: var(--accent); color: var(--bg); text-decoration: none; }

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

@media (max-width: 800px) {
  .site-header { grid-template-columns: 1fr auto; min-height: 70px; }
  .top-nav { position: fixed; z-index: 19; right: 14px; bottom: 14px; left: 14px; justify-content: center; box-shadow: var(--shadow); }
  .theme-toggle { grid-column: 2; }
  .home-main { padding-top: 72px; }
  .document-grid { grid-template-columns: 1fr; }
  .document-card { min-height: 280px; }
  .principle-strip { grid-template-columns: 1fr; }
  .legal-layout { display: block; width: min(100% - 22px, 820px); padding-top: 18px; }
  .toc-panel { position: static; display: none; }
  .legal-paper { border-radius: 20px; }
  .site-footer { padding-bottom: 90px; }
}

@media (max-width: 480px) {
  .brand small { display: none; }
  .hero h1 { font-size: 52px; }
  .document-meta { display: block; }
  .document-meta span { display: block; margin: 3px 0; }
  .legal-content p,
  .legal-content li { font-size: 13px; }
  .site-footer { display: block; }
  .site-footer a { display: inline-block; margin-top: 8px; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; }
  .site-header,
  .toc-panel,
  .site-footer,
  .document-end { display: none; }
  .legal-layout { display: block; width: 100%; padding: 0; }
  .legal-paper { box-shadow: none; }
  .legal-content { padding: 20px; }
  .legal-content h2 { break-after: avoid; }
  .legal-content p,
  .legal-content li { font-size: 11pt; }
}
