:root {
  --sidebar-w: 320px;
  --toc-w: 260px;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.main-column {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 20;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 24px;
  align-items: start;
}

.content {
  min-width: 0;
}

.toc {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

@media (max-width: 1280px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
    max-height: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: 0;
    overflow: hidden;
    transition: max-height 240ms ease;
  }

  .app-shell[data-sidebar-open="true"] .sidebar {
    max-height: 70vh;
  }
}
