:root {
    --forum-accent: #4f46e5;
    --forum-accent-rgb: 79, 70, 229;
    --forum-accent-soft: rgba(79, 70, 229, .12);
    --forum-border: rgb(199 199 199);
    --forum-shadow: 0 .5rem 1.25rem rgba(15, 23, 42, .06);
    --forum-btn-color: var(--bs-body-color);
    --forum-btn-bg: var(--bs-body-bg);
    --forum-btn-border: rgba(var(--forum-accent-rgb), .24);
    --forum-btn-hover-bg: var(--forum-accent);
    --forum-btn-hover-color: #fff;
    --forum-btn-hover-border: var(--forum-accent);
    --forum-like-color: #198754;
    --forum-dislike-color: #dc3545;
    --body-bd: linear-gradient(rgb(255 255 255 / 14%), rgb(255 255 255 / 50%)), url(/assets/img/bg.jpg);
}

[data-bs-theme="dark"] {
    --forum-accent: #8b5cf6;
    --forum-accent-rgb: 139, 92, 246;
    --forum-accent-soft: rgba(139, 92, 246, .16);
    --forum-border: rgba(255, 255, 255, .08);
    --forum-shadow: 0 .65rem 1.4rem rgba(0, 0, 0, .28);
    --forum-btn-color: #dfe5ef;
    --forum-btn-bg: rgba(255, 255, 255, .03);
    --forum-btn-border: rgba(255, 255, 255, .16);
    --body-bd: linear-gradient(rgb(0 0 0 / 49%), rgb(154 113 248 / 52%)), url(/assets/img/bg.jpg);
}

/* =========================
   BASE
   ========================= */

body {
    min-height: 100vh;
    background: var(--body-bd);
}

.page-shell {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

.min-w-0 {
    min-width: 0;
}

.panel-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--forum-border);
    border-radius: 1rem;
    box-shadow: var(--forum-shadow);
}

/* =========================
   HEADER
   ========================= */

