:root {
    --bg-color: #050608;
    --bg-secondary: #0d1117;
    --bg-tertiary: #141a22;
    --panel-color: rgba(17, 24, 34, 0.88);
    --panel-strong: #111827;
    --text-main: #f8fafc;
    --text-muted: #92a0b5;
    --accent-color: #ff234f;
    --accent-soft: rgba(255, 35, 79, 0.12);
    --accent-glow: rgba(255, 35, 79, 0.3);
    --border-color: rgba(148, 163, 184, 0.16);
    --border-strong: rgba(148, 163, 184, 0.24);
    --success-color: #4ade80;
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.28);
    --radius-md: 16px;
    --radius-lg: 24px;
    --font-text: "Inter", sans-serif;
    --font-code: "Fira Code", monospace;
}

body.light-theme {
    --bg-color: #f4f7fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf2f7;
    --panel-color: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --text-main: #132033;
    --text-muted: #607086;
    --accent-color: #d90429;
    --accent-soft: rgba(217, 4, 41, 0.1);
    --accent-glow: rgba(217, 4, 41, 0.18);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.08);
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(255, 35, 79, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(82, 157, 255, 0.12), transparent 24%),
        var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-text);
    line-height: 1.6;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 85%);
    opacity: 0.24;
}

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

button {
    font: inherit;
}

img {
    max-width: 100%;
    display: block;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(18px);
    background: rgba(5, 6, 8, 0.72);
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .header {
    background: rgba(244, 247, 251, 0.82);
}

.header-inner {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-code);
    font-size: 1.12rem;
    font-weight: 700;
}

.logo img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 0 0 1px var(--border-strong);
}

.logo strong {
    color: var(--accent-color);
    font-weight: 700;
}

