:root {
    --xiunext-ink: #34404d;
    --xiunext-muted: #87919c;
    --xiunext-accent: var(--bs-primary);
    --xiunext-header: var(--bs-primary);
    --xiunext-paper: rgba(255, 255, 255, .96);
    --xiunext-line: #edf0f2;
    --xiunext-page-image: none;
    --xiunext-page-position: center;
    --xiunext-page-size: cover;
    --xiunext-page-repeat: no-repeat;
    --xiunext-page-overlay: .18;
}

/* 固定纵向滚动条槽位，首页与较长的主题页切换时不再横向收缩。 */
html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body {
    color: var(--xiunext-ink);
    background-color: #eef2f4;
    background-image:
        radial-gradient(circle at 12px 12px, rgba(112, 133, 151, .08) 1.5px, transparent 1.6px),
        radial-gradient(circle at 36px 36px, rgba(112, 133, 151, .055) 1.5px, transparent 1.6px);
    background-size: 48px 48px;
}

body[data-xiunext-style="mist"],
html[data-xiunext-style="mist"] body {
    --xiunext-paper: rgba(250, 251, 252, .94);
    --xiunext-line: #e6ebef;
    background-color: #eef1f3;
}

body[data-xiunext-style="clean"],
html[data-xiunext-style="clean"] body {
    --xiunext-paper: #fff;
    --xiunext-line: #edf0f2;
    background-color: #f7f8f9;
    background-image: none;
}

body.xiunext-style-has-background,
html.xiunext-style-has-background body {
    background-image:
        linear-gradient(rgba(239, 243, 246, var(--xiunext-page-overlay)), rgba(239, 243, 246, var(--xiunext-page-overlay))),
        var(--xiunext-page-image);
    background-position: center, var(--xiunext-page-position);
    background-size: cover, var(--xiunext-page-size);
    background-repeat: no-repeat, var(--xiunext-page-repeat);
    background-attachment: fixed;
}

/* Keep the header compact: the site name is exposed as the logo tooltip. */
#header .site-name { display: none !important; }

/* Authentication: a compact, calm single-column card inspired by the JianShan flow. */
.xiunext-style-auth {
    display: block;
    width: 100%;
    min-height: 0;
    margin: .2rem 0 2.25rem;
    padding: 0 1rem;
    border: 0;
    background: transparent;
}

.xiunext-style-auth > .mx-auto {
    display: block !important;
    width: min(100%, 32.5rem);
    max-width: 32.5rem !important;
    margin: 0 auto !important;
}

.xiunext-style-auth > .mx-auto > .text-center {
    display: none !important;
}

.xiunext-style-auth .site-logo-lg {
    width: auto;
    max-width: 10rem;
    height: 2.7rem;
    max-height: 2.7rem;
    margin: 0 !important;
    object-fit: contain;
}

.xiunext-style-auth .x-card.card {
    display: block !important;
    width: 100% !important;
    flex: none !important;
    margin-top: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    border: 1px solid #dfe3e7;
    border-radius: .15rem;
    background: var(--bs-body-bg);
    box-shadow: none;
}

.xiunext-style-auth .x-card.card > .card-body:first-child {
    margin: 0 !important;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--xiunext-line);
    background: #f5f5f5;
    color: var(--xiunext-ink);
    font-size: .9rem;
    font-weight: 500;
}

.xiunext-style-auth .x-card.card > .card-body:not(:first-child) {
    padding: 1.1rem 1.1rem 1.25rem;
}

.xiunext-style-auth .input-group-text,
.xiunext-style-auth .form-control {
    height: 2.1rem;
    min-height: 2.1rem;
    border-color: #cbd3db;
    background: #fff;
}

.xiunext-style-auth .input-group-text {
    width: 2.5rem;
    justify-content: center;
    color: var(--bs-primary);
}

.xiunext-style-auth .form-control:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .12);
}

