/* Shared document reading layer; Wiki layout rules remain scoped. Palette follows the active frontend theme tokens. */
body[data-theme-area="frontend"].route-wiki-show .wiki-docs-reading-grid {
    grid-template-columns: minmax(0, 760px) minmax(180px, 220px);
    gap: clamp(36px, 4vw, 64px);
    max-width: 1120px;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) {
    max-width: 760px;
    color: var(--ink, #172033);
    font-size: 16.5px;
    line-height: 1.92;
    letter-spacing: .005em;
    overflow-wrap: break-word;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :is(p, li) {
    color: var(--ink-2, var(--ink, #172033));
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) > p,
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) > ul,
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) > ol {
    margin: 0 0 1.4em;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) h2 {
    margin: 3em 0 1em;
    padding: 0 0 .48em;
    border: 0;
    border-bottom: 1px solid var(--border, #dbe3ee);
    color: var(--ink, #172033);
    font-size: clamp(1.4rem, 2vw, 1.65rem);
    font-weight: 730;
    line-height: 1.36;
    letter-spacing: -.025em;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) h3 {
    margin: 2.2em 0 .85em;
    color: var(--ink, #172033);
    font-size: 1.22rem;
    line-height: 1.45;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) h4 {
    margin: 1.9em 0 .65em;
    color: var(--ink, #172033);
    font-size: 1.05rem;
    line-height: 1.5;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) h2 + p {
    margin-top: .25em;
    color: var(--ink, #172033);
    font-size: 1.055em;
    line-height: 1.9;
}

body[data-theme-area="frontend"] .wiki-docs-prose--synced h2:first-of-type + p {
    margin: 0 0 1.65em;
    padding: .15em 0 .15em 1.15em;
    border-left: 3px solid var(--link, #2563eb);
    color: var(--ink, #172033);
    font-size: 1.08em;
}

body[data-theme-area="frontend"].route-wiki-show .wiki-docs-page-head > p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :is(ul, ol) {
    padding-inline-start: 1.55em;
}
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) ul { list-style: disc; }
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) ol { list-style: decimal; }

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) li {
    padding-inline-start: .15em;
    margin: .45em 0;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) li::marker {
    color: var(--link, #2563eb);
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) a {
    color: var(--link, #2563eb);
    text-decoration-color: color-mix(in srgb, var(--link, #2563eb) 48%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: .18em;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) a:hover {
    text-decoration-color: currentColor;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) strong { color: var(--ink, #172033); font-weight: 700; }
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :is(img, video) { max-width: 100%; height: auto; border-radius: 8px; }
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--border, #dbe3ee); }

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :not(pre) > code {
    padding: .12em .3em;
    border: 1px solid color-mix(in srgb, var(--link, #2563eb) 25%, var(--border, #dbe3ee));
    border-radius: 5px;
    background: color-mix(in srgb, var(--link, #2563eb) 9%, var(--surface, #fff));
    color: var(--ink, #172033);
    font-size: .88em;
    font-weight: 550;
    white-space: break-spaces;
    overflow-wrap: anywhere;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) blockquote {
    margin: 1.75em 0;
    padding: .65em 1.3em;
    border-left: 3px solid var(--link, #2563eb);
    border-radius: 0 8px 8px 0;
    background: color-mix(in srgb, var(--link, #2563eb) 5%, var(--surface, #fff));
    color: var(--ink-2, var(--ink, #172033));
    font-style: normal;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) blockquote > :last-child { margin-bottom: 0; }

/* Tables stay within the document and use explicit themed surfaces in both modes. */
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) table {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 1.8em 0 2.1em;
    overflow-x: auto;
    border: 1px solid var(--border, #dbe3ee);
    border-radius: 10px;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface, #fff);
    color: var(--ink, #172033);
    font-size: .88em;
    line-height: 1.65;
    scrollbar-width: thin;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :is(thead, tbody, tr, th, td) {
    background: transparent;
    color: var(--ink, #172033);
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) thead {
    background: color-mix(in srgb, var(--link, #2563eb) 7%, var(--surface, #fff));
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :is(th, td) {
    min-width: 7.5em;
    padding: .72em .95em;
    border-right: 1px solid var(--border, #dbe3ee);
    border-bottom: 1px solid var(--border, #dbe3ee);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) th {
    font-weight: 700;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) tr > :last-child { border-right: 0; }
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) tbody tr:last-child > * { border-bottom: 0; }
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--ink, #172033) 2.5%, var(--surface, #fff));
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) td code {
    white-space: normal;
}
.wiki-table-shell { max-width: 100%; margin: 1.8em 0 2.1em; }
body[data-theme-area="frontend"] .wiki-table-shell table { margin: 0; }
.wiki-table-hint { display: none; }

/* Code remains dark in both palettes; selection colors are explicit and readable. */
body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) pre {
    max-width: 100%;
    margin: 1.8em 0;
    padding: 1.2em 1.35em;
    overflow: auto;
    border: 1px solid #334155;
    border-radius: 0 0 10px 10px;
    background: #111b2a;
    color: #e6edf7;
    font: 13.5px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) pre code {
    display: block;
    max-width: none;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    white-space: inherit;
    overflow: visible;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) pre ::selection {
    background: #456cc9;
    color: #fff;
}

body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) ::selection {
    background: color-mix(in srgb, var(--link, #2563eb) 34%, var(--surface, #fff));
    color: var(--ink, #172033);
}

.wiki-code-block { position: relative; margin: 1.8em 0; }
body[data-theme-area="frontend"] .wiki-code-block pre { margin: 0; }
.wiki-code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 35px;
    padding: 0 12px;
    border: 1px solid #334155;
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: #1a2940;
    color: #adbed6;
    font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.wiki-code-copy {
    padding: 4px 8px;
    border: 1px solid #536783;
    border-radius: 5px;
    background: transparent;
    color: #e6edf7;
    cursor: pointer;
    font: inherit;
}
.wiki-code-copy:hover, .wiki-code-copy:focus-visible { background: #334c70; outline-offset: 2px; }
:is(.wiki-docs-prose, .document-prose) .hljs-keyword, :is(.wiki-docs-prose, .document-prose) .hljs-selector-tag { color: #bda9ff; }
:is(.wiki-docs-prose, .document-prose) .hljs-string, :is(.wiki-docs-prose, .document-prose) .hljs-attr { color: #a9ddc4; }
:is(.wiki-docs-prose, .document-prose) .hljs-number, :is(.wiki-docs-prose, .document-prose) .hljs-literal { color: #f4c084; }
:is(.wiki-docs-prose, .document-prose) .hljs-comment, :is(.wiki-docs-prose, .document-prose) .hljs-quote { color: #91a3bb; }
:is(.wiki-docs-prose, .document-prose) .hljs-title, :is(.wiki-docs-prose, .document-prose) .hljs-built_in, :is(.wiki-docs-prose, .document-prose) .hljs-function { color: #90caff; }
:is(.wiki-docs-prose, .document-prose) .hljs-variable, :is(.wiki-docs-prose, .document-prose) .hljs-params { color: #f1b3c4; }

/* Standards use compact clause numbers and clear breaks between requirements. */
body[data-theme-area="frontend"] .wiki-docs-prose--standard h2 {
    margin-top: 2.6em;
    font-variant-numeric: tabular-nums;
}
body[data-theme-area="frontend"] .wiki-docs-prose--standard :is(h3, h4) {
    font-variant-numeric: tabular-nums;
}
body[data-theme-area="frontend"] .wiki-docs-prose--standard p {
    margin-bottom: 1.05em;
}
body[data-theme-area="frontend"] .wiki-docs-prose--standard p > strong:first-child {
    color: var(--ink, #172033);
}
.wiki-standard-reference {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -8px 0 28px;
    padding: 13px 16px;
    border: 1px solid var(--border, #dbe3ee);
    border-radius: 8px;
    background: color-mix(in srgb, var(--link, #2563eb) 5%, var(--surface, #fff));
    color: var(--muted, #64748b);
    font-size: 13px;
}
.wiki-standard-reference a { color: var(--link, #2563eb); font-weight: 650; text-decoration: none; }
.wiki-standard-reference a:hover { text-decoration: underline; }

@media (max-width: 1080px) {
    body[data-theme-area="frontend"].route-wiki-show .wiki-docs-reading-grid {
        grid-template-columns: minmax(0, 760px);
    }
}

@media (max-width: 760px) {
    html:has(body.route-wiki-show) { scroll-padding-top: calc(var(--df-header-total, 58px) + 54px); }
    body[data-theme-area="frontend"].route-wiki-show .wiki-docs-menu-toggle {
        position: fixed;
        top: var(--df-header-total, 58px);
        left: 0;
        z-index: 31;
        width: 100%;
        min-height: 46px;
        margin: 0;
        padding: 0 20px;
        border: 0;
        border-bottom: 1px solid var(--border, #dbe3ee);
        border-radius: 0;
        background: var(--surface, #fff);
        color: var(--ink, #172033);
        text-align: left;
    }
    body[data-theme-area="frontend"].route-wiki-show .wiki-docs-toc-toggle {
        position: fixed;
        top: calc(var(--df-header-total, 58px) + 7px);
        right: 18px;
        z-index: 32;
        min-height: 32px;
        margin: 0;
    }
    body[data-theme-area="frontend"].route-wiki-show .wiki-docs-reading-grid {
        padding: 72px 20px 54px;
    }
    body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) { font-size: 16px; line-height: 1.85; }
    body[data-theme-area="frontend"] :is(.wiki-docs-prose, .document-prose) :is(th, td) { min-width: 9em; }
    body[data-theme-area="frontend"] .wiki-table-shell { scroll-margin-top: calc(var(--df-header-total, 58px) + 54px); }
    .wiki-table-hint { display: block; margin-bottom: 7px; color: var(--muted, #64748b); font-size: 12px; }
    .wiki-standard-reference { align-items: flex-start; flex-direction: column; }
}
