/* Docs layout on top of site.css: sidebar, content, table of contents, search, tabs, callouts, endpoints. */
.docs-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr) 216px; gap: 40px; max-width: 1440px; margin: 0 auto; padding: 0 var(--gutter); }
.docs-sidebar { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding: 28px 0 40px; }
.docs-sidebar h2 { font: 600 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px 12px; }
.docs-sidebar h2:first-child { margin-top: 0; }
.docs-sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.docs-sidebar a { display: block; padding: 8px 12px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.docs-sidebar a:hover { color: var(--text); background: var(--surface); }
.docs-sidebar a[aria-current='page'] { color: var(--text); background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
[data-theme='light'] .docs-sidebar a[aria-current='page'] { box-shadow: inset 3px 0 0 var(--text); }
.search-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font: 500 14px/1 var(--font-sans); cursor: pointer; margin-bottom: 20px; }
.search-btn svg { width: 16px; height: 16px; flex: none; }
.search-btn kbd { margin-left: auto; font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }

.docs-main { min-width: 0; padding: 28px 0 80px; }
.docs-main > article { max-width: 780px; }
.page-api .docs-main > article { max-width: none; }
.crumbs { font: 500 13px/1.4 var(--font-mono); color: var(--muted); margin-bottom: 18px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li + li::before { content: '/'; margin-right: 6px; opacity: .6; }
.crumbs a { color: var(--muted); }
.docs-main h1 { font-family: var(--font-display); font-weight: 800; font-stretch: 115%; letter-spacing: -0.02em; font-size: clamp(34px, 5vw, 52px); line-height: 1.04; margin-bottom: 16px; overflow-wrap: anywhere; }
.lead { font-size: 18px; color: var(--muted); max-width: 680px; }
.docs-main h2 { font-family: var(--font-display); font-weight: 800; font-stretch: 110%; font-size: 26px; margin: 56px 0 14px; scroll-margin-top: 84px; }
.docs-main h3 { font-size: 18px; margin: 32px 0 10px; scroll-margin-top: 84px; }
.docs-main h2, .docs-main h3 { position: relative; overflow-wrap: anywhere; }
.anchor { margin-left: 8px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 500; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
.docs-main p, .docs-main li { line-height: 1.65; }
.docs-main ul, .docs-main ol { padding-left: 22px; }
.docs-main a { color: var(--text); text-decoration-color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
[data-theme='light'] .docs-main a { text-decoration-color: var(--text); }
.docs-main table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0 24px; display: block; overflow-x: auto; }
.docs-main th, .docs-main td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.docs-main th { font-weight: 600; color: var(--muted); white-space: nowrap; }
.docs-main td code { white-space: nowrap; }
.docs-main pre code { background: none; padding: 0; font-size: inherit; }
pre { max-width: 100%; }

.docs-toc { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding: 32px 0; font-size: 13px; }
.docs-toc h2 { font: 600 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-left: 1px solid var(--line); }
.docs-toc a { display: block; padding: 5px 12px; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--text); border-left-color: var(--accent); }
[data-theme='light'] .docs-toc a.active { border-left-color: var(--text); }
.docs-toc .lvl3 a { padding-left: 24px; }

.page-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.page-meta a { color: var(--muted); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.pager a { display: block; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-card); text-decoration: none; background: var(--surface); }
.pager a:hover { border-color: var(--muted); }
.pager small { display: block; font: 500 12px/1 var(--font-mono); color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .08em; }
.pager .next { text-align: right; grid-column: 2; }

/* Callouts */
.callout { border: 1px solid var(--line); border-left-width: 4px; border-radius: 16px; padding: 14px 18px; margin: 18px 0 24px; background: var(--surface); }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; font: 600 12px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.callout.note { border-left-color: var(--cyan); }
.callout.warning { border-left-color: var(--owe); }
.callout.testnet { border-left-color: var(--accent); }
[data-theme='light'] .callout.note { border-left-color: #0a6e7a; }
[data-theme='light'] .callout.testnet { border-left-color: #0b0b0d; }

/* Badges */
.badge { display: inline-block; font: 700 11px/1 var(--font-mono); letter-spacing: .06em; padding: 5px 8px; border-radius: 999px; vertical-align: middle; color: #0b0b0d; }
.m-get { background: var(--owed); }
.m-post { background: var(--accent); }
.m-patch, .m-put { background: var(--cyan); }
.m-delete { background: var(--owe); }
[data-theme='light'] .m-get { background: #0b7a4b; color: #fff; }
[data-theme='light'] .m-delete { background: #c8104f; color: #fff; }
[data-theme='light'] .m-post { background: #d4ff3f; outline: 1px solid #0b0b0d33; }
[data-theme='light'] .m-patch { background: #7cf5ff; outline: 1px solid #0b0b0d33; }
.planned { display: inline-block; font: 600 11px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; border: 1px dashed var(--muted); color: var(--muted); vertical-align: middle; margin-left: 6px; }

/* Code tabs */
.tabs { margin: 0 0 1.2em; }
.tablist { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tablist button { font: 500 13px/1 var(--font-sans); padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.tablist button[aria-selected='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab-panel[hidden] { display: none; }
.tab-panel pre { margin-bottom: 0; }

/* Endpoints */
.endpoint { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 40px; }
.endpoint h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font: 600 16px/1.4 var(--font-mono); margin-top: 24px; }
.endpoint h3 .path { overflow-wrap: anywhere; }
.ep-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 32px; }
.ep-label { font: 600 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
@media (min-width: 1360px) { .ep-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* Syntax colours */
.tk-s { color: #b6e86b; } .tk-n { color: #ffb86b; } .tk-k { color: #7cf5ff; } .tk-c { color: var(--muted); font-style: italic; } .tk-p { color: #c9a8ff; }
[data-theme='light'] .tk-s { color: #2f6b00; } [data-theme='light'] .tk-n { color: #9a4a00; } [data-theme='light'] .tk-k { color: #005f73; } [data-theme='light'] .tk-p { color: #6b3fb3; }

/* Diagram */
.diagram { margin: 20px 0 28px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); overflow-x: auto; }
.diagram svg { min-width: 640px; width: 100%; height: auto; }
.diagram .box { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.diagram .box.hi { stroke: var(--accent); }
[data-theme='light'] .diagram .box.hi { stroke: #0b0b0d; }
.diagram text { fill: var(--text); font: 600 14px var(--font-sans); }
.diagram text.sub { fill: var(--muted); font: 500 11px var(--font-mono); }
.diagram .arrow { stroke: var(--muted); stroke-width: 1.5; fill: none; marker-end: url(#ah); }
.diagram .arrow.dash { stroke-dasharray: 5 4; }
.diagram marker path { fill: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 24px; }
.cards a { display: block; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); text-decoration: none; }
.cards a:hover { border-color: var(--muted); }
.cards strong { display: block; margin-bottom: 4px; }
.cards span { color: var(--muted); font-size: 14px; }
.day { font-family: var(--font-display); }

/* Search modal */
.search-modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55); display: none; padding: 10vh var(--gutter) 0; }
.search-modal.open { display: block; }
.search-panel { max-width: 640px; margin: 0 auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.search-panel input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: 500 17px/1 var(--font-sans); padding: 18px 20px; outline: none; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 60vh; overflow-y: auto; }
.search-results a { display: block; padding: 10px 12px; border-radius: 12px; text-decoration: none; }
.search-results a:hover, .search-results a.sel { background: var(--surface); }
.search-results small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.search-results .r-page { font: 500 11px/1 var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.search-empty { padding: 16px 20px; color: var(--muted); }

/* Drawer toggle */
.sidebar-btn { display: none; align-items: center; gap: 8px; margin: 16px 0 0; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 500 14px/1 var(--font-sans); cursor: pointer; }

@media (max-width: 1199px) {
  .docs-shell { grid-template-columns: 232px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 959px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar-btn { display: inline-flex; }
  .docs-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); max-height: none; z-index: 150; background: var(--bg); border-right: 1px solid var(--line); padding: 20px 16px; transform: translateX(-105%); transition: transform .2s ease; }
  .docs-sidebar.open { transform: none; }
  .drawer-scrim { position: fixed; inset: 0; z-index: 140; background: rgba(0,0,0,.5); display: none; }
  .drawer-scrim.open { display: block; }
  .cards { grid-template-columns: 1fr; }
  .site-header .nav a[data-wide] { display: none; }
}
@media (max-width: 640px) {
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .docs-main h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .docs-sidebar { transition: none; } }
.drawer-scrim { display: none; }
.brand { white-space: nowrap; }
.docs-main :not(pre) > code { overflow-wrap: anywhere; }
.docs-main td code { white-space: normal; overflow-wrap: normal; }
@media (max-width: 959px) { .drawer-scrim.open { display: block; } }
@media (max-width: 480px) { .brand .tag { display: none; } .brand { font-size: 16px; } }
.docs-main .crumbs ol { padding-left: 0; }