.xiunext-style-auth #submit {
    height: 1.9rem;
    min-height: 1.9rem;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
    background-color: color-mix(in srgb, var(--bs-primary) 80%, #fff);
    font-size: .86rem;
    font-weight: 500;
    letter-spacing: .02em;
}

.xiunext-style-auth #submit:hover,
.xiunext-style-auth #submit:focus-visible {
    border-color: transparent;
    background-color: color-mix(in srgb, var(--bs-primary) 88%, #fff);
}

.xiunext-style-auth .mb-3 {
    margin-bottom: .85rem !important;
}

.xiunext-style-auth .text-primary {
    color: var(--bs-primary) !important;
}

[data-bs-theme="dark"] .xiunext-style-auth .x-card.card {
    border-color: rgba(255, 255, 255, .1);
    background: rgba(34, 42, 50, .94);
    box-shadow: 0 .35rem 1.15rem rgba(0, 0, 0, .25);
}

[data-bs-theme="dark"] .xiunext-style-auth .input-group-text,
[data-bs-theme="dark"] .xiunext-style-auth .form-control {
    background: rgba(20, 27, 34, .8);
}

/* The profile-page two-column grid must never apply to authentication forms. */
body.xiunext-route-user #body .xiunext-style-auth > .mx-auto {
    display: block !important;
    width: min(100%, 32.5rem) !important;
    max-width: 32.5rem !important;
    margin: 0 auto !important;
    grid-template-columns: none !important;
    gap: 0 !important;
}

body.xiunext-route-user #body .xiunext-style-auth > .mx-auto > .x-card.card {
    display: block !important;
    width: 100% !important;
    grid-column: auto !important;
}

@media (max-width: 575.98px) {
    .xiunext-style-auth { padding: 0 .4rem; }
    .xiunext-style-auth .x-card.card > .card-body:not(:first-child) { padding: 1rem; }
    .xiunext-style-auth > .mx-auto > .text-center { gap: .5rem; }
    .xiunext-style-auth .site-logo-lg { max-width: 8.5rem; height: 2.35rem; }
}

.navbar,
header .navbar {
    background: var(--xiunext-header) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .08);
}

.navbar .nav-link,
.navbar .navbar-brand,
.navbar .dropdown-toggle {
    color: rgba(255, 255, 255, .7) !important;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff !important;
}

/* Header action icons need a stable contrast on arbitrary custom header colors. */
#header .nav-icon-btn {
    color: #fff !important;
    background-color: rgba(0, 0, 0, .18);
    text-shadow: 0 1px 2px rgba(0, 0, 0, .58);
}

#header .nav-icon-btn:hover,
#header .nav-icon-btn:focus-visible,
#header .nav-icon-btn[aria-expanded="true"] {
    color: #fff !important;
    background-color: rgba(0, 0, 0, .34);
    outline: 2px solid rgba(255, 255, 255, .72);
    outline-offset: 1px;
}

#header #navSearchForm {
    display: none !important;
}

.xiunext-style-header-search {
    order: -10;
    height: 34px;
    padding: 0 .45rem;
    color: #fff;
    font-size: .82rem;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .58);
}

.xiunext-style-header-search:hover {
    color: #fff;
}

.container {
    max-width: 1080px;
}

#body {
    padding-top: .55rem;
    transition: opacity .14s ease, transform .14s ease;
}

body.xiunext-style-page-changing #body {
    opacity: .48;
    pointer-events: none;
    transform: translateY(2px);
}

/* 首页首块从内容起点开始；主题首卡也必须使用同一条基线。 */
.xiunext-route-thread .card-thread {
    margin-top: 0 !important;
}

/* Separate the author/meta line from the thread body or paid-content notice. */
.xiunext-route-thread .card-thread > .card-body > h1 + .d-flex.justify-content-between.align-items-center.small {
    margin-bottom: .9rem;
}

#body > .container > .xiunext-style-layout-has-right > .xiunext-style-main-column {
    width: 75%;
    flex: 0 0 75%;
}

#body > .container > .xiunext-style-layout-full > .xiunext-style-main-column {
    width: 100%;
    flex: 0 0 100%;
}

