#header-container {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 41;
    backdrop-filter: blur(10px) saturate(1.2);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    background: var(--bg-card);
    width: 50%;
    border-radius: 30px;
}

#banner {
    position: relative;
    display: none;
    padding: 10px 48px;
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
    background: transparent;
}

#banner-close {
    position: absolute;
    top: 50%;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    transform: translateY(-50%);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: inherit;
    opacity: 0.6;
}

#banner-close:hover {
    opacity: 1;
    background: var(--hover-bg);
}

#navbar {
    position: relative;
    background: transparent;
}

#navbar .nav-top {
    position: relative;
    display: flex;
    align-items: center;
    height: 60px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 10px;
}

#navbar .brand {
    display: flex;
    align-items: center;
}

#navbar .brand img {
    height: 28px;
    width: 28px;
    border-radius: 50%;
    display: block;
}

#navbar .links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

#navbar .tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 48px;
    max-width: 1400px;
    margin: 0 auto;
    overflow-x: auto;
}

#navbar .tabs a {
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

#navbar .tabs a:hover {
    color: var(--text);
}

#navbar .tabs a.active {
    color: var(--text);
    font-weight: 600;
}

#layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
}

#sidebar {
    margin-top: 40px;
    border-radius: 12px;
    width: var(--sidebar-width);
    flex-shrink: 0;
    padding-top: 20px;
    padding-left: 20px;
    position: sticky;
    height: fit-content;
    top: calc(var(--header-height) + 40px);
    max-height: calc(100vh - var(--header-height) - 40px);
    overflow-y: auto;
}

#sidebar .group {
    margin-bottom: 10px;
}

#sidebar .group-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 23px;
    color: var(--text);
    margin: 0 0 10px 16px;
}

#sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#sidebar li a {
    display: block;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 21px;
    color: var(--muted);
}

#sidebar li a.active {
    color: var(--text);
}

#sidebar li a:hover {
    background: var(--hover-bg);
    color: var(--text);
}

#content-col {
    flex: 1;
    min-width: 0;
    display: flex;
    padding: 16px max(20px, env(safe-area-inset-right)) 20px max(20px, env(safe-area-inset-left));
    gap: 92px;
    max-width: 100%;
    box-sizing: border-box;
    width: 80vw;
}

#main-wrap {
    flex: 1;
    min-width: 0;
    max-width: 720px;
    margin-top: 120px;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

footer#site-footer {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 48px 0 60px;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.footer-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-height: 22px;
    margin: 0 0 36px;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: opacity 0.15s ease;
}

.footer-link:hover {
    opacity: 0.8;
}

.footer-link.hidden {
    visibility: hidden;
}

.footer-link.next {
    margin-left: auto;
}

.footer-bottom {
    width: 100%;
    border-top: 1px solid var(--footer-border);
    padding-top: 28px;
}

.footer-socials {
    display: flex;
    gap: 16px;
}

.footer-socials a {
    display: flex;
    align-items: center;
    color: var(--muted);
    transition: color 0.15s ease;
}

.footer-socials a:hover {
    color: var(--text);
}

.footer-icon {
    width: 20px;
    height: 20px;
}

.theme-wrap {
    position: relative;
}

#theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

#theme-toggle .ico {
    width: 18px;
    height: 18px;
}

#theme-toggle:hover {
    background: var(--hover-bg);
}

#theme-menu {
    display: flex;
    flex-direction: column;
    position: absolute;
    right: 0;
    top: 46px;
    width: 215px;
    max-height: 75vh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding: 8px;
    border-radius: 16px;
    background: var(--bg-menu);
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    pointer-events: none;
    box-sizing: border-box;
}

#theme-menu::-webkit-scrollbar,
#theme-seg-menu::-webkit-scrollbar {
    width: 4px;
}

#theme-menu::-webkit-scrollbar-thumb,
#theme-seg-menu::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

