:root {
    --bg:        #0f0f23;
    --surface:   #1a1a2e;
    --surface2:  #16213e;
    --accent:    #7c3aed;
    --accent2:   #ec4899;
    --text:      #e2e8f0;
    --text-soft: #f1f5f9;
    --muted:     #64748b;
    --border:    rgba(124,58,237,0.25);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; }
a { color: inherit; }

/* NAV */
.f-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.f-nav .brand {
    font-weight: 900;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: .5rem; }
.nav-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: #94a3b8;
    border-radius: 8px;
    padding: .35rem .85rem;
    font-size: .85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
}
.nav-btn:hover { border-color: rgba(124,58,237,0.5); color: #a78bfa; }
.nav-btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: #fff;
    font-weight: 700;
}
.nav-btn.primary:hover { opacity: .88; color: #fff; }
.user-tag {
    background: rgba(124,58,237,0.2);
    border: 1px solid rgba(124,58,237,0.35);
    color: #a78bfa;
    padding: .25rem .75rem;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
}

/* HERO */
.f-hero {
    background: linear-gradient(135deg, var(--bg) 0%, var(--surface) 60%, var(--surface2) 100%);
    padding: 3.5rem 0 2.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}
.f-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(124,58,237,0.15) 0%, transparent 65%);
    pointer-events: none;
}
.f-hero h1 {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #a78bfa, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    margin-bottom: .5rem;
}
.f-hero p { color: var(--muted); position: relative; }
.f-badge {
    display: inline-block;
    background: rgba(124,58,237,0.18);
    border: 1px solid rgba(124,58,237,0.4);
    color: #a78bfa;
    font-size: .75rem;
    font-weight: 700;
    padding: .2rem .75rem;
    border-radius: 20px;
    margin-bottom: .85rem;
    letter-spacing: .6px;
    text-transform: uppercase;
    position: relative;
}

/* SEARCH */
.f-search-wrap { position: relative; max-width: 560px; margin: 0 auto; padding: 0 1rem; }
.f-search {
    width: 100%;
    background: rgba(15,15,35,0.9);
    border: 1px solid rgba(124,58,237,0.35);
    color: var(--text);
    border-radius: 12px;
    padding: .8rem 1.2rem .8rem 3rem;
    font-size: .95rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.f-search:focus { border-color: rgba(124,58,237,0.7); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.f-search::placeholder { color: #475569; }
.f-search-icon { position: absolute; left: 1.9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* CATEGORIES as BUTTONS */
.cat-section { padding: 2.5rem 0 1.5rem; }
.cat-section h2 { font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 1rem; }
.cat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}
.cat-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-soft);
    border-radius: 12px;
    padding: .7rem 1.4rem;
    font-size: .95rem;
    font-weight: 700;
    text-decoration: none;
    transition: all .25s ease;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
}
.cat-btn:hover {
    background: rgba(124,58,237,0.18);
    border-color: rgba(124,58,237,0.6);
    color: #c4b5fd;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124,58,237,0.2);
}
.cat-btn .cat-stats {
    font-size: .75rem;
    font-weight: 400;
    color: var(--muted);
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    padding: .1rem .45rem;
    margin-left: .25rem;
}

/* TOPICS LIST */
.topics-section { padding: 1.5rem 0 2rem; }
.topics-section h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.topic-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.1rem 1.4rem;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color .2s, box-shadow .2s;
    text-decoration: none;
    color: inherit;
}
.topic-card:hover {
    border-color: rgba(124,58,237,0.5);
    box-shadow: 0 8px 28px rgba(124,58,237,0.15);
    color: inherit;
}
.topic-card.pinned { border-color: rgba(234,179,8,0.35); }
.topic-card.pinned:hover { border-color: rgba(234,179,8,0.6); }
.topic-title { font-weight: 700; font-size: 1rem; margin-bottom: .2rem; }
.topic-meta { font-size: .8rem; color: var(--muted); display: flex; gap: .75rem; flex-wrap: wrap; }
.badge-tag {
    font-size: .73rem;
    font-weight: 600;
    border-radius: 20px;
    padding: .15rem .6rem;
}
.badge-pinned { background: rgba(234,179,8,0.15); color: #facc15; border: 1px solid rgba(234,179,8,0.3); }
.badge-closed { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-cat    { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }

/* FOOTER */
.f-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    padding: 1.2rem 0;
    text-align: center;
    font-size: .85rem;
}
.f-footer a { color: var(--muted); text-decoration: none; }
.f-footer a:hover { color: var(--text); }

/* SEARCH RESULTS */
#searchResults { padding-bottom: 1rem; }

@media(max-width:600px){
    .f-hero h1 { font-size: 1.6rem; }
    .cat-btn { padding: .55rem 1rem; font-size: .88rem; }
    .f-nav { padding: 0 1rem; }
}

/* ── TOPIC CARD GRID (card view mode) ──────────────────────────────────────── */
.topic-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: .5rem;
}
.topic-card-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem 1.3rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    text-decoration: none;
    color: inherit;
    transition: border-color .2s, box-shadow .2s, transform .15s;
}
.topic-card-item:hover {
    border-color: rgba(124,58,237,0.55);
    box-shadow: 0 8px 28px rgba(124,58,237,0.18);
    transform: translateY(-2px);
    color: inherit;
}
.topic-card-item.pinned { border-color: rgba(234,179,8,0.35); }
.topic-card-item.pinned:hover { border-color: rgba(234,179,8,0.65); }
.tci-head {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    min-height: 22px;
}
.tci-title {
    font-weight: 700;
    font-size: .97rem;
    line-height: 1.4;
    flex: 1;
}
.tci-meta {
    font-size: .78rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.tci-meta span { display: flex; align-items: center; gap: .3rem; }
.tci-footer {
    margin-top: auto;
    padding-top: .65rem;
    border-top: 1px solid rgba(255,255,255,.06);
    font-size: .8rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: .35rem;
}

/* Pagination tweaks */
.pagination .page-link { border-radius: 8px !important; }