/* 两栏顶部统一以列容器为基线；公告存在与否都不让主栏首块额外下沉。 */
#body > .container > .xiunext-style-layout > .xiunext-style-main-column > :first-child {
    margin-top: 0 !important;
}

#body > .container > .row > .xiunext-style-right-column {
    display: block !important;
    width: 25%;
    flex: 0 0 25%;
}

.xiunext-style-right-column > #sidebar-right {
    display: block !important;
}

.x-card,
.card {
    background: var(--xiunext-paper);
    border: 0 !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 3px rgba(40, 51, 61, .09) !important;
}

.threadlist > li,
.thread-list > li {
    padding-top: .68rem !important;
    padding-bottom: .68rem !important;
    border-color: var(--xiunext-line) !important;
}

.threadlist .subject,
.thread-list .subject {
    font-size: .96rem;
    font-weight: 500;
    color: #405469;
}

.xiunext-style-sidebar-create {
    margin-top: 0 !important;
    margin-bottom: .5rem !important;
    min-height: 38px;
    border-radius: 2px !important;
}

#sidebar-right .card a[href*="thread-create"] {
    display: none;
}

.xiunext-style-side-search .form-control,
.xiunext-style-side-search .btn {
    min-height: 36px;
}

.xiunext-style-board-card .card-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--xiunext-line);
}

.xiunext-style-board-grid {
    display: flex;
    gap: .55rem .75rem;
    flex-wrap: wrap;
}

.xiunext-style-board-grid a {
    color: var(--xiunext-muted);
    text-decoration: none;
    font-size: .82rem;
}

.xiunext-style-board-grid a:hover {
    color: var(--xiunext-accent);
}

.xiunext-route-user #body > .container {
    max-width: 1080px;
}

.xiunext-route-user #body .mx-auto {
    max-width: none !important;
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.xiunext-route-user #body .mx-auto > .alert {
    grid-column: 1 / -1;
}

.xiunext-route-user #body .mx-auto > .xiunext-style-user-main-card {
    grid-column: 2;
    overflow: hidden;
}

.xiunext-style-user-sidebar-nav {
    grid-column: 1;
    width: 100%;
    position: sticky;
    top: 19rem;
}

.xiunext-style-user-sidebar-nav .side-nav-title {
    color: var(--xiunext-muted);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.xiunext-style-user-sidebar-nav .side-nav-link {
    min-height: 42px;
}

/* 用户主页、主题和回复列表共用同一张内容卡与导航基线。 */
.xiunext-route-user #body .mx-auto > .xiunext-style-user-main-card > .card-body:first-child {
    padding: .7rem 1rem 0;
    background: rgba(248, 249, 250, .78);
}

.xiunext-route-user #body .mx-auto > .xiunext-style-user-main-card > .card-body:last-child {
    padding: 0;
}

.xiunext-route-user #body .mx-auto .nav-tabs {
    gap: .15rem;
}

.xiunext-route-user #body .mx-auto .nav-tabs .nav-link {
    padding: .55rem .8rem;
}

.xiunext-route-user #body .mx-auto .threadlist,
.xiunext-route-user #body .mx-auto .postlist {
    margin: 0;
    background: transparent;
}

.xiunext-route-user #body .mx-auto .threadlist > li,
.xiunext-route-user #body .mx-auto .postlist > li {
    padding-left: 1rem;
    padding-right: 1rem;
}

.xiunext-style-user-hero {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
    min-height: 290px;
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    background-color: #e6ebee;
    background-size: cover;
    background-position: center;
}

.xiunext-style-hero-upload {
    position: absolute;
    z-index: 2;
    top: 14px;
    right: 14px;
}

.xiunext-style-user-hero-inner {
    min-height: 290px;
    display: flex;
    align-items: flex-end;
    gap: 22px;
    padding: 0 30px 26px;
    background: linear-gradient(to bottom, transparent 30%, rgba(255,255,255,.25) 54%, rgba(255,255,255,.98) 78%);
}

