:root {
    --header-height: 64px;
    --sidebar-width: 280px;
    --color-text: #222;
    --color-muted: #666;
    --color-border: #e5e5e5;
    --color-banner: #4a4a4a;
    --color-active: #f3f3f3;
    --color-link: #222;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--color-text);
    background: #fff;
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    border-bottom: 1px solid var(--color-border);
    background: #fff;
}

.site-header__inner {
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.site-brand__logo {
    height: 40px;
    width: auto;
    max-width: none;
    display: block;
    object-fit: contain;
}

.site-brand__text {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.site-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}

.header-action {
    position: relative;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #444;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s ease, color .15s ease;
}

.header-icon-btn:hover,
.header-icon-btn.is-active {
    background: var(--color-active);
    color: #222;
}

.header-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 120;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: 8px;
}

.header-panel[hidden] {
    display: none !important;
}

.site-search {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.site-search input {
    border: 0;
    outline: 0;
    padding: 8px 12px;
    width: 220px;
    font-size: 14px;
}

.site-search button {
    border: 0;
    background: transparent;
    padding: 8px 10px;
    cursor: pointer;
    color: #444;
}

.header-panel--lang select {
    min-width: 160px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.site-body {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - var(--header-height));
}

.site-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    min-height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
}

.sidebar-nav {
    padding: 16px 0;
}

.sidebar-group + .sidebar-group {
    border-top: 1px solid var(--color-border);
}

.sidebar-group__title {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 20px;
    border: 0;
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.sidebar-group__title.is-active,
.sidebar-group__title:hover {
    background: var(--color-active);
}

.sidebar-group__chevron {
    transition: transform .2s ease;
    color: #888;
}

.sidebar-group.is-open .sidebar-group__chevron {
    transform: rotate(180deg);
}

.sidebar-group__items {
    list-style: none;
    margin: 0;
    padding: 0 0 8px;
}

.sidebar-group__items[hidden] {
    display: none;
}

.sidebar-link {
    display: block;
    padding: 10px 20px 10px 28px;
    font-size: 14px;
    color: #333;
}

.sidebar-link.is-active {
    background: var(--color-active);
    font-weight: 600;
}

.site-main {
    flex: 1;
    min-width: 0;
    padding: 0 32px 48px;
}

.section-panel__banner,
.article-panel .section-panel__banner {
    margin-top: 24px;
    background: var(--color-banner);
    color: #fff;
    padding: 18px 24px;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.3;
}

.section-panel__intro {
    margin: 20px 0 0;
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}

.article-panel__title {
    margin: 24px 0 0;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.3;
    color: #111;
}

.article-panel__summary-box {
    margin-top: 20px;
    padding: 16px 20px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #f9f9f9;
}

.article-panel__summary {
    margin: 0;
    font-size: 14px;
    line-height: 1.75;
    color: var(--color-muted);
    letter-spacing: 0.02em;
}

.article-panel__content.rich-text > h1:first-child {
    display: none;
}

.section-panel__toc {
    margin-top: 28px;
}

.section-panel__toc-title {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 700;
}

.section-panel__toc-list {
    margin: 0;
    padding-left: 20px;
}

.section-panel__toc-list li {
    margin: 10px 0;
    font-size: 15px;
    line-height: 1.6;
}

.article-panel__content,
.rich-text {
    margin-top: 24px;
    font-size: 15px;
    line-height: 1.9;
    color: #333;
}

.rich-text p {
    margin: 0 0 1em;
}

.rich-text p:last-child {
    margin-bottom: 0;
}

.rich-text img {
    max-width: 100%;
    height: auto;
}

.rich-text video,
.rich-text iframe {
    max-width: 100%;
}

.rich-text video {
    display: block;
    margin: 1em 0;
}

.rich-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.rich-text th,
.rich-text td {
    border: 1px solid var(--color-border);
    padding: 8px 10px;
}

.rich-text blockquote {
    margin: 1em 0;
    padding: 8px 16px;
    border-left: 4px solid #ccc;
    color: #555;
    background: #fafafa;
}

.search-results {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .25);
    z-index: 200;
    display: none;
    justify-content: center;
    padding-top: 96px;
}

