:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --navy: #002147;
  --navy-deep: #061027;
  --gold: #c8a951;
  --ink: #1a2236;
  --muted: #6b6b6b;
  --line: #e5e0d4;
  --link: #002147;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b1426;
  --surface: #111c33;
  --navy: #061027;
  --navy-deep: #061027;
  --gold: #c8a951;
  --ink: #e8e6de;
  --muted: #9aa3b2;
  --line: #1f2a44;
  --link: #e8e6de;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif Pro", Georgia, serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a { color: var(--link); }
a:hover { color: var(--gold); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible, .reading-pane h1:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 200;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  font-size: 13px;
}
.skip-link:focus { top: 8px; }

.site-header {
  height: 70px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.site-header__inner {
  width: min(100%, 1120px);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
}
.site-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  color: var(--link);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.site-brand:hover { color: var(--gold); }
.site-brand__mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold);
  color: var(--link);
  font-family: Inter, Arial, sans-serif;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: -0.05em;
}
.site-brand:hover .site-brand__mark { background: var(--gold); color: var(--navy-deep); }
.site-nav { display: flex; align-items: center; gap: clamp(16px, 2vw, 29px); }
.site-nav > a {
  position: relative;
  padding: 6px 0;
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  font-size: 0.79rem;
  text-decoration: none;
}
.site-nav > a:hover, .site-nav > a[aria-current="page"] { color: var(--link); }
.site-nav > a[aria-current="page"]::after {
  position: absolute;
  right: 0;
  bottom: 3px;
  left: 0;
  height: 2px;
  background: var(--gold);
  content: "";
}
.theme-toggle {
  width: 31px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--link);
  cursor: pointer;
  font-size: 15px;
}
.theme-toggle:hover { border-color: var(--gold); background: var(--surface); }