.topbar-card {
    position: relative;
    background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
    backdrop-filter: blur(12px);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: .75rem;
    background: linear-gradient(140deg, #6862e9, #fefeff);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-card {
    padding: 1rem 1.1rem;
}

.hero-title {
    font-size: 1.35rem;
    line-height: 1.2;
}

.hero-description {
    margin-bottom: 0;
    font-size: .95rem;
}

.stat-box {
    height: 100%;
    padding: .7rem .85rem;
    border: 1px solid var(--forum-border);
    border-radius: .85rem;
    background: var(--bs-tertiary-bg);
}

/* =========================
   SIDEBAR
   ========================= */

.sidebar-sticky {
    position: sticky;
    top: 1rem;
}

.sidebar-list {
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.sidebar-link {
    display: block;
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid transparent;
    border-radius: .85rem;
    color: inherit;
    text-decoration: none;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.sidebar-link:hover {
    background: var(--forum-accent-soft);
    border-color: rgba(var(--forum-accent-rgb), .14);
}

.sidebar-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--forum-accent), color-mix(in srgb, var(--forum-accent) 78%, #fff));
}

.sidebar-link.active .text-body-secondary {
    color: rgba(255, 255, 255, .92) !important;
}

.sidebar-link-inner {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    min-width: 0;
}

.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: .65rem;
    background: var(--forum-accent-soft);
    color: var(--forum-accent);
    font-size: .95rem;
}

.sidebar-link.active .sidebar-icon {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

.sidebar-text {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.sidebar-title {
    display: block;
    margin-bottom: .15rem;
    overflow: hidden;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-desc {
    display: block;
    overflow: hidden;
    font-size: .75rem;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-badge {
    flex-shrink: 0;
    margin-left: .35rem;
}

.mobile-sections-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--forum-border);
    border-radius: .65rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.mobile-sections-toggle:hover {
    background: var(--forum-accent-soft);
    border-color: rgba(var(--forum-accent-rgb), .2);
}

.mobile-sections-toggle i {
    font-size: 1.2rem;
    line-height: 1;
}

/* =========================
   TOPICS
   ========================= */

.topic-item {
    display: block;
    padding: .8rem .95rem;
    border: 1px solid var(--forum-border);
    border-radius: .9rem;
    background: var(--bs-body-bg);
    color: inherit;
    text-decoration: none;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.topic-item + .topic-item {
    margin-top: .65rem;
}

.topic-item:hover {
    transform: translateY(-1px);
    background: var(--forum-accent-soft);
    border-color: rgba(var(--forum-accent-rgb), .16);
}

.topic-item--pinned {
    border-color: rgba(138, 109, 59, .35);
    background: linear-gradient(180deg, rgba(138, 109, 59, .09), transparent 42%), var(--bs-body-bg);
}

.topic-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    flex-shrink: 0;
    border-radius: .8rem;
    background: var(--forum-accent-soft);
    color: var(--forum-accent);
}

.topic-avatar--pinned {
    background: rgba(138, 109, 59, .12);
    color: #8a6d3b;
}

.topic-title {
    margin-bottom: .2rem;
    font-size: .98rem;
    font-weight: 600;
    line-height: 1.2;
}

.topic-meta {
    font-size: .8rem;
}

.topic-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.topic-status-list {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

.topic-status-pill {
    --topic-status-color: #6c757d;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .6rem;
    border: 1px solid color-mix(in srgb, var(--topic-status-color) 28%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--topic-status-color) 12%, transparent);
    color: var(--topic-status-color);
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.topic-status-pill i {
    font-size: .78rem;
    line-height: 1;
}

[data-bs-theme="dark"] .topic-status-pill {
    background: color-mix(in srgb, var(--topic-status-color) 18%, transparent);
    border-color: color-mix(in srgb, var(--topic-status-color) 36%, transparent);
}

[data-bs-theme="dark"] .topic-item--pinned {
    border-color: rgba(196, 166, 93, .35);
    background: linear-gradient(180deg, rgba(196, 166, 93, .08), transparent 42%), var(--bs-body-bg);
}

/* =========================
   POST CARDS
   ========================= */

.post-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--forum-border);
    border-radius: 1rem;
    background: var(--bs-body-bg);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.post-card + .post-card {
    margin-top: 1.15rem;
}

.post-card:hover {
    transform: translateY(-2px);
}

.post-card__body {
    padding: 1rem;
}

.post-card--first {
    border-color: rgba(var(--forum-accent-rgb), .45);
    box-shadow: 0 0 0 1px rgba(var(--forum-accent-rgb), .08), 0 1rem 2rem rgba(var(--forum-accent-rgb), .10);
}

.post-card--first::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--forum-accent) 0%, #7c3aed 100%);
}

.post-card--hidden {
    opacity: .92;
    border-style: dashed;
}

.post-card--hidden .post-content {
    opacity: .92;
}

.post-card:target {
    animation: post-highlight 1.8s ease;
}

@keyframes post-highlight {
    0% {
        box-shadow: 0 0 0 3px rgb(118 0 0 / 71%);
        background-color: rgb(255 255 193);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--forum-accent-rgb), 0);
        background-color: var(--bs-body-bg);
    }
}

.post-avatar {
    width: 55px;
    min-width: 55px;
    height: 55px;
    overflow: hidden;
    border-radius: 10%;
}

.avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 7px;
    transform: scale(1.3);
}

.post-author-name .name {
    font-weight: 700;
}

.post-author-line {
    row-gap: .35rem;
}

.post-header__meta {
    min-width: 88px;
}

.post-anchor {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: rgba(127, 127, 127, 0.08);
    color: var(--bs-secondary-color);
    transition: background .15s ease, color .15s ease;
}

.post-anchor:hover {
    background: rgba(127, 127, 127, 0.16);
    color: var(--bs-emphasis-color);
}

.post-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .22rem .55rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1;
}

.post-badge--topic-start {
    background: rgba(79, 70, 229, .12);
    color: #6d5efc;
    border-color: rgba(79, 70, 229, .2);
}

.post-badge--admin {
    background: rgba(25, 135, 84, .12);
    color: #198754;
    border-color: rgba(25, 135, 84, .2);
}

.post-badge--self {
    background: rgba(13, 110, 253, .12);
    color: #0d6efd;
    border-color: rgba(13, 110, 253, .2);
}

.post-badge--hidden {
    background: rgba(220, 53, 69, .12);
    color: #dc3545;
    border-color: rgba(220, 53, 69, .2);
}

.post-intro-note {
    display: inline-flex;
    align-items: center;
    padding: .55rem .8rem;
    border-radius: .8rem;
    background: rgba(79, 70, 229, .08);
    color: var(--bs-emphasis-color);
    font-size: .875rem;
    font-weight: 600;
}

.post-content {
    font-size: .95rem;
    line-height: 1.6;
    word-break: break-word;
}