.xiunext-style-user-hero .avatar-xl {
    width: 112px !important;
    height: 112px !important;
    border: 5px solid #fff;
    border-radius: 28px !important;
    box-shadow: 0 8px 22px rgba(36, 48, 60, .18);
}

.xiunext-style-user-identity {
    min-width: 150px;
    padding-bottom: 2px;
}

.xiunext-style-user-identity h3 {
    color: #ae2830;
    margin: 0 0 8px;
    font-weight: 700;
}

.xiunext-style-user-signature {
    max-width: 300px;
    margin: .55rem 0 .35rem;
    color: #56616d;
    font-size: .8rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.xiunext-style-user-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem .65rem;
    color: #7d8893;
    font-size: .7rem;
    line-height: 1.5;
}

.xiunext-style-user-meta i {
    color: var(--xiunext-accent);
    margin-right: .15rem;
}

.xiunext-style-user-stats {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 14px 0;
    border-radius: 18px;
    background: rgba(255,255,255,.7);
}

.xiunext-style-user-stats > * {
    display: flex;
    flex-direction: column;
    text-align: center;
    text-decoration: none;
    border-left: 1px solid #edf0f2;
}

.xiunext-style-user-stats > *:first-child {
    border-left: 0;
}

.xiunext-style-user-stats b {
    color: #333;
    font-size: 1.1rem;
}

.xiunext-style-user-stats span {
    color: #8b97a2;
    font-size: .72rem;
}

.xiunext-route-my #body > .container > .row.g-4 > .col-xl-8 {
    width: 83.333333%;
    flex: 0 0 83.333333%;
}

.xiunext-route-my #body > .container > .row.g-4 > .d-none.col-xl-3 {
    display: none !important;
}

/* OY wallet reuses the member-center shell, so it needs the same expanded content column. */
.xiunext-route-oy_credits #body > .container > .row.g-4 > .col-xl-8 {
    width: 83.333333%;
    flex: 0 0 83.333333%;
}

.xiunext-route-oy_credits #body > .container > .row.g-4 > .d-none.col-xl-3 {
    display: none !important;
}

.xiunext-route-oy_credits .oy-credits-wallet {
    width: 100%;
}

.xiunext-style-my-hero-card {
    position: relative;
    color: #fff;
    background-image: linear-gradient(90deg, rgba(24,31,39,.72), rgba(24,31,39,.28)), var(--xiunext-my-image) !important;
    background-size: cover, var(--xiunext-my-size, cover) !important;
    background-position: var(--xiunext-my-position) !important;
    background-repeat: no-repeat, var(--xiunext-my-repeat, no-repeat) !important;
}

.xiunext-style-my-hero-upload {
    position: absolute;
    z-index: 2;
    top: 12px;
    right: 12px;
}

.xiunext-style-my-hero-card .text-body-secondary,
.xiunext-style-my-hero-card .text-primary {
    color: rgba(255,255,255,.85) !important;
}

.xiunext-route-my #body .x-card > .card-body.d-flex > .flex-fill > p.text-body-secondary.small {
    margin-top: .55rem !important;
    line-height: 1.5;
}

.xiunext-style-uid-badge,
.xiunext-style-group-badge {
    padding: .34em .62em;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: .68em;
    font-weight: 700;
    letter-spacing: .025em;
    line-height: 1.2;
    text-shadow: none;
}

.xiunext-style-uid-badge {
    color: #fff;
    background: #35404c;
    border-color: #2b3540;
}

