/* Clean Compact Wiki CSS - Theme Adaptive Code Blocks & Precise Callout Spacing */
:root {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #f1f5f9;
    --bg-card: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.9);
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    
    --sidebar-width: 210px;
    --toc-width: 210px;
    --header-height: 48px;
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #0b0f19;
        --bg-surface: #111827;
        --bg-sidebar: #0f172a;
        --bg-card: #1e293b;
        --bg-header: rgba(15, 23, 42, 0.9);
        
        --border-color: #1e293b;
        --border-hover: #334155;
        
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-light: rgba(59, 130, 246, 0.12);
    }
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15.5px;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
    background-color: var(--bg-header);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
}

.mobile-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.brand-link {
    display: flex;
    align-items: baseline;
    gap: 5px;
    text-decoration: none;
}

.brand-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-tag {
    font-weight: 500;
    font-size: 13.5px;
    color: var(--text-muted);
}

/* Search Box - Dead Center */
.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 420px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 4px 12px;
    gap: 8px;
}

.search-box:focus-within {
    border-color: var(--accent);
    background-color: var(--bg-surface);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 13px;
    color: var(--text-primary);
    padding-right: 6px;
}

.search-kbd {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
}

/* Header Right & Language Selector */
.header-right {
    display: flex;
    align-items: center;
    z-index: 2;
}

.lang-toggle {
    display: flex;
    align-items: center;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px;
    gap: 2px;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.lang-btn.active {
    background-color: var(--bg-surface);
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

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

.nav-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    background-color: var(--bg-sidebar);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border-color);
}

.nav-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

/* Layout Container */
.layout-container {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    padding: 0 16px;
    max-width: 1340px;
    margin: 0 auto;
}

/* Left Sidebar (210px) */
.sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-color);
    padding: 16px 8px 16px 0;
    flex-shrink: 0;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow-y: auto;
    background-color: var(--bg-main);
}

.sidebar-category {
    margin-bottom: 16px;
}

.sidebar-category-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding-left: 6px;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-item-link {
    display: block;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.12s ease;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
}

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

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

/* Central Content */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 20px 36px;
    display: flex;
    justify-content: center;
}

.content-wrapper {
    max-width: 760px;
    width: 100%;
}

.breadcrumbs {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--accent);
}

/* Compact Guide Header & Article Flags */
.guide-header {
    padding-bottom: 4px;
    margin-bottom: 16px;
}

.guide-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.guide-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 4px;
    color: var(--text-primary);
}

/* Full-Width Article OS Tabs Bar */
.article-os-tabs {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    margin-top: 14px;
    margin-bottom: 6px;
}

.os-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 6px 2px 8px 2px;
    margin-bottom: -1px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.os-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
    box-shadow: none;
}

.os-tab-btn svg {
    flex-shrink: 0;
}

/* Custom Article Language Dropdown */
.article-lang-dropdown {
    position: relative;
    display: inline-block;
}

.article-lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--bg-sidebar);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
}

.article-lang-btn:hover {
    border-color: var(--accent);
    background-color: var(--bg-surface);
}

.article-lang-btn svg {
    color: var(--text-muted);
}

.article-lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    min-width: 130px;
    padding: 4px;
    display: none;
    flex-direction: column;
    gap: 2px;
}

.article-lang-dropdown.open .article-lang-menu {
    display: flex;
}

.article-lang-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: background 0.12s ease;
}

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

.article-lang-option.active {
    color: var(--accent);
    font-weight: 600;
    background-color: var(--accent-light);
}

.guide-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Clean Markdown Body */
.markdown-body {
    font-size: 15.5px;
    line-height: 1.6;
    color: var(--text-primary);
}

.markdown-body h2 {
    font-size: 21px;
    font-weight: 700;
    margin-top: 24px;
    margin-bottom: 8px;
    scroll-margin-top: 55px;
}

.markdown-body h3 {
    font-size: 17px;
    font-weight: 700;
    margin-top: 16px;
    margin-bottom: 6px;
    scroll-margin-top: 55px;
}

.markdown-body p {
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 10px;
    padding-left: 20px;
    color: var(--text-secondary);
}

