:root {
    color-scheme: light;
    --background: #f7f8fa;
    --surface: #ffffff;
    --text: #20242a;
    --muted: #667085;
    --border: #d9dee7;
    --accent: #2b6f77;
    --code-bg: #151a20;
    --code-text: #e7edf3;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    overflow-x: hidden;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.65;
}

a {
    color: var(--accent);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    text-decoration-thickness: 0.14em;
}

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.site-nav,
.site-main {
    width: min(100% - 2rem, 1200px);
    margin: 0 auto;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.65rem 0;
}

.site-name {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.site-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.site-links a {
    display: block;
    padding: 0.5rem 0.65rem;
}

.site-main {
    padding: 2rem 0 3rem;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
}

.primary-column,
.sidebar {
    min-width: 0;
}

.page-header,
.article-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1,
.article h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 3.25rem);
    line-height: 1.12;
    letter-spacing: 0;
}

.article-nav {
    margin-bottom: 1.1rem;
    font-size: 0.95rem;
}

.article-meta,
.article-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.article-meta {
    align-items: center;
    margin-top: 1rem;
}

.article-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.article-categories li {
    color: var(--accent);
    font-weight: 600;
}

.article-body,
.article-summary,
.sidebar {
    min-width: 0;
}

.article-body > * + * {
    margin-top: 1.1em;
}

.article-body h2,
.article-body h3,
.article-body h4 {
    margin-top: 2em;
    line-height: 1.25;
    letter-spacing: 0;
}

.article-body p,
.article-body ul,
.article-body ol,
.article-body pre,
.article-body blockquote,
.article-body table {
    margin-bottom: 0;
}

.article-body img {
    display: block;
    max-width: 100%;
    height: auto;
}

.article-body code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}

.article-body :not(pre) > code {
    padding: 0.12rem 0.28rem;
    border-radius: 4px;
    background: #e9edf2;
}

.article-body pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 1rem;
    border-radius: 6px;
    background: var(--code-bg);
    color: var(--code-text);
}

.article-body pre code {
    color: inherit;
    background: transparent;
}

.article-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.article-body th,
.article-body td {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    text-align: left;
}

.article-body blockquote {
    margin-left: 0;
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
    color: var(--muted);
}

.article-summary {
    padding: 1.35rem 0;
    border-top: 1px solid var(--border);
}

.article-summary h2 {
    margin: 0.35rem 0 0;
    font-size: clamp(1.25rem, 4vw, 1.7rem);
    line-height: 1.3;
    letter-spacing: 0;
}

.sidebar {
    align-self: start;
}

.sidebar-section {
    padding: 1.1rem 0;
    border-top: 1px solid var(--border);
}

.sidebar-section:first-child {
    padding-top: 0;
    border-top: 0;
}

.sidebar-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.75rem;
    cursor: pointer;
    font-weight: 700;
    line-height: 1.3;
    list-style: none;
}

.sidebar-section summary::-webkit-details-marker {
    display: none;
}

.sidebar-section summary::after {
    content: "+";
    margin-left: 0.75rem;
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 400;
}

.sidebar-section[open] summary::after {
    content: "-";
}

.sidebar-section-title {
    flex: 1 1 auto;
}

.sidebar-section-count {
    flex: 0 0 auto;
    margin-left: 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 400;
}

.sidebar:focus-visible,
.sidebar-section summary:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.sidebar-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
}

.sidebar-article-list li {
    display: block;
}

.sidebar-count {
    flex: 0 0 auto;
    color: var(--muted);
}

@media (min-width: 900px) {
    html {
        height: 100%;
        overflow-y: clip;
    }

    body {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        height: 100dvh;
        min-height: 100dvh;
        overflow-y: clip;
        font-size: 17px;
    }

    .site-nav,
    .site-main {
        width: min(100% - 4rem, 1200px);
    }

    .site-main {
        min-height: 0;
        height: 100%;
        overflow: clip;
        padding-top: 3rem;
    }

    .content-grid {
        min-height: 0;
        height: 100%;
        overflow: clip;
        grid-template-columns: minmax(0, 800px) minmax(280px, 320px);
        gap: clamp(2rem, 4vw, 3rem);
    }

    .primary-column {
        min-height: 0;
        height: 100%;
        overflow-y: auto;
        scrollbar-gutter: stable;
    }

    .sidebar {
        align-self: stretch;
        min-height: 0;
        height: 100%;
        overflow-y: auto;
        padding: 1rem 1.1rem;
        border-left: 3px solid var(--accent);
        background-color: var(--surface);
        background-image:
            linear-gradient(to bottom, var(--surface), transparent 2.5rem),
            linear-gradient(to top, var(--surface), transparent 2.5rem);
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .sidebar::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
}
