:root {
    --color-primary: #2563eb;
    --color-primary-light: #4a88f0;
    --color-primary-dark: #1a4aab;
    --color-primary-bg: rgba(37, 99, 235, 0.08);
    --color-text: #1a202c;
    --color-text-secondary: #4a5a72;
    --color-text-muted: #7a8a9e;
    --color-bg: #f5f7fb;
    --color-bg-card: #ffffff;
    --color-border: #e2e8f0;
    --color-success: #16a34a;
    --color-warning: #b91c1c;
    --color-tip: #eab308;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius: 8px;
    --transition: 0.2s ease;
    --sidebar-width: 280px;
    --right-sidebar-width: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 1.5rem; margin: 0.5rem 0; }
li { margin-bottom: 0.25rem; }

code {
    background: #eef2f6;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    color: var(--color-primary-dark);
}

pre {
    background: #0d1525;
    color: #e2e8f0;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.7;
    border: 1px solid #2d3a50;
    margin: 0.75rem 0;
}

pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin: 1rem 0; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--color-border); }
th { background: #eef2f8; font-weight: 600; color: var(--color-text); }
.table-category td { background: #eef2f8; font-weight: 700; color: var(--color-text); }

.highlight { background: #facc15; color: var(--color-text); padding: 0 0.2rem; border-radius: 3px; font-weight: 600; }

.app { display: flex; flex-direction: column; min-height: 100vh; margin: 0 auto; background: var(--color-bg); }

.header {
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-sm);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-brand { font-weight: 700; font-size: 1.25rem; color: var(--color-primary); letter-spacing: -0.3px; }
.header-version { font-size: 0.7rem; color: var(--color-text-muted); background: #eef2f6; padding: 2px 10px; border-radius: 12px; font-weight: 500; }

.header-center { flex: 1; max-width: 420px; margin: 0 20px; position: relative; }

.header-search {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 40px;
    padding: 8px 48px 8px 40px;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8a9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
    color: var(--color-text);
}

.header-search:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); background-color: var(--color-bg-card); }
.header-search::placeholder { color: var(--color-text-muted); }

.search-shortcut {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 0.65rem; color: var(--color-text-muted); background: var(--color-bg);
    padding: 2px 8px; border-radius: 4px; border: 1px solid var(--color-border); font-weight: 500;
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
    background: none; border: none; cursor: pointer; padding: 6px; border-radius: 50%;
    color: var(--color-text-secondary); display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}

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

.mobile-menu-btn {
    background: none; border: none; cursor: pointer; color: var(--color-text-secondary);
    display: none; padding: 6px; border-radius: 6px; transition: var(--transition);
}

.mobile-menu-btn:hover { background: var(--color-bg); }

.body-wrap { display: flex; flex: 1; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-bg-card);
    border-right: 1px solid var(--color-border);
    padding: 20px 12px 32px;
    flex-shrink: 0;
    height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header { padding: 0 8px 16px 8px; border-bottom: 1px solid var(--color-border); margin-bottom: 12px; }
.sidebar-title { font-weight: 700; font-size: 1.1rem; color: var(--color-text); }
.sidebar-sub { font-size: 0.8rem; color: var(--color-text-muted); font-weight: 400; }
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover { background: var(--color-bg); color: var(--color-primary); }
.nav-link:hover svg { opacity: 1; }
.nav-link.active { background: var(--color-primary-bg); color: var(--color-primary); font-weight: 600; }
.nav-link.active svg { opacity: 1; stroke: var(--color-primary); }
.nav-link-content { display: flex; align-items: center; gap: 10px; flex: 1; }

.has-submenu { position: relative; }
.submenu-toggle { cursor: pointer !important; user-select: none; }
.submenu-toggle .submenu-arrow { display: flex; align-items: center; transition: transform 0.3s ease; flex-shrink: 0; margin-left: auto; }
.submenu { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out; margin-left: 28px; padding-left: 8px; }
.submenu.open { max-height: 600px; }

.sub-link {
    display: block; width: 100%; text-align: left; padding: 6px 12px; font-size: 0.8rem;
    color: var(--color-text-secondary); cursor: pointer; border-radius: 4px; transition: var(--transition);
    border: none; background: none; font-family: inherit;
}

.sub-link:hover { background: var(--color-bg); color: var(--color-primary); }
.sub-link.active-sub { background: var(--color-primary-bg); color: var(--color-primary); font-weight: 600; }

.content-wrapper { display: flex; flex: 1; min-width: 0; }

.main {
    flex: 1;
    padding: 28px 44px 48px;
    min-height: calc(100vh - 64px);
    max-width: 860px;
    background: var(--color-bg);
    min-width: 0;
}

.breadcrumb {
    display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 500;
    color: var(--color-text-muted); margin-bottom: 16px;
}

.breadcrumb-link { color: var(--color-primary); cursor: pointer; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-separator { color: var(--color-text-muted); }
.breadcrumb-current { color: var(--color-text); font-weight: 600; }

.page-header { margin-bottom: 32px; }
.page-header h1 { font-size: 2.2rem; font-weight: 700; color: var(--color-text); letter-spacing: -0.02em; margin-bottom: 4px; }
.page-header p { font-size: 1.05rem; color: var(--color-text-secondary); }

.doc-section { display: none; animation: fadeIn 0.3s ease; }
.doc-section.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.doc-section h2 {
    font-size: 1.6rem; font-weight: 600; color: var(--color-text);
    border-bottom: 1px solid var(--color-border); padding-bottom: 10px;
    margin: 36px 0 18px 0; scroll-margin-top: 80px;
}

.doc-section h3 { font-size: 1.15rem; font-weight: 600; margin: 22px 0 10px; color: var(--color-text); scroll-margin-top: 80px; }
.doc-section p { margin: 10px 0; color: var(--color-text-secondary); }

.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin: 16px 0;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--shadow-md); }
.card-info { background: #f8faff; padding: 12px; }
.card-warning { background: #fef2f2; padding: 12px; }
.card-success { background: #f0fdf4; padding: 12px; }
.card-tip { background: #fffbeb; padding: 12px; }
.flex-row { display: flex; gap: 14px; align-items: flex-start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.file-path { font-family: monospace; background: #eef2f6; padding: 2px 12px; border-radius: 4px; display: inline-block; font-size: 0.85rem; color: var(--color-text); }

.steps-list { list-style: none; padding: 0; margin: 16px 0; }
.step-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--color-border); }
.step-item:last-child { border-bottom: none; }
.step-number { flex-shrink: 0; width: 32px; height: 32px; background: var(--color-primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; }
.step-content { flex: 1; }
.step-content strong { display: block; font-size: 1rem; color: var(--color-text); margin-bottom: 4px; }
.step-content p { margin: 4px 0; color: var(--color-text-secondary); }
.step-content ol { padding-left: 1.2rem; margin: 4px 0; }
.step-content ol li { color: var(--color-text-secondary); }

.right-sidebar {
    width: var(--right-sidebar-width);
    flex-shrink: 0;
    padding: 28px 16px 32px 20px;
    height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    overflow-y: auto;
    background: var(--color-bg);
    display: block;
}

.right-sidebar-title {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--color-text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border);
}

.right-sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.right-sidebar-link {
    display: block; padding: 4px 8px; font-size: 0.8rem; color: var(--color-text-secondary);
    cursor: pointer; border-radius: 4px; transition: var(--transition); border: none;
    background: none; width: 100%; text-align: left; line-height: 1.4; font-family: inherit;
}

.right-sidebar-link:hover { color: var(--color-primary); background: var(--color-bg); }
.right-sidebar-link.active-toc { color: var(--color-primary); font-weight: 600; background: var(--color-primary-bg); }
.right-sidebar-link.toc-indent-1 { padding-left: 8px; }
.right-sidebar-link.toc-indent-2 { padding-left: 20px; font-size: 0.75rem; }

.code-wrapper { position: relative; margin: 0.75rem 0; }
.code-wrapper pre { margin: 0; padding-right: 80px; }

.copy-btn {
    position: absolute; top: 8px; right: 8px;
    background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12);
    color: #b0b8c8; padding: 4px 10px; border-radius: 4px; font-size: 0.7rem;
    font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 4px;
    transition: all 0.2s ease; font-family: inherit; backdrop-filter: blur(4px); opacity: 0.6;
}

.code-wrapper:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.copy-btn.copied { background: rgba(74, 222, 128, 0.2); border-color: rgba(74, 222, 128, 0.3); color: #4ade80; }

.pagination {
    display: flex; justify-content: space-between;
    border-top: 1px solid var(--color-border); padding-top: 24px; margin-top: 40px;
}

.pagination-prev, .pagination-next {
    display: flex; flex-direction: column; cursor: pointer; color: var(--color-primary);
    padding: 8px 16px; border-radius: var(--radius); transition: all 0.2s ease;
    border: 1px solid transparent;
}

.pagination-prev:hover, .pagination-next:hover {
    background: var(--color-bg-card); border-color: var(--color-border);
    text-decoration: none; box-shadow: var(--shadow-sm);
}

.pagination-label { font-size: 0.75rem; color: var(--color-text-muted); font-weight: 500; }
.pagination-title { font-weight: 500; color: var(--color-text); }

.faq-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.faq-item { border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; background: var(--color-bg-card); transition: box-shadow 0.2s ease; }
.faq-item:hover { box-shadow: var(--shadow-sm); }
.faq-question { padding: 14px 20px; font-weight: 600; color: var(--color-text); cursor: pointer; background: var(--color-bg); transition: background 0.2s ease; border: none; width: 100%; text-align: left; font-size: 0.95rem; font-family: inherit; }
.faq-question:hover { background: #e8ecf4; }
.faq-answer { padding: 14px 20px; border-top: 1px solid var(--color-border); color: var(--color-text-secondary); }
.faq-answer pre { margin: 8px 0; }
.warning-text { color: var(--color-warning); font-weight: 600; }

.contact-cards { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.contact-cards .card { margin: 0; }

/* Dark mode */
html.dark {
    --color-bg: #0f1729;
    --color-bg-card: #1a2235;
    --color-border: #2d3a50;
    --color-text: #e2e8f0;
    --color-text-secondary: #b0b8c8;
    --color-text-muted: #7a8a9e;
    --color-primary: #8ba4e0;
    --color-primary-light: #a5b4fc;
    --color-primary-dark: #6a8ac0;
    --color-primary-bg: rgba(139, 164, 224, 0.12);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

html.dark code { background: #1e273b; color: #e2e8f0; }
html.dark pre { background: #0d1525; border-color: #2d3a50; }
html.dark th { background: #1e273b; color: #e2e8f0; }
html.dark td { border-color: #2d3a50; }
html.dark .table-category td { background: #1e273b; }
html.dark .file-path { background: #1e273b; color: #cbd5e1; }
html.dark .header-search { background: #1e273b; border-color: #2d3a50; color: #e2e8f0; }
html.dark .header-search:focus { background: #1e273b; }
html.dark .search-shortcut { background: #1e273b; border-color: #2d3a50; color: #7a8a9e; }
html.dark .card-info { background: #1a2235; }
html.dark .card-warning { background: #1a2235; }
html.dark .card-success { background: #1a2235; }
html.dark .card-tip { background: #1a2235; }
html.dark .faq-item { background: #1a2235; border-color: #2d3a50; }
html.dark .faq-question { background: #1e273b; color: #e2e8f0; }
html.dark .faq-question:hover { background: #2a3348; }
html.dark .faq-answer { border-color: #2d3a50; }
html.dark .step-item { border-color: #2d3a50; }
html.dark .step-number { background: #8ba4e0; color: #0f1729; }
html.dark .pagination-prev:hover, html.dark .pagination-next:hover { background: #1a2235; border-color: #2d3a50; }
html.dark .nav-link:hover { background: #1e273b; }
html.dark .nav-link.active { background: rgba(139, 164, 224, 0.12); color: #8ba4e0; }
html.dark .nav-link.active svg { stroke: #8ba4e0; }
html.dark .sub-link:hover { background: #1e273b; }
html.dark .sub-link.active-sub { background: rgba(139, 164, 224, 0.12); color: #8ba4e0; }
html.dark .sidebar { background: #151d2e; border-color: #2d3a50; }
html.dark .right-sidebar { background: #0f1729; border-color: #2d3a50; }
html.dark .right-sidebar-link:hover { background: #1a2235; }
html.dark .right-sidebar-link.active-toc { background: rgba(139, 164, 224, 0.12); color: #8ba4e0; }
html.dark .sidebar-title { color: #e2e8f0; }
html.dark .sidebar-sub { color: #7a8a9e; }
html.dark .theme-toggle:hover { background: #1e273b; }
html.dark .highlight { background: #fbbf24; color: #0b1c30; }
html.dark .header-version { background: #1e273b; color: #7a8a9e; }
html.dark .breadcrumb-link { color: #8ba4e0; }
html.dark .breadcrumb-current { color: #e2e8f0; }

/* Responsive */
@media (max-width: 1199px) {
    .right-sidebar { width: 180px; padding: 28px 12px 32px 16px; }
}

@media (max-width: 899px) {
    .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
    .sidebar {
        position: fixed; top: 64px; left: -100%; width: 280px;
        height: calc(100vh - 64px); transition: left 0.3s ease; z-index: 100;
        background: var(--color-bg-card); border-right: 1px solid var(--color-border);
        padding: 16px 12px; overflow-y: auto; box-shadow: var(--shadow-md);
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay { display: none; position: fixed; top: 64px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 99; backdrop-filter: blur(2px); }
    .sidebar-overlay.active { display: block; }
    .right-sidebar { display: none; }
    .main { padding: 20px 24px 32px; max-width: 100%; }
    .grid-2 { grid-template-columns: 1fr; }
    .header-center { margin: 0 12px; max-width: 200px; }
    .header-search { font-size: 0.8rem; padding: 6px 12px 6px 34px; background-position: 10px center; }
    .search-shortcut { display: none; }
    .page-header h1 { font-size: 1.6rem; }
    .content-wrapper { flex-direction: column; }
}

@media (max-width: 600px) {
    .header { padding: 0 12px; height: 56px; }
    .header-center { max-width: 140px; }
    .header-search { font-size: 0.75rem; padding: 4px 10px 4px 30px; background-position: 8px center; }
    .header-version { display: none; }
    .page-header h1 { font-size: 1.3rem; }
    .page-header p { font-size: 0.9rem; }
    .main { padding: 16px 16px 28px; }
    .card { padding: 14px 16px; }
    .step-item { flex-direction: column; gap: 8px; }
    .step-number { width: 28px; height: 28px; font-size: 0.75rem; }
    .pagination { flex-direction: column; gap: 12px; align-items: stretch; }
    .pagination-prev, .pagination-next { align-items: center; }
}

/* Image styles */
.image-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.step-image { width: 100%; height: auto; max-height: 320px; object-fit: contain; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg-card); box-shadow: var(--shadow-sm); transition: box-shadow 0.2s ease; }
.step-image:hover { box-shadow: var(--shadow-md); }
.image-wrapper { border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; background: var(--color-bg-card); box-shadow: var(--shadow-sm); margin: 12px 0; }
.image-wrapper img { width: 100%; height: auto; display: block; max-height: 400px; object-fit: contain; }
.image-wrapper .image-caption { padding: 10px 16px; font-size: 0.85rem; color: var(--color-text-secondary); background: var(--color-bg); border-top: 1px solid var(--color-border); text-align: center; }
.single-image { max-width: 100%; max-height: 400px; height: auto; border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin: 16px 0; display: block; }
.single-image:hover { box-shadow: var(--shadow-md); }
.image-small { max-width: 60%; max-height: 300px; height: auto; border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin: 12px auto; display: block; }
.image-small:hover { box-shadow: var(--shadow-md); }

html.dark .step-image { border-color: #2d3a50; background: #1a2235; }
html.dark .image-wrapper { border-color: #2d3a50; background: #1a2235; }
html.dark .image-wrapper .image-caption { background: #1e273b; border-color: #2d3a50; color: #b0b8c8; }
html.dark .single-image { border-color: #2d3a50; }
html.dark .image-small { border-color: #2d3a50; }

@media (max-width: 992px) { .image-grid { gap: 12px; } .step-image { max-height: 280px; } }
@media (max-width: 768px) { .image-grid { grid-template-columns: 1fr; gap: 12px; } .step-image { max-height: 300px; } .image-wrapper img { max-height: 300px; } .single-image { max-height: 300px; } .image-small { max-width: 80%; max-height: 250px; } }
@media (max-width: 480px) { .step-image { max-height: 220px; } .image-wrapper img { max-height: 220px; } .single-image { max-height: 220px; } .image-small { max-width: 95%; max-height: 200px; } .image-wrapper .image-caption { font-size: 0.75rem; padding: 8px 12px; } }
