/* A quiet, low-ceremony notebook.
   Visual language adapted from lishun.space's minimal theme. */

:root {
    color-scheme: light;
    --bg: #f6f3ee;
    --card: #ffffff;
    --card-post: #eef5f6;
    --text: #26221d;
    --muted: #8a8377;
    --accent: #0b8298;
    --accent-hover: #075f70;
    --soft-border: #e7e1d6;
    --code-bg: #f1eee8;
    --mark-bg: #ffe0a3;
    --font-serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", serif;
}

:root[data-color-scheme="dark"] {
    color-scheme: dark;
    --bg: #0d0b09;
    --card: #2b251f;
    --card-post: #213033;
    --text: #ebe4d9;
    --muted: #a49b8e;
    --accent: #6ec6d6;
    --accent-hover: #8dd5e2;
    --soft-border: #433a31;
    --code-bg: #2a251f;
    --mark-bg: #4a3f28;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.72;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
    text-decoration: none;
    text-underline-offset: 3px;
}

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

a:focus-visible,
.search-toggle:focus-visible,
.color-scheme-toggle:focus-visible {
    border-radius: 2px;
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* ---------- Layout ---------- */

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

/* ---------- Header ---------- */

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 24px 0;
}

.site-title {
    color: var(--accent);
    font-size: 20px;
    font-weight: 650;
    line-height: 1.2;
}

.site-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.search-toggle {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 15px;
}

.search-toggle:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.color-scheme-toggle {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 15px;
}

.color-scheme-toggle:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.color-scheme-label-light {
    display: none;
}

:root[data-color-scheme="dark"] .color-scheme-label-light {
    display: inline;
}

:root[data-color-scheme="dark"] .color-scheme-label-dark {
    display: none;
}

/* ---------- Stream ---------- */

.stream {
    display: flex;
    flex-direction: column;
}

.entry {
    position: relative;
    margin-bottom: 16px;
    padding: 20px 22px;
    background: var(--card);
    border: 1px solid var(--soft-border);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.entry:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.entry-date {
    position: absolute;
    top: 14px;
    right: 18px;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.entry:hover .entry-date {
    opacity: 1;
}

/* ---------- Post preview ---------- */

.entry-post {
    border: 2px solid var(--accent);
    background: var(--card-post);
}

.entry-post .post-title {
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.35;
}

.entry-post .post-title a {
    color: var(--text);
    text-decoration: none;
}

.entry-post .post-title a:hover {
    color: var(--accent);
}

.post-excerpt {
    color: var(--muted);
}

.post-more {
    display: inline-block;
    margin-top: 8px;
    color: var(--accent);
    font-size: 14px;
}

.post-date {
    display: block;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    font-size: 14px;
}

.page-link {
    color: var(--accent);
    text-decoration: none;
    padding: 2px 10px;
    border-radius: 4px;
}

.page-link:hover {
    color: var(--accent-hover);
    background: var(--code-bg);
}

.page-current {
    padding: 2px 10px;
    border-radius: 4px;
    background: var(--code-bg);
    font-weight: 600;
    color: var(--text);
}

.page-gap {
    color: var(--muted);
    padding: 2px 4px;
}

.empty {
    color: var(--muted);
    margin-top: 8px;
}

/* ---------- Rendered Markdown ---------- */

.entry-body {
    font-family: var(--font-serif);
}

.entry-body > * + * {
    margin-top: 16px;
}

.entry-body h1,
.entry-body h2,
.entry-body h3 {
    line-height: 1.3;
    scroll-margin-top: 24px;
}

.entry-body h1::before,
.entry-body h2::before,
.entry-body h3::before {
    display: inline-block;
    margin-right: 0.42em;
    color: var(--accent);
    content: "#";
    font-weight: 400;
    opacity: 0.48;
}

.entry-body h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.entry-body h2 {
    margin-top: 32px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.entry-body h3 {
    margin-top: 24px;
    font-size: 17px;
    font-weight: 600;
}

.entry-body a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
}

.entry-body ul,
.entry-body ol {
    padding-left: 24px;
}

.entry-body li + li {
    margin-top: 4px;
}

.entry-body blockquote {
    padding-left: 16px;
    border-left: 2px solid var(--soft-border);
    color: var(--muted);
}

.entry-body code {
    font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    font-size: 0.9em;
    background: var(--code-bg);
    border-radius: 4px;
    padding: 0.1em 0.35em;
}

.entry-body pre {
    overflow-x: auto;
    padding: 14px 16px;
    border: 1px solid var(--soft-border);
    border-radius: 4px;
    background: var(--code-bg);
    line-height: 1.55;
}

.entry-body pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
}

.entry-body img,
.entry-body video {
    display: block;
    max-width: 100%;
    height: auto;
    margin-right: auto;
    margin-left: auto;
    border-radius: 4px;
}

.entry-body .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
}

.entry-body hr {
    border: 0;
    border-top: 2px solid var(--soft-border);
}

.entry-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 14px;
}

.entry-body th,
.entry-body td {
    padding: 7px 12px;
    border: 1px solid var(--soft-border);
    text-align: left;
}

.entry-body th {
    background: var(--code-bg);
    font-weight: 600;
}

/* ---------- Search dialog ---------- */

.search-dialog {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 23, 25, 0.4);
}

.search-panel {
    position: relative;
    width: min(560px, calc(100% - 32px));
    margin: 12vh auto 0;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--soft-border);
    border-radius: 10px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

#search-input {
    width: 100%;
    font: inherit;
    font-size: 18px;
    color: var(--text);
    background: transparent;
    border: 0;
    border-bottom: 2px solid var(--soft-border);
    padding: 8px 0;
    outline: none;
}

#search-input:focus {
    border-bottom-color: var(--accent);
}

#search-input::placeholder {
    color: var(--muted);
}

.search-results {
    max-height: 56vh;
    overflow-y: auto;
    margin-top: 8px;
}

.result {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--soft-border);
    text-decoration: none;
}

.result:last-child {
    border-bottom: 0;
}

.result:hover .result-snippet {
    color: var(--text);
}

.result-snippet {
    margin-top: 2px;
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.search-empty {
    padding: 12px 0;
    color: var(--muted);
}

mark {
    background: var(--mark-bg);
    color: inherit;
    border-radius: 2px;
    padding: 0 0.1em;
}

/* ---------- Responsive ---------- */

@media (max-width: 680px) {
    .container {
        padding: 40px 18px 56px;
    }

    .site-header {
        padding: 24px 18px 0;
    }

    .entry-body h1 {
        font-size: 22px;
    }

    .entry-body h2 {
        font-size: 18px;
    }

    .entry-body h3 {
        font-size: 15px;
    }
}

@media (max-width: 420px) {
    body {
        font-size: 15px;
    }
}
