/* ---------- page skeleton: sidebar + one reading column ---------- */
.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  width: 100%;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter) 4rem;
}

/* ---------- table of contents ---------- */
.toc {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 1.6rem 1rem 2rem 1.4rem;
  border-right: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--sans);
}
.toc-title {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 1.2rem;
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { margin: 0; }
.toc-list a {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.42rem 0.7rem;
  margin: 0 -0.7rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.toc-list a:hover { background: #f0ece3; color: var(--ink); }
.toc-list a.active {
  color: var(--ink);
  font-weight: 600;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.toc-num { min-width: 1.2em; color: var(--accent); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.toc-gap { height: 0.5rem; }

/* ---------- reading progress bar ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; background: transparent; }
.progress-bar { height: 100%; width: 0; background: var(--accent); }

/* ---------- title block ---------- */
.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 1.4rem; }
.hero h1 {
  font-size: clamp(2.2rem, 1.5rem + 3.2vw, 3.6rem);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 1.1rem;
}
.authors { font-size: 1.1rem; margin: 0 0 0.2rem; }
.authors a { color: var(--ink); text-decoration-color: #b9b3a6; }
.affiliation { margin: 0; color: var(--muted); font-size: 0.98rem; }

.callout {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.55;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.9rem 1.1rem;
  margin: 0.5rem 0 1rem;
}

/* ---------- sections ---------- */
.section { padding: 3rem 0 1.2rem; border-top: 1px solid var(--line); scroll-margin-top: 1.5rem; }
.section:first-child { border-top: none; }
.loading { color: var(--muted); font-family: var(--sans); }
.footer { margin-top: 3rem; font-family: var(--sans); font-size: 0.9rem; }

/* ---------- narrow screens: the table of contents becomes a slide-in menu ---------- */
.topbar, .toc-backdrop { display: none; }

@media (max-width: 1000px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 0.9rem;
    position: sticky; top: 0; z-index: 50;
    height: 52px; padding: 0 var(--gutter);
    background: var(--bg); border-bottom: 1px solid var(--line);
    font-family: var(--sans);
  }
  .topbar-title { font-family: var(--serif); font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-button {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font: 500 0.88rem var(--sans);
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: 8px;
    padding: 0.4rem 0.7rem; cursor: pointer;
  }
  .menu-icon, .menu-icon::before, .menu-icon::after {
    display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; position: relative;
  }
  .menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
  .menu-icon::before { top: -5px; }
  .menu-icon::after { top: 5px; }

  .toc {
    position: fixed; z-index: 70; top: 0; left: 0; bottom: 0;
    width: min(320px, 86vw); height: 100vh; height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.18);
  }
  .toc:not(.open) { box-shadow: none; }
  .toc.open { transform: translateX(0); }
  .toc-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(20, 20, 20, 0.35); }
  .toc-backdrop.show { display: block; }
  .section { scroll-margin-top: 70px; }
}
@media (prefers-reduced-motion: reduce) { .toc { transition: none; } }
.affiliation a { color: inherit; text-decoration-color: #b9b3a6; }
.affiliation a:hover { color: var(--accent); }