.post-content p {
    margin-top: 0;
    margin-bottom: 0;
}

.post-content blockquote {
    margin: 0 0 10px;
    padding: .75rem .9rem;
    border-left: 4px solid rgba(var(--forum-accent-rgb), .5);
    border-radius: .7rem;
    background: var(--forum-accent-soft);
}

.post-content blockquote .user {
    margin-bottom: .35rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid rgba(var(--forum-accent-rgb), .28);
    font-weight: 700;
}

.post-content blockquote .message {
    font-size: .875rem;
    font-style: italic;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: .75rem;
}

.post-content code {
    padding: .15rem .4rem;
    border-radius: .45rem;
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

.post-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: .75rem;
    padding: .75rem 0 0;
    border-top: 1px solid var(--forum-border);
}

.post-toolbar-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
}

.post-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

.post-reactions {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-left: auto;
}

.reply-trigger {
    margin-right: auto;
}

.reaction-btn-compact {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 2rem;
    padding: .32rem .55rem;
    border-radius: .7rem;
    font-size: .82rem;
    line-height: 1;
}

.reaction-btn-compact .reaction-count {
    margin-left: 0 !important;
    padding: .2rem .4rem;
    font-size: .72rem;
}

.reaction-btn.active-like {
    background: var(--forum-like-color);
    border-color: var(--forum-like-color);
    color: #fff;
}

.reaction-btn.active-dislike {
    background: var(--forum-dislike-color);
    border-color: var(--forum-dislike-color);
    color: #fff;
}

.post-edited-note {
    display: inline-flex;
    align-items: center;
    margin-top: .75rem;
    padding: .4rem .65rem;
    border-radius: .65rem;
    background: rgba(127, 127, 127, 0.08);
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.post-edited-note i {
    opacity: .85;
}

.small.discussion {
    font-size: 11px;
}

/* =========================
   EMPTY STATES
   ========================= */

.empty-state {
    max-width: 680px;
    margin: 0 auto;
}

.empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.75rem;
    height: 4.75rem;
    margin: 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(79, 70, 229, .12), rgba(124, 58, 237, .12));
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .08);
    color: #6d5efc;
    font-size: 1.85rem;
}

.empty-state__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--bs-emphasis-color);
}

.empty-state__text {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    font-size: .98rem;
}

.empty-state__actions .btn {
    min-width: 170px;
}

/* =========================
   BUTTONS / CONTROLS
   ========================= */

.btn-forum-outline {
    --bs-btn-color: var(--forum-btn-color);
    --bs-btn-bg: var(--forum-btn-bg);
    --bs-btn-border-color: var(--forum-btn-border);
    --bs-btn-hover-color: var(--forum-btn-hover-color);
    --bs-btn-hover-bg: var(--forum-btn-hover-bg);
    --bs-btn-hover-border-color: var(--forum-btn-hover-border);
    --bs-btn-active-color: var(--forum-btn-hover-color);
    --bs-btn-active-bg: var(--forum-btn-hover-bg);
    --bs-btn-active-border-color: var(--forum-btn-hover-border);
    --bs-btn-disabled-color: var(--forum-btn-color);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--forum-btn-border);
    box-shadow: var(--forum-shadow);
}

.btn-create-topic {
    --bs-btn-bg: var(--forum-accent);
    --bs-btn-border-color: var(--forum-accent);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--forum-accent) 85%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--forum-accent) 85%, #000);
    --bs-btn-active-bg: color-mix(in srgb, var(--forum-accent) 80%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--forum-accent) 80%, #000);
}

.btn-post-action {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 2rem;
    padding: .32rem .55rem;
    border-radius: .7rem;
    font-size: .82rem;
    line-height: 1;
}

.btn-post-delete {
    --bs-btn-color: #dc3545;
    --bs-btn-border-color: rgba(220, 53, 69, .28);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #dc3545;
    --bs-btn-hover-border-color: #dc3545;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #dc3545;
    --bs-btn-active-border-color: #dc3545;
}

.theme-toggle .dropdown-menu {
    min-width: 12rem;
    border-radius: .85rem;
}

.theme-toggle .dropdown-item {
    padding: .55rem .75rem;
    border-radius: .65rem;
}

.theme-toggle .dropdown-item.active,
.theme-toggle .dropdown-item:active {
    background: var(--forum-accent-soft);
    color: var(--bs-body-color);
}

/* =========================
   MODALS / SEARCH / TOASTS
   ========================= */

