/* --- Core Dynamic Theme Architecture --- */
:root[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-accent-1: rgba(255, 255, 255, 0.03);
    --bg-accent-2: rgba(255, 255, 255, 0.05);
    --border-ui: rgba(255, 255, 255, 0.1);
    --border-ui-soft: rgba(255, 255, 255, 0.05);
    --bg-sidebar: rgba(255, 255, 255, 0.03);
    --bg-viewer: #050914;
    --bg-markdown: #070b14;
    --bg-pre: #090d16;
    --text-main: #cbd5e1;
    --text-heading: #ffffff;
    --text-muted: #94a3b8;
    --text-code: #fca5a5;
    --text-nav-title: #f8fafc;
    --glow-opacity: 0.1;
    --scrollbar-thumb: rgba(255, 255, 255, 0.1);
}

:root[data-theme="light"] {
    --bg-app: #f8fafc;
    --bg-accent-1: rgba(15, 23, 42, 0.03);
    --bg-accent-2: rgba(15, 23, 42, 0.05);
    --border-ui: rgba(15, 23, 42, 0.08);
    --border-ui-soft: rgba(15, 23, 42, 0.04);
    --bg-sidebar: rgba(15, 23, 42, 0.01);
    --bg-viewer: #ffffff;
    --bg-markdown: #ffffff;
    --bg-pre: #f1f5f9;
    --text-main: #334155;
    --text-heading: #0f172a;
    --text-muted: #64748b;
    --text-code: #b91c1c;
    --text-nav-title: #0f172a;
    --glow-opacity: 0.02;
    --scrollbar-thumb: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.luxury-font {
    font-family: 'Outfit', sans-serif;
}

.glass {
    background: var(--bg-accent-1);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-ui);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

/* --- Semantic Markdown Framework --- */
.markdown-body {
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--text-main);
}

.markdown-body h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-heading);
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-ui);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-ui-soft);
    padding-bottom: 0.25rem;
}

.markdown-body h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

.markdown-body p {
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

.markdown-body ul {
    list-style-type: disc;
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    color: var(--text-main);
}

.markdown-body ol {
    list-style-type: decimal;
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    color: var(--text-main);
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body code {
    font-family: monospace;
    background: var(--bg-accent-2);
    color: var(--text-code);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.markdown-body pre {
    background: var(--bg-pre);
    border: 1px solid var(--border-ui-soft);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.markdown-body pre code {
    background: transparent;
    color: var(--text-heading);
    font-size: 0.85em;
}

.markdown-body table {
    width: 100%;
    margin-bottom: 1.5rem;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border-ui);
    padding: 0.75rem;
    text-align: left;
}

.markdown-body th {
    background: var(--bg-accent-1);
    font-weight: 600;
    color: var(--text-heading);
}

.markdown-body td {
    color: var(--text-main);
}

.markdown-body a {
    color: #3b82f6;
    text-decoration: none;
    border-bottom: 1px dashed #3b82f6;
    transition: color 0.2s;
}

.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--border-ui);
    margin: 2rem 0;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border-ui);
    border-radius: 4px;
}

/* --- High-Fidelity Sidebar & Dynamic Layout Upgrades --- */
.sidebar-icon {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px;
    min-height: 14px;
    display: inline-block;
    vertical-align: middle;
}

#sidebar-search {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar-search:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    background: var(--bg-accent-2) !important;
}

.doc-btn {
    min-height: 40px;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.doc-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-btn:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
}

:root[data-theme="dark"] .doc-btn:hover {
    box-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.3);
}

/* Glassmorphic border glow & shadow effects for high density navigation */
#library-sidebar {
    box-shadow: 2px 0 20px -5px rgba(0, 0, 0, 0.05);
}

:root[data-theme="dark"] #library-sidebar {
    box-shadow: 2px 0 30px -10px rgba(0, 0, 0, 0.5);
}