/* ── VSCode-style Markdown Preview ── */
:root {
    /* Light theme (default) */
    --bg: #ffffff;
    --bg-secondary: #f8f8f8;
    --text: #1e1e1e;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border: #e5e5e5;
    --link: #007acc;
    --link-hover: #005999;
    --code-bg: #f5f5f5;
    --code-text: #1e1e1e;
    --pre-bg: #f5f5f5;
    --blockquote-border: #007acc;
    --blockquote-bg: #f8f8f8;
    --heading: #111111;
    --table-border: #ddd;
    --table-stripe: #f8f8f8;
    --toggle-bg: #e5e5e5;
    --toggle-icon: "☀️";
    --inline-code-bg: #f0f0f0;
}

[data-theme="dark"] {
    --bg: #1e1e1e;
    --bg-secondary: #252526;
    --text: #d4d4d4;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    --border: #3c3c3c;
    --link: #3794ff;
    --link-hover: #5ca8ff;
    --code-bg: #2d2d2d;
    --code-text: #d4d4d4;
    --pre-bg: #2d2d2d;
    --blockquote-border: #3794ff;
    --blockquote-bg: #252526;
    --heading: #e0e0e0;
    --table-border: #3c3c3c;
    --table-stripe: #252526;
    --toggle-bg: #3c3c3c;
    --toggle-icon: "🌙";
    --inline-code-bg: #2d2d2d;
}

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

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    max-width: 860px;
    margin: 0 auto;
    padding: 0 24px;
    transition: background 0.3s, color 0.3s;
}

/* ── Header ── */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 0 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.site-header .site-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--heading);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.site-header nav { display: flex; align-items: center; gap: 24px; }

.site-header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.site-header nav a:hover { color: var(--link); }

/* Theme toggle button */
.theme-toggle {
    background: var(--toggle-bg);
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    transition: background 0.3s;
    white-space: nowrap;
}

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

/* ── Main content ── */
main {
    min-height: 70vh;
    padding-bottom: 40px;
}

/* ── Headings (VSCode preview style) ── */
h1, h2, h3, h4, h5, h6 {
    color: var(--heading);
    line-height: 1.35;
    margin: 1.5em 0 0.5em;
}

h1 { font-size: 1.85rem; font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
h2 { font-size: 1.5rem; font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.1rem; font-weight: 600; }

.subtitle { font-weight: 400; color: var(--text-secondary); font-size: 1rem; margin-bottom: 1em; }

/* ── Links ── */
a {
    color: var(--link);
    text-decoration: none;
}

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

/* ── Paragraphs & spacing ── */
p { margin-bottom: 1em; }

/* ── Images ── */
article img { max-width: 100%; height: auto; border-radius: 4px; }

/* ── Blockquotes ── */
blockquote {
    border-left: 4px solid var(--blockquote-border);
    background: var(--blockquote-bg);
    padding: 12px 20px;
    margin: 1em 0;
    color: var(--text-secondary);
    border-radius: 0 4px 4px 0;
}

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

/* ── Inline code ── */
code {
    background: var(--inline-code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", Consolas, "Courier New", monospace;
    font-size: 0.875em;
}

/* ── Code blocks ── */
.code-block-wrapper {
    position: relative;
    margin: 1em 0;
}

.code-block-wrapper .highlight { margin: 0; }

.highlight .chroma {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-x: auto;
}

.highlight table.lntable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border-spacing: 0;
}

.highlight td.lntd {
    padding: 0;
    border: none;
    background: none;
    vertical-align: top;
}

/* Line number column */
.highlight td.lntd:first-child {
    width: 3.5em;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    user-select: none;
}

.highlight td.lntd:first-child pre {
    margin: 0;
    padding: 12px 0 12px 8px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

.highlight span.lnt {
    display: block;
    padding-right: 12px;
    padding-left: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.6;
    text-align: right;
}

/* Code content column */
.highlight td.lntd:last-child { width: auto; }

.highlight td.lntd:last-child pre {
    margin: 0;
    padding: 12px 16px;
    background: var(--pre-bg);
    border: none;
    border-radius: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    overflow-x: auto;
}

/* Copy button */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 1;
}

.code-block-wrapper:hover .copy-btn { opacity: 1; }

.copy-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.copy-btn.copied {
    color: #2ea043;
    border-color: #2ea043;
}

pre {
    background: var(--pre-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 20px;
    overflow-x: auto;
    margin: 1em 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* ── Tables ── */
article table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    font-size: 0.95rem;
}

article thead { border-bottom: 2px solid var(--table-border); }

article th, article td {
    padding: 10px 16px;
    text-align: left;
    border: 1px solid var(--table-border);
}

article th { font-weight: 600; background: var(--table-stripe); color: var(--heading); }

article tr:nth-child(even) { background: var(--table-stripe); }

/* Undo table stripe inside code blocks */
.lntable tr:nth-child(even),
.lntable tr,
.lntable td { background: transparent; }
.lntable tr:nth-child(even) { background: transparent; }

/* ── Lists ── */
article ul, article ol { padding-left: 24px; margin-bottom: 1em; }
article li { margin-bottom: 0.25em; }
article li > ul, article li > ol { margin-top: 0.25em; margin-bottom: 0; }

/* ── Horizontal rule ── */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

/* ── Post item (list) ── */
.post-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.post-item:first-child { padding-top: 0; }

.post-item h2 {
    font-size: 1.3rem;
    border-bottom: none;
    margin: 0 0 6px;
}

.post-item h2 a { color: var(--heading); }
.post-item h2 a:hover { color: var(--link); text-decoration: none; }

.post-item .summary { color: var(--text-secondary); font-size: 0.95rem; margin: 6px 0 0; }

.post-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.post-meta a { color: var(--text-muted); }
.post-meta a:hover { color: var(--link); }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 40px 0;
    font-size: 0.95rem;
}

.pagination a {
    padding: 6px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--link);
    text-decoration: none;
    transition: background 0.2s;
}

.pagination a:hover { background: var(--bg-secondary); text-decoration: none; }
.pagination span { color: var(--text-muted); }

/* ── Password protection ── */
.password-form {
    text-align: center;
    padding: 48px 24px;
    margin: 2em 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
}

.password-icon { font-size: 2.5rem; margin-bottom: 16px; }

.password-form p { margin-bottom: 16px; color: var(--text-secondary); }

.password-input-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    max-width: 320px;
    margin: 0 auto;
}

.password-input-row input[type="password"] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.password-input-row input:focus { border-color: var(--link); }

.password-input-row button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: var(--link);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.password-input-row button:hover { background: var(--link-hover); }

.password-error { color: #e74c3c; font-size: 0.9rem; margin-top: 12px; }

/* ── Footer ── */
.site-footer {
    padding: 24px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    body { padding: 0 16px; }
    .site-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .site-header nav { gap: 16px; }
    article th, article td { padding: 8px 10px; font-size: 0.85rem; }
}
