:root {
    --ink: #172033;
    --muted: #5d687a;
    --line: #dde3ec;
    --soft: #f5f7fb;
    --panel: #ffffff;
    --brand: #5b3fd6;
    --brand-dark: #4027ad;
    --brand-soft: #f0edff;
    --teal: #0f766e;
    --teal-soft: #ecfdf8;
    --warn: #9a3412;
    --warn-soft: #fff7ed;
    --blue: #1d4ed8;
    --blue-soft: #eff6ff;
    --shadow: 0 12px 30px rgba(35, 45, 75, .08);
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 92px; }
body { margin: 0; color: var(--ink); background: var(--soft); font-family: var(--font); line-height: 1.65; }
a { color: var(--brand-dark); text-underline-offset: 3px; }
a:hover { color: var(--brand); }
img, svg { max-width: 100%; }
button, input { font: inherit; }
code { padding: .12em .35em; border-radius: 5px; background: #edf0f6; font-size: .92em; }
pre { position: relative; overflow: auto; margin: 18px 0; padding: 20px; color: #e8edf7; background: #111827; border-radius: 14px; }
pre code { padding: 0; color: inherit; background: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; left: 12px; top: -80px; padding: 9px 13px; color: var(--ink); background: #fff; border: 2px solid var(--brand); border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar { position: sticky; z-index: 50; top: 0; display: grid; grid-template-columns: 310px minmax(280px, 660px) 1fr; align-items: center; gap: 22px; min-height: 72px; padding: 10px 22px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar__right { justify-content: flex-end; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand__logo { display: grid; width: 38px; height: 38px; place-items: center; color: #fff; background: linear-gradient(145deg, #684cf0, #4526b8); border-radius: 11px; font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.brand__text { display: grid; line-height: 1.25; }
.brand__text small { color: var(--muted); font-size: 12px; }
.topbar__center { position: relative; }
.search { display: flex; align-items: center; width: 100%; min-height: 43px; padding: 0 12px 0 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 5px 18px rgba(40,50,80,.04); }
.search:focus-within { border-color: #a99af1; box-shadow: 0 0 0 3px rgba(91,63,214,.12); }
.search input { flex: 1; min-width: 0; padding: 9px 6px; color: var(--ink); background: transparent; border: 0; outline: 0; }
.search kbd { padding: 1px 6px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 5px; font-family: inherit; font-size: 10px; }
.search > span:not(.sr-only) { margin: 0 3px; color: var(--muted); font-size: 10px; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; overflow: auto; max-height: min(65vh, 560px); padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 45px rgba(26,36,70,.18); }
.search-results a { display: block; padding: 11px 12px; color: var(--ink); border-radius: 9px; text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--brand-soft); outline: none; }
.search-results strong { display: block; }
.search-results span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.search-empty { padding: 15px; color: var(--muted); text-align: center; }
.pill { padding: 5px 9px; color: var(--brand-dark); background: var(--brand-soft); border-radius: 999px; font-size: 12px; font-weight: 700; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 7px 12px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 700; }
.btn--ghost { color: var(--ink); background: #fff; border-color: var(--line); }
.docs-nav-toggle, .docs-nav-close, .docs-nav-backdrop { display: none; }

.layout { display: grid; grid-template-columns: 280px minmax(0, 900px) 240px; align-items: start; gap: 30px; max-width: 1500px; margin: 0 auto; padding: 30px 22px 70px; }
.sidebar, .toc { position: sticky; top: 102px; overflow: auto; max-height: calc(100vh - 126px); }
.sidebar { padding: 4px 8px 24px 0; }
.sidebar__section + .sidebar__section { margin-top: 28px; }
.sidebar__title, .toc__title { margin: 0 0 8px; color: #778196; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.nav { display: grid; gap: 3px; }
.nav__link { display: block; padding: 7px 10px; color: #4c566a; border-radius: 8px; font-size: 13px; line-height: 1.35; text-decoration: none; }
.nav__link:hover { color: var(--ink); background: #eaedf4; }
.nav__link.is-active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 700; }
.sidebar__footer { display: grid; gap: 5px; margin-top: 28px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; }
.sidebar__footer span { color: var(--muted); line-height: 1.5; }
.content { min-width: 0; padding: 0 8px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 16px; color: var(--muted); font-size: 12px; }
.breadcrumb a { color: var(--muted); }
.toc { padding-top: 8px; }
.toc__list { display: grid; gap: 2px; border-left: 1px solid var(--line); }
.toc__list a { padding: 5px 0 5px 13px; color: var(--muted); font-size: 12px; line-height: 1.35; text-decoration: none; }
.toc__list a:hover, .toc__list a.is-active { color: var(--brand-dark); border-left: 2px solid var(--brand); margin-left: -1px; }
.toc__list a[data-level="3"] { padding-left: 25px; }

.hero-panel { overflow: hidden; margin-bottom: 28px; padding: 32px; background: linear-gradient(135deg, #fff 0%, #f4f0ff 60%, #edf7ff 100%); border: 1px solid #ddd7f9; border-radius: 22px; box-shadow: var(--shadow); }
.doc-kicker { color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3 { color: #151d2e; line-height: 1.25; }
h1 { max-width: 780px; margin: 7px 0 12px; font-size: clamp(2rem, 4.2vw, 3.2rem); letter-spacing: -.035em; }
h2 { margin: 38px 0 12px; font-size: clamp(1.45rem, 2.4vw, 1.85rem); letter-spacing: -.02em; }
h3 { margin: 24px 0 9px; font-size: 1.12rem; }
p { margin: 0 0 15px; }
.lead { max-width: 780px; margin: 0; color: #4f5b70; font-size: 1.08rem; line-height: 1.75; }
.role-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; }
.role-chips span { padding: 5px 9px; color: var(--brand-dark); background: rgba(255,255,255,.86); border: 1px solid #d9d2fa; border-radius: 999px; font-size: 12px; font-weight: 700; }
.workflow-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 24px; }
.workflow-summary div { padding: 15px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.workflow-summary strong, .workflow-summary span { display: block; }
.workflow-summary strong { margin-bottom: 5px; color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.workflow-summary span { font-size: 13px; line-height: 1.5; }
.path-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin: 18px 0 30px; }
.path-grid a { position: relative; display: grid; min-height: 160px; padding: 20px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); text-decoration: none; }
.path-grid a:hover { transform: translateY(-2px); border-color: #afa2ed; }
.path-grid a > span { position: absolute; top: 15px; right: 15px; color: #8d80d8; font-size: 12px; font-weight: 800; }
.path-grid strong { align-self: end; font-size: 1.2rem; }
.path-grid p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.link-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; margin: 14px 0 22px; }
.link-list a { padding: 13px 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; text-decoration: none; }
.link-list a:hover { color: var(--brand-dark); border-color: #b6abef; background: var(--brand-soft); }

.steps { margin: 14px 0 24px; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; min-height: 52px; margin: 0 0 10px; padding: 13px 15px 13px 58px; background: #fff; border: 1px solid var(--line); border-radius: 12px; counter-increment: step; }
.steps li::before { position: absolute; left: 13px; top: 11px; display: grid; width: 31px; height: 31px; place-items: center; color: #fff; background: var(--brand); border-radius: 9px; content: counter(step); font-weight: 800; }
.list { margin: 10px 0 22px; padding-left: 22px; }
.list li { margin: 7px 0; padding-left: 3px; }
.two-column { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.two-column > section { min-width: 0; }
.callout { margin: 20px 0; padding: 15px 17px; border-left: 5px solid var(--blue); background: var(--blue-soft); border-radius: 0 12px 12px 0; }
.callout--warning { border-color: var(--warn); background: var(--warn-soft); }
.callout--tip { border-color: var(--teal); background: var(--teal-soft); }
.developer-note { margin: 22px 0; padding: 17px 18px; background: var(--teal-soft); border: 1px solid #bce8df; border-left: 5px solid var(--teal); border-radius: 0 14px 14px 0; }
.developer-note > strong { color: #0d5d57; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.developer-note p { margin: 5px 0; }
.developer-note a { color: #0d5d57; font-size: 13px; font-weight: 700; }

.media { overflow: hidden; margin: 22px 0 30px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.media img { display: block; width: 100%; height: auto; background: #eef1f6; }
.media figcaption, .diagram-card figcaption { padding: 11px 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.screen-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.screen-grid .media { margin: 0; }
.diagram-card { overflow: hidden; margin: 22px 0 30px; padding: 14px 14px 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.diagram-card svg { display: block; width: 100%; height: auto; overflow: visible; }
.diagram-node { fill: #f0edff; stroke: #8e7be2; stroke-width: 1.5; }
.diagram-arrow { fill: none; stroke: #6651cb; stroke-width: 2; }
.diagram-card marker path { fill: #6651cb; }
.diagram-card text { fill: #263047; font-family: var(--font); font-size: 13px; font-weight: 700; }

table { width: 100%; margin: 16px 0 26px; border-spacing: 0; border-collapse: separate; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { color: #3e485b; background: #f3f5f9; }
tr:last-child td { border-bottom: 0; }
.copyBtn { position: absolute; top: 8px; right: 8px; padding: 5px 8px; color: #dce3f2; background: #273245; border: 1px solid #46536a; border-radius: 6px; cursor: pointer; font-size: 11px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--line); }
.pager a { display: grid; padding: 13px 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.pager a:hover { border-color: #b6abef; }
.pager small { color: var(--muted); }
.pager__next { text-align: right; }

@media (max-width: 1220px) {
    .topbar { grid-template-columns: 250px minmax(280px, 1fr) auto; }
    .layout { grid-template-columns: 250px minmax(0, 1fr); max-width: 1120px; }
    .toc { display: none; }
}

@media (max-width: 860px) {
    html { scroll-padding-top: 80px; }
    .topbar { grid-template-columns: 1fr auto; min-height: 64px; padding: 9px 14px; }
    .topbar__center { grid-column: 1 / -1; grid-row: 2; }
    .topbar__right .pill { display: none; }
    .layout { display: block; padding: 20px 13px 50px; }
    .content { padding: 0; }
    .sidebar { position: fixed; z-index: 80; top: 0; left: 0; bottom: 0; width: min(88vw, 340px); max-height: none; padding: 62px 18px 30px; background: #fff; box-shadow: 20px 0 40px rgba(25,35,65,.22); transform: translateX(-105%); transition: transform .2s ease; }
    .sidebar.is-open { transform: translateX(0); }
    body.docs-nav-open { overflow: hidden; }
    .docs-nav-toggle { display: inline-flex; align-items: center; gap: 7px; margin-right: 4px; padding: 6px 9px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; }
    .docs-nav-close { position: absolute; top: 14px; right: 15px; display: block; padding: 7px 9px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px; }
    .docs-nav-backdrop { position: fixed; z-index: 70; inset: 0; display: block; width: 100%; height: 100%; background: rgba(17,24,39,.48); border: 0; }
    .docs-nav-backdrop[hidden] { display: none; }
    .brand__text small { display: none; }
    .hero-panel { padding: 23px 20px; border-radius: 17px; }
    h1 { font-size: clamp(1.85rem, 9vw, 2.5rem); }
    .workflow-summary, .two-column { grid-template-columns: 1fr; }
    .path-grid, .screen-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .topbar__right .btn { display: none; }
    .search kbd, .search > span:not(.sr-only) { display: none; }
    .path-grid, .link-list { grid-template-columns: 1fr; }
    .pager { grid-template-columns: 1fr; }
    .pager__next { text-align: left; }
    .diagram-card { overflow-x: auto; }
    .diagram-card svg { min-width: 680px; }
    table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .01ms !important; }
}

@media print {
    body { background: #fff; font-size: 10pt; }
    .topbar, .sidebar, .toc, .pager, .copyBtn { display: none !important; }
    .layout { display: block; max-width: none; padding: 0; }
    .content { max-width: none; padding: 0; }
    .hero-panel, .media, .diagram-card, .workflow-summary div, .steps li { box-shadow: none; break-inside: avoid; }
    .hero-panel { padding: 18px; }
    h2 { break-after: avoid; }
    a { color: inherit; text-decoration: none; }
    .diagram-card svg { min-width: 0; }
}
