* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--fp-text);
  background: var(--fp-bg);
  font-family: var(--fp-font-sans);
  font-size: var(--fp-size-base);
  line-height: var(--fp-leading);
}

#main-content {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  box-sizing: content-box;
  max-width: var(--fp-col-width);
  margin: 0 auto;
  padding: 2em 2em 4em 3em;
  overflow-wrap: break-word;
  flex: 1;
}

.fp-shell-footer {
  position: sticky;
  bottom: 0;
  z-index: 110;
}

html { scroll-padding-top: calc(var(--fp-header-h) + 1rem); }
.fp-shell-header { position: sticky; top: 0; z-index: 300; }
.has-toc:not(.toc-collapsed) #main-content {
  margin-left: max(var(--fp-nav-width), calc((100vw - var(--fp-col-width)) / 2));
  margin-right: 0;
}
#site-sidebar {
  position: fixed;
  top: var(--fp-header-h);
  bottom: 36px;
  left: 0;
  width: var(--fp-nav-width);
  overflow-y: auto;
  padding: 1em 0;
  background: var(--fp-surface);
  border-right: 1px solid var(--fp-border);
  z-index: 100;
  scrollbar-width: thin;
}
.toc-title {
  display: flex;
  justify-content: space-between;
  padding-bottom: 0.8em;
  margin-bottom: 0.5em;
  border-bottom: 1px solid var(--fp-border);
  color: var(--fp-text-strong);
  font-size: 0.9em;
  font-weight: 700;
  line-height: 1.4;
}
.toc-title > span { padding-left: 1em; }
#toc-close {
  padding: 0 0.6em;
  border: 0;
  border-left: 1px solid var(--fp-border);
  background: none;
  color: var(--fp-text-muted);
  font-size: 1.1em;
  cursor: pointer;
}
#site-sidebar ul { list-style: none; margin: 0; padding: 0; }
#site-sidebar li + li { border-top: 1px solid var(--fp-border-light); }
#site-sidebar a {
  display: block;
  padding: 0.45em 1em;
  border-left: 3px solid transparent;
  color: var(--fp-text);
  font-size: 0.85em;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
}
#site-sidebar .toc-level-3 a { padding-left: 2em; color: var(--fp-text-muted); }
#site-sidebar a:hover { color: var(--fp-accent); }
#site-sidebar a[aria-current] {
  color: var(--fp-accent);
  border-left-color: var(--fp-accent);
  background: var(--fp-active-bg);
  font-weight: 600;
}
#toc-toggle {
  position: fixed;
  top: calc(var(--fp-header-h) + 0.5em);
  left: 0.5em;
  z-index: 200;
  padding: 0.3em 0.6em;
  border: 1px solid var(--fp-border);
  border-radius: 8px;
  background: var(--fp-surface);
  color: var(--fp-text);
  font-size: 1.2em;
  cursor: pointer;
}
#toc-backdrop {
  position: fixed;
  inset: var(--fp-header-h) 0 0;
  z-index: 90;
  border: 0;
  background: rgb(0 0 0 / 30%);
}

.fp-prose h1,
.fp-prose h2,
.fp-prose h3 {
  color: var(--fp-text-strong);
  line-height: var(--fp-leading-ui);
}

.fp-prose h1 {
  margin: 0 0 var(--fp-rhythm);
  font-size: var(--fp-size-h1);
}

.fp-prose h2 {
  margin: 2em 0 0.6em;
  font-size: var(--fp-size-h2);
}

.fp-prose h3 {
  font-size: var(--fp-size-h3);
}

.fp-prose :where(p, ul, ol, pre, table) {
  margin-block: var(--fp-rhythm);
}

.fp-prose :where(p, ul, ol) { margin-block: 1em; }
.fp-prose :where(ul, ol) > li { margin-bottom: 0.25em; }

.fp-prose :where(ul, ol) {
  padding-left: 2.5em;
}

@media (max-width: 60em) {
  #site-sidebar { max-width: calc(100% - 3.5rem); bottom: 0; }

  #main-content,
  .has-toc:not(.toc-collapsed) #main-content {
    margin-inline: 0;
    padding: 3.5em 1.2em 2em;
  }

  .fp-shell-footer {
    position: static;
  }
}
