:root {
    --bg-light: #f9fafb;
    --bg-dark: #020617;
    --bg-elevated-light: #ffffff;
    --bg-elevated-dark: #020617;
    --text-light: #0f172a;
    --text-dark: #e5e7eb;
    --muted-light: #6b7280;
    --muted-dark: #9ca3af;
    --border-light: #e5e7eb;
    --border-dark: #1f2937;
    --accent: #2563eb; /* Dortania blue */
    --accent-soft-light: #dbeafe;
    --accent-soft-dark: #1d3557;
    --sidebar-width: 260px;
    --radius: 10px;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
    color-scheme: light dark;
}

html[data-theme="light"] {
    background-color: var(--bg-light);
    color: var(--text-light);
}

html[data-theme="dark"] {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

body {
    margin: 0;
    font-family: var(--font-sans);
}

/* Layout */

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid;
    padding: 1rem;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
}

html[data-theme="light"] .sidebar {
    background: #f3f4f6;
    border-color: var(--border-light);
}

html[data-theme="dark"] .sidebar {
    background: #020617;
    border-color: var(--border-dark);
}

.sidebar-header {
    margin-bottom: 1.5rem;
}

.site-title {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.3;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.nav-link {
    display: block;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
}

html[data-theme="light"] .nav-link {
    color: var(--muted-light);
}

html[data-theme="dark"] .nav-link {
    color: var(--muted-dark);
}

.nav-link:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
}

.nav-link.active {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    font-size: 0.75rem;
    color: var(--muted-dark);
}

/* Content */

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

html[data-theme="light"] .topbar {
    background: rgba(249, 250, 251, 0.9);
    border-color: var(--border-light);
}

html[data-theme="dark"] .topbar {
    background: rgba(2, 6, 23, 0.9);
    border-color: var(--border-dark);
}

.topbar-title {
    font-weight: 600;
}

.theme-toggle {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

html[data-theme="light"] .theme-toggle {
    color: var(--muted-light);
}

html[data-theme="dark"] .theme-toggle {
    color: var(--muted-dark);
}

.theme-toggle:hover {
    border-color: var(--accent);
}

.icon-moon,
.icon-sun {
    font-size: 1rem;
}

/* Page */

.page {
    padding: 1.5rem 1.75rem 2.5rem;
    max-width: 960px;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.lead {
    color: var(--muted-dark);
    max-width: 40rem;
    margin-bottom: 1.5rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.card {
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    text-decoration: none;
    border: 1px solid;
    font-size: 0.9rem;
}

html[data-theme="light"] .card {
    background: var(--bg-elevated-light);
    border-color: var(--border-light);
    color: var(--text-light);
}

html[data-theme="dark"] .card {
    background: var(--bg-elevated-dark);
    border-color: var(--border-dark);
    color: var(--text-dark);
}

.card h2 {
    margin-top: 0;
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.card p {
    margin: 0;
    color: var(--muted-dark);
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.section {
    margin-top: 1.5rem;
}

.section p,
.section ul,
.section ol {
    font-size: 0.95rem;
}

.page-footer {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: var(--muted-dark);
}

/* Responsive */

@media (max-width: 800px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid;
    }

    .content {
        min-height: auto;
    }
}
