
:root {
    color-scheme: light dark;
    --bg: #f7f4ef;
    --bg-start: #fbf8f2;
    --bg-end: #f4efe6;
    --surface: #fffdf9;
    --surface-alpha: rgba(255, 253, 249, 0.8);
    --sidebar-bg: rgba(255, 253, 249, 0.94);
    --surface-strong: #f0e6d9;
    --surface-muted: #ebe4d7;
    --text: #1e241e;
    --muted: #5f675d;
    --border: #d6cbbd;
    --accent: #117a65;
    --accent-strong: #0a5e4d;
    --accent-soft: #d9f0ea;
    --code-bg: #1f2520;
    --code-text: #f5f3ed;
    --shadow: 0 16px 40px rgba(63, 39, 8, 0.08);
    --radius: 8px;
    --sidebar-width: 320px;
    --content-width: 920px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
    color-scheme: light;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #191724;
    --bg-start: #1f1d2e;
    --bg-end: #191724;
    --surface: #1f1d2e;
    --surface-alpha: rgba(31, 29, 46, 0.88);
    --sidebar-bg: rgba(25, 23, 36, 0.94);
    --surface-strong: #26233a;
    --surface-muted: #2a273f;
    --text: #e0def4;
    --muted: #908caa;
    --border: #403d52;
    --accent: #9ccfd8;
    --accent-strong: #c4a7e7;
    --accent-soft: #26233a;
    --code-bg: #191724;
    --code-text: #e0def4;
    --shadow: 0 18px 42px rgba(6, 5, 10, 0.42);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #191724;
        --bg-start: #1f1d2e;
        --bg-end: #191724;
        --surface: #1f1d2e;
        --surface-alpha: rgba(31, 29, 46, 0.88);
        --sidebar-bg: rgba(25, 23, 36, 0.94);
        --surface-strong: #26233a;
        --surface-muted: #2a273f;
        --text: #e0def4;
        --muted: #908caa;
        --border: #403d52;
        --accent: #9ccfd8;
        --accent-strong: #c4a7e7;
        --accent-soft: #26233a;
        --code-bg: #191724;
        --code-text: #e0def4;
        --shadow: 0 18px 42px rgba(6, 5, 10, 0.42);
    }
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@view-transition {
    navigation: auto;
}

body {
    margin: 0;
    background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text);
    transition: background-color 180ms ease, color 180ms ease;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, var(--sidebar-width)) minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.5rem 1rem 5rem;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(14px);
    view-transition-name: sidebar;
}

.sidebar-header {
    margin-bottom: 1rem;
}

.eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
}

.site-title {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
}

.site-version {
    margin-left: 0.5rem;
    color: var(--muted);
    font-size: 0.78em;
    font-weight: 600;
    white-space: nowrap;
}

.site-summary {
    margin: 0.65rem 0 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.5;
    white-space: pre-line;
}

.sidebar-toggle {
    display: none;
    width: 100%;
    margin: 1rem 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
}

