
:root {
    --sidebar-width: 260px;
    --topbar-height: 52px;

    --bg: #ffffff;
    --bg-sidebar: #f7f7f8;
    --bg-hover: #efefef;
    --bg-active: #e8e8eb;
    --border: #e4e4e7;
    --border-light: #f0f0f2;

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --text-link: #2563eb;

    --accent: #18181b;
    --accent-soft: #f4f4f5;

    --radius: 6px;
    --radius-sm: 4px;

    --font-ui: 'Geist', 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Geist Mono', 'JetBrains Mono', 'Fira Code', monospace;
    --font-prose: 'Lora', Georgia, serif;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow: 0 2px 8px rgba(0,0,0,.08);

    --transition: 150ms ease;

    --code-bg: #18181b;
    --code-border: #27272a;
    --code-text: #e4e4e7;
}

[data-theme="dark"] {
    --bg: #0f0f11;
    --bg-sidebar: #141416;
    --bg-hover: #1e1e22;
    --bg-active: #26262c;
    --border: #2a2a30;
    --border-light: #212126;

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --text-link: #60a5fa;

    --accent: #fafafa;
    --accent-soft: #1e1e22;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 2px 8px rgba(0,0,0,.4);
}

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

html { font-size: 15px; }

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: width var(--transition), transform var(--transition);
    z-index: 100;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 0 16px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.93rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.sidebar-logo svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.sidebar-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    transition: border-color var(--transition);
}

.search-wrap:focus-within {
    border-color: #a1a1aa;
}

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

.search-wrap input {
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-ui);
    font-size: 0.83rem;
    color: var(--text-primary);
    width: 100%;
}

.search-wrap input::placeholder { color: var(--text-muted); }

.plugin-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.plugin-list::-webkit-scrollbar { width: 4px; }
.plugin-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.plugin-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-ui);
    font-size: 0.84rem;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    position: relative;
}

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

.plugin-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
    font-weight: 500;
}

.plugin-icon {
    flex-shrink: 0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.plugin-item.active .plugin-icon,
.plugin-item:hover .plugin-icon {
    color: var(--text-secondary);
}

.plugin-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
}

.badge-missing {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    padding: 24px 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.6;
}

.empty-state code {
    background: var(--bg-active);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.sidebar-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 0 12px;
    flex-shrink: 0;
    background: var(--bg);
}

