:root {
    --bg: #0c0c10;
    --bg-subtle: #14141a;
    --text: #e0d8cc;
    --text-muted: #8a8078;
    --accent: #c9913a;
    --accent-glow: rgba(201, 145, 58, 0.15);
    --border: rgba(201, 145, 58, 0.12);

    --font-mono: 'Space Mono', 'JetBrains Mono', 'Fira Code', monospace;
    --font-serif: Georgia, 'Times New Roman', Times, serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

    --max-width: 660px;
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 4rem;
    --space-2xl: 8rem;
}

/* ---- Reset ---- */

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

a {
    color: inherit;
    text-decoration: none;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-serif);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

::selection {
    background: var(--accent-glow);
    color: var(--text);
}

/* ---- Canvas ---- */

#network {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

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

.container {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-lg);
}

/* ---- Navigation ---- */

.back-link {
    padding: var(--space-lg) 0 var(--space-md);
}

.back-link a {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
}

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

/* ---- Hero ---- */

.hero {
    padding: var(--space-2xl) 0 var(--space-xl);
}

.logo {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.1;
}

.logo .dot {
    color: var(--accent);
}

.tagline {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: lowercase;
    margin-top: var(--space-sm);
}

/* ---- Page Header (subpages) ---- */

.page-header {
    padding: var(--space-lg) 0 var(--space-xl);
}

.page-header h1 {
    font-family: var(--font-sans);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.page-description {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ---- Intro ---- */

.intro {
    padding-bottom: var(--space-2xl);
    border-bottom: 1px solid var(--border);
}

.intro p {
    margin-bottom: var(--space-md);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.85;
}

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

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

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.section-header h2 {
    margin-bottom: 0;
}

.topic-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

/* ---- Threads ---- */

.threads {
    padding: var(--space-2xl) 0;
}

.threads h2 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: var(--space-xl);
}

/* ---- Thread Preview (homepage, topic pages) ---- */

.thread-preview {
    margin-bottom: var(--space-2xl);
    padding-left: var(--space-lg);
    border-left: 1px solid var(--border);
    transition: border-color 0.4s ease;
}

.thread-preview:hover {
    border-left-color: var(--accent);
}

.thread-preview:last-child {
    margin-bottom: 0;
}

.thread-preview header {
    margin-bottom: var(--space-md);
}

.thread-preview h3 {
    font-family: var(--font-sans);
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.thread-preview h3 a {
    color: var(--text);
    transition: color 0.3s ease;
}

.thread-preview h3 a:hover {
    color: var(--accent);
}

.thread-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.thread-meta time {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.meta-tags {
    display: flex;
    gap: var(--space-xs);
}

.preview-body p {
    margin-bottom: var(--space-md);
    line-height: 1.85;
}

.read-more {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    transition: color 0.3s ease;
}

.read-more:hover {
    color: var(--accent);
}

/* ---- Thread Full (individual page) ---- */

.thread-full {
    padding: var(--space-lg) 0 var(--space-xl);
}

.thread-header {
    margin-bottom: var(--space-xl);
}

.thread-header h1 {
    font-family: var(--font-sans);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: var(--space-sm);
}

.thread-header .thread-meta {
    margin-top: var(--space-sm);
}

.thread-body p {
    margin-bottom: var(--space-md);
    line-height: 1.85;
}

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

.thread-body em {
    font-style: italic;
    color: var(--accent);
}

/* ---- Tags ---- */

.tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 0.15em 0.5em;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.tag:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

/* ---- Topic Chips (homepage filter row) ---- */

.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.topic-chip:hover {
    color: var(--accent);
}

.topic-chip .topic-count {
    font-size: 0.55rem;
    opacity: 0.5;
}

/* ---- Topics Overview (homepage) ---- */

.topics-overview {
    padding-bottom: var(--space-2xl);
}

.topics-overview h2 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: var(--space-lg);
}

.topics-grid {
    display: grid;
    gap: var(--space-md);
}

/* ---- Topic Cards ---- */

.topic-card {
    display: block;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--border);
    border-radius: 3px;
    transition: border-color 0.4s ease, background 0.4s ease;
}

.topic-card:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.topic-card h2,
.topic-card h3 {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-xs);
}

.topic-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: var(--space-xs);
}

.topic-card .topic-count {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ---- Topics List (topics index page) ---- */

.topics-list {
    display: grid;
    gap: var(--space-md);
    padding-bottom: var(--space-xl);
}

/* ---- Related Threads ---- */

.related {
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--border);
}

.related h2 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: var(--space-lg);
}

.related-link {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

.related-link:last-child {
    border-bottom: none;
}

.related-link:hover {
    border-bottom-color: var(--accent);
}

.related-title {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    transition: color 0.3s ease;
}

.related-link:hover .related-title {
    color: var(--accent);
}

.related-meta {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: var(--space-md);
}

/* ---- Footer ---- */

.site-footer {
    padding: var(--space-xl) 0 var(--space-2xl);
    border-top: 1px solid var(--border);
    margin-top: var(--space-xl);
}

.site-footer p {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.footer-meta {
    margin-top: var(--space-xs);
    opacity: 0.5;
}

/* ---- Animations ---- */

.fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger previews */
.thread-preview.fade-in:nth-child(2) { transition-delay: 0.1s; }
.thread-preview.fade-in:nth-child(3) { transition-delay: 0.2s; }
.thread-preview.fade-in:nth-child(4) { transition-delay: 0.3s; }

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

@media (max-width: 640px) {
    html {
        font-size: 16px;
    }

    .container {
        padding: var(--space-md);
    }

    .hero {
        padding: var(--space-xl) 0 var(--space-lg);
    }

    .logo {
        font-size: 2.2rem;
    }

    .thread-preview {
        padding-left: var(--space-md);
    }

    .threads {
        padding: var(--space-xl) 0;
    }

    .section-header {
        flex-direction: column;
    }

    .thread-header h1 {
        font-size: 1.35rem;
    }

    .related-link {
        flex-direction: column;
        gap: var(--space-xs);
    }

    .related-meta {
        margin-left: 0;
    }
}

@media (max-width: 380px) {
    .logo {
        font-size: 1.8rem;
    }
}

/* ---- Print ---- */

@media print {
    #network { display: none; }

    body {
        background: white;
        color: #111;
    }

    .thread-preview,
    .thread-full {
        border-left-color: #ccc;
    }

    .tag {
        border-color: #ccc;
        color: #333;
    }
}