.modal-content {
    border: 1px solid var(--forum-border);
    border-radius: 1rem;
    box-shadow: var(--forum-shadow);
}

.modal-header,
.modal-footer {
    border-color: var(--forum-border);
}

#forumSearchResult {
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    width: fit-content;
    margin: auto;
}

.forum-toast {
    min-width: 320px;
    max-width: 420px;
    overflow: hidden;
    border-radius: 18px;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .18);
}

.forum-note {
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 18px;
}

.forum-note__inner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.forum-note__title {
    margin-bottom: .15rem;
    font-weight: 700;
}

.forum-note__text {
    line-height: 1.4;
}

.forum-note--success {
    background: rgba(25, 135, 84, .12);
    border-color: rgba(25, 135, 84, .18);
    color: #0f5132;
}

.forum-note--danger {
    background: rgba(220, 53, 69, .12);
    border-color: rgba(220, 53, 69, .18);
    color: #842029;
}

.forum-note--warning {
    background: rgba(255, 193, 7, .14);
    border-color: rgba(255, 193, 7, .24);
    color: #664d03;
}

.forum-note--info {
    background: rgba(13, 110, 253, .10);
    border-color: rgba(13, 110, 253, .18);
    color: #084298;
}

[data-bs-theme="dark"] .forum-note--success {
    color: #75b798;
}

[data-bs-theme="dark"] .forum-note--danger {
    color: #ea868f;
}

[data-bs-theme="dark"] .forum-note--warning {
    color: #ffda6a;
}

[data-bs-theme="dark"] .forum-note--info {
    color: #6ea8fe;
}

/* =========================
   BB EDITOR
   ========================= */

.bb-editor {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .5rem;
    padding: .5rem;
    border: 1px solid var(--forum-border);
    border-radius: .75rem;
    background: var(--bs-tertiary-bg);
}

.bb-editor__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 .65rem;
    border: 1px solid var(--forum-btn-border);
    border-radius: .5rem;
    background: var(--forum-btn-bg);
    color: var(--forum-btn-color);
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
    user-select: none;
}

.bb-editor__btn:hover {
    background: var(--forum-accent-soft);
    border-color: rgba(var(--forum-accent-rgb), .25);
}

.bb-editor__separator {
    width: 1px;
    margin: 0 .15rem;
    background: var(--forum-border);
}

.bb-smiles {
    position: relative;
}

.bb-smiles__menu {
    position: absolute;
    top: calc(100% + .35rem);
    left: 0;
    z-index: 20;
    display: none;
    min-width: 220px;
    padding: .5rem;
    border: 1px solid var(--forum-border);
    border-radius: .75rem;
    background: var(--bs-body-bg);
    box-shadow: var(--forum-shadow);
    grid-template-columns: repeat(6, 1fr);
    gap: .35rem;
}

.bb-smiles.open .bb-smiles__menu {
    display: grid;
}

.bb-smiles__item {
    height: 2rem;
    border: 1px solid var(--forum-border);
    border-radius: .5rem;
    background: var(--bs-tertiary-bg);
    cursor: pointer;
    font-size: 1rem;
}

.bb-smiles__item:hover {
    background: var(--forum-accent-soft);
}

pre {
    margin-bottom: 0;
}

/* =========================
   SCROLL CONTROLS
   ========================= */

.forum-scroll-controls {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1055;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.forum-scroll-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    transition: all .2s ease;
}

.forum-scroll-btn.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
}

.forum-scroll-btn i {
    font-size: 1.1rem;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 1199.98px) {
    #forumSectionsMenu {
        margin-top: .75rem;
    }
}

@media (max-width: 991.98px) {
    .sidebar-sticky {
        position: static;
    }
}

@media (max-width: 767.98px) {
    .post-card__body {
        padding: .9rem;
    }

    .post-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .post-header__meta {
        text-align: left !important;
    }

    .empty-state__actions .btn {
        width: 100%;
        min-width: 0;
    }

    .forum-scroll-controls {
        right: 12px;
        bottom: 12px;
    }

    .forum-scroll-btn {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 575.98px) {
    .post-toolbar {
        align-items: stretch;
    }

    .post-toolbar-left,
    .post-actions {
        width: 100%;
    }

    .post-actions .btn-post-action {
        flex: 1 1 auto;
        justify-content: center;
    }

    .reply-trigger {
        width: 100%;
        justify-content: center;
        margin-right: 0;
    }

    .post-reactions {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
    }
}