#theme-menu::-webkit-scrollbar-track,
#theme-seg-menu::-webkit-scrollbar-track {
    background: transparent;
}

#theme-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.theme-menu-divider {
    height: 1px;
    margin: 6px 6px;
    background: var(--border);
    flex-shrink: 0;
}

.theme-menu-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 6px 10px 4px;
    text-align: left;
    user-select: none;
}

#theme-menu button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--text);
    ;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;
}

#theme-menu button:hover {
    background: var(--hover-bg);
}

#theme-menu button .ico {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--muted);
}

#theme-menu button span {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#theme-menu .check {
    margin-left: auto;
    flex-shrink: 0;
    font-style: normal;
    font-size: 13px;
    visibility: hidden;
}

#theme-menu button.on {
    font-weight: 600;
    color: var(--text);
}

#theme-menu button.on .ico {
    color: var(--text);
}

#theme-menu button.on .check {
    visibility: visible;
}

#theme-seg {
    position: relative;
    display: none;
    gap: 4px;
}

#theme-seg-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 180px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 14px;
    background: var(--bg-menu);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 250;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.96);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    pointer-events: none;
}

#theme-seg-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#theme-seg-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 215px;
    max-height: 340px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding: 6px;
    border-radius: 14px;
    background: var(--bg-menu);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 250;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.96);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    pointer-events: none;
    box-sizing: border-box;
}

#theme-seg-menu button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 36px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--text);
    ;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;
}

#theme-seg-menu button:hover {
    background: var(--hover-bg);
}

#theme-seg-menu button .ico {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--muted);
}

#theme-seg-menu button span {
    display: block;
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    ;
}

#theme-seg-menu button.on span {
    color: var(--text);
    font-weight: 600;
}

#theme-seg-menu button.on .ico {
    color: var(--text);
}

#theme-seg-menu button .check {
    margin-left: auto;
    flex-shrink: 0;
    font-style: normal;
    font-size: 13px;
    visibility: hidden;
}

#theme-seg-menu button.on .check {
    visibility: visible;
    color: var(--text);
}

#theme-seg-menu button:hover {
    background: var(--hover-bg);
}

#theme-seg-menu button.on {
    font-weight: 600;
    color: var(--text);
}

#theme-seg-menu .check {
    margin-left: auto;
    font-style: normal;
    visibility: hidden;
}

#theme-seg-menu button.on .check {
    visibility: visible;
}

#theme-seg>button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
}

#theme-seg>button.on {
    background: var(--hover-bg);
    color: var(--text);
}

#mobile-bar {
    display: none;
    position: relative;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--muted);
    background: transparent;
    border-top: 1px solid var(--border-subtle);
}

#mobile-bar button {
    display: flex;
    padding: 0;
    margin-right: 4px;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-crumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.mobile-crumbs span {
    flex-shrink: 0;
}

.mobile-crumbs .crumb-group {
    color: var(--muted);
}

.mobile-crumbs .crumb-sep {
    opacity: 0.55;
    font-size: 12px;
}

.mobile-crumbs .crumb-page {
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.mobile-crumbs .crumb-page:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.mobile-crumbs .crumb-page.muted {
    color: var(--muted);
    font-weight: 400;
}

.mobile-crumb-sub-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.mobile-crumb-sub-btn:hover .crumb-heading {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.mobile-crumbs .crumb-heading {
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

.mobile-tabs {
    display: none;
    position: relative;
    margin-bottom: 20px;
}

.mt-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: var(--hover-bg);
    border-radius: 100px;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
}

.mt-btn .ico {
    color: var(--muted);
    transition: transform 0.15s ease;
}

.mobile-tabs.open .mt-btn .ico {
    transform: rotate(180deg);
}

.mt-menu {
    display: block;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 5;
    padding: 6px;
    border-radius: 16px;
    background: var(--bg-menu);
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    pointer-events: none;
}

.mobile-tabs.open .mt-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.mt-menu .mt-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.mt-menu .mt-item:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.mt-menu .mt-item.on {
    color: var(--text);
    font-weight: 600;
}

.mt-menu .mt-item svg {
    display: none;
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    flex-shrink: 0;
}

.mt-menu .mt-item.on svg {
    display: block;
}

.side-head {
    display: none;
}

body.is-home #layout {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
}

body.is-home #content-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

body.is-home #content-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px 30px;
    margin: 0 auto;
    gap: 0;
    box-sizing: border-box;
}

