:root {
    --bg: #fff;
    --bg2: #f7f7f6;
    --border: rgba(0, 0, 0, .08);
    --text: #1a1a1a;
    --muted: #666;
    --accent: #1D9E75;
    --accent-bg: #E1F5EE;
    --accent-deep: #085041;
    --mono: 'IBM Plex Mono', monospace;
    --sans: 'IBM Plex Sans', sans-serif;
    --sw: 240px;
    --cw: 720px;
}

/* @media(prefers-color-scheme:dark) {
    :root {
        --bg: #111;
        --bg2: #1a1a1a;
        --border: rgba(255, 255, 255, .08);
        --text: #e8e8e8;
        --muted: #888;
        --accent-bg: #0a2e22;
    }
} */

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

body {
    font-family: var(--sans);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.75
}

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

a:hover {
    text-decoration: underline
}

code {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg2);
    padding: 1px 5px;
    border-radius: 3px
}

pre {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.2rem 0
}

pre code {
    background: none;
    padding: 0
}

h1 {
    font-family: var(--mono);
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1.25;
    margin: 2rem 0 .5rem
}

h2 {
    font-family: var(--mono);
    font-size: 1.15rem;
    font-weight: 500;
    margin: 2rem 0 .5rem
}

h3 {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 500;
    margin: 1.5rem 0 .3rem
}

p {
    margin: .8rem 0
}

ul,
ol {
    margin: .8rem 0 .8rem 1.5rem
}

li {
    margin: .3rem 0
}

blockquote {
    border-left: 3px solid var(--accent);
    padding: .5rem 1rem;
    color: var(--muted);
    margin: 1rem 0;
    font-style: italic
}

.callout {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .75rem 1rem;
    margin: 1rem 0;
    display: flex;
    gap: .5rem
}

figure {
    margin: 1.5rem 0
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95em;
}

th, td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    text-align: left;
}

th {
    background: var(--bg2);
    font-weight: 500;
}

figure img {
    max-width: 100%;
    border-radius: 6px
}

figcaption {
    font-size: 12px;
    color: var(--muted);
    margin-top: .4rem
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0
}

strong {
    font-weight: 500
}

.summary-card {
    display: flex;
    gap: 0.5rem;
    background: var(--accent-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 7px;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100dvh
}

.sidebar {
    width: var(--sw);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
    background: var(--bg)
}

.main {
    flex: 1;
    padding: 2rem 2.5rem;
    min-width: 0
}

.content {
    max-width: var(--cw)
}

/* Sidebar */
.site-name {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 1.5rem;
    display: block
}

.site-name span {
    color: var(--muted);
    font-weight: 400
}

.nav-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 1.2rem 0 .4rem;
    display: block
}

.toc a {
    display: block;
    font-size: 12px;
    color: var(--muted);
    padding: 3px 0 3px 8px;
    border-left: 2px solid transparent;
    transition: all .15s
}

.toc a:hover,
.toc a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    text-decoration: none
}

.toc a.h3 {
    padding-left: 20px;
    font-size: 11px
}

/* Tags */
.tag {
    background: var(--accent-bg);
    color: var(--accent-deep);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    font-family: var(--mono)
}

.tag-members {
    background: #fef3c7;
    color: #92400e
}

@media(prefers-color-scheme:dark) {
    .tag-members {
        background: #2a1a00;
        color: #f59e0b
    }
}

/* Article header */
.art-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border)
}

.art-title {
    font-family: var(--mono);
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 1rem
}

.art-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    font-family: var(--mono)
}

/* Audio */
.audio-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 14px;
    margin: 1rem 0 1.5rem;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted)
}

.audio-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 11px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center
}

.audio-track {
    flex: 1;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
    position: relative
}

.audio-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    pointer-events: none
}

/* Members gate */
.gate {
    position: relative;
    overflow: hidden;
    border-radius: 6px
}

.gate-blur {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
    max-height: 300px;
    overflow: hidden
}

.gate-cover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: linear-gradient(to bottom, transparent 0%, var(--bg) 70%)
}

.gate-label {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: .5rem 1.2rem;
    border-radius: 4px
}

/* Index */
.art-list {
    list-style: none
}

.art-item {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: .85rem 0;
    border-bottom: 1px solid var(--border)
}

.art-num {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    min-width: 22px
}

.art-link {
    font-size: 14px
}

.art-byline {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
    white-space: nowrap
}

/* Citations */
.refs {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border)
}

.refs-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: .8rem;
    display: block
}

.refs ol {
    font-size: 13px;
    color: var(--muted)
}

.refs li {
    margin: .35rem 0
}

/* ─── Mobile top nav ───────────────────────────────────────── */
.mobile-topnav {
    display: none;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-tags {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: .5rem 0 .25rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.mobile-tags::-webkit-scrollbar {
    display: none
}

/* ─── Search + Tag filter (sidebar) ───────────────────────── */
.search-wrap {
    margin: .75rem 0 .5rem
}

.search-input {
    width: 100%;
    font-family: var(--mono);
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg2);
    color: var(--text);
    outline: none;
}

.search-input:focus {
    border-color: var(--accent)
}

.tag-filter {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: .25rem;
}

.tag-btn {
    font-family: var(--mono);
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    transition: all .1s;
}

.tag-btn:hover {
    color: var(--accent)
}

.tag-btn.active {
    background: var(--accent-bg);
    color: var(--accent-deep);
    border-color: var(--accent-bg);
}

/* ─── Related articles ─────────────────────────────────────── */
.related {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ─── Mobile overrides ─────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        display: none
    }

    .mobile-topnav {
        display: block
    }

    .main {
        padding: 1.5rem 1rem
    }

    .art-meta {
        font-size: 11px;
        gap: .5rem
    }

    .summary-card {
        flex-direction: column
    }
}