.header-nav,
.header-actions,
.hero-actions,
.thread-actions,
.footer-links {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-nav {
    flex-wrap: wrap;
    justify-content: center;
}

.nav-link,
.inline-link {
    color: var(--text-muted);
    transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-link {
    font-family: var(--font-code);
    font-size: 0.88rem;
}

.nav-link:hover,
.inline-link:hover {
    color: var(--text-main);
}

.primary-button,
.secondary-button,
.ghost-button,
.theme-toggle,
.back-btn {
    border-radius: 999px;
    border: 1px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.primary-button,
.secondary-button,
.ghost-button {
    padding: 11px 18px;
    font-weight: 600;
}

.primary-button {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 14px 28px rgba(255, 35, 79, 0.24);
}

.primary-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(255, 35, 79, 0.32);
}

.secondary-button,
.ghost-button,
.theme-toggle,
.back-btn {
    background: var(--panel-color);
    border-color: var(--border-color);
    color: var(--text-main);
}

.secondary-button:hover,
.ghost-button:hover,
.theme-toggle:hover,
.back-btn:hover {
    border-color: var(--accent-color);
    box-shadow: 0 10px 24px var(--accent-glow);
}

.ghost-button {
    font-size: 0.95rem;
}

.theme-toggle {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.hero {
    padding: 56px 0 28px;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.9fr);
    gap: 24px;
    align-items: stretch;
}

.hero-copy,
.hero-panel,
.section-block,
.thread-shell,
.forum-section,
.topic-card,
.category-card {
    background: var(--panel-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.hero-copy,
.hero-panel {
    border-radius: var(--radius-lg);
    padding: 30px;
}

.eyebrow,
.section-kicker {
    font-family: var(--font-code);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.76rem;
    color: var(--accent-color);
}

.hero-copy h1 {
    margin-top: 14px;
    font-size: clamp(2.3rem, 5vw, 4.4rem);
    line-height: 1.02;
    letter-spacing: -0.05em;
}

.hero-copy p {
    margin-top: 18px;
    max-width: 54ch;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.hero-actions {
    margin-top: 28px;
    flex-wrap: wrap;
}

.hero-panel {
    display: grid;
    gap: 16px;
    align-content: start;
}

.hero-stat {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.hero-stat-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-family: var(--font-code);
}

.hero-stat strong {
    font-size: 1.04rem;
}

.page-shell {
    padding-bottom: 64px;
}

.section-block,
.thread-shell {
    border-radius: var(--radius-lg);
    padding: 26px;
}

.toolbar,
.section-heading,
.thread-meta,
.thread-badges {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.toolbar {
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-info {
    color: var(--text-muted);
    font-family: var(--font-code);
    font-size: 0.85rem;
}

.section-heading {
    margin-bottom: 20px;
}

.section-heading h2 {
    font-size: 1.5rem;
    margin-top: 6px;
}

.section-heading.compact {
    margin-bottom: 18px;
}

.section-block + .section-block,
.forum-section + .forum-section {
    margin-top: 22px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.category-card {
    padding: 22px 20px;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.category-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-soft), transparent 62%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.category-card:hover::before,
.category-card.active::before {
    opacity: 1;
}

.category-card:hover,
.category-card.active {
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.category-emoji {
    font-size: 1.5rem;
}

.category-card h3 {
    margin-top: 14px;
    font-size: 1.08rem;
}

.category-card p {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.category-count {
    margin-top: 16px;
    font-family: var(--font-code);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.topics-container,
.comments-list {
    display: grid;
    gap: 14px;
}

.topic-card {
    border-radius: var(--radius-md);
    padding: 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: start;
}

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

.topic-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.topic-title {
    font-size: 1.1rem;
    line-height: 1.35;
}

.topic-excerpt {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.96rem;
}

.topic-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.topic-stats {
    display: grid;
    gap: 10px;
    min-width: 126px;
    justify-items: end;
    text-align: right;
}

.stat-box,
.meta-chip,
.badge {
    border-radius: 999px;
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    background: var(--bg-tertiary);
    font-size: 0.78rem;
    font-weight: 600;
}

.badge {
    color: var(--accent-color);
    background: var(--accent-soft);
    border-color: rgba(255, 35, 79, 0.22);
}

.meta-chip {
    color: var(--text-muted);
}

.stat-box strong {
    display: block;
    color: var(--text-main);
    font-size: 1rem;
}

.stat-box span {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-family: var(--font-code);
}

.thread-view[hidden] {
    display: none;
}

.back-btn {
    padding: 11px 16px;
    margin-bottom: 18px;
    cursor: pointer;
}

.thread-header h1 {
    margin-top: 16px;
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.12;
}

.thread-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.thread-actions {
    flex-wrap: wrap;
    margin-top: 20px;
}

.forum-section {
    border-radius: var(--radius-md);
    padding: 22px;
}

.thread-body,
.comment-body {
    color: var(--text-main);
}

.thread-body > :first-child,
.comment-body > :first-child {
    margin-top: 0;
}

.thread-body > :last-child,
.comment-body > :last-child {
    margin-bottom: 0;
}

.thread-body p,
.thread-body li,
.comment-body p,
.comment-body li {
    color: var(--text-muted);
    margin-bottom: 1em;
    overflow-wrap: anywhere;
}

.thread-body h1,
.thread-body h2,
.thread-body h3,
.thread-body h4,
.comment-body h1,
.comment-body h2,
.comment-body h3,
.comment-body h4 {
    margin: 1.2em 0 0.6em;
}

.thread-body ul,
.thread-body ol,
.comment-body ul,
.comment-body ol {
    padding-left: 1.25rem;
}

.thread-body pre,
.comment-body pre {
    overflow-x: auto;
    background: #020408;
    color: #d7e3f4;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    padding: 16px;
    margin-bottom: 1.2em;
}

.thread-body code,
.comment-body code {
    font-family: var(--font-code);
    background: rgba(148, 163, 184, 0.12);
    padding: 0.18em 0.38em;
    border-radius: 6px;
    font-size: 0.9em;
}

.thread-body pre code,
.comment-body pre code {
    background: transparent;
    padding: 0;
}

.thread-body blockquote,
.comment-body blockquote {
    margin: 0 0 1.2em;
    padding: 12px 16px;
    border-left: 3px solid var(--accent-color);
    background: var(--accent-soft);
    border-radius: 0 12px 12px 0;
}

.thread-body table,
.comment-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2em;
}

.thread-body th,
.thread-body td,
.comment-body th,
.comment-body td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.thread-body a,
.comment-body a {
    color: var(--accent-color);
}

.comment-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    padding: 18px;
}

.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.comment-author {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.comment-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-secondary);
}

.comment-date {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.empty-state,
.loading-placeholder,
.error-msg {
    padding: 22px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-strong);
    color: var(--text-muted);
    text-align: center;
    background: rgba(148, 163, 184, 0.04);
}

.error-msg {
    border-style: solid;
    border-color: rgba(255, 35, 79, 0.24);
    color: var(--text-main);
}

.footer {
    border-top: 1px solid var(--border-color);
    padding: 32px 0 52px;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer-brand {
    font-weight: 700;
    font-size: 1.05rem;
}

.footer p,
.footer-links a {
    color: var(--text-muted);
}

@media (max-width: 960px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    body::before {
        background-size: 28px 28px;
    }

    .container {
        width: min(100% - 24px, 1180px);
    }

    .header-nav {
        order: 3;
        width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .hero {
        padding-top: 36px;
    }

    .hero-copy,
    .hero-panel,
    .section-block,
    .thread-shell {
        padding: 20px;
    }

    .toolbar,
    .section-heading,
    .footer-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .topic-card {
        grid-template-columns: 1fr;
    }

    .topic-stats {
        min-width: 0;
        width: 100%;
        grid-auto-flow: column;
        justify-content: flex-start;
        text-align: left;
        justify-items: stretch;
    }

    .thread-actions,
    .hero-actions,
    .footer-links {
        width: 100%;
        flex-wrap: wrap;
    }

    .primary-button,
    .secondary-button,
    .ghost-button {
        flex: 1 1 220px;
        text-align: center;
    }
}

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

    .logo img {
        width: 30px;
        height: 30px;
    }

    .hero-copy h1 {
        font-size: 2rem;
    }

    .section-heading h2 {
        font-size: 1.25rem;
    }

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