:root {
    color-scheme: dark;
    --bg: #111312;
    --panel: #181a18;
    --panel-raised: #20231f;
    --text: #f2f1eb;
    --muted: #a6aaa4;
    --line: #30342f;
    --accent: #0093d1;
    --accent-strong: #8bd7f4;
    --accent-soft: #082536;
    --accent-warm: #f78f1e;
    --index-accent: #f6c945;
    --index-accent-soft: rgba(246, 201, 69, 0.12);
    --index-accent-border: rgba(246, 201, 69, 0.58);
    --code-bg: #191c1b;
    --shadow: rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f6f4;
    --panel: #ffffff;
    --panel-raised: #eef2ee;
    --text: #20231f;
    --muted: #676d66;
    --line: #d9ded6;
    --accent: #0077a8;
    --accent-strong: #005f85;
    --accent-soft: #e4f5fb;
    --accent-warm: #c96500;
    --index-accent: #9a6b00;
    --index-accent-soft: #fff5cf;
    --index-accent-border: #e0ad25;
    --code-bg: #ecefeb;
    --shadow: rgba(42, 49, 43, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: clamp(270px, 19vw, 320px) minmax(0, 1fr);
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    padding: 20px 18px;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.sidebar-header {
    display: grid;
    gap: 18px;
    margin-bottom: 22px;
}

.brand {
    display: inline-grid;
    gap: 4px;
    align-items: start;
    justify-items: center;
    width: 100%;
    color: var(--text);
}

.brand:hover {
    text-decoration: none;
}

.brand::after {
    content: "";
    width: min(178px, 78%);
    height: 1px;
    margin-top: 10px;
    background: linear-gradient(90deg, transparent, var(--line), transparent);
    opacity: 0.72;
}

.brand-logo {
    display: block;
    width: min(100%, 174px);
}

.brand-logo img {
    display: block;
    width: 100%;
    height: auto;
}

.brand-logo .brand-logo-light {
    display: none;
}

html[data-theme="light"] .brand-logo .brand-logo-dark {
    display: none;
}

html[data-theme="light"] .brand-logo .brand-logo-light {
    display: block;
}

.brand-section {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.25;
    text-align: center;
}

.theme-toggle,
.sidebar-layout-control {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 8px;
    align-items: center;
    justify-self: start;
    color: var(--muted);
    font-size: 0.78rem;
    cursor: pointer;
    user-select: none;
}

.theme-label,
.sidebar-layout-control .document-layout-label {
    color: var(--muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.2;
}

.theme-toggle input,
.sidebar-layout-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-raised);
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 140ms ease;
}

.theme-toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(18px);
}

.sidebar-layout-control input:checked + .toggle-track .toggle-thumb {
    transform: translateX(18px);
}

.sidebar-preferences {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.sidebar-preferences .theme-toggle {
    justify-self: start;
}

.sidebar-search {
    display: grid;
    gap: 7px;
}

.sidebar-search label:not(.visually-hidden) {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.sidebar-search input,
.search-page-form input {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-raised);
    color: var(--text);
    font: inherit;
    font-size: 0.84rem;
}

.sidebar-search input:focus,
.search-page-form input:focus {
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.sidebar-search input::placeholder,
.search-page-form input::placeholder {
    color: var(--muted);
}

.space-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.space-switcher a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-raised);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 650;
    text-align: center;
}

.space-switcher a:hover {
    border-color: var(--accent-warm);
    text-decoration: none;
}

.space-switcher a.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

nav ul {
    list-style: none;
    margin: 0;
    padding-left: 13px;
}

nav > ul {
    padding-left: 0;
}

nav li {
    margin: 3px 0;
}

nav a,
.nav-folder > summary {
    display: flex;
    align-items: center;
    min-height: 30px;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.3;
}

nav a {
    overflow-wrap: anywhere;
}

.nav-document {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    align-items: center;
}

.nav-document.has-index {
    grid-template-columns: minmax(0, 1fr) auto;
}

.nav-document-link {
    min-width: 0;
}

.nav-index-link {
    justify-content: center;
    width: 26px;
    min-height: 26px;
    padding: 0;
    border: 1px solid var(--index-accent-border);
    border-radius: 6px;
    background: var(--index-accent-soft);
    color: var(--index-accent);
    flex: 0 0 auto;
}

