/* ── Variables ── */
:root {
    --bg: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --code-bg: #f5f5f5;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e5e5e5;
    --tag-bg: #f0f0f0;
    --btn-bg: var(--accent);
    --btn-hover: var(--accent-hover);
    --max-width: 42rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --text: #e0e0e0;
        --text-secondary: #9ca3af;
        --code-bg: #2a2a2a;
        --accent: #60a5fa;
        --accent-hover: #93bbfd;
        --border: #333;
        --tag-bg: #2a2a2a;
        --btn-bg: #2563eb;
        --btn-hover: #1d4ed8;
    }
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Base ── */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Typography ── */
h1, h2, h3, h4 {
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p {
    margin-bottom: 1rem;
}

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

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

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

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

blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 1.5rem 0;
}

/* ── Navigation ── */
nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.nav-home {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.nav-home:hover {
    color: var(--accent);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

/* ── Post list ── */
.post-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.post-list li {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.post-list .post-title a {
    font-size: 1.1rem;
    font-weight: 600;
}

.post-list time {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.post-list p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* ── Post ── */
.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.post-header time {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.post-body a,
.project-body a,
.page a {
    text-decoration: underline;
}

.post-body h2,
.post-body h3 {
    margin-top: 2.5rem;
}

.post-body ul,
.post-body ol,
.project-body ul,
.project-body ol,
.page ul,
.page ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.post-body li,
.project-body li,
.page li {
    margin-bottom: 0.25rem;
}

/* ── Tags ── */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
    background: var(--tag-bg);
    border-radius: 3px;
    color: var(--text-secondary);
}

.tag:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ── Code ── */
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.875em;
    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: 1.5rem 0;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th, td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
}

/* ── Heading anchors ── */
.anchor {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 0.3rem;
    opacity: 0;
    transition: opacity 0.15s;
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor {
    opacity: 1;
}

/* ── Intro ── */
.intro {
    margin-bottom: 2.5rem;
}

.intro h1 {
    margin-top: 0;
}

/* ── Recent posts ── */
.recent-posts h2 {
    margin-top: 0;
}

/* ── Page ── */
.page h1 {
    margin-top: 0;
}

/* ── 404 ── */
.not-found {
    text-align: center;
    padding: 4rem 0;
}

.not-found h1 {
    font-size: 3rem;
    margin-top: 0;
}

/* ── Projects ── */
.project-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.project-list li {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.project-list li a {
    font-size: 1.1rem;
    font-weight: 600;
}

.project-list p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

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

.project-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.project-meta h1 {
    margin-top: 0;
    margin-bottom: 0;
}

.project-repo {
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
}

.project-repo:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

.private-badge {
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
    background: var(--tag-bg);
    border-radius: 3px;
    color: var(--text-secondary);
}

.post-project {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.featured-projects h2,
.related-posts h2 {
    margin-top: 2.5rem;
}

/* ── Comments ── */
.comments {
    margin-top: 3rem;
    border-top: 1px solid var(--border);
    padding-top: 2rem;
}

.comments h2 {
    margin-top: 0;
}

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

.comment-meta {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.comment-meta time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.no-comments {
    color: var(--text-secondary);
}

.comment-form {
    margin-top: 2rem;
}

.comment-form h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.comment-form label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.comment-form input[type="text"],
.comment-form textarea {
    display: block;
    width: 100%;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    margin-bottom: 1rem;
}

.comment-form textarea {
    resize: vertical;
}

.comment-form button {
    padding: 0.5rem 1.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--btn-bg);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.comment-form button:hover {
    background: var(--btn-hover);
}

/* ── Search ── */
.search-page h1 {
    margin-top: 0;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.search-form input[type="search"] {
    flex: 1;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
}

.search-form button {
    padding: 0.5rem 1.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--btn-bg);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.search-form button:hover {
    background: var(--btn-hover);
}

.search-results {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-results li a {
    font-size: 1.1rem;
    font-weight: 600;
}

.search-results p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.search-type {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.no-results {
    color: var(--text-secondary);
}

mark {
    background: #fef08a;
    color: inherit;
    padding: 0.1em 0.15em;
    border-radius: 2px;
}

@media (prefers-color-scheme: dark) {
    mark {
        background: #854d0e;
    }
}

/* ── Footer ── */
footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ── Responsive ── */
@media (max-width: 600px) {
    body {
        padding: 1.5rem 1rem;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
