:root {
    --bg:           #ede8de;
    --surface:      #f7f4ee;
    --surface-alt:  #f0ece4;
    --sidebar-bg:   #e6e1d7;
    --border:       #ccc7bc;
    --border-light: #d8d3c8;
    --text:         #28231e;
    --text-muted:   #6b6258;
    --text-faint:   #9a9189;
    --heading:      #1a1612;
    --link:         #3b5470;
    --link-hover:   #1e3348;
    --link-visited: #5a4a6e;
    --accent:       #7a6b59;
    --accent-light: #a8957e;
    --tag-bg:       #dcd7cc;
    --tag-hover:    #c8c2b5;
    --tag-text:     #3d3630;
    --header-bg:    #1e1a16;
    --header-text:  #e2dcd4;
    --header-muted: #8a8078;
    --footer-bg:    #201c18;
    --footer-text:  #7a736a;
    --err:          #7a3030;
    --err-bg:       #f0e8e8;

    --font-body:    Georgia, 'Times New Roman', Times, serif;
    --font-heading: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
    --font-ui:      'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;

    --radius:       3px;
    --sidebar-w:    260px;
    --content-max:  860px;
    --gap:          2rem;
}

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

html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.75;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */

.site-header {
    background: var(--header-bg);
    border-bottom: 1px solid #0a0806;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: calc(var(--content-max) + var(--sidebar-w) + var(--gap) * 2 + 4rem);
    margin: 0 auto;
    padding: 0 2rem;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-logo {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    color: var(--header-text);
    text-decoration: none;
    white-space: nowrap;
    opacity: 0.92;
    flex-shrink: 0;
}

.site-logo:hover {
    opacity: 1;
    color: #fff;
}

.header-search {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 520px;
    margin-left: auto;
    border: 1px solid #3a342e;
    border-radius: var(--radius);
    background: #2a241e;
    overflow: hidden;
    transition: border-color 0.15s;
}

.header-search:focus-within {
    border-color: var(--accent-light);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0 0.9rem;
    height: 34px;
    color: var(--header-text);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    caret-color: var(--accent-light);
}

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

.search-btn {
    background: none;
    border: none;
    border-left: 1px solid #3a342e;
    color: var(--header-muted);
    padding: 0 0.8rem;
    height: 34px;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
}

.search-btn:hover {
    color: var(--header-text);
    background: #342e28;
}

/* ── Page layout ─────────────────────────────────────── */

.page-wrap {
    flex: 1;
    max-width: calc(var(--content-max) + var(--sidebar-w) + var(--gap) * 2 + 4rem);
    margin: 0 auto;
    padding: 2.2rem 2rem;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr var(--sidebar-w);
    gap: var(--gap) 2.5rem;
    align-items: start;
}

/* ── Breadcrumb ──────────────────────────────────────── */

.breadcrumb {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--text-faint);
    margin-bottom: 1.4rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--link);
}

.bc-sep {
    padding: 0 0.35rem;
    opacity: 0.5;
}

.bc-current {
    color: var(--text-muted);
}

/* ── Article ─────────────────────────────────────────── */

.article-main {
    min-width: 0;
}

.article-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: normal;
    color: var(--heading);
    line-height: 1.22;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.6rem;
    letter-spacing: -0.01em;
}

.article-body {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 2rem 2.2rem;
    margin-top: 1.4rem;
}

/* ── Article body typography ─────────────────────────── */

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
    font-family: var(--font-heading);
    font-weight: normal;
    color: var(--heading);
    margin: 1.8rem 0 0.6rem;
    line-height: 1.3;
}

.article-body h1 { font-size: 1.75rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.3rem; }
.article-body h2 { font-size: 1.45rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.25rem; }
.article-body h3 { font-size: 1.2rem; }
.article-body h4 { font-size: 1.05rem; font-style: italic; }
.article-body h5 { font-size: 0.95rem; font-style: italic; }
.article-body h6 { font-size: 0.88rem; font-style: italic; color: var(--text-muted); }

.article-body p {
    margin-bottom: 1rem;
}

.article-body p:last-child {
    margin-bottom: 0;
}

.article-body a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.12s;
}

.article-body a:hover {
    color: var(--link-hover);
}

