:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-code: #282c34;
    --bg-sidebar: #f5f6f8;
    --bg-hover: #e8eaed;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f2f5;
    --bg-badge: #e3f2fd;
    --bg-table-header: #f5f6f8;
    --bg-table-row-alt: #fafbfc;
    --bg-callout-info: #e8f4fd;
    --bg-callout-warn: #fff8e1;
    --bg-callout-tip: #e8f5e9;
    --bg-callout-danger: #fde8e8;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-tertiary: #7a7a9a;
    --text-code: #e06c75;
    --text-link: #2563eb;
    --text-link-hover: #1d4ed8;
    --border-primary: #e2e5e9;
    --border-secondary: #d0d5dd;
    --accent-primary: #2563eb;
    --accent-secondary: #7c3aed;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --header-height: 56px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1b26;
    --bg-tertiary: #24253a;
    --bg-code: #1a1b26;
    --bg-sidebar: #141520;
    --bg-hover: #24253a;
    --bg-card: #1a1b26;
    --bg-card-hover: #24253a;
    --bg-badge: #1e3a5f;
    --bg-table-header: #1a1b26;
    --bg-table-row-alt: #141520;
    --bg-callout-info: #0d2137;
    --bg-callout-warn: #2a2000;
    --bg-callout-tip: #0d2818;
    --bg-callout-danger: #2a0d0d;
    --text-primary: #e1e4e8;
    --text-secondary: #9da5b4;
    --text-tertiary: #6b7280;
    --text-code: #e06c75;
    --text-link: #58a6ff;
    --text-link-hover: #79b8ff;
    --border-primary: #2d2f45;
    --border-secondary: #3d3f55;
    --accent-primary: #58a6ff;
    --accent-secondary: #a78bfa;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

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

.app {
    min-height: 100vh;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.85);
}

[data-theme="dark"] .header {
    background: rgba(15,17,23,0.85);
}

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

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-primary);
    border-radius: 18px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-primary);
    transition: var(--transition);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.search-result-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-link {
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.header-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.icon-moon { display: none; }
.icon-sun { display: block; }

[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }

.layout {
    display: flex;
    padding-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-primary);
    overflow-y: auto;
    padding: 12px 0;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 2px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 8px 20px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--accent-primary);
    background: var(--bg-hover);
    border-left-color: var(--accent-primary);
    font-weight: 600;
}

.nav-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-link.active svg {
    opacity: 1;
}

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.content-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 40px 80px;
}

.content-inner h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.3;
    color: var(--text-primary);
}

.content-inner .page-desc {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.content-inner h2 {
    font-size: 22px;
    font-weight: 700;
    margin-top: 40px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.content-inner h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.content-inner h4 {
    font-size: 15px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.content-inner p {
    margin-bottom: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.content-inner ul, .content-inner ol {
    margin-bottom: 14px;
    padding-left: 24px;
    color: var(--text-secondary);
}

.content-inner li {
    margin-bottom: 6px;
    line-height: 1.7;
}

.content-inner strong {
    color: var(--text-primary);
    font-weight: 600;
}

.content-inner a {
    color: var(--text-link);
    text-decoration: none;
    transition: var(--transition);
}

.content-inner a:hover {
    color: var(--text-link-hover);
    text-decoration: underline;
}

.content-inner code {
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 0.88em;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-code);
}

.content-inner pre {
    margin: 16px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-primary);
}

.content-inner pre code {
    display: block;
    padding: 16px 20px;
    background: var(--bg-code);
    color: #abb2bf;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    border-radius: 0;
}

.content-inner pre code::-webkit-scrollbar {
    height: 4px;
}

.content-inner pre code::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.content-inner table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.content-inner thead {
    background: var(--bg-table-header);
}

.content-inner th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-primary);
    white-space: nowrap;
}

.content-inner td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

.content-inner tr:last-child td {
    border-bottom: none;
}

.content-inner tr:nth-child(even) {
    background: var(--bg-table-row-alt);
}

.content-inner blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-callout-info);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.content-inner blockquote p {
    margin-bottom: 0;
}

.callout {
    margin: 16px 0;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    border-left: 4px solid;
}

.callout p { margin-bottom: 6px; }
.callout p:last-child { margin-bottom: 0; }

.callout-info {
    background: var(--bg-callout-info);
    border-color: var(--accent-primary);
}

.callout-warn {
    background: var(--bg-callout-warn);
    border-color: var(--accent-warning);
}

.callout-tip {
    background: var(--bg-callout-tip);
    border-color: var(--accent-success);
}

.callout-danger {
    background: var(--bg-callout-danger);
    border-color: var(--accent-danger);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.card-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-badge);
    color: var(--accent-primary);
}

.badge-success {
    background: var(--bg-callout-tip);
    color: var(--accent-success);
}

.badge-warn {
    background: var(--bg-callout-warn);
    color: var(--accent-warning);
}

.badge-danger {
    background: var(--bg-callout-danger);
    color: var(--accent-danger);
}

.flow-diagram {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
    overflow-x: auto;
}

.flow-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.flow-node {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 2px solid;
}

.flow-node-primary {
    background: rgba(37,99,235,0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.flow-node-success {
    background: rgba(16,185,129,0.1);
    border-color: var(--accent-success);
    color: var(--accent-success);
}

.flow-node-warning {
    background: rgba(245,158,11,0.1);
    border-color: var(--accent-warning);
    color: var(--accent-warning);
}

.flow-node-danger {
    background: rgba(239,68,68,0.1);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

.flow-node-secondary {
    background: rgba(124,58,237,0.1);
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

.flow-arrow {
    color: var(--text-tertiary);
    font-size: 18px;
    flex-shrink: 0;
}

.arch-diagram {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
    text-align: center;
}

.arch-layer {
    margin: 16px 0;
}

.arch-layer-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.arch-nodes {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.arch-node {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    border: 2px solid;
    min-width: 100px;
    text-align: center;
}

.arch-connector {
    display: flex;
    justify-content: center;
    margin: 8px 0;
    color: var(--text-tertiary);
    font-size: 20px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

.feature-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.feature-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.step-list {
    counter-reset: step;
    list-style: none;
    padding-left: 0;
}

.step-list li {
    counter-increment: step;
    position: relative;
    padding: 12px 16px 12px 48px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

.step-list li::before {
    content: counter(step);
    position: absolute;
    left: 14px;
    top: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-primary);
    margin-bottom: 16px;
    gap: 0;
}

.tab-btn {
    padding: 8px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.toc {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.toc-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.toc-list {
    list-style: none;
    padding-left: 0;
}

.toc-list li {
    margin-bottom: 4px;
}

.toc-list a {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.toc-list a:hover {
    color: var(--accent-primary);
}

.toc-list .toc-h3 {
    padding-left: 16px;
}

.hero {
    text-align: center;
    padding: 48px 0 32px;
}

.hero h1 {
    font-size: 40px;
    font-weight: 900;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

.hero-badges {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 32px 0;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-toggle {
        display: flex;
    }

    .content {
        margin-left: 0;
    }

    .content-inner {
        padding: 24px 20px 60px;
    }

    .header-center {
        display: none;
    }

    .hero h1 {
        font-size: 28px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
}

.sidebar-overlay.active {
    display: block;
}

@media print {
    .header, .sidebar, .sidebar-overlay { display: none; }
    .content { margin-left: 0; }
    .content-inner { max-width: 100%; padding: 0; }
}
