/* ── MD Viewer — Blog stylesheet ───────────────────────────── */

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

:root {
    --bg: #282c34;
    --surface: #21252b;
    --surface2: #2c313a;
    --border: #3e4451;
    --text: #abb2bf;
    --text-dim: #5c6370;
    --heading: #dcdfe4;
    --blue: #61afef;
    --green: #98c379;
    --yellow: #e5c07b;
    --red: #e06c75;
    --code-bg: #1e222a;
}

[data-theme="light"] {
    --bg: #f9fafb;
    --surface: #ffffff;
    --surface2: #f3f4f6;
    --border: #e5e7eb;
    --text: #374151;
    --text-dim: #9ca3af;
    --heading: #111827;
    --blue: #2563eb;
    --green: #16a34a;
    --yellow: #d97706;
    --red: #dc2626;
    --code-bg: #f0f2f5;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 38px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
    color: var(--heading);
    text-decoration: none;
}

.topbar-logo:hover {
    text-decoration: none;
    opacity: .85;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.topbar-btn:hover {
    background: var(--surface2);
    border-color: var(--border);
    text-decoration: none;
}

.topbar-btn.primary {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.topbar-btn.primary:hover {
    opacity: .88;
}

#btn-theme-blog {
    padding: 4px 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
}

/* ── Page wrapper ───────────────────────────────────────────── */
.page {
    max-width: 780px;
    margin: 0 auto;
    padding: 48px 24px 96px;
}

/* ── Blog index ─────────────────────────────────────────────── */
.blog-header {
    margin-bottom: 40px;
}

.blog-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--heading);
}

.blog-header p {
    font-size: 14px;
    color: var(--text-dim);
    margin-top: 6px;
}

.post-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 22px 24px;
    margin-bottom: 18px;
    background: var(--surface);
    transition: border-color .15s;
}

.post-card:hover {
    border-color: var(--blue);
}

.post-card .tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--green);
    margin-bottom: 8px;
}

.post-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--heading);
    margin-bottom: 8px;
}

.post-card h2 a {
    color: inherit;
}

.post-card h2 a:hover {
    color: var(--blue);
    text-decoration: none;
}

.post-card .excerpt {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 12px;
}

.post-card .meta {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Article ─────────────────────────────────────────────────── */
.article-hero {
    margin-bottom: 40px;
}

.article-hero .tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--green);
    margin-bottom: 12px;
}

.article-hero h1 {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--heading);
    margin-bottom: 14px;
}

.article-hero .meta {
    font-size: 13px;
    color: var(--text-dim);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.article-hero .meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.article-body {
    font-size: 15.5px;
}

.article-body h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--heading);
    margin: 44px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.article-body h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--heading);
    margin: 28px 0 10px;
}

.article-body p {
    margin-bottom: 16px;
}

.article-body ul,
.article-body ol {
    padding-left: 22px;
    margin-bottom: 16px;
}

.article-body li {
    margin-bottom: 6px;
}

.article-body code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13.5px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--yellow);
}

.article-body pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 18px;
    overflow-x: auto;
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.6;
}

.article-body pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
}

.article-body blockquote {
    border-left: 3px solid var(--blue);
    padding: 12px 18px;
    margin: 20px 0;
    background: var(--surface2);
    border-radius: 0 6px 6px 0;
    color: var(--text);
    font-style: italic;
}

.article-body .callout {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: 0 6px 6px 0;
    padding: 14px 18px;
    margin: 20px 0;
    font-size: 14px;
}

.article-body .callout strong {
    color: var(--green);
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

.article-body th {
    text-align: left;
    padding: 8px 12px;
    background: var(--surface2);
    color: var(--heading);
    font-weight: 600;
    border: 1px solid var(--border);
}

.article-body td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    vertical-align: top;
}

/* Steps */
.steps {
    counter-reset: steps;
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}

.steps li {
    counter-increment: steps;
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.steps li::before {
    content: counter(steps);
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

/* CTA block */
.cta-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--blue);
    border-radius: 8px;
    padding: 28px 28px 24px;
    text-align: center;
    margin: 48px 0 32px;
}

.cta-block h3 {
    font-size: 20px;
    color: var(--heading);
    margin-bottom: 8px;
}

.cta-block p {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 18px;
}

.cta-block .btn-cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--blue);
    color: #fff;
    padding: 10px 22px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: opacity .15s;
}

.cta-block .btn-cta:hover {
    opacity: .88;
    text-decoration: none;
}

/* Table of contents */
.toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 22px;
    margin-bottom: 36px;
    font-size: 14px;
}

.toc-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.toc ol {
    padding-left: 18px;
    margin: 0;
}

.toc li {
    margin-bottom: 4px;
}

.toc a {
    color: var(--blue);
}

/* ── Footer ─────────────────────────────────────────────────── */
.blog-footer {
    text-align: center;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
}

.blog-footer a {
    color: var(--text-dim);
}

.blog-footer a:hover {
    color: var(--blue);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .page {
        padding: 28px 16px 60px;
    }

    .article-hero h1 {
        font-size: 24px;
    }

    .article-body h2 {
        font-size: 19px;
    }

    .topbar {
        padding: 0 14px;
    }

    .topbar-btn .btn-label-text {
        display: none;
    }
}