.nav-index-link svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

nav a:hover,
.nav-folder > summary:hover {
    background: var(--panel-raised);
    color: var(--text);
    text-decoration: none;
}

nav a.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    box-shadow: inset 3px 0 0 var(--accent-warm);
}

.nav-index-link:hover,
.nav-index-link:focus-visible {
    border-color: var(--index-accent);
    background: var(--index-accent-soft);
    color: var(--index-accent);
    outline: 0;
    text-decoration: none;
}

.nav-folder.active-branch > summary {
    background: var(--panel-raised);
    color: var(--accent-strong);
    box-shadow: inset 2px 0 0 var(--accent);
}

.nav-folder.active-branch > summary::before {
    color: var(--accent-warm);
}

.nav-folder > summary {
    gap: 8px;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.nav-folder > summary::-webkit-details-marker {
    display: none;
}

.nav-folder > summary::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 140ms ease;
}

.nav-folder[open] > summary::before {
    transform: rotate(45deg);
}

.nav-folder > ul {
    margin: 2px 0 6px;
    padding-left: 14px;
}

.content {
    width: 100%;
    min-width: 0;
    padding: 44px 48px 56px;
    overflow-x: clip;
}

.content-inner {
    width: min(100%, 1120px);
}

.content-inner-document {
    transition: width 160ms ease;
}

.document {
    width: min(100%, 980px);
}

html[data-document-width="wide"] .content-inner-document {
    width: min(100%, 1920px);
}

html[data-document-width="wide"] .document,
html[data-document-width="wide"] .calculator-page,
html[data-document-width="wide"] .page-tools-document,
html[data-document-width="wide"] .site-footer-document {
    width: min(100%, 1896px);
}

.home-hero {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.home-intro {
    grid-column: span 2;
    min-width: 0;
    max-width: 680px;
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.home-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 650;
}

.home-actions a:hover {
    border-color: var(--accent-warm);
    text-decoration: none;
}

.recent-documents {
    display: grid;
    align-content: start;
    min-height: 250px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.recent-documents h2 {
    margin: 0 0 14px;
    font-size: 1.02rem;
    line-height: 1.25;
}

.recent-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.recent-list a {
    display: grid;
    gap: 3px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-raised);
    color: var(--text);
}

.recent-list a:hover {
    border-color: var(--accent-warm);
    text-decoration: none;
}

.recent-title {
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.3;
}

.recent-meta {
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.3;
}

.home-section {
    width: 100%;
    margin-top: 48px;
}

.home-section h2 {
    margin: 0 0 16px;
    font-size: 1.18rem;
    line-height: 1.25;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.info-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.info-card h3 {
    margin: 0 0 9px;
    font-size: 0.94rem;
    line-height: 1.25;
}

.info-card p,
.home-note p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 16px;
    font-size: 1.9rem;
    line-height: 1.15;
}

.lede {
    max-width: 680px;
    color: var(--muted);
    font-size: 0.96rem;
    line-height: 1.62;
}

.search-page {
    width: min(100%, 980px);
}

.search-page-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin: 22px 0 18px;
}

.search-page-form button {
    min-height: 36px;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 650;
    cursor: pointer;
}

.search-page-form button:hover {
    border-color: var(--accent-warm);
}

