/* ---------- Docs page ---------- */
.docs-hero {
  max-width: var(--max); margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) var(--gutter) clamp(40px, 6vw, 72px);
}
.docs-hero h1 {
  font-size: clamp(3rem, 8vw, 6.4rem); font-weight: 800; font-stretch: 78%;
  letter-spacing: -.035em; line-height: .9;
  color: var(--butter); text-shadow: 5px 5px 0 var(--ink);
}
.docs-hero p { margin-top: 20px; max-width: 34em; font-size: 1.2rem; color: #e6e9ff; }

.docs-layout {
  background: var(--paper); color: var(--ink);
  border-top: var(--border);
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 88px);
  padding: 0 max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
}

/* TOC */
.docs-toc { padding: 48px 0; }
.toc { position: sticky; top: 24px; display: grid; gap: 2px; }
.toc-group {
  margin: 18px 0 6px; font: 700 1rem/1.2 var(--display); font-stretch: 88%; color: var(--ink);
}
.toc-group:first-child { margin-top: 0; }
.toc a {
  text-decoration: none; color: var(--muted);
  padding: 6px 12px; margin-left: -12px; border-radius: 10px;
  border: 2px solid transparent;
}
.toc a:hover { color: var(--ink); background: #eef0ff; }
.toc a.is-active { color: var(--ink); font-weight: 600; background: var(--butter); border-color: var(--ink); }
.docs-page :focus-visible { outline-color: var(--cobalt); }
.docs-page .nav :focus-visible, .docs-page .footer :focus-visible { outline-color: var(--butter); }

/* Content */
.docs-content { padding: 48px 0 96px; max-width: 46rem; }
.docs-content section { padding-top: 8px; scroll-margin-top: 16px; }
.docs-content section + section { margin-top: 64px; }
.docs-content h2 {
  font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; font-stretch: 82%; letter-spacing: -.025em;
  margin-bottom: 18px;
}
.docs-content h3 { font-size: 1.3rem; font-stretch: 90%; margin: 28px 0 8px; }
.docs-content p { margin-top: 14px; line-height: 1.7; color: #1c1f3d; }
.docs-content h3 + p, .docs-content h2 + p { margin-top: 0; }
.docs-content ul { margin: 14px 0 0; padding-left: 1.2em; line-height: 1.7; color: #1c1f3d; }
.docs-content li + li { margin-top: 6px; }
.docs-content li::marker { color: var(--cobalt); }
.docs-content a { color: var(--cobalt); text-underline-offset: 3px; }
.docs-content code {
  font: 500 .9em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eef0ff; padding: 2px 6px; border-radius: 6px;
}

.formula {
  margin: 18px 0 0; padding: 16px 18px; overflow-x: auto;
  background: var(--cobalt); color: var(--paper);
  border: var(--border); border-radius: 14px; box-shadow: var(--hard-sm);
}
.formula code { background: none; padding: 0; color: inherit; font-size: .95rem; white-space: pre-wrap; }

.callout {
  margin-top: 24px; padding: 16px 18px;
  background: #eef0ff; border: 2.5px solid var(--ink); border-radius: 16px;
}
.callout strong { font: 700 1.05rem/1.2 var(--display); }
.callout p { margin-top: 4px; }
.callout-warn { background: #ffe1ef; }

/* Real sequence, so numbered */
.doc-steps { list-style: none; counter-reset: s; margin: 8px 0 0; padding: 0; }
.doc-steps li {
  counter-increment: s; position: relative;
  padding: 0 0 22px 60px; margin: 0;
}
.doc-steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--butter); border: 2.5px solid var(--ink); border-radius: 50%;
  font: 800 1.2rem/1 var(--display);
}
.doc-steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 19px; top: 44px; bottom: 4px; width: 2.5px; background: var(--ink);
}
.doc-steps h3 { margin: 8px 0 4px; }
.doc-steps p { margin-top: 0; }

/* Tables */
.docs-content table {
  width: 100%; margin-top: 22px; border-collapse: separate; border-spacing: 0;
  border: 2.5px solid var(--ink); border-radius: 16px; overflow: hidden;
  font-size: .96rem;
}
.docs-content caption { text-align: left; font: 700 1.05rem/1.2 var(--display); padding-bottom: 10px; }
.docs-content th, .docs-content td { padding: 12px 14px; text-align: left; vertical-align: top; }
.docs-content tr + tr > * { border-top: 1.5px solid #d7dbf5; }
.docs-content thead th { background: var(--ink); color: var(--paper); font-weight: 600; }
.docs-content tbody th { font-weight: 600; width: 34%; }

/* Glossary */
.glossary { margin: 8px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 0 24px; }
.glossary dt, .glossary dd { padding: 12px 0; border-top: 1.5px solid #d7dbf5; }
.glossary dt { font: 700 1.1rem/1.3 var(--display); font-stretch: 90%; }
.glossary dd { margin: 0; color: #1c1f3d; }

.docs-end {
  margin-top: 72px; padding: 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  background: var(--bubble); border: var(--border); border-radius: 22px; box-shadow: var(--hard);
}
.docs-end p { margin: 0; font: 800 1.8rem/1 var(--display); font-stretch: 82%; color: var(--ink); }

.docs-page .footer { margin-top: 0; padding-top: 48px; border-top: 0; }

/* Responsive */
@media (max-width: 860px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .docs-toc { min-width: 0; }
  .docs-toc {
    position: sticky; top: 0; z-index: 5;
    margin: 0 calc(-1 * var(--gutter)); padding: 10px var(--gutter);
    background: var(--paper); border-bottom: 2px solid var(--ink);
  }
  .toc { position: static; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .toc::-webkit-scrollbar { display: none; }
  .toc-group { display: none; }
  .toc a { flex: none; margin: 0; white-space: nowrap; border-color: #d7dbf5; }
  .docs-content { padding-top: 32px; }
  .docs-content section { scroll-margin-top: 72px; }
}
@media (max-width: 560px) {
  .glossary { grid-template-columns: 1fr; }
  .glossary dd { border-top: 0; padding-top: 0; }
  .docs-content table { font-size: .88rem; }
  .docs-content th, .docs-content td { padding: 10px; }
}