.search-results.is-open {
    display: flex;
}

.search-results__panel {
    width: min(640px, calc(100% - 32px));
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .15);
    max-height: 60vh;
    overflow: auto;
}

.search-results__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
}

.search-results__header button {
    border: 0;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.search-results__list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.search-results__list a {
    display: block;
    padding: 12px 18px;
}

.search-results__list a:hover {
    background: #f7f7f7;
    text-decoration: none;
}

.site-footer {
    margin-top: 48px;
    background: #f0f0f0;
    border-top: 1px solid var(--color-border);
}

.site-footer__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.site-footer__brand {
    min-width: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.site-footer__logo-link {
    display: inline-flex;
    align-items: center;
    min-height: 52px;
}

.site-footer__logo {
    height: 52px;
    width: auto;
    max-width: none;
    display: block;
    object-fit: contain;
}

.site-footer__brand-text {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.site-footer__aside {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
}

.site-footer__copyright {
    margin: 0;
    font-size: 13px;
    color: #888;
    line-height: 1.5;
    text-align: right;
}

.site-footer__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 20px;
}

.site-footer__nav a {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

.site-footer__nav a:hover {
    text-decoration: underline;
}

.site-footer__icp {
    color: #666;
}

.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 4px;
    background: #4a4a4a;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
    z-index: 90;
    transition: opacity .2s ease, transform .2s ease;
}

.back-to-top[hidden] {
    display: none !important;
}

.back-to-top:hover {
    background: #333;
}

.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.mobile-nav-toggle__bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #333;
    border-radius: 1px;
    transition: transform .2s ease, opacity .2s ease;
}

.mobile-nav-toggle.is-open .mobile-nav-toggle__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-nav-toggle.is-open .mobile-nav-toggle__bar:nth-child(2) {
    opacity: 0;
}

.mobile-nav-toggle.is-open .mobile-nav-toggle__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 150;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.mobile-drawer-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.mobile-drawer-overlay[hidden] {
    display: none !important;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(320px, 86vw);
    height: 100vh;
    background: #fff;
    z-index: 160;
    transform: translateX(100%);
    transition: transform .28s ease;
    box-shadow: -6px 0 24px rgba(0, 0, 0, .14);
    display: flex;
    flex-direction: column;
}

.mobile-drawer.is-open {
    transform: translateX(0);
}

.mobile-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.mobile-drawer__title {
    font-size: 16px;
    font-weight: 600;
}

.mobile-drawer__close {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666;
}

.mobile-drawer__body {
    flex: 1;
    overflow-y: auto;
}

.mobile-nav__list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.mobile-nav__link {
    display: block;
    padding: 16px 24px;
    font-size: 15px;
    color: #333;
    border-bottom: 1px solid #f3f3f3;
}

.mobile-nav__link.is-active,
.mobile-nav__link:hover {
    background: var(--color-active);
    text-decoration: none;
}

body.drawer-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .site-header__inner {
        padding: 10px 16px;
    }

    .site-brand {
        flex: 1;
        min-width: 0;
    }

    .site-brand__logo {
        height: 32px;
    }

    .site-search input {
        width: min(68vw, 260px);
    }

    .header-panel--lang select {
        min-width: 140px;
    }

    .mobile-nav-toggle {
        display: inline-flex;
    }

    .site-body { display: block; }

    .site-sidebar {
        display: none;
    }

    .site-main { padding: 0 16px 32px; }

    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px 16px 28px;
        gap: 20px;
    }

    .site-footer__aside {
        align-items: flex-start;
        width: 100%;
    }

    .site-footer__copyright {
        text-align: left;
    }

    .site-footer__nav {
        justify-content: flex-start;
    }

    .back-to-top {
        right: 16px;
        bottom: 16px;
    }
}
