:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #050b12;
    --panel: rgba(14, 22, 33, 0.9);
    --panel-solid: #101927;
    --panel-soft: rgba(255, 255, 255, 0.04);
    --border: rgba(120, 146, 176, 0.18);
    --divider: rgba(255, 255, 255, 0.08);
    --text: #edf4ff;
    --muted: #98abc2;
    --accent: #56f0ff;
    --accent-soft: rgba(86, 240, 255, 0.14);
    --accent-2: #8bf6b4;
    --accent-strong: #38c4d0;
    --accent-contrast: #061018;
    --success-bg: rgba(139, 246, 180, 0.12);
    --success-text: #8bf6b4;
    --error-bg: rgba(255, 122, 144, 0.12);
    --error-text: #ffb2c0;
    --input-bg: rgba(17, 24, 36, 0.9);
    --sidebar-bg: rgba(7, 12, 20, 0.94);
    --mobile-header-bg: rgba(8, 14, 24, 0.9);
    --overlay-bg: rgba(3, 7, 11, 0.72);
    --active-row-bg: rgba(86, 240, 255, 0.08);
    --icon-button-bg: rgba(255, 255, 255, 0.06);
    --shortcut-color: #ff6b6b;
    --page-bg:
        radial-gradient(circle at top left, rgba(86, 240, 255, 0.16), transparent 24%),
        radial-gradient(circle at bottom right, rgba(139, 246, 180, 0.1), transparent 20%),
        linear-gradient(180deg, #07111c 0%, #0b1320 45%, #050b12 100%);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
    --sidebar-width: 320px;
    --radius: 22px;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef4fb;
    --panel: rgba(255, 255, 255, 0.94);
    --panel-solid: #ffffff;
    --panel-soft: rgba(8, 35, 67, 0.05);
    --border: rgba(113, 139, 168, 0.22);
    --divider: rgba(113, 139, 168, 0.22);
    --text: #16253a;
    --muted: #60738c;
    --accent: #0b8e9b;
    --accent-soft: rgba(11, 142, 155, 0.12);
    --accent-2: #278a5f;
    --accent-strong: #0c7481;
    --accent-contrast: #f5fbff;
    --success-bg: rgba(39, 138, 95, 0.1);
    --success-text: #278a5f;
    --error-bg: rgba(224, 93, 93, 0.1);
    --error-text: #b54444;
    --input-bg: rgba(255, 255, 255, 0.98);
    --sidebar-bg: rgba(246, 250, 255, 0.96);
    --mobile-header-bg: rgba(246, 250, 255, 0.92);
    --overlay-bg: rgba(24, 38, 56, 0.22);
    --active-row-bg: rgba(11, 142, 155, 0.08);
    --icon-button-bg: rgba(17, 34, 54, 0.05);
    --shortcut-color: #cf4343;
    --page-bg:
        radial-gradient(circle at top left, rgba(11, 142, 155, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(39, 138, 95, 0.1), transparent 22%),
        linear-gradient(180deg, #f7fbff 0%, #f0f6fd 52%, #e9f0f8 100%);
    --shadow: 0 20px 44px rgba(40, 72, 108, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.mobile-header {
    display: none;
}

.site-frame {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

.site-sidebar {
    width: var(--sidebar-width);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.site-content-shell {
    width: 100%;
    min-width: 0;
    padding: 24px;
}

.sidebar-brand-box,
.content-card,
.hero-panel,
.article-card,
.list-card,
.badge-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.sidebar-brand-box {
    padding: 18px;
    margin-bottom: 18px;
}

.sidebar-brand,
.brand-link,
.mobile-brand {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.sidebar-brand-box p,
.hero-copy,
.lead-text,
.list-card p,
.article-card p,
.sidebar-search input,
.sidebar-static-links a,
.prose p,
.prose li,
.result-summary,
.empty-state {
    color: var(--muted);
}

.sidebar-search,
.search-form-large,
.article-pagination,
.form-actions,
.breadcrumbs,
.flash-stack,
.pagination,
.top-links,
.section-heading,
.article-header,
.panel-heading,
.article-meta,
.article-card-meta {
    display: flex;
    gap: 12px;
}

.sidebar-search {
    margin-bottom: 24px;
}

.sidebar-search input,
.search-form-large input,
.search-form-large select {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
}

.sidebar-search button,
.button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
}

.sidebar-search button,
.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: var(--accent-contrast);
}

.button-secondary {
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.article-nav-link {
    display: grid;
    gap: 6px;
    min-width: 220px;
}

.article-nav-link strong {
    font-size: 0.95rem;
    line-height: 1.4;
}

.site-topbar,
.section-heading,
.article-header,
.article-pagination {
    align-items: center;
    justify-content: space-between;
}

.site-topbar {
    padding: 12px 0 24px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.top-links {
    flex-wrap: wrap;
}

.top-links a {
    color: var(--muted);
}

.top-links .active,
.ghost-link,
.sidebar-item.is-active > .sidebar-item-row > a,
.sidebar-static-links .is-active {
    color: var(--accent);
}

.site-content {
    display: grid;
    gap: 22px;
    min-width: 0;
}

.content-card,
.list-card {
    padding: 24px;
}

.article-view {
    min-width: 0;
}

.article-view .article-header {
    display: grid;
    gap: 18px;
    align-items: start;
    justify-content: stretch;
}

.article-view .article-header > * {
    min-width: 0;
    margin: 0;
}

.article-view .article-meta {
    flex-wrap: wrap;
}

.article-view h1,
.article-nav-link strong,
.breadcrumbs {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.category-subsection {
    margin: 28px 0;
}

.hero-panel {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    padding: 30px;
}

.hero-badge-grid,
.stack-list,
.article-grid {
    display: grid;
    gap: 16px;
}

.article-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.badge-card,
.article-card {
    padding: 18px 20px;
}

.meta-chip {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.75rem;
    color: var(--accent);
}

.article-cover {
    margin: 22px 0;
    border-radius: 18px;
    border: 1px solid var(--border);
}

.prose {
    line-height: 1.75;
}

.prose h2,
.prose h3 {
    margin-top: 1.8em;
}

.list-card {
    align-items: center;
    justify-content: space-between;
}

.flash {
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.breadcrumbs {
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.92rem;
    color: var(--muted);
}

.pagination {
    flex-wrap: wrap;
}

.pagination a {
    min-width: 40px;
    text-align: center;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-soft);
}

.pagination .is-current {
    color: var(--accent);
}

.frontend-table-wrap {
    overflow-x: auto;
}

.glossary-toolbar {
    align-items: stretch;
}

.glossary-filter {
    min-width: 220px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
}

.frontend-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.frontend-table th,
.frontend-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.frontend-table th {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
}

.addon-thumb {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.addon-image-cell {
    width: 120px;
}

.table-note {
    color: var(--muted);
}

.glossary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--divider);
}

.glossary-row {
    display: grid;
    grid-template-columns: minmax(90px, 140px) 1fr auto;
    gap: 10px;
    align-items: start;
    padding: 14px 0;
    border-bottom: 1px solid var(--divider);
    list-style: none;
    line-height: 1.7;
}

.glossary-row .shortcut {
    color: var(--shortcut-color);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}

.glossary-row .description {
    color: var(--text);
}

.glossary-tag {
    color: var(--muted);
    font-size: 0.88rem;
    white-space: nowrap;
}

.sidebar-title {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.sidebar-tree,
.sidebar-static-links,
.sidebar-article-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 8px;
}

.sidebar-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
}

.sidebar-item.is-active > .sidebar-item-row {
    background: var(--active-row-bg);
}

.submenu-toggle {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.sidebar-submenu {
    display: none;
    margin-left: 14px;
    padding-left: 10px;
    border-left: 1px dashed var(--border);
    margin-top: 8px;
}

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

.sidebar-article-list {
    display: grid;
    gap: 4px;
    margin-top: 8px;
}

.sidebar-article-link {
    display: block;
    padding: 8px 10px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.sidebar-article-link:hover,
.sidebar-article-link.is-active {
    background: var(--active-row-bg);
    color: var(--accent);
}

.sidebar-static-links li a {
    display: block;
    padding: 8px 0;
}

.site-footer {
    padding: 30px 0 10px;
    color: var(--muted);
}

.icon-button {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    gap: 4px;
    background: var(--icon-button-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.icon-button span {
    width: 18px;
    height: 2px;
    background: var(--text);
    display: block;
}

.sidebar-overlay {
    display: none;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.theme-toggle-knob {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.theme-toggle-knob::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    transition: transform 0.2s ease;
}

:root[data-theme="light"] .theme-toggle-knob::after {
    transform: translateX(18px);
}

.theme-toggle-label {
    font-size: 0.92rem;
    font-weight: 600;
}

@media (max-width: 1080px) {
    .hero-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 920px) {
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 14px 18px;
        position: sticky;
        top: 0;
        z-index: 40;
        backdrop-filter: blur(18px);
        background: var(--mobile-header-bg);
        border-bottom: 1px solid var(--border);
    }

    .site-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        z-index: 50;
    }

    .site-sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-overlay.is-open {
        display: block;
        position: fixed;
        inset: 0;
        background: var(--overlay-bg);
        z-index: 45;
    }

    .site-content-shell {
        padding: 18px;
    }

    .site-topbar {
        display: none;
    }

    .theme-toggle-mobile {
        padding: 8px;
    }

    .theme-toggle-mobile .theme-toggle-label {
        display: none;
    }

    .list-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .article-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .article-pagination > * {
        width: 100%;
    }

    .article-nav-link {
        min-width: 0;
    }

    .glossary-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding-left: 0;
        padding-right: 0;
    }

    .glossary-filter {
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .content-card,
    .hero-panel,
    .list-card {
        padding: 18px;
    }

    .search-form-large,
    .sidebar-search {
        flex-direction: column;
    }

    .mobile-brand {
        max-width: calc(100vw - 154px);
        font-size: 1.15rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .article-view .article-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .meta-chip {
        max-width: 100%;
    }
}
