:root {
    --bg: #fafafa;
    --fg: #1a1a1a;
    --accent: #2563eb;
    --muted: #6b7280;
    --border: #e5e7eb;
    --canvas-bg: #f3f4f6;
    --code-bg: #f9fafb;
    --max-width: 720px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111827;
        --fg: #f9fafb;
        --accent: #60a5fa;
        --muted: #9ca3af;
        --border: #374151;
        --canvas-bg: #1f2937;
        --code-bg: #1f2937;
    }
}

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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.7;
    padding: 2rem 1rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

h1, h2, h3 {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; margin-top: 3rem; }
h3 { font-size: 1.2rem; }

p { margin-bottom: 1rem; }

.subtitle {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 2rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

nav.toc ol {
    list-style: decimal;
    padding-left: 1.5rem;
}

nav.toc li {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    background: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

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

/* Widget containers */
.widget {
    background: var(--canvas-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.widget canvas {
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.widget-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    font-family: system-ui, sans-serif;
    font-size: 0.85rem;
}

.widget-controls button {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    font-size: 0.85rem;
}

.widget-controls button:hover {
    border-color: var(--accent);
}

.widget-controls label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
}

.widget-controls input[type="range"] {
    width: 80px;
}

.widget-stats {
    font-family: 'SF Mono', monospace;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

/* Compare widget: side-by-side */
.compare-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.compare-panel {
    flex: 1;
    min-width: 250px;
    text-align: center;
}

.compare-panel h4 {
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--muted);
}

/* Feature explorer checkboxes */
.feature-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
    font-family: system-ui, sans-serif;
    font-size: 0.85rem;
}

.feature-toggles label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.feature-toggles label:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Post navigation */
.post-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
}