.search-summary,
.search-empty {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.search-results {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.search-results a {
    display: grid;
    gap: 5px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
}

.search-results a:hover {
    border-color: var(--accent-warm);
    text-decoration: none;
}

.search-result-title {
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.3;
}

.search-result-meta {
    color: var(--accent-strong);
    font-size: 0.76rem;
    font-weight: 650;
    line-height: 1.3;
}

.search-snippet {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.52;
}

.error-page {
    width: 100%;
}

.error-ascii {
    width: min(100%, 760px);
    margin: 26px auto 20px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--accent-strong);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: clamp(0.72rem, 1.2vw, 0.92rem);
    line-height: 1.35;
    overflow-x: auto;
    text-align: center;
}

.error-ascii-art {
    display: inline-block;
    width: max-content;
    max-width: none;
    text-align: left;
}

.error-map-marker {
    color: #ff3b30;
    font-weight: 800;
    text-shadow: 0 0 10px rgba(255, 59, 48, 0.45);
}

.error-map-note {
    color: var(--text);
    font-weight: 750;
}

.error-map-tree {
    color: #57d68d;
    font-weight: 750;
}

.error-status-alert {
    color: var(--accent-warm);
    font-weight: 800;
    text-shadow: 0 0 10px rgba(201, 101, 0, 0.45);
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.error-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 650;
}

.error-actions a:hover {
    border-color: var(--accent-warm);
    text-decoration: none;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 26px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.doc-header-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.document-layout-control {
    display: flex;
    gap: 8px;
    align-items: center;
}

.document-layout-label {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.layout-segments {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
}

.layout-segment {
    min-height: 30px;
    padding: 5px 9px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.layout-segment:hover,
.layout-segment:focus-visible,
.layout-segment.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    outline: 0;
}

.sidebar-layout-control {
    display: inline-grid;
    grid-template-columns: auto auto;
    justify-self: end;
}

.raw-link {
    flex: 0 0 auto;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    background: var(--accent-soft);
    font-size: 0.82rem;
}

.raw-link:hover {
    color: var(--accent-strong);
    border-color: var(--accent-warm);
    text-decoration: none;
}

.markdown-body {
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.64;
    overflow-wrap: anywhere;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin-top: 1.8rem;
    line-height: 1.25;
}

.markdown-body h2 {
    font-size: 1.34rem;
}

.markdown-body h3 {
    font-size: 1.12rem;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body table,
.markdown-body pre {
    margin-bottom: 1rem;
}

.markdown-body #index + ol {
    line-height: 1.5;
}

.markdown-body #index + ol li {
    margin: 0.08rem 0;
}

.markdown-body #index + ol ul {
    margin: 0.04rem 0 0;
    padding-left: 1.35rem;
    list-style: none;
    line-height: 1.5;
}

.markdown-body #index + ol ul > li {
    margin: 0;
    position: relative;
    padding-left: 0.95rem;
}

.markdown-body #index + ol ul > li::before {
    content: ">";
    position: absolute;
    left: 0;
    color: var(--muted);
    font-weight: 700;
}

.markdown-body code {
    padding: 0.12em 0.3em;
    border-radius: 4px;
    background: var(--code-bg);
}

.markdown-body pre {
    overflow-x: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--code-bg);
}

.markdown-body pre code {
    padding: 0;
    background: transparent;
    white-space: inherit;
}

.markdown-body blockquote {
    margin-left: 0;
    padding-left: 16px;
    border-left: 3px solid var(--accent);
    color: var(--muted);
}

.markdown-body table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-scroll-shell {
    max-width: 100%;
    margin-bottom: 1rem;
}

.code-popout-shell {
    max-width: 100%;
    margin-bottom: 1rem;
}

.code-popout-shell pre {
    margin-bottom: 0;
}

.code-overflow-measure {
    position: fixed;
    top: 0;
    left: -99999px;
    width: max-content;
    max-width: none;
    overflow: visible;
    white-space: pre;
    visibility: hidden;
    pointer-events: none;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.64;
}

.table-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.code-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.table-scroll-shell:not(.has-horizontal-overflow) .table-tools {
    display: none;
}

.code-popout-shell:not(.has-code-overflow) .code-tools {
    display: none;
}

.table-expand-button,
.code-expand-button {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--muted);
    font: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}

.table-expand-button:hover,
.table-expand-button:focus-visible,
.code-expand-button:hover,
.code-expand-button:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
    outline: 0;
}

.table-expand-button svg,
.code-expand-button svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.table-scroll-main {
    position: relative;
    max-width: 100%;
    overflow: hidden;
}

.table-scroll-main {
    padding-bottom: 2px;
}

.markdown-body .table-scroll-shell table {
    margin-bottom: 0;
}

.table-scroll-shell.has-horizontal-overflow .table-scroll-main::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 2px;
    z-index: 4;
    width: 16px;
    border-right: 2px solid var(--accent-warm);
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
}

.markdown-body th,
.markdown-body td {
    min-width: 8rem;
    padding: 8px 10px;
    border: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    overflow-wrap: normal;
    text-align: left;
    vertical-align: top;
    word-break: normal;
}