.article-body a:visited {
    color: var(--link-visited);
}

.article-body ul,
.article-body ol {
    margin: 0.8rem 0 1rem 1.6rem;
}

.article-body li {
    margin-bottom: 0.3rem;
}

.article-body blockquote {
    margin: 1.2rem 0;
    padding: 0.8rem 1.2rem;
    border-left: 3px solid var(--accent-light);
    background: var(--surface-alt);
    color: var(--text-muted);
    font-style: italic;
}

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

.article-body code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: 2px;
    padding: 0.1em 0.35em;
    color: var(--text);
}

.article-body pre {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.article-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1.55;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
    font-size: 0.9rem;
}

.article-body th {
    background: var(--surface-alt);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-transform: uppercase;
}

.article-body td {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border-light);
    vertical-align: top;
}

.article-body tr:nth-child(even) td {
    background: var(--surface-alt);
}

.article-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.8rem 0;
}

.article-body img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.article-body sup,
.article-body sub {
    font-size: 0.72em;
    line-height: 0;
}

/* ── Error state ─────────────────────────────────────── */

.err-msg {
    color: var(--err);
    background: var(--err-bg);
    border: 1px solid #d4b0b0;
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    font-family: var(--font-ui);
    font-size: 0.88rem;
}

/* ── Tags ────────────────────────────────────────────── */

.tag-block {
    margin-top: 1.8rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tag-label {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-chip {
    display: inline-block;
    background: var(--tag-bg);
    color: var(--tag-text);
    font-family: var(--font-ui);
    font-size: 0.76rem;
    padding: 0.2rem 0.65rem;
    border-radius: 2px;
    text-decoration: none;
    border: 1px solid var(--border);
    transition: background 0.12s, border-color 0.12s;
}

.tag-chip:hover {
    background: var(--tag-hover);
    border-color: var(--accent-light);
    color: var(--heading);
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    position: sticky;
    top: 70px;
}

.sidebar-card {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
}

.sidebar-heading {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Recent pages list */

.recent-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.recent-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}

.recent-list li:last-child {
    border-bottom: none;
}

.recent-list a {
    color: var(--link);
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-ui);
    font-size: 0.82rem;
}

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

.recent-time {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    color: var(--text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar-empty {
    font-size: 0.82rem;
    color: var(--text-faint);
    font-style: italic;
    font-family: var(--font-ui);
}

/* Meta list */

.meta-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.82rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border-light);
}

.meta-row:last-child {
    border-bottom: none;
}

.meta-row dt {
    font-family: var(--font-ui);
    color: var(--text-faint);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-row dd {
    font-family: var(--font-ui);
    color: var(--text-muted);
    font-size: 0.82rem;
}

.meta-of {
    color: var(--text-faint);
    margin: 0 0.2rem;
}

/* Sidebar tags */

.sidebar-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.sidebar-tag {
    display: inline-block;
    background: var(--tag-bg);
    color: var(--tag-text);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    text-decoration: none;
    border: 1px solid var(--border);
    transition: background 0.12s;
}

.sidebar-tag:hover {
    background: var(--tag-hover);
    color: var(--heading);
}

/* ── Footer ──────────────────────────────────────────── */

.site-footer {
    background: var(--footer-bg);
    border-top: 1px solid #0a0806;
    margin-top: auto;
}

.footer-inner {
    max-width: calc(var(--content-max) + var(--sidebar-w) + var(--gap) * 2 + 4rem);
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--footer-text);
}

.footer-inner a {
    color: var(--header-muted);
    text-decoration: none;
    white-space: nowrap;
}

.footer-inner a:hover {
    color: var(--header-text);
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 800px) {
    .page-wrap {
        grid-template-columns: 1fr;
        padding: 1.4rem 1rem;
        gap: 1.8rem;
    }

    .sidebar {
        position: static;
        order: -1;
    }

    .article-body {
        padding: 1.2rem 1.1rem;
    }

    .header-inner {
        padding: 0 1rem;
        gap: 0.8rem;
    }

    .article-title {
        font-size: 1.6rem;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 0.4rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 15.5px;
    }

    .header-search {
        max-width: 100%;
    }

    .site-logo {
        font-size: 0.7rem;
    }
}
