:root {
    --bg: #fff;
    --text: #111;
    --muted: #666;
    --border: #e5e5e5;
    --hover: #f5f5f5;
    --accent: #0a66c2;
}

.dark-mode {
    --bg: #111;
    --text: #f5f5f5;
    --muted: #999;
    --border: #2a2a2a;
    --hover: #1a1a1a;
    --accent: #6aa6ff;
}

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

html {
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: "kern", "liga", "calt";
}

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

a:hover {
    text-decoration: underline;
}

.site-nav {
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.nav-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-home {
    font-weight: 600;
    color: var(--text);
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.nav-links a {
    color: var(--muted);
    font-size: 0.9rem;
}

.nav-links a:hover {
    color: var(--text);
    text-decoration: none;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.85rem;
    border-radius: 4px;
}

.theme-toggle:hover {
    background: var(--hover);
}

.theme-icon::before { content: '☀'; }
.dark-mode .theme-icon::before { content: '☾'; }

.content {
    max-width: 680px;
    margin: 0 auto;
    padding: 3rem 1rem 4rem;
}

.page-header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin-bottom: 0.4rem;
}

h2 {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 2.75rem 0 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text);
    margin: 1.75rem 0 0.5rem;
}

/* Group header: h3 immediately followed by hr (category dividers) */
h3:has(+ hr) {
    font-size: 1.2rem;
    font-weight: 700;
    font-style: normal;
    letter-spacing: -0.01em;
    margin: 3rem 0 0;
}

h3 + hr {
    margin: 0.5rem 0 2rem;
}

h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.4rem 0 0.4rem;
    color: var(--text);
}

p {
    margin-bottom: 1.2rem;
    color: var(--text);
}

.subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    font-style: italic;
}

blockquote {
    margin: 1.5rem 0;
    padding: 0.5rem 0 0.5rem 1.25rem;
    border-left: 3px solid var(--accent);
    color: var(--muted);
}

blockquote p:last-child {
    margin-bottom: 0;
}

.experiment-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

code {
    font-family: ui-monospace, 'SF Mono', Menlo, Monaco, monospace;
    font-size: 0.9em;
    background: var(--hover);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    overflow-wrap: anywhere;
}

pre {
    background: var(--hover);
    padding: 0.9rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1.2rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
    font-size: 1em;
    overflow-wrap: normal;
}

.intro-section {
    margin-bottom: 2rem;
}

.section {
    margin: 2rem 0;
}

.experiment-grid {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.experiment-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
}

.experiment-card:hover {
    background: var(--hover);
}

.experiment-card h3 {
    margin-bottom: 0.15rem;
}

.experiment-card p {
    margin-bottom: 0.5rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.read-more {
    font-size: 0.85rem;
    color: var(--accent);
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* SVGs (typically Excalidraw diagrams) auto-invert in dark mode */
.dark-mode img[src$=".svg"] {
    filter: invert(93%) hue-rotate(180deg);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

.log-list {
    list-style: none;
    padding-left: 1.5rem;
}

.log-list li {
    margin-bottom: 0.4rem;
}

ol {
    padding-left: 2rem;
    margin: 0.6rem 0 1.2rem;
}

ol li {
    margin-bottom: 0.4rem;
    padding-left: 0.25rem;
}

@media (max-width: 640px) {
    html { font-size: 16px; }
    .content { padding: 2rem 1rem 3rem; }
}