.markdown-body li {
    margin-bottom: 3px;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.markdown-body hr {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 20px 0;
    opacity: 0.5;
}

/* Image & Media Styling */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin: 14px 0;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.markdown-body img:not([width]) {
    max-height: 420px;
    object-fit: contain;
}

.markdown-body figure {
    margin: 14px 0;
    text-align: center;
}

.markdown-body figure img {
    margin: 0 auto 6px auto;
}

.markdown-body figcaption {
    font-size: 12.5px;
    color: var(--text-muted);
    font-style: italic;
}

/* Code Blocks - Light & Dark Mode Theme Adaptive */
.code-wrapper {
    position: relative;
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    background-color: #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
    font-size: 11px;
    color: #475569;
    font-family: var(--font-mono);
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    border-radius: 3px;
    padding: 2px 7px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.15s ease;
}

.copy-btn:hover {
    background: #f8fafc;
    color: #0f172a;
}

.copy-btn.copied {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
}

.markdown-body pre {
    margin: 0;
    padding: 10px 14px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.45;
    color: #0f172a;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background-color: var(--bg-sidebar);
    color: var(--accent);
    padding: 1px 4px;
    border-radius: 3px;
}

.markdown-body pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

/* Styled Keyboard Badges (<kbd>) */
.markdown-body kbd,
kbd {
    display: inline-block;
    padding: 1.5px 5px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
    vertical-align: middle;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-bottom: 2px solid var(--border-hover);
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

/* Dark Mode Code Block Overrides */
@media (prefers-color-scheme: dark) {
    .code-wrapper {
        background-color: #0d1117;
        border-color: #30363d;
    }
    .code-header {
        background-color: #161b22;
        border-bottom-color: #30363d;
        color: #8b949e;
    }
    .copy-btn {
        background-color: #21262d;
        border-color: #30363d;
        color: #c9d1d9;
    }
    .copy-btn:hover {
        background-color: #30363d;
        color: #ffffff;
    }
    .markdown-body pre {
        color: #e6edf3;
    }
}

/* Compact Alert Infoboxes - Perfect Tight Spacing */
.callout {
    margin: 10px 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    background-color: var(--accent-light);
}

.callout-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1;
}

.callout.note {
    border-left-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.07);
    color: #1d4ed8;
}
.callout.note .callout-title { color: #1e40af; }

.callout.tip {
    border-left-color: #10b981;
    background-color: rgba(16, 185, 129, 0.07);
    color: #047857;
}
.callout.tip .callout-title { color: #065f46; }

.callout.warning {
    border-left-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.07);
    color: #b45309;
}
.callout.warning .callout-title { color: #92400e; }

.callout.caution {
    border-left-color: #f43f5e;
    background-color: rgba(244, 63, 94, 0.07);
    color: #be123c;
}
.callout.caution .callout-title { color: #9f1239; }

.callout-content p {
    margin: 0;
    color: var(--text-primary);
    font-size: 14.5px;
    line-height: 1.45;
}

/* Clean Guide Footer Nav */
.guide-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 24px;
    padding-top: 4px;
}

.prev-guide, .next-guide {
    display: flex;
    flex-direction: column;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    text-decoration: none;
    max-width: 48%;
}

.prev-guide:hover, .next-guide:hover {
    border-color: var(--accent);
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.nav-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
}

/* Right TOC Sidebar (210px) with Vertical Indicator Line */
.toc-sidebar {
    width: var(--toc-width);
    padding: 16px 0 16px 10px;
    flex-shrink: 0;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow-y: auto;
}

.toc-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toc-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 1px solid var(--border-color);
}

.toc-link {
    display: block;
    padding: 3px 0 3px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
    border-left: 2px solid transparent;
    margin-left: -1px;
}

.toc-link.indent-3 {
    padding-left: 18px;
    font-size: 11.5px;
}

.toc-link:hover {
    color: var(--text-primary);
}

.toc-link.active {
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
}

.scroll-top-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    margin-top: 8px;
}

.scroll-top-btn:hover {
    color: var(--accent);
}

/* Spinner */
.content-loading {
    display: flex;
    justify-content: center;
    padding: 30px 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
    .toc-sidebar { display: none; }
    .main-content { padding: 14px 14px; }
}

@media (max-width: 768px) {
    .mobile-toggle-btn { display: block; }
    .header-center { display: none; }
    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        z-index: 40;
        background-color: var(--bg-surface);
        transition: left 0.2s ease;
    }
    .sidebar.open { left: 0; }
}