.sidebar-toggle {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

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

.breadcrumb {
    flex: 1;
    font-size: 0.84rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb .bc-plugin {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb .bc-home {
    cursor: pointer;
    transition: color var(--transition);
}

.breadcrumb .bc-home:hover {
    color: var(--text-primary);
}

.topbar-actions { display: flex; gap: 6px; }

.action-btn {
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-family: var(--font-ui);
    transition: background var(--transition), color var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.action-btn.copied {
    color: #16a34a;
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

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

.icon-sun, .icon-moon { display: flex; align-items: center; }

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

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

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

body, .sidebar, .topbar, .main, .plugin-item, .action-btn, .theme-toggle,
.markdown-body code, .search-wrap, .markdown-body table,
.markdown-body blockquote, .markdown-body th, .markdown-body td {
    transition:
            background-color 200ms ease,
            color 200ms ease,
            border-color 200ms ease;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--topbar-height));
    padding: 60px 24px;
    text-align: center;
}

.welcome-hero {
    margin-bottom: 32px;
}

.welcome-wordmark {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.welcome-wordmark-icon {
    width: 44px;
    height: 44px;
    background: var(--text-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg);
    flex-shrink: 0;
}

.welcome-wordmark h1 {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0;
    border: none;
    padding: 0;
}

.welcome-tagline {
    color: var(--text-muted);
    font-size: 0.92rem;
    max-width: 380px;
    margin: 0 auto 32px;
    line-height: 1.65;
}

.welcome-stats {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-bottom: 36px;
}

.welcome-stat {
    padding: 10px 22px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.welcome-stat:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.welcome-stat:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.welcome-stat:only-child  { border-radius: var(--radius); }

.stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.welcome-plugins-preview {
    max-width: 420px;
    width: 100%;
}

.preview-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.preview-chip {
    padding: 4px 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    font-family: var(--font-ui);
}

.preview-chip:hover {
    background: var(--bg-active);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.preview-chip-more {
    padding: 4px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-ui);
    align-self: center;
}

.welcome-hint {
    margin-top: 28px;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.welcome-hint kbd {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--topbar-height));
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--text-secondary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--topbar-height));
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.error-state h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.markdown-body {
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 48px 80px;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-family: var(--font-ui);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-top: 2em;
    margin-bottom: 0.6em;
}

.markdown-body h1 { font-size: 1.9rem; margin-top: 0; padding-bottom: 0.4em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.35rem; padding-bottom: 0.3em; border-bottom: 1px solid var(--border-light); }
.markdown-body h3 { font-size: 1.1rem; }
.markdown-body h4 { font-size: 0.95rem; }
.markdown-body h5, .markdown-body h6 { font-size: 0.88rem; color: var(--text-secondary); }

.markdown-body p { margin-bottom: 1em; }

.markdown-body a {
    color: var(--text-link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition);
}

.markdown-body a:hover { border-bottom-color: var(--text-link); }

.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.6em;
    margin-bottom: 1em;
}

.markdown-body li { margin-bottom: 0.25em; }
.markdown-body li > ul,
.markdown-body li > ol { margin-top: 0.25em; margin-bottom: 0; }

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.82em;
    background: var(--bg-active);
    color: var(--text-primary);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.markdown-body pre {
    background: #18181b;
    border-radius: var(--radius);
    padding: 16px 20px;
    overflow-x: auto;
    margin-bottom: 1.2em;
    border: 1px solid #27272a;
    position: relative;
}

.markdown-body pre code {
    font-family: var(--font-mono);
    font-size: 0.83em;
    background: transparent;
    color: #e4e4e7;
    padding: 0;
    border: none;
    border-radius: 0;
    line-height: 1.6;
}

.markdown-body blockquote {
    border-left: 3px solid var(--border);
    padding: 8px 16px;
    margin: 0 0 1em;
    color: var(--text-secondary);
    background: var(--bg-sidebar);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body blockquote p { margin: 0; }

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2em;
    font-size: 0.88rem;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.markdown-body thead { background: var(--bg-sidebar); }

.markdown-body th,
.markdown-body td {
    padding: 8px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.markdown-body th {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.markdown-body tr:last-child td { border-bottom: none; }
.markdown-body tr:hover td { background: var(--bg-sidebar); }

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.markdown-body input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--accent);
}

.markdown-body img[src*="shields.io"],
.markdown-body img[src*="badge"] {
    display: inline;
    border: none;
    border-radius: 3px;
    vertical-align: middle;
    margin: 0 2px;
}

.hljs { background: transparent !important; color: #e4e4e7 !important; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 250ms ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
    opacity: 1;
}

@media (max-width: 768px) {

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        width: var(--sidebar-width) !important;
        transform: translateX(calc(-1 * var(--sidebar-width)));
        box-shadow: var(--shadow);
        z-index: 100;
        transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    }

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

    .sidebar-overlay {
        display: block;
    }

    .main {
        width: 100%;
    }

    .topbar {
        padding: 0 12px;
        gap: 8px;
    }

    .breadcrumb {
        font-size: 0.8rem;
    }

    .markdown-body {
        padding: 24px 16px 60px;
        font-size: 0.88rem;
    }

    .markdown-body table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .markdown-body pre {
        padding: 12px 14px;
    }

    .welcome {
        padding: 40px 16px;
    }

    .welcome-wordmark h1 {
        font-size: 1.4rem;
    }

    .welcome-stats {
        flex-wrap: wrap;
        gap: 6px;
    }

    .welcome-stat {
        border-radius: var(--radius) !important;
        min-width: 80px;
    }

    .preview-list {
        gap: 5px;
    }
}

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

.markdown-body { animation: fadeIn 0.2s ease; }