:root {
    --bg-color: #0f172a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(148, 163, 184, 0.1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color); 
}
::-webkit-scrollbar-thumb {
    background: #475569; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #64748b; 
}

/* Layout */
.layout-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--card-border);
    padding: 2rem 1rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
    padding-left: 0.5rem;
}

.nav-item {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    border-left: 2px solid var(--accent-color);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem 4rem;
    max-width: 1200px;
}

/* System Map (Mindmap Container) */
.system-map-container {
    height: 400px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    margin-bottom: 3rem;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.system-map-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    z-index: 10;
    pointer-events: none;
}

/* Typography & Content */
h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.meta-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    display: flex;
    gap: 1.5rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

section {
    margin-bottom: 4rem;
    position: relative;
    scroll-margin-top: 2rem; /* For smooth scrolling */
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

p {
    margin-bottom: 1.25rem;
    color: #cbd5e1;
    font-size: 1.05rem;
}

/* Code Blocks */
pre {
    background: #1e293b;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    border: 1px solid var(--card-border);
    margin: 1.5rem 0;
}

code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.85em;
    color: #e2e8f0;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Mermaid Diagrams */
.mermaid {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--card-border);
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    /* Pan/Zoom container requires explicit overflow usually, but mermaid renders svg */
    overflow: hidden; 
}

.diagram-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
    display: block;
    text-align: center;
}

/* Alerts / Callouts */
.callout {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    border-left: 4px solid;
    background: rgba(30, 41, 59, 0.5);
}

.callout.info {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.callout.warning {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.callout.danger {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Utility */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    background-color: var(--accent-color);
    color: white;
}

/* Header Actions */
.header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    user-select: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(148, 163, 184, 0.15);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(148, 163, 184, 0.25);
}

/* Sidebar Extras */
.sidebar-divider {
    height: 1px;
    background: rgba(148, 163, 184, 0.1);
    margin: 1.5rem 0;
}

#system-directory .nav-item {
    font-size: 0.85rem;
    padding-left: 1.25rem;
}

/* System Map Actions */
.system-map-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 12;
    display: flex;
    gap: 0.5rem;
}

.system-map-btn {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.system-map-btn:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(148, 163, 184, 0.3);
}

/* Modal */
body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1000;
}

.modal.is-open {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    margin: 5vh auto;
    width: min(1200px, 96vw);
    height: min(900px, 86vh);
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.modal-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.modal-title {
    font-weight: 700;
    color: var(--text-primary);
}

.modal-titlebar-actions {
    display: flex;
    gap: 0.5rem;
}

.modal-body {
    flex: 1;
    background: rgba(11, 18, 32, 0.95);
}

.modal-body .markmap {
    width: 100%;
    height: 100%;
}
