/* ============================================================
   docs.css — public documentation reader.
   Built on tokens.css (same palette/theme as the SPA). Layout:
   top bar + search, then a 3-column shell: left nav · content · TOC.
   ============================================================ */

.docs-body { background: var(--bg); color: var(--ink); }

.docs-skip {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.docs-skip:focus { left: 0; }

/* ---------- top bar ---------- */
.docs-topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.docs-topbar__inner {
  display: flex; align-items: center; gap: 18px;
  max-width: 1400px; margin: 0 auto; padding: 12px 22px;
}
.docs-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); flex: none; }
.docs-brand__mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #1B1A17;
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #fff 45%));
  box-shadow: var(--shadow-1);
}
.docs-brand__mark svg { width: 20px; height: 20px; }
.docs-brand__name { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 1.05rem; line-height: 1; display: flex; flex-direction: column; gap: 2px; }
.docs-brand__sub { font-family: "IBM Plex Mono", monospace; font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

.docs-rootnav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.docs-rootnav::-webkit-scrollbar { display: none; }
.docs-rootnav__link {
  text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .93rem;
  padding: 8px 13px; border-radius: var(--r-pill); white-space: nowrap; transition: background .15s ease, color .15s ease;
}
.docs-rootnav__link:hover { background: var(--sink); color: var(--ink); }
.docs-rootnav__link.is-active { background: var(--accent-tint); color: var(--accent-ink); }

.docs-topbar__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.docs-theme-moon { display: none; }
:root[data-theme="dark"] .docs-theme-sun { display: none; }
:root[data-theme="dark"] .docs-theme-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .docs-theme-sun { display: none; }
  :root:not([data-theme="light"]) .docs-theme-moon { display: inline; }
}

.docs-navtoggle { display: none; }

/* ---------- search bar ---------- */
.docs-searchbar { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.docs-search {
  position: relative; display: flex; align-items: center; gap: 10px;
  max-width: 1400px; margin: 0 auto; padding: 10px 22px;
}
.docs-search__icon { color: var(--muted); display: grid; place-items: center; flex: none; margin-left: 2px; }
.docs-search__input {
  flex: 1; border: none; background: transparent; font-size: 1rem; padding: 6px 4px; color: var(--ink);
}
.docs-search__input::placeholder { color: var(--muted); }
.docs-search__input:focus { outline: none; }
.docs-search__kbd {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: var(--radius-xs); padding: 2px 8px; background: var(--surface-2);
}
.docs-search__results {
  position: absolute; top: calc(100% - 2px); left: 22px; right: 22px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.docs-search__result { display: flex; flex-direction: column; gap: 2px; padding: 10px 16px; text-decoration: none; border-bottom: 1px solid var(--line); }
.docs-search__result:last-child { border-bottom: none; }
.docs-search__result:hover, .docs-search__result.is-active { background: var(--accent-tint); }
.docs-search__rsection { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.docs-search__rtitle { font-weight: 600; color: var(--ink); }
.docs-search__rsnippet { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-search__empty { padding: 16px; color: var(--muted); text-align: center; font-size: .9rem; }

/* ---------- shell grid ---------- */
.docs-shell {
  max-width: 1400px; margin: 0 auto; padding: 0 22px;
  display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 34px; align-items: start;
}
.docs-shell--with-toc { grid-template-columns: 264px minmax(0, 1fr) 232px; }

/* ---------- left sidebar ---------- */
.docs-sidebar { position: sticky; top: 118px; align-self: start; max-height: calc(100vh - 130px); }
.docs-sidebar__scroll { max-height: calc(100vh - 140px); overflow-y: auto; padding: 26px 8px 40px 0; scrollbar-width: thin; }
.docs-nav__root {
  display: block; text-decoration: none; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: 1.02rem; color: var(--ink); padding: 6px 12px; border-radius: var(--radius-xs); margin-bottom: 6px;
}
.docs-nav__root.is-active, .docs-nav__root:hover { background: var(--sink); }
.docs-nav__list { list-style: none; margin: 0; padding: 0; }
.docs-nav__list--top { margin-top: 4px; }
.docs-nav__group { margin: 2px 0; padding-left: calc(var(--depth, 0) * 12px); }
.docs-nav__grouphead { margin: 10px 0 3px; }
.docs-nav__grouplink {
  display: block; text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: .82rem;
  letter-spacing: .01em; padding: 4px 12px; border-radius: var(--radius-xs);
}
.docs-nav__group[style*="--depth: 0"] > .docs-nav__grouphead > .docs-nav__grouplink { text-transform: none; font-size: .86rem; }
.docs-nav__grouplink:hover { color: var(--ink); }
.docs-nav__grouphead.is-active .docs-nav__grouplink { color: var(--accent-ink); }
.docs-nav__item {
  display: block; text-decoration: none; color: var(--ink-2); font-size: .9rem; line-height: 1.35;
  padding: 6px 12px; border-radius: var(--radius-xs); border-left: 2px solid transparent; margin-left: 2px;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.docs-nav__item:hover { background: var(--surface); color: var(--ink); }
.docs-nav__item.is-active { background: var(--accent-tint); color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }
.docs-nav__empty { color: var(--muted); font-size: .86rem; padding: 8px 12px; }

/* ---------- main content ---------- */
.docs-main { min-width: 0; padding: 30px 0 80px; }
.doc-article { max-width: 780px; }

.doc-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); margin-bottom: 18px; }
.doc-breadcrumbs a { color: var(--muted); text-decoration: none; }
.doc-breadcrumbs a:hover { color: var(--accent-ink); }
.doc-breadcrumbs__sep { color: var(--line-2); }
.doc-breadcrumbs [aria-current="page"] { color: var(--ink-2); }

.doc-article__head { margin-bottom: 30px; }
.doc-article__title { font-size: 2.3rem; margin: 8px 0 0; }
.doc-article__lead { margin-top: 12px; max-width: 62ch; }

/* ---------- block content typography ---------- */
.doc-content { font-size: 1.02rem; line-height: 1.7; color: var(--ink-2); }
.doc-content > * + * { margin-top: 1.15em; }
.doc-content .doc-h { color: var(--ink); font-family: "Bricolage Grotesque", sans-serif; letter-spacing: -0.01em; scroll-margin-top: 130px; position: relative; }
.doc-content .doc-h--2 { font-size: 1.5rem; margin-top: 2em; padding-top: .3em; border-top: 1px solid var(--line); }
.doc-content .doc-h--3 { font-size: 1.18rem; margin-top: 1.6em; }
.doc-h__anchor { position: absolute; left: -1.1em; color: var(--line-2); text-decoration: none; opacity: 0; transition: opacity .12s ease; font-weight: 400; }
.doc-h:hover .doc-h__anchor { opacity: 1; }
.doc-h__anchor:hover { color: var(--accent); }

.doc-p { margin: 0; }
.doc-content a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--accent-tint-2); }
.doc-content a:hover { text-decoration-color: var(--accent); }
.doc-content code {
  font-family: "IBM Plex Mono", monospace; font-size: .87em; background: var(--sink);
  border: 1px solid var(--line); border-radius: var(--radius-xs); padding: .1em .4em;
}
.doc-content strong { color: var(--ink); font-weight: 700; }

.doc-list { padding-left: 1.4em; margin: 0; }
.doc-list li { margin: .4em 0; }
.doc-list--bullet li::marker { color: var(--accent); }
.doc-list--ordered li::marker { color: var(--accent-ink); font-weight: 600; }

/* ---------- figures / screenshots ---------- */
.doc-figure { margin: 0; }
.doc-figure--full { width: 100%; }
.doc-figure--wide { width: 100%; }
.doc-figure--inline { max-width: 420px; }
.doc-img {
  display: block; width: 100%; height: auto; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-2); background: var(--surface-2);
}
.doc-figure--wide .doc-img { width: min(100%, 900px); }
.doc-figcaption { margin-top: 8px; font-size: .84rem; color: var(--muted); text-align: center; }

/* Placeholder spot for a not-yet-uploaded screenshot (seeded doc image blocks). */
.doc-figure--placeholder {
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.doc-figure__ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 140px; padding: 40px 20px;
  color: var(--muted); font-size: .92rem; text-align: center;
}
.doc-figure__ph svg { opacity: .65; }

/* ---------- alert boxes ---------- */
.doc-alert {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); border-left-width: 3px;
}
.doc-alert__icon { flex: none; margin-top: 1px; }
.doc-alert__body { min-width: 0; }
.doc-alert__title { font-weight: 700; color: var(--ink); margin: 0 0 3px; }
.doc-alert__text { color: var(--ink-2); font-size: .96rem; line-height: 1.6; }
.doc-alert__text > * + * { margin-top: .6em; }
.doc-alert--info { border-left-color: #3B82F6; }
.doc-alert--info .doc-alert__icon { color: #3B82F6; }
.doc-alert--success { border-left-color: var(--good); background: var(--good-tint); }
.doc-alert--success .doc-alert__icon { color: var(--good); }
.doc-alert--warning { border-left-color: var(--accent); background: var(--accent-tint); }
.doc-alert--warning .doc-alert__icon { color: var(--accent-ink); }
.doc-alert--danger { border-left-color: var(--bad); background: var(--bad-tint); }
.doc-alert--danger .doc-alert__icon { color: var(--bad); }

/* ---------- numbered step boxes ---------- */
.doc-steps {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 6px 20px 18px;
  box-shadow: var(--shadow-1);
}
.doc-steps__title { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; color: var(--ink); margin: 16px 0 4px; }
.doc-steps__list { list-style: none; counter-reset: step; margin: 8px 0 0; padding: 0; }
.doc-step { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.doc-step:first-child { border-top: none; }
.doc-step__num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #1B1A17; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: .95rem; box-shadow: var(--shadow-1);
}
.doc-step__body { min-width: 0; padding-top: 2px; }
.doc-step__title { font-weight: 700; color: var(--ink); margin: 0 0 3px; }
.doc-step__text { color: var(--ink-2); font-size: .97rem; line-height: 1.6; }
.doc-step__text > * + * { margin-top: .5em; }

/* ---------- code block ---------- */
.doc-code { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line-2); background: var(--sink); }
.doc-code__lang { position: absolute; top: 8px; right: 12px; font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.doc-code__pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.doc-code__pre code { font-family: "IBM Plex Mono", monospace; font-size: .86rem; line-height: 1.6; background: none; border: none; padding: 0; color: var(--ink); }

/* ---------- quote ---------- */
.doc-quote { margin: 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent-tint-2); color: var(--ink-2); }
.doc-quote__body { font-size: 1.05rem; font-style: italic; }
.doc-quote__cite { display: block; margin-top: 8px; font-size: .85rem; color: var(--muted); font-style: normal; }

.doc-divider { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

/* ---------- pager ---------- */
.doc-pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.doc-pager__link { display: flex; flex-direction: column; gap: 3px; text-decoration: none; padding: 12px 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); max-width: 48%; transition: border-color .15s ease, background .15s ease; }
.doc-pager__link:hover { border-color: var(--accent); background: var(--surface); }
.doc-pager__link--next { text-align: right; margin-left: auto; }
.doc-pager__dir { font-size: .8rem; color: var(--muted); }
.doc-pager__title { font-weight: 600; color: var(--ink); }

/* ---------- right TOC ---------- */
.docs-toc { position: sticky; top: 118px; align-self: start; max-height: calc(100vh - 130px); overflow-y: auto; padding: 30px 0; }
.docs-toc__label { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.docs-toc__list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.docs-toc__item a { display: block; text-decoration: none; color: var(--muted); font-size: .85rem; line-height: 1.4; padding: 5px 12px; margin-left: -1px; border-left: 2px solid transparent; transition: color .12s ease, border-color .12s ease; }
.docs-toc__item--l3 a { padding-left: 24px; font-size: .82rem; }
.docs-toc__item a:hover { color: var(--ink); }
.docs-toc__item a.is-active { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }

/* ---------- section index + home cards ---------- */
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 6px; }
.doc-card { position: relative; display: flex; flex-direction: column; gap: 5px; text-decoration: none; padding: 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease; }
.doc-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.doc-card__title { font-weight: 700; color: var(--ink); }
.doc-card__desc { font-size: .88rem; color: var(--muted); line-height: 1.45; }
.doc-card__count { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; color: var(--accent-ink); }
.doc-section-index__sub { font-family: "Bricolage Grotesque", sans-serif; font-size: 1.2rem; color: var(--ink); margin: 34px 0 4px; }

.doc-home { max-width: 100%; }
.doc-home__hero { margin-bottom: 34px; }
.doc-home__title { font-size: 2.6rem; margin: 8px 0 0; }
.doc-home__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 28px; }
.doc-home__colhead { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 1.1rem; }
.doc-home__colicon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent-ink); border: 1px solid var(--accent-tint-2); flex: none; }
.doc-home__coldesc { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
.doc-home__links { list-style: none; margin: 12px 0 0; padding: 0; }
.doc-home__links li { margin: 2px 0; }
.doc-home__links a { display: block; text-decoration: none; color: var(--ink-2); font-size: .93rem; padding: 5px 10px; border-radius: var(--radius-xs); }
.doc-home__links a:hover { background: var(--sink); color: var(--ink); }

/* ---------- search page + results ---------- */
.doc-results { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.doc-result__link { display: flex; flex-direction: column; gap: 3px; text-decoration: none; padding: 16px 18px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s ease; }
.doc-result__link:hover { border-color: var(--accent); }
.doc-result__section { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.doc-result__title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.doc-result__snippet { color: var(--muted); font-size: .9rem; line-height: 1.5; }

/* ---------- scrim (mobile) ---------- */
.docs-scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .docs-shell--with-toc { grid-template-columns: 240px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 1000px) {
  .docs-navtoggle { display: inline-flex; order: -1; }
  .docs-shell, .docs-shell--with-toc { grid-template-columns: minmax(0, 1fr); }
  .docs-rootnav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .docs-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 300px; max-height: none; z-index: 55;
    background: var(--surface); border-right: 1px solid var(--line-2); box-shadow: var(--shadow-drawer);
    transform: translateX(-100%); transition: transform .22s ease; padding-top: 12px;
  }
  .docs-sidebar__scroll { max-height: 100vh; padding: 12px 12px 40px; }
  body.docs-nav-open .docs-sidebar { transform: translateX(0); }
  body.docs-nav-open .docs-scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); border: none; }
  .docs-main { padding: 22px 0 60px; }
  .doc-article__title { font-size: 1.9rem; }
}
@media (max-width: 560px) {
  .docs-topbar__inner { padding: 10px 14px; gap: 12px; }
  .docs-search { padding: 10px 14px; }
  .docs-shell { padding: 0 14px; }
  .docs-search__kbd { display: none; }
  .docs-applink { display: none; }
  .doc-pager { flex-direction: column; }
  .doc-pager__link { max-width: 100%; }
  .doc-pager__link--next { text-align: left; }
}
