:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #fbfbfa;
  --surface-muted: #f3f3ef;
  --ink: #37352f;
  --ink-soft: #6f6e69;
  --ink-faint: #9b9a97;
  --line: #e8e7e4;
  --line-strong: #d9d8d4;
  --accent: #516b8f;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 40px rgba(15, 23, 42, 0.03);
  --display-font: "Avenir Next", "Aptos", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  --text-font: "Avenir Next", "Aptos", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  --serif-font: "Iowan Old Style", "Palatino Linotype", "Songti SC", "STSong", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text-font);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 250, 0.9);
  backdrop-filter: blur(10px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-copy strong {
  font-family: var(--display-font);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.site-primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.primary-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.52rem 0.82rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  transition: background-color 180ms ease, color 180ms ease;
}

.primary-nav-link:hover,
.primary-nav-link.is-active {
  background: var(--surface-muted);
  color: var(--ink);
}

.site-frame {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.sidebar {
  position: sticky;
  top: 4.2rem;
  align-self: start;
  height: calc(100vh - 5rem);
  overflow: auto;
  padding: 1.5rem 1.1rem 2rem 0;
  border-right: 1px solid var(--line);
}

.sidebar-intro {
  margin-bottom: 1.25rem;
  padding-right: 1rem;
}

.eyebrow {
  margin: 0 0 0.38rem;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-intro h2,
.section-heading h2,
.feature-copy h2,
.chapter-article h1,
.chapter-nav-card strong,
.home-hero h1,
.book-hero h1,
.blog-hero h1,
.post-header h1 {
  margin: 0;
  font-family: var(--display-font);
}

.sidebar-intro h2 {
  font-size: 1rem;
  font-weight: 620;
  letter-spacing: -0.02em;
}

.sidebar-intro p:last-child {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

.sidebar-home-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
  padding: 0.72rem 0.85rem;
  border-radius: 0.8rem;
  color: var(--ink-soft);
  font-size: 0.94rem;
  transition: background-color 180ms ease, color 180ms ease;
}

.sidebar-home-link:hover,
.sidebar-home-link.is-active {
  background: var(--surface-muted);
  color: var(--ink);
}

.sidebar-home-link-note {
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.45rem;
  padding-right: 0.55rem;
}

.sidebar-group {
  border: 1px solid transparent;
  border-radius: 0.9rem;
  background: transparent;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.sidebar-group:hover,
.sidebar-group[open] {
  border-color: var(--line);
  background: var(--surface-soft);
}

.sidebar-group summary {
  position: relative;
  display: grid;
  gap: 0.12rem;
  padding: 0.82rem 2.1rem 0.82rem 0.9rem;
  cursor: pointer;
  list-style: none;
}

.sidebar-group summary::-webkit-details-marker {
  display: none;
}

.sidebar-group summary::after {
  content: "›";
  position: absolute;
  top: 0.78rem;
  right: 0.9rem;
  color: var(--ink-faint);
  font-size: 1rem;
  transition: transform 180ms ease;
}

.sidebar-group[open] summary::after {
  transform: rotate(90deg);
}

.sidebar-group-label {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 650;
}

.sidebar-group-title {
  font-size: 0.97rem;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.sidebar-group-subtitle,
.chapter-link-subtitle,
.latin,
.chapter-subtitle,
.book-hero-subtitle {
  color: var(--ink-soft);
}

.sidebar-group-subtitle {
  font-size: 0.84rem;
}

.chapter-list {
  display: grid;
  gap: 0.18rem;
  margin: 0;
  padding: 0 0.45rem 0.65rem 0.75rem;
  list-style: none;
}

.chapter-link {
  display: grid;
  gap: 0.12rem;
  padding: 0.58rem 0.7rem;
  border-radius: 0.72rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.chapter-link:hover,
.chapter-link.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.chapter-link-subtitle {
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.content-area {
  min-width: 0;
  padding: 2rem 0 0 2.5rem;
}

.site-main {
  padding: 2.25rem 1.5rem 3rem;
}

.content-shell {
  max-width: 760px;
  margin: 0 auto;
}

.content-shell--wide {
  max-width: 960px;
}

.paper-card,
.chapter-article,
.post-article,
.feature-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.paper-card {
  padding: 1.45rem 1.65rem;
}

.home-shell,
.book-home-shell,
.blog-shell,
.columns-shell,
.directory-shell {
  display: grid;
  gap: 1.25rem;
}

.home-hero,
.book-hero,
.blog-hero,
.columns-hero,
.directory-hero {
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--line);
}

.home-hero h1,
.book-hero h1,
.blog-hero h1,
.columns-hero h1,
.directory-hero h1 {
  font-size: clamp(2.55rem, 4vw, 4rem);
  font-weight: 700;
  line-height: 1.03;
  letter-spacing: -0.05em;
}

.hero-deck {
  max-width: 44rem;
  margin: 0.85rem 0 0;
  color: var(--ink-soft);
  font-size: 1.06rem;
  line-height: 1.8;
}

.home-intro {
  color: var(--ink-soft);
}

.feature-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  padding: 1.35rem 1.45rem;
}

.column-grid {
  display: grid;
  gap: 1rem;
}

.directory-preview-grid,
.directory-grid {
  display: grid;
  gap: 1rem;
}

.directory-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.column-card {
  align-items: center;
}

.directory-group {
  gap: 1rem;
}

.directory-section-heading {
  display: grid;
  gap: 0.4rem;
}

.directory-section-heading h2 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 1.32rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.directory-section-deck {
  margin: 0;
  max-width: 46rem;
  color: var(--ink-soft);
  line-height: 1.72;
}

.directory-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.directory-card {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 1rem;
  padding: 1.3rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.directory-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.directory-card-heading h3 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.directory-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 620;
  white-space: nowrap;
}

.directory-role {
  margin: 0.5rem 0 0;
  color: var(--accent);
  font-size: 0.93rem;
  font-weight: 620;
}

.directory-description {
  margin: 0.6rem 0 0;
  color: var(--ink-soft);
  line-height: 1.72;
}

.directory-notes {
  margin: 0.65rem 0 0;
  color: var(--ink-faint);
  font-size: 0.88rem;
  line-height: 1.65;
}

.directory-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.95rem;
}

.directory-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.64rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.2;
}

.directory-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.feature-copy h2 {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.feature-copy p {
  margin: 0.6rem 0 0;
  max-width: 34rem;
  color: var(--ink-soft);
  line-height: 1.72;
}

.column-brand {
  margin: 0.45rem 0 0;
  color: var(--ink-faint);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.feature-actions,
.book-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.05rem;
  border-radius: 0.82rem;
  font-size: 0.95rem;
  font-weight: 620;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.primary-action {
  background: var(--ink);
  color: #ffffff;
}

.primary-action:hover {
  background: #23211d;
  transform: translateY(-1px);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-action:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.text-link,
.back-link {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 620;
}

.text-link:hover,
.back-link:hover {
  text-decoration: underline;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2,
.chapter-nav-header h2 {
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.list-section {
  display: grid;
  gap: 0.9rem;
}

.post-stream {
  display: grid;
}

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

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

.post-row-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  padding: 1rem 0;
}

.post-row-link:hover h3 {
  color: var(--accent);
}

.post-row-main {
  min-width: 0;
}

.post-row-main h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 630;
  letter-spacing: -0.02em;
}

.post-summary {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.post-date {
  color: var(--ink-faint);
  font-size: 0.86rem;
  white-space: nowrap;
  margin-top: 0.12rem;
}

.empty-state {
  padding: 1.1rem 1.15rem;
  border: 1px dashed var(--line-strong);
  border-radius: 0.95rem;
  background: var(--surface-soft);
  color: var(--ink-soft);
  line-height: 1.7;
}

.book-hero-subtitle {
  margin: 0.4rem 0 0;
  font-size: 1.08rem;
}

.chapter-article {
  max-width: 920px;
  padding: 1.55rem 1.8rem;
}

.chapter-header {
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}

.chapter-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.chapter-article h1,
.post-header h1 {
  margin: 0.65rem 0 0;
  font-size: clamp(2.05rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.05em;
}

.chapter-subtitle {
  margin: 0.42rem 0 0;
  font-size: 1.02rem;
}

.chapter-deck,
.post-deck {
  max-width: 42rem;
  margin: 0.95rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.78;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.chapter-meta span {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.68rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.2;
}

.chapter-body,
.post-body {
  margin-top: 1.55rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.chapter-nav-wrap {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.chapter-nav-header {
  margin-bottom: 0.9rem;
}

.chapter-nav-header h2 {
  margin: 0;
  font-family: var(--display-font);
}

.chapter-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
  align-items: start;
}

.chapter-nav.has-prev-only,
.chapter-nav.has-next-only {
  grid-template-columns: minmax(0, 1fr);
}

.chapter-nav.has-prev-only {
  justify-items: start;
}

.chapter-nav.has-next-only {
  justify-items: end;
}

.chapter-nav-link {
  display: grid;
  gap: 0.22rem;
  min-width: 0;
  max-width: 28rem;
  color: var(--ink-soft);
  transition: color 180ms ease, transform 180ms ease;
}

.chapter-nav-link:hover {
  color: var(--ink);
  transform: translateX(2px);
}

.chapter-nav-link.is-next:hover {
  transform: translateX(-2px);
}

.chapter-nav-meta {
  color: var(--ink-faint);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-nav-link strong {
  font-size: 0.96rem;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--ink);
}

.chapter-nav-link-subtitle {
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.chapter-nav-link.is-next {
  justify-items: end;
  text-align: right;
}

.post-article {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.6rem 1.8rem;
}

.back-link {
  display: inline-flex;
  margin-bottom: 1rem;
}

.post-header {
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--line);
}

.post-meta {
  margin-top: 0.95rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.prose {
  font-size: 1.03rem;
  line-height: 1.86;
  color: var(--ink);
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose h2,
.prose h3 {
  margin: 2rem 0 0.9rem;
  font-family: var(--display-font);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.prose h2 {
  font-size: 1.46rem;
}

.prose h3 {
  font-size: 1.18rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
  margin: 1rem 0;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose blockquote {
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid var(--line-strong);
  background: linear-gradient(90deg, rgba(55, 53, 47, 0.03), transparent 50%);
  color: var(--ink-soft);
  font-family: var(--serif-font);
}

.prose code {
  padding: 0.12rem 0.38rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--surface-soft);
  font-size: 0.92em;
}

.prose hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.site-footer {
  padding: 0 1rem 2rem;
  color: var(--ink-faint);
  font-size: 0.84rem;
  text-align: center;
}

@media (max-width: 1080px) {
  .site-frame {
    grid-template-columns: 1fr;
    padding: 0 1rem 2rem;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 1.1rem 0 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content-area {
    padding: 1.35rem 0 0;
  }

  .site-main {
    padding-inline: 1rem;
  }

  .content-shell,
  .content-shell--wide,
  .chapter-article,
  .post-article {
    max-width: none;
  }
}

@media (max-width: 720px) {
  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding-inline: 1rem;
  }

  .site-primary-nav {
    width: 100%;
  }

  .primary-nav-link {
    padding-inline: 0.72rem;
  }

  .paper-card,
  .feature-card,
  .chapter-article,
  .post-article {
    padding: 1.2rem;
    border-radius: 0.95rem;
  }

  .home-hero h1,
  .book-hero h1,
  .blog-hero h1,
  .columns-hero h1,
  .directory-hero h1,
  .chapter-article h1,
  .post-header h1 {
    font-size: clamp(2rem, 10vw, 2.65rem);
  }

  .feature-card {
    grid-template-columns: 1fr;
  }

  .directory-preview-grid,
  .directory-grid {
    grid-template-columns: 1fr;
  }

  .directory-card-heading {
    flex-direction: column;
  }

  .feature-actions,
  .book-hero-actions {
    align-items: stretch;
  }

  .post-row-link {
    grid-template-columns: 1fr;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .chapter-nav-link,
  .chapter-nav-link.is-next {
    max-width: none;
    justify-items: start;
    text-align: left;
  }
}
