:root {
    --primary-color: #2563eb;
    --secondary-color: #475569;
    --text-color: #1f2937;
    --bg-color: #ffffff;
    --sidebar-bg: #f8fafc;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Navigation */
nav {
    background: var(--code-bg);
    color: white;
    padding: 0 2rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav .logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    text-decoration: none;
    letter-spacing: -0.5px;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

nav a {
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.95rem;
}

nav a:hover, nav a.active {
    color: white;
}

/* Layout */
.container {
    display: flex;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    padding: 2rem;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.sidebar h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin-bottom: 0.25rem;
}

.sidebar a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

.sidebar a:hover {
    background: #e2e8f0;
    color: var(--primary-color);
}

.content {
    flex: 1;
    padding: 3rem 5rem;
    max-width: 900px;
}

/* Typography */
h1 { font-size: 2.5rem; letter-spacing: -1px; margin-bottom: 1.5rem; color: #111827; }
h2 { font-size: 1.8rem; margin-top: 3rem; margin-bottom: 1rem; color: #1f2937; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
h3 { font-size: 1.4rem; margin-top: 2rem; margin-bottom: 1rem; color: #374151; }

p { margin-bottom: 1.25rem; color: #4b5563; }
li { margin-bottom: 0.5rem; color: #4b5563; }

/* Diagram / SVG Container */
.diagram-container {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.diagram-caption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: -1.5rem;
    margin-bottom: 2rem;
    font-style: italic;
}

/* Components */
.callout {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 0 8px 8px 0;
}

.callout h4 { margin-top: 0; color: var(--primary-color); }
.callout p:last-child { margin-bottom: 0; }

code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Menlo', 'Monaco', monospace;
    font-size: 0.9em;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

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

/* Wiki Specifics */
.term-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-top: 3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.term-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.term-tag {
    background: #e0e7ff;
    color: var(--primary-color);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Pagination / Pager */
.pager {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    gap: 1rem;
}

.pager-link {
    text-decoration: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0; /* Prevents overflow */
}

.pager-link:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.pager-link .label {
    font-size: 0.8rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.pager-link .title {
    font-weight: 600;
    color: var(--primary-color);
}

.pager-link.prev {
    text-align: left;
}

.pager-link.next {
    text-align: right;
    margin-left: auto;
}

/* Home Page Cards */
.doc-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.doc-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    background: white;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.doc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.doc-card a {
    text-decoration: none;
    color: inherit;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.doc-id {
    color: var(--secondary-color);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

.doc-title {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.doc-desc {
    font-size: 0.95rem;
    color: var(--secondary-color);
    line-height: 1.5;
}

.badge {
    background: var(--success-color);
    color: white;
    padding: 0.15em 0.5em;
    border-radius: 4px;
    font-size: 0.75em;
    margin-left: 0.5rem;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content {
        padding: 3rem 2rem;
    }
}

@media (max-width: 768px) {
    nav {
        padding: 0 1rem;
    }

    nav ul {
        gap: 1rem;
        font-size: 0.9rem;
    }

    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        position: static;
        overflow-y: visible;
    }
    
    .sidebar h3 {
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        margin-bottom: 0;
    }
    
    /* Simple JS toggle would be better, but pure CSS solution for now: */
    /* Hide links by default on mobile unless we add JS, for now keep them visible but compact */
    .sidebar ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .sidebar li {
        width: calc(50% - 0.5rem);
        margin-bottom: 0;
    }
    
    .sidebar a {
        background: white;
        border: 1px solid var(--border-color);
    }

    .content {
        padding: 2rem 1.5rem;
    }

    h1 {
        font-size: 2rem;
    }
    
    .doc-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    nav ul {
        display: none; /* Hide nav links on very small screens or use hamburger */
    }
    
    .sidebar li {
        width: 100%;
    }
    
    .pager {
        flex-direction: column;
    }
    
    .pager-link {
        width: 100%;
        text-align: left !important;
    }
    
    .pager-link.next {
        margin-left: 0;
    }
}