.nav-search {
    width: 100%;
    margin: 0 0 1rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.nav-search-wrap {
    position: relative;
}

.nav-search-dropdown {
    position: absolute;
    z-index: 10;
    top: calc(100% - 0.7rem);
    left: 0;
    right: 0;
    max-height: min(24rem, 60vh);
    overflow-y: auto;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transform-origin: top center;
    animation: search-dropdown-in 160ms ease;
}

.nav-search-dropdown[hidden] {
    display: none;
}

.search-empty {
    padding: 0.7rem 0.8rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.search-result {
    display: block;
    padding: 0.6rem 0.7rem;
    border-radius: 6px;
    color: var(--text);
    transition: background-color 180ms ease, transform 180ms ease;
}

.search-result + .search-result {
    margin-top: 0.2rem;
}

.search-result:hover,
.search-result.is-selected {
    background: var(--accent-soft);
    text-decoration: none;
    transform: translateY(-1px);
}

.search-result-kind {
    display: inline-flex;
    margin-bottom: 0.3rem;
    padding: 0.14rem 0.42rem;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.search-result-title {
    display: block;
    line-height: 1.35;
}

.search-result-meta {
    display: block;
    margin-top: 0.22rem;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

.search-result mark {
    padding: 0;
    background: transparent;
    color: var(--accent-strong);
    font-weight: 700;
}

.nav-group-title {
    margin: 1.2rem 0 0.45rem;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.nav-list,
.nav-sublist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list > li + li {
    margin-top: 0.25rem;
}

.nav-link {
    display: block;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius);
    color: var(--text);
    line-height: 1.35;
    transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: var(--accent-soft);
    text-decoration: none;
}

.nav-link:hover {
    transform: translateX(2px);
}

.nav-sublist {
    margin: 0.2rem 0 0.45rem 0.85rem;
    border-left: 2px solid var(--surface-muted);
    padding-left: 0.7rem;
    animation: sidebar-subnav-in 220ms ease;
}

.nav-sublist .nav-link {
    padding: 0.4rem 0.55rem;
    font-size: 0.93rem;
    color: var(--muted);
}

.nav-empty {
    color: var(--muted);
    font-size: 0.9rem;
}

.content-wrap {
    min-width: 0;
}

.page-header {
    padding: 2.25rem 2rem 1.3rem;
}

.page-header-inner,
.page-content {
    width: min(calc(100% - 4rem), var(--content-width));
    margin: 0 auto;
    min-width: 0;
}

.page-header-inner {
    view-transition-name: page-header;
}

.page-title {
    margin: 0;
    font-size: clamp(2rem, 2.4rem, 2.4rem);
    line-height: 1.05;
}

.page-lead {
    margin: 0.9rem 0 0;
    max-width: 62ch;
    font-size: 1.03rem;
    line-height: 1.65;
    color: var(--muted);
    white-space: pre-line;
}

.summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin: 1.2rem 0 1.5rem;
    min-width: 0;
}

.summary-pill {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 0.92rem;
    max-width: 100%;
}

.page-content {
    padding: 0 0 4rem;
    view-transition-name: page-content;
}

.overview-list {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.overview-item,
.command-section,
.empty-state {
    background: var(--surface-alpha);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
    max-width: 100%;
}

.overview-item {
    padding: 1.1rem 1.2rem;
}

.overview-item h2,
.command-section h2 {
    margin: 0;
    font-size: 1.28rem;
    line-height: 1.2;
}

.command-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.command-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.55rem;
    padding: 0.22rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
}

.command-badge-internal {
    background: var(--surface-strong);
}

.overview-meta,
.command-meta {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.overview-desc {
    margin: 0.75rem 0 0;
    line-height: 1.6;
    color: var(--muted);
}

.overview-link {
    display: inline-flex;
    margin-top: 0.85rem;
    font-weight: 600;
}

.command-stack {
    display: grid;
    gap: 1.1rem;
    min-width: 0;
}

.command-section {
    padding: 1.25rem 1.25rem 1.4rem;
    scroll-margin-top: 1rem;
}

.command-description p:first-child,
.section-text p:first-child {
    margin-top: 0.25rem;
}

.command-description p,
.section-text p {
    margin: 0.75rem 0 0;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.doc-section {
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--surface-muted);
    min-width: 0;
}

.doc-section h3 {
    margin: 0;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0;
    color: var(--muted);
}

pre,
code {
    font-family: "SFMono-Regular", SFMono-Regular, ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

pre {
    margin: 0.95rem 0 0;
    padding: 0.95rem 1rem;
    border-radius: var(--radius);
    background: var(--code-bg);
    color: var(--code-text);
    overflow-x: auto;
    line-height: 1.55;
    font-size: 0.94rem;
}

pre[data-shiki-lang] {
    position: relative;
}

.shiki {
    margin: 0;
    overflow-x: auto;
    border-radius: var(--radius);
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    line-height: 1.55;
    font-size: 0.94rem;
}

.doc-section > .shiki,
.doc-section > pre[data-shiki-lang] {
    margin-top: 0.95rem;
}

.shiki code {
    display: grid;
}

.shiki .line {
    min-height: 1.5rem;
}

code {
    font-size: 0.94em;
}

:not(pre) > code {
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text);
}

.def-list {
    display: grid;
    gap: 0.8rem;
    margin: 0.95rem 0 0;
    min-width: 0;
}

.def-item {
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    min-width: 0;
}

.def-item dt {
    font-weight: 700;
}

.def-item dd {
    margin: 0.35rem 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.io-table {
    width: 100%;
    max-width: 100%;
    margin-top: 0.9rem;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.command-section > *,
.doc-section > *,
.def-item > * {
    min-width: 0;
    max-width: 100%;
}

h1,
h2,
h3,
p,
dd,
th,
td,
li,
a,
code {
    overflow-wrap: anywhere;
}

.io-table th,
.io-table td {
    padding: 0.75rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.io-table thead {
    background: var(--surface-strong);
}

.io-table tbody tr:nth-child(even) {
    background: rgba(17, 122, 101, 0.03);
}

.example-block + .example-block {
    margin-top: 1rem;
}

.example-label {
    margin: 0 0 0.45rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.empty-state {
    padding: 1.2rem;
    color: var(--muted);
}

.theme-picker {
    position: fixed;
    z-index: 20;
    left: 1rem;
    bottom: 1rem;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--accent-soft);
}

.theme-toggle-icon {
    width: 0.86rem;
    height: 0.86rem;
    border-radius: 999px;
    flex: 0 0 auto;
    background: linear-gradient(90deg, var(--text) 0 50%, var(--surface-muted) 50% 100%);
    border: 1px solid var(--accent-strong);
}

.theme-toggle[data-theme-mode="light"] .theme-toggle-icon {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    box-shadow:
        0 -0.38rem 0 -0.28rem var(--accent-strong),
        0 0.38rem 0 -0.28rem var(--accent-strong),
        0.38rem 0 0 -0.28rem var(--accent-strong),
        -0.38rem 0 0 -0.28rem var(--accent-strong),
        0.27rem 0.27rem 0 -0.3rem var(--accent-strong),
        -0.27rem 0.27rem 0 -0.3rem var(--accent-strong),
        0.27rem -0.27rem 0 -0.3rem var(--accent-strong),
        -0.27rem -0.27rem 0 -0.3rem var(--accent-strong);
}

.theme-toggle[data-theme-mode="dark"] .theme-toggle-icon {
    background: var(--accent-strong);
    border-color: transparent;
    box-shadow: inset -0.25rem -0.18rem 0 var(--surface);
}

.theme-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.45rem);
    min-width: 10rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transform-origin: bottom left;
    animation: theme-menu-in 140ms ease;
}

.theme-menu[hidden] {
    display: none;
}

.theme-choice {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.theme-choice:hover,
.theme-choice[aria-checked="true"] {
    background: var(--accent-soft);
}

.theme-choice-icon {
    width: 0.86rem;
    height: 0.86rem;
    border-radius: 999px;
    flex: 0 0 auto;
}

.theme-icon-system {
    background: linear-gradient(90deg, var(--text) 0 50%, var(--surface-muted) 50% 100%);
    border: 1px solid var(--accent-strong);
}

.theme-icon-light {
    background: var(--accent-strong);
    border: 1px solid var(--accent-strong);
    box-shadow:
        0 -0.38rem 0 -0.28rem var(--accent-strong),
        0 0.38rem 0 -0.28rem var(--accent-strong),
        0.38rem 0 0 -0.28rem var(--accent-strong),
        -0.38rem 0 0 -0.28rem var(--accent-strong),
        0.27rem 0.27rem 0 -0.3rem var(--accent-strong),
        -0.27rem 0.27rem 0 -0.3rem var(--accent-strong),
        0.27rem -0.27rem 0 -0.3rem var(--accent-strong),
        -0.27rem -0.27rem 0 -0.3rem var(--accent-strong);
}

.theme-icon-dark {
    background: var(--accent-strong);
    box-shadow: inset -0.25rem -0.18rem 0 var(--surface);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 180ms;
    animation-timing-function: ease;
}

::view-transition-old(sidebar),
::view-transition-new(sidebar),
::view-transition-old(page-header),
::view-transition-new(page-header),
::view-transition-old(page-content),
::view-transition-new(page-content) {
    animation-duration: 220ms;
    animation-timing-function: ease;
}

@keyframes sidebar-subnav-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes search-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scaleY(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

@keyframes theme-menu-in {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .nav-link,
    .search-result {
        transition: none;
    }

    .nav-sublist,
    .nav-search-dropdown,
    .theme-menu,
    ::view-transition-old(root),
    ::view-transition-new(root),
    ::view-transition-old(sidebar),
    ::view-transition-new(sidebar),
    ::view-transition-old(page-header),
    ::view-transition-new(page-header),
    ::view-transition-old(page-content),
    ::view-transition-new(page-content) {
        animation: none;
    }
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding-bottom: 4.5rem;
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-nav {
        display: none;
    }

    .sidebar-nav.is-open {
        display: block;
    }

    .page-header {
        padding-top: 1.5rem;
    }
}