.page-shell {
  width: min(100%, 1120px);
  min-height: calc(100vh - 170px);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px) 94px;
}
.reader-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: start;
  gap: clamp(48px, 6vw, 86px);
  padding-top: 58px;
}
.reader-sidebar {
  position: sticky;
  top: 26px;
  max-height: calc(100vh - 52px);
  overflow: auto;
  padding-right: 8px;
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  scrollbar-width: thin;
}
.reader-sidebar__header h2 {
  margin: 0 0 19px;
  color: var(--link);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.reader-sidebar__toggle { display: none; }
.topic-tree__topic {
  border-top: 1px solid var(--line);
}
.topic-tree__topic:last-child { border-bottom: 1px solid var(--line); }
.topic-tree summary {
  display: flex;
  align-items: baseline;
  gap: 9px;
  list-style: none;
  cursor: pointer;
  line-height: 1.42;
  overflow-wrap: anywhere;
}
.topic-tree summary::-webkit-details-marker { display: none; }
.topic-tree summary::before {
  flex: 0 0 auto;
  content: '›';
  color: var(--muted);
  font-size: 1.12em;
  line-height: 1;
  transform: rotate(0);
  transition: transform 0.16s ease;
}
.topic-tree details[open] > summary::before { transform: rotate(90deg); }
.topic-tree__topic > summary {
  padding: 13px 2px;
  color: var(--link);
  font-size: 0.82rem;
  font-weight: 600;
}
.topic-tree__children { padding: 0 0 13px 15px; }
.topic-tree__group > summary {
  padding: 6px 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}
.topic-tree__group[open] > summary { color: var(--link); }
.topic-tree__list {
  margin: 2px 0 7px;
  padding: 0 0 0 14px;
  list-style: none;
}
.topic-tree__list li { margin: 1px 0; }
.topic-tree__list :is(a, button) {
  display: block;
  width: 100%;
  padding: 6px 8px 6px 10px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: Inter, Arial, sans-serif;
  font-size: 0.75rem;
  line-height: 1.45;
  text-align: left;
  text-decoration: none;
}
.topic-tree__list :is(a, button):hover { color: var(--link); background: var(--surface); }
.topic-tree__list :is(a[aria-current="page"], button[aria-pressed="true"]) {
  border-left-color: var(--gold);
  background: var(--surface);
  color: var(--link);
  font-weight: 600;
}
.reader-main { min-width: 0; }
.reading-pane {
  min-height: min(66vh, 650px);
  max-width: 760px;
}
.reading-pane__eyebrow,
.reading-pane__path,
.reading-pane__draft-label {
  font-family: Inter, Arial, sans-serif;
  font-size: 0.74rem;
  line-height: 1.5;
}
.reading-pane__eyebrow {
  margin: 0 0 33px;
  color: var(--muted);
}
.reading-pane__path {
  margin: 0 0 15px;
  color: var(--muted);
}
.reading-pane__path span { padding: 0 5px; color: var(--gold); }
.reading-pane h1 {
  max-width: 740px;
  margin: 0;
  color: var(--link);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.5rem, 4vw, 3.3rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.17;
  overflow-wrap: anywhere;
}
.reading-pane__draft {
  margin-top: 58px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.reading-pane__draft-label {
  margin: 0 0 9px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.reading-pane__draft p:last-child {
  margin: 0;
  color: var(--ink);
  font-size: 1.04rem;
}
.published { margin-top: 48px; }
.published--landing { margin-top: 0; }
.published--landing .reading-pane__eyebrow { margin-bottom: 33px; }
.published--landing h1 {
  margin: 0 0 19px;
  color: var(--link);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.5rem, 4vw, 3.3rem);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.17;
}
.published__intro { margin: 0 0 42px; color: var(--muted); font-size: 1.08rem; }
.published h2 {
  margin: 0 0 10px;
  color: var(--link);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.55rem;
}
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list__item { padding: 22px 0; border-top: 1px solid var(--line); }
.post-list__meta {
  display: flex;
  gap: 10px;
  margin: 0 0 7px;
  color: var(--muted);
  font-family: Inter, Arial, sans-serif;
  font-size: 0.73rem;
}
.post-list__separator { color: var(--gold); }
.post-list__item h3 {
  margin: 0 0 7px;
  color: var(--link);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.45rem;
  line-height: 1.3;
}
.post-list__item h3 a { text-decoration: none; }
.post-list__item h3 a:hover { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }
.post-list__summary { margin: 0; line-height: 1.62; }

.site-footer { border-top: 1px solid var(--line); }
.site-footer__inner {
  width: min(100%, 1120px);
  min-height: 99px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 18px clamp(20px, 4vw, 40px);
  color: var(--muted);
  font-family: Inter, Arial, sans-serif;
  font-size: 0.77rem;
}
.site-footer__inner p { margin: 0; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 20px; }
.site-footer__links a { color: var(--link); text-decoration-color: var(--gold); text-underline-offset: 3px; }

@media (max-width: 760px) {
  .reader-layout { grid-template-columns: 1fr; gap: 31px; padding-top: 31px; }
  .reader-sidebar { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .reader-sidebar__header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
  .reader-sidebar__header h2 { margin: 0; }
  .reader-sidebar__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: transparent;
    color: var(--link);
    cursor: pointer;
    font-family: Inter, Arial, sans-serif;
    font-size: 0.76rem;
  }
  .reader-sidebar__toggle span { font-size: 1.1rem; line-height: 1; }
  .reader-sidebar[data-open="true"] .reader-sidebar__toggle span { transform: rotate(180deg); }
  .reader-sidebar:not([data-open="true"]) .topic-tree { display: none; }
  .topic-tree { max-height: 54vh; overflow: auto; margin-top: 14px; }
  .reading-pane { min-height: 48vh; }
}

@media (max-width: 560px) {
  .site-header { height: auto; }
  .site-header__inner { min-height: 94px; flex-wrap: wrap; align-content: center; gap: 6px; padding-top: 9px; padding-bottom: 9px; }
  .site-brand { width: 100%; }
  .site-nav { width: 100%; justify-content: space-between; gap: 10px; }
  .site-nav > a { font-size: 0.72rem; }
  .page-shell { padding-bottom: 65px; }
  .reading-pane__eyebrow { margin-bottom: 29px; }
  .reading-pane h1 { font-size: clamp(2.4rem, 10vw, 3.4rem); }
  .reading-pane__draft { margin-top: 42px; }
  .site-footer__inner { align-items: flex-start; flex-direction: column; justify-content: center; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .topic-tree summary::before { transition: none; }
}