.xiunext-style-group-badge {
    color: var(--xiunext-group-text, #fff);
    background: var(--xiunext-group-color, var(--xiunext-accent));
    border-color: color-mix(in srgb, var(--xiunext-group-color, var(--xiunext-accent)) 78%, #000);
    box-shadow: inset 0 1px rgba(255,255,255,.18);
}

.xiunext-style-profile-locked-card .d-flex.gap-4.mt-2 {
    display: none !important;
}

.xiunext-style-profile-login-card,
.xiunext-style-profile-login-gate {
    border-color: var(--xiunext-line);
}

.xiunext-style-profile-login-gate {
    color: #66717d;
    background: linear-gradient(135deg, rgba(91,146,207,.07), rgba(255,255,255,.96));
}

.xiunext-style-profile-login-gate .ti-lock {
    color: var(--xiunext-accent);
}


.avatar-3,
.avatar-4 {
    border-radius: 4px !important;
}

.btn-primary {
    --bs-btn-bg: var(--xiunext-accent);
    --bs-btn-border-color: var(--xiunext-accent);
    --bs-btn-hover-bg: #4f84bd;
    --bs-btn-hover-border-color: #4f84bd;
    background-color: var(--xiunext-accent) !important;
    border-color: var(--xiunext-accent) !important;
    border-radius: 2px;
}

.thread-nav-tabs .nav-link.active {
    color: var(--xiunext-accent) !important;
    border-bottom-color: var(--xiunext-accent) !important;
}

.form-control,
.form-select {
    border-color: #e1e6ea;
    border-radius: 2px;
}

.xiunext-style-background-panel {
    padding: .9rem 1rem;
    background: #f7f9fa;
    border-radius: 3px;
}

.xiunext-style-background-panel summary {
    cursor: pointer;
    color: #52677c;
    font-weight: 600;
    list-style: none;
}

.xiunext-style-background-panel summary::-webkit-details-marker {
    display: none;
}

.xiunext-style-background-preview {
    min-height: 108px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 3px;
    background-color: #e9eef1;
    background-position: center;
    background-size: cover;
    color: #8b98a3;
    transition: background-image .2s ease, min-height .2s ease;
}

.xiunext-style-background-preview.is-ready {
    min-height: 150px;
    color: rgba(255, 255, 255, .88);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.xiunext-style-profile-settings {
    padding-top: 1.25rem;
    border-top: 1px solid var(--xiunext-line);
}

.xiunext-style-section-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 3px;
    color: #fff;
    background: var(--xiunext-accent);
}

#xiunext-style-page-background {
    display: none;
}

[data-bs-theme="dark"] body {
    --xiunext-paper: rgba(34, 39, 45, .96);
    --xiunext-line: #303840;
    --xiunext-ink: #dce3e8;
    background-color: #20252a;
}

[data-bs-theme="dark"] .xiunext-style-background-panel {
    background: #292f35;
}

@media (prefers-reduced-motion: reduce) {
    #body {
        transition: none;
    }
}

@media (max-width: 767.98px) {
    /*
     * 核心移动端把 .row > * 的 gutter 顶距压缩为 8px，但 .g-4 的 row
     * 仍保留 -24px 顶部负边距，会让第一张内容卡侵入 sticky header 下方。
     */
    html {
        scroll-padding-top: 72px;
    }
    #body > .container > .row.g-4 {
        margin-top: 0;
    }
    body {
        background-size: 36px 36px;
    }
    .container {
        padding-left: .65rem;
        padding-right: .65rem;
    }
    .card-body {
        padding: .9rem;
    }
    #body > .container > .row > .xiunext-style-main-column,
    #body > .container > .row > .xiunext-style-right-column {
        width: 100%;
        flex-basis: 100%;
    }
    #body > .container > .row > .xiunext-style-right-column {
        display: none !important;
    }
    .xiunext-route-user #body .mx-auto {
        display: block;
    }
    .xiunext-style-user-sidebar-nav {
        position: static;
        margin-bottom: .75rem;
    }
    .xiunext-style-user-hero,
    .xiunext-style-user-hero-inner {
        min-height: 235px;
    }
    .xiunext-style-user-hero-inner {
        padding: 18px;
        align-items: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }
    .xiunext-style-user-hero .avatar-xl {
        width: 74px !important;
        height: 74px !important;
        border-radius: 18px !important;
    }
    .xiunext-style-user-stats {
        flex-basis: 100%;
    }
}