body.is-home #main-wrap {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.is-home main.prose {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.is-home #toc,
body.is-home #sidebar,
body.is-home #mobile-bar {
    display: none !important;
}

@media (max-width: 900px) {
    :root {
        --header-height: 60px;
    }

    #header-container {
        width: 90%;
        border-radius: 30px;
        backdrop-filter: blur(15px) saturate(1.2);
        -webkit-backdrop-filter: blur(15px) saturate(1.2);
        top: max(6px, env(safe-area-inset-top));
    }

    #navbar .tabs,
    #theme-toggle {
        display: none;
    }

    #navbar .nav-top {
        padding-right: 20px;
        padding-left: 15px;
    }

    #navbar .links {
        order: 1;
        margin-left: auto;
        margin-right: 8px;
    }

    #mobile-bar {
        display: flex;
    }

    .mobile-tabs {
        display: block;
        margin-top: 8px;
    }

    #sidebar #theme-seg {
        display: flex;
        align-items: center;
        background: var(--hover-bg);
        border-radius: 50px;
        padding: 2px 4px;
        gap: 2px;
    }

    #sidebar #theme-seg>button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border: none;
        border-radius: 50%;
        background: none;
        color: var(--muted);
        cursor: pointer;
        padding: 0;
        flex-shrink: 0;
    }

    #sidebar #theme-seg>button.on {
        color: var(--text);
        font-weight: 900;
    }

    #banner {
        padding: 10px 40px;
        font-size: 12.5px;
    }

    body.nav-open {
        overflow: hidden;
    }

    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        margin-top: 0 !important;
        width: 80%;
        max-width: 340px;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        padding: 0 16px 20px;
        background: var(--bg);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
        border-radius: 0 35px 35px 0;
        z-index: 200;
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebar li a,
    #sidebar .group-title {
        font-size: 15px;
    }

    #layout {
        display: block;
        width: 100%;
        max-width: 100vw;
    }

    #content-col {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 16px 20px 30px;
        gap: 0;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    #main-wrap {
        width: 100%;
        max-width: 100%;
    }

    footer#site-footer {
        width: 100%;
        max-width: 100%;
    }

    .side-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 60px;
        margin: 0 -16px 12px;
        padding: 0 16px;
        margin-top: max(6px, env(safe-area-inset-top));
    }

    #sidebar .side-head .brand {
        display: flex;
        align-items: center;
    }

    #sidebar .side-head .brand img {
        height: 28px;
        width: 28px;
        border-radius: 50%;
        display: block;
    }

    #sidebar .side-links {
        display: flex;
        align-items: center;
        margin-right: 4px;
    }
}

@media (orientation: landscape) and (max-height: 550px) {
    :root {
        --header-height: 52px;
    }

    #header-container {
        top: max(6px, env(safe-area-inset-top));
        width: min(600px, 88vw);
        border-radius: 20px;
    }

    #navbar .nav-top {
        height: 46px;
    }

    #navbar .tabs {
        height: 38px;
    }

    #navbar .tabs a {
        padding: 4px 10px;
        font-size: 13px;
    }

    #main-wrap {
        margin-top: 100px;
    }

    #sidebar {
        top: calc(var(--header-height) + 16px);
        max-height: calc(100vh - var(--header-height) - 16px);
        margin-top: 10px;
    }

    #mobile-bar {
        padding: 6px 14px;
        font-size: 13px;
    }
}