/* Docs: sections rail | article | on this page. Rails become a drawer below 1100px. */
.search-btn { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 12px; border: 0; border-radius: var(--r-full); background: var(--surface-high); color: var(--on-surface-variant); font: var(--label-l); cursor: pointer; margin-left: 8px; transition: background .2s; }
.search-btn:hover { background: var(--surface-highest); }
.search-btn kbd, .search-hint kbd { font: 500 12px/20px var(--font); padding: 0 6px; border-radius: 6px; background: var(--surface-c); color: var(--on-surface-variant); box-shadow: inset 0 0 0 1px var(--outline-variant); }
@media (max-width: 1080px) { .search-btn .search-label, .search-btn kbd { display: none; } .search-btn { padding: 0; width: 40px; justify-content: center; background: transparent; } }

.docs-bar { display: none; align-items: center; gap: 16px; padding-block: 4px 12px; }
.docs-bar-current { font: var(--label-l); color: var(--on-surface-variant); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.docs-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr) 216px; gap: 48px; align-items: start; }
.side-in { position: sticky; top: calc(64px + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 64px - env(safe-area-inset-top, 0px)); overflow-y: auto; padding-block: 24px 32px; scrollbar-width: thin; }
.side-title { font: var(--label-l); letter-spacing: .06em; text-transform: uppercase; color: var(--on-surface-variant); padding: 0 16px 8px; }
.toc, .toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.toc a { display: block; padding: 8px 16px; border-radius: var(--r-full); text-decoration: none; font: var(--label-l); color: var(--on-surface-variant); transition: background .3s var(--effects), color .3s var(--effects); }
.toc a:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); color: var(--on-surface); }
.toc a.level-3 { padding-left: 32px; font: var(--body-m); }
.toc li > ul { display: none; padding-block: 2px 6px; }
.toc li.open > ul { display: grid; }
.toc a.active { background: var(--secondary-container); color: var(--on-secondary-container); }
#onPage a { transition: color .3s var(--effects), border-color .3s var(--effects); display: block; padding: 6px 12px; border-left: 2px solid var(--outline-variant); text-decoration: none; font: var(--body-m); color: var(--on-surface-variant); }
#onPage a.lv4 { padding-left: 24px; }
#onPage a:hover { color: var(--on-surface); }
#onPage a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 500; }
#onPage:empty::after { content: "No subsections"; display: block; padding: 6px 12px; font: var(--body-m); color: var(--on-surface-variant); }