.markdown-body th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg);
}

.markdown-body tr:first-child th,
.markdown-body tr:first-child td {
    border-top: 1px solid var(--line);
}

.markdown-body th:first-child,
.markdown-body td:first-child {
    border-left: 1px solid var(--line);
}

.markdown-body th:first-child,
.markdown-body td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg);
    box-shadow: 1px 0 0 var(--line);
}

.markdown-body th:first-child {
    z-index: 3;
}

.markdown-body th code,
.markdown-body td code {
    white-space: nowrap;
}

.page-tools {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 48px;
}

.page-tools-document {
    width: min(100%, 980px);
}

.page-tool {
    appearance: none;
    display: inline-grid;
    width: 34px;
    height: 34px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.page-tool:hover,
.page-tool:focus-visible,
.page-tool.copied {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
    text-decoration: none;
}

.page-tool svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.page-tools-status {
    margin-left: 2px;
    color: var(--muted);
    font-size: 0.76rem;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
}

.site-footer-document {
    width: min(100%, 980px);
}

.site-footer span:first-child,
.site-footer span:nth-child(3) {
    flex: 0 0 auto;
}

.site-footer span:nth-child(2) {
    flex: 1 1 auto;
    text-align: center;
}

.site-footer span:nth-child(3) {
    text-align: right;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.clipboard-helper {
    position: fixed;
    top: 0;
    left: -9999px;
    opacity: 0;
}

.table-popout-open {
    overflow: hidden;
}

.table-popout[hidden] {
    display: none;
}

.table-popout {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    padding: 24px;
}

.table-popout-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.58);
    cursor: pointer;
}

.table-popout-panel {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(100%, 1800px);
    min-height: 0;
    margin: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    box-shadow: 0 24px 80px var(--shadow);
}

.table-popout-header {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.table-popout-header h2 {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.25;
}

.table-popout-close {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.table-popout-close:hover,
.table-popout-close:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
    outline: 0;
}

.table-popout-body {
    min-height: 0;
    max-height: min(78vh, 900px);
    overflow: auto;
    padding: 14px 14px 14px 0;
}

.table-popout table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.55;
}

.table-popout th,
.table-popout td {
    min-width: 8rem;
    padding: 8px 10px;
    border: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    overflow-wrap: normal;
    text-align: left;
    vertical-align: top;
    word-break: normal;
}

.table-popout th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-popout tr:first-child th,
.table-popout tr:first-child td {
    border-top: 1px solid var(--line);
}

.table-popout th:first-child,
.table-popout td:first-child {
    border-left: 1px solid var(--line);
}

.table-popout th:first-child,
.table-popout td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 1px 0 0 var(--line);
}

.table-popout th:first-child {
    z-index: 3;
}

.table-popout code {
    padding: 0.12em 0.3em;
    border-radius: 4px;
    background: var(--code-bg);
    white-space: nowrap;
}

.code-popout-body {
    padding: 14px;
}

.code-popout-body pre {
    width: max-content;
    min-width: 100%;
    margin: 0;
    overflow: visible;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
    line-height: 1.56;
}

.code-popout-body pre code {
    padding: 0;
    background: transparent;
    white-space: pre;
}

@media (max-width: 820px) {
    body {
        display: block;
    }

    .sidebar {
        position: relative;
        height: auto;
        max-height: 46vh;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .content {
        padding: 30px 22px 48px;
    }

    .doc-header {
        display: block;
    }

    .doc-header-actions {
        justify-content: flex-start;
        margin-top: 8px;
    }

    .document-layout-control {
        display: grid;
        gap: 6px;
    }

    .home-hero,
    .home-grid {
        grid-template-columns: 1fr;
    }

    .home-intro {
        grid-column: auto;
    }

    .home-hero {
        gap: 28px;
    }

    .recent-documents {
        min-height: 0;
        padding: 20px;
    }

    .search-page-form {
        grid-template-columns: 1fr;
    }

    .raw-link {
        display: inline-block;
        margin-top: 8px;
    }

    .site-footer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .site-footer span,
    .site-footer span:nth-child(2),
    .site-footer span:nth-child(3) {
        text-align: left;
    }

    h1 {
        font-size: 1.55rem;
    }
}
