:root {
    --bg: #f6f6f3;
    --fg: #403f53;
    --accent: #d6652b;
    --muted: #7e7a8a;
    --border: #d9d8e0;
    --input-bg: #fff;
    --max-w: 52rem;
}

[data-theme="dark"] {
    --bg: #011627;
    --fg: #d6deeb;
    --accent: #f0864a;
    --muted: #637777;
    --border: #1d3b53;
    --input-bg: #012240;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'IBM Plex Mono', monospace;
    background: var(--bg);
    color: var(--fg);
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 1.5rem 1rem;
    line-height: 1.7;
    font-size: 0.95rem;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'IBM Plex Sans', sans-serif;
}

h1 {
    font-weight: 200;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    letter-spacing: -0.02em;
}

h2 {
    font-weight: 300;
    font-size: 1.3rem;
}

h3 {
    font-weight: 300;
    font-size: 1.1rem;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}
a:hover {
    text-decoration-style: dashed;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}
header .site-name {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--fg);
    text-decoration: none;
}
header .site-name:hover { color: var(--accent); }
header nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}
.nav-links {
    display: flex;
    gap: 2rem;
}
header nav a {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.9rem;
}
header nav a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 3px;
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.2rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.nav-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

@media (max-width: 600px) {
    .nav-toggle { display: flex; }
    header nav { position: relative; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 4px;
        padding: 0.5rem 0;
        min-width: 140px;
        z-index: 10;
        flex-direction: column;
        gap: 0;
    }
    .nav-links.open {
        display: flex;
    }
    .nav-links a {
        padding: 0.5rem 1rem;
        display: block;
    }
    .nav-links a:hover {
        background: var(--border);
    }
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    line-height: 1;
    margin: 0;
    transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}

article {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
}
article:last-child { border-bottom: none; }
article h2 { margin: 0 0 0.25rem; display: inline; }
article .meta { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
article time { color: var(--muted); font-size: 0.8rem; }
article p { margin: 0.5rem 0 0; }

.badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--border);
    color: var(--muted);
    vertical-align: middle;
}

.post-full time { display: block; color: var(--muted); margin-bottom: 1rem; font-size: 0.85rem; }
.post-full .body { margin-top: 1rem; }
.post-full .body img { max-width: 100%; height: auto; border-radius: 4px; }

.media img { width: 100%; height: auto; }

.media figure { margin: 1rem 0; }
.media img { max-width: 100%; height: auto; border-radius: 4px; }
.media figcaption { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }

.billboard-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.billboard-item h3 { margin: 0; }
.billboard-item .kind { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
}

/* Forms */
label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 500; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"],
textarea, select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--fg);
    font: inherit;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="url"]:focus,
input[type="number"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}
textarea { resize: vertical; }
button, .btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    margin: 0.5rem 0.25rem 0.5rem 0;
}
button:hover, .btn:hover { opacity: 0.85; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.85rem; }
.btn-danger { background: #c00; }

.error { color: #c02818; font-weight: 600; }
[data-theme="dark"] .error { color: #e85040; }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }

fieldset { border: 1px solid var(--border); padding: 1rem; margin: 1rem 0; border-radius: 4px; }

.actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

.media-upload { margin-top: 2rem; }
.media-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
.media-list li { text-align: center; }
.media-list code { display: block; font-size: 0.75rem; word-break: break-all; margin-top: 0.25rem; }

.summary { color: var(--muted); font-style: italic; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    padding: 1.5rem 0 0.5rem;
    margin-top: 0.5rem;
}
.pagination a {
    padding: 0.4rem 0.8rem;
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.pagination a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Post thumbnails in feed */
.post-thumbnail { display: block; margin: 0.5rem 0; }
.post-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.post-caption {
    color: var(--muted);
    margin: 0.5rem 0 0;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.post-date {
    color: var(--muted);
    text-decoration: none;
}
.post-date:hover {
    color: var(--accent);
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    background: var(--border);
    color: var(--accent);
    font-size: 0.75rem;
    text-decoration: none;
}
.tag:hover {
    background: var(--accent);
    color: #fff;
}

.post-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}
.gallery-item {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--fg);
    display: block;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.gallery-item:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--muted);
}
[data-theme="dark"] .gallery-item:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    border-color: #3e3238;
}
.gallery-item img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}
.gallery-item .gallery-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
}
.gallery-item .gallery-date {
    padding: 0 0.75rem 0.5rem;
    font-size: 0.75rem;
    color: var(--muted);
}