.docs-main { min-width: 0; padding-bottom: 32px; }
.docs-hero { display: grid; gap: 16px; padding-block: 40px 32px; border-bottom: 1px solid var(--outline-variant); margin-bottom: 8px; justify-items: start; }
.docs-hero .kicker { font: var(--label-l); letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.docs-hero h1 { font: var(--display-l); font-size: clamp(36px, 4.6vw, 52px); letter-spacing: -0.02em; }
.docs-hero p { font-size: 18px; line-height: 28px; color: var(--on-surface-variant); max-width: 40em; }

.prose { max-width: 78ch; font: var(--body-l); font-size: 16px; line-height: 26px; }
.prose > * + * { margin-top: 16px; }
.prose h2 { font: 500 28px/36px var(--font); margin-top: 48px; scroll-margin-top: 96px; letter-spacing: -0.01em; }
.prose h3 { font: var(--title-l); margin-top: 36px; scroll-margin-top: 96px; }
.prose h4 { font: var(--title-m); font-size: 17px; margin-top: 28px; scroll-margin-top: 96px; }
.prose hr { border: 0; height: 1px; background: var(--outline-variant); margin-block: 48px 0; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li + li { margin-top: 6px; }
.prose li > ul, .prose li > ol { margin-top: 6px; }
.prose a { color: var(--primary); text-underline-offset: 2px; }
.prose strong { font-weight: 600; }
.prose .anchor { margin-left: 8px; opacity: 0; text-decoration: none; color: var(--on-surface-variant); font-weight: 400; transition: opacity .15s; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor, .prose .anchor:focus-visible { opacity: 1; }
.prose :not(pre) > code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; padding: 2px 6px; border-radius: 6px; background: var(--surface-high); overflow-wrap: anywhere; }
.prose pre { position: relative; margin-top: 16px; background: var(--surface-c); border-radius: 16px; padding: 16px 20px; overflow-x: auto; font: 400 13.5px/21px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; scrollbar-width: thin; }
.prose pre code { font: inherit; background: none; padding: 0; }
.copy { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 0; border-radius: var(--r-full); display: grid; place-items: center; background: var(--surface-high); color: var(--on-surface-variant); cursor: pointer; opacity: 0; transition: opacity .15s, border-radius .3s var(--spring), background .2s; }
.copy .ms { font-size: 18px; }
.prose pre:hover .copy, .copy:focus-visible, .copy.done { opacity: 1; }
.copy.done { background: var(--primary-container); color: var(--on-primary-container); border-radius: 12px; }
@media (hover: none) { .copy { opacity: 1; } }
.table-wrap { overflow-x: auto; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.prose table { border-collapse: collapse; width: 100%; font: var(--body-m); }
.prose th { text-align: left; font-weight: 500; background: var(--surface-c); color: var(--on-surface-variant); }
.prose th, .prose td { padding: 10px 16px; border-bottom: 1px solid var(--outline-variant); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.callout { display: flex; gap: 12px; margin-inline: 0; padding: 16px 20px; border-radius: 16px; background: var(--tertiary-container); color: var(--on-tertiary-container); }
.callout > .ms { font-size: 20px; margin-top: 3px; }
.callout > div { min-width: 0; } .callout p { margin: 0; } .callout p + p { margin-top: 8px; }
.callout code { background: color-mix(in srgb, currentColor 12%, transparent) !important; }

/* Code colors from the scheme */
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-meta { color: var(--primary); font-weight: 500; }
.hljs-string, .hljs-regexp, .hljs-symbol { color: var(--tertiary); }
.hljs-number, .hljs-literal { color: var(--tertiary); font-weight: 500; }
.hljs-attr, .hljs-property, .hljs-variable, .hljs-params { color: var(--on-surface); }
.hljs-attr { color: var(--primary); }
.hljs-title, .hljs-title.function_, .hljs-function { color: var(--on-surface); font-weight: 600; }
.hljs-comment, .hljs-quote { color: var(--on-surface-variant); font-style: italic; }

/* Search view */
.search { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, #000 40%, transparent); display: grid; align-items: start; justify-items: center; padding: calc(10vh + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.search-panel { width: min(640px, 100%); background: var(--surface-high); color: var(--on-surface); border-radius: 28px; overflow: hidden; box-shadow: 0 8px 24px rgb(0 0 0 / .25); animation: pop .45s var(--emph-decel) both; transform-origin: top center; }
.search { animation: fade .25s var(--effects) both; }
.search.closing { animation: fade-out .18s var(--emph-accel) both; }
.search.closing .search-panel { animation: pop-out .18s var(--emph-accel) both; }
@keyframes pop { from { transform: scale(.94) translateY(-12px); opacity: 0; } }
@keyframes pop-out { to { transform: scale(.97) translateY(-6px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.scrim { transition: opacity .3s var(--effects); }
.scrim.shown { opacity: 1; } .scrim:not(.shown) { opacity: 0; }
.search-field { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 8px 0 20px; border-bottom: 1px solid var(--outline-variant); }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; color: inherit; font: var(--body-l); font-size: 17px; outline: none; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.search-results a { display: grid; gap: 2px; padding: 12px 16px; border-radius: 16px; text-decoration: none; }
.search-results a b { font: var(--title-m); }
.search-results a small { font: var(--body-m); color: var(--on-surface-variant); }
.search-results a mark { background: none; color: var(--primary); }
.search-results a.sel, .search-results a:hover { background: var(--secondary-container); color: var(--on-secondary-container); }
.search-results .empty { padding: 24px 16px; color: var(--on-surface-variant); }
.search-hint { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 12px 24px 16px; font: var(--body-m); color: var(--on-surface-variant); border-top: 1px solid var(--outline-variant); }
.search-hint kbd { margin-right: 4px; }
.scrim { position: fixed; inset: 0; z-index: 39; background: color-mix(in srgb, #000 40%, transparent); }

@media (max-width: 1279px) { .docs-shell { grid-template-columns: 248px minmax(0, 1fr); gap: 40px; } .docs-onpage { display: none; } }
@media (max-width: 1099px) {
  .docs-bar { display: flex; }
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .docs-side { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); background: var(--surface-low); border-radius: 0 28px 28px 0; transform: translateX(-104%); transition: transform .45s var(--emph-decel); padding-left: env(safe-area-inset-left, 0px); }
  .docs-side.open { transform: none; }
  .docs-side .side-in { position: static; max-height: 100%; height: 100%; padding: calc(24px + env(safe-area-inset-top, 0px)) 12px 24px; }
  .docs-hero { padding-block: 16px 24px; }
}
@media (max-width: 400px) { .search-btn { margin-left: 0; } }
