/*
 * Forum UI parity with www.vnpy.com/forum (P0).
 * Loaded AFTER FlaskBB app.css (BS5) and CDN BS3/site chrome CSS.
 * Does not modify shared CDN assets.
 */

/* --- rem / typography: defeat BS3 html{font-size:10px} + BS5 rem --- */
html {
    font-size: 14px;
}

body {
    font-family: "微软雅黑", Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.42857143;
    color: #333;
    background-color: #f6f9fc;
    /* FlaskBB app.css reserves 60px for .flaskbb-footer; footer is in-flow */
    margin-bottom: 0 !important;
}

/* --- site chrome: same .navs / .large-screen layout as the homepage --- */
/* CDN style_new-1: text-align:right, li margin 0 24px. Undo BS5 reboot only. */
#nav.navs {
    text-align: right;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    width: 100%;
    height: 60px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
    /* Homepage body is ~16px; forum body is 14px — keep the bar at 16px. */
    font-size: 16px;
    /* !important beats CDN script_new.min.js inline transparent-on-scroll */
    background-color: rgb(23, 30, 64) !important;
    box-shadow: none;
}

#nav.navs .large-screen > li {
    display: inline-block;
    float: none;
    margin: 0 24px;
    color: #fff;
    line-height: 60px;
}

#nav.navs .large-screen > li a {
    display: inline-block;
    color: #fff !important;
    text-decoration: none;
    line-height: 60px;
    font-size: 16px;
}

.flaskbb-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 60px !important;
    padding-bottom: 0;
    position: relative;
}

/* Banner sits below the 60px fixed topnav (same on /forum and form pages). */
.flaskbb-header {
    margin-top: 0;
}

@media (max-width: 767.98px) {
    .flaskbb-header {
        height: auto;
        min-height: 12em;
        padding: 2.5em 0.75em;
    }

    .flaskbb-header .flaskbb-title {
        font-size: clamp(2em, 7vw, 3em);
        line-height: 1.2;
        white-space: nowrap;
    }

    .flaskbb-header .flaskbb-subtitle {
        display: block;
        overflow: visible;
    }
}

@media (max-width: 767.98px) {
    /* Parent is flex-column on xs and flex-sm-row from 576. flex: 0 0 100%
       on a column item sets height to 100% of the name block and the
       stats then spill into the tabs. */
    .flaskbb-layout .col.d-flex:has(.profile-stats) {
        flex-wrap: wrap;
    }

    .flaskbb-layout .profile-stats {
        flex: 0 0 auto;
        align-self: stretch;
        width: 100% !important;
        max-width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem 0.75rem;
        text-align: center;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .flaskbb-layout .profile-stats > .row {
        display: flex;
        flex-direction: column;
        min-width: 0;
        width: auto;
        max-width: none;
        margin: 0;
    }

    .flaskbb-layout .profile-stats > .row > .col {
        max-width: none !important;
        width: 100%;
        float: none !important;
        text-align: center !important;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    /* FlaskBB ships text-nowrap on the date; 3 columns at 390px would
       otherwise overflow into the profile tabs. */
    .flaskbb-layout .profile-stats .text-nowrap {
        white-space: normal !important;
    }
}

@media (max-width: 575.98px) {
    .flaskbb-layout .profile-stats {
        grid-template-columns: 1fr;
        text-align: start;
    }

    .flaskbb-layout .profile-stats > .row {
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.5rem;
    }

    .flaskbb-layout .profile-stats > .row > .col {
        width: auto;
        text-align: start !important;
    }
}

/* Align outer width with BS3 aurora container ladder */
.flaskbb-layout > .container {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1170px;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 768px) {
    .flaskbb-layout > .container {
        width: 750px;
        max-width: 750px;
    }
}

@media (min-width: 992px) {
    .flaskbb-layout > .container {
        width: 970px;
        max-width: 970px;
    }
}

@media (min-width: 1200px) {
    .flaskbb-layout > .container {
        width: 1170px;
        max-width: 1170px;
    }
}

/* --- defeat style_new-1.min.css global .card ---
 * CDN sets .card { padding:24px auto; margin:8px; max-width; heavy shadow }.
 * Even when shorthand is partially ignored, residual padding shows as a white
 * band above .card-header inside the border (「论坛统计」红框空白).
 * FlaskBB cards must be flush: header/body own their padding.
 */
.flaskbb-layout .card {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 0 20px 0 !important;
    top: auto !important;
    left: auto !important;
    border-radius: 0;
    background-color: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05) !important;
}

.flaskbb-layout .index-view > .card {
    width: 100%;
}

.flaskbb-layout .card.category,
.flaskbb-layout .card.forum,
.flaskbb-layout .card.topic,
.flaskbb-layout .card.page {
    margin-bottom: 20px !important;
    border-color: #cad7e1;
}

/* BS5 mt-3 is !important — kill stacked top gap before stats / categories */
.flaskbb-layout .card.category.mt-3,
.flaskbb-layout .card.category,
.flaskbb-layout .card.page.mt-3,
.flaskbb-layout .card.page {
    margin-top: 0 !important;
}

/* www panel-heading: padding 10px 15px, bold, #555 on #f5f5f5 (category titles) */
.flaskbb-layout .card.category > .card-header.category-header,
.flaskbb-layout .card.forum > .card-header.forum-header,
.flaskbb-layout .card.topic > .card-header.topic-header {
    margin: 0;
    padding: 10px 15px;
    font-weight: bold;
    color: #555;
    background-color: #f5f5f5;
    border-bottom: 1px solid #cad7e1;
}

.flaskbb-layout .card.category > .card-header.category-header a,
.flaskbb-layout .card.forum > .card-header.forum-header a {
    color: inherit;
    text-decoration: none;
}

/* Stats / page cards: same title-bar chrome as www panel-heading */
.flaskbb-layout .card.page > .card-header.page-header {
    margin: 0;
    padding: 10px 15px;
    font-weight: bold;
    color: #555;
    background-color: #f5f5f5;
    border-bottom: 1px solid #cad7e1;
}

/* category-meta / forum-meta table heads stay #eaf1f5 (www panel-meta) */
.flaskbb-layout .category .category-meta,
.flaskbb-layout .forum .forum-meta,
.flaskbb-layout .card.page .page-meta {
    background-color: #eaf1f5;
}

.flaskbb-layout .card.page > .card-body.page-body {
    padding: 0;
}

/* List pages keep padding 0; any card that hosts a form needs gutters.
 * Login (FlaskBB) has no page-body-form class; fill_phone / register do.
 */
.flaskbb-layout .card.page > .card-body.page-body.page-body-form,
.flaskbb-layout .card.page > .card-body.page-body:has(> form) {
    padding: 24px 20px;
}

/* CDN / leftover BS3 float grid must not collapse BS5 form rows. */
.flaskbb-layout .card.page .page-body form > .row,
.flaskbb-layout .page-body-form .row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1rem;
    float: none;
}

@media (min-width: 576px) {
    .flaskbb-layout .card.page .page-body form .col-3,
    .flaskbb-layout .card.page .page-body form .col-sm-3 {
        flex: 0 0 25%;
        max-width: 25%;
        width: 25% !important;
        float: none !important;
    }

    .flaskbb-layout .card.page .page-body form .col-4,
    .flaskbb-layout .card.page .page-body form .col-sm-4 {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
        width: 33.3333% !important;
        float: none !important;
    }

    .flaskbb-layout .card.page .page-body form .col-6,
    .flaskbb-layout .card.page .page-body form .col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
        width: 50% !important;
        float: none !important;
    }

    .flaskbb-layout .card.page .page-body form .offset-3,
    .flaskbb-layout .card.page .page-body form .offset-sm-3,
    .flaskbb-layout .card.page .page-body form .col-sm-offset-3 {
        margin-left: 25% !important;
    }
}

@media (max-width: 575.98px) {
    .flaskbb-layout .card.page .page-body form .col-3,
    .flaskbb-layout .card.page .page-body form .col-4,
    .flaskbb-layout .card.page .page-body form .col-6,
    .flaskbb-layout .card.page .page-body form .col-sm-3,
    .flaskbb-layout .card.page .page-body form .col-sm-4,
    .flaskbb-layout .card.page .page-body form .col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100% !important;
        float: none !important;
    }

    .flaskbb-layout .card.page .page-body form .offset-3,
    .flaskbb-layout .card.page .page-body form .offset-sm-3,
    .flaskbb-layout .card.page .page-body form .col-sm-offset-3 {
        margin-left: 0 !important;
    }

    .flaskbb-layout .card.page .page-body form .form-label.text-end {
        text-align: start !important;
    }
}

.flaskbb-layout .card.page .page-body > .page-row {
    padding-top: 0.5em;
    padding-bottom: 0.5em;
    margin: 0;
}

/* --- forum sub-nav --- */
.flaskbb-navbar {
    min-height: 50px;
    margin-bottom: 20px;
    border: 1px solid #cad7e1;
    background-color: #f8f8f8 !important;
}

.flaskbb-navbar .nav-link {
    padding: 15px !important;
    line-height: 20px;
}

.flaskbb-navbar .nav-link.active,
.flaskbb-navbar .nav-link.active:hover {
    color: #555;
    background-color: #e7e7e7;
    box-shadow: none;
}

.flaskbb-navbar .nav-link:focus-visible {
    outline: 2px solid #337ab7;
    outline-offset: -2px;
    box-shadow: none;
}

.flaskbb-layout .row {
    --bs-gutter-x: 30px;
}

/* 比 .g-0 (0,1,0) 更具体；否则管理页 row g-0 仍是 30px gutter，
 * settings-col 又 padding:0，负边距会把侧栏文字拉出卡片边框。 */
.flaskbb-layout .row.g-0,
.flaskbb-layout .row.gx-0 {
    --bs-gutter-x: 0;
}

/* --- category forum list: pixel parity with www ---
 * Nested .forum-info-inner (icon | text). No float wrap under icon.
 * Icon metrics match www aurora: font-size 2em, padding-right 0.5em.
 */
.flaskbb-layout .category .forum-info {
    min-width: 0;
    padding-left: 0.5rem !important;
}

.flaskbb-layout .category .forum-info > .forum-info-inner {
    --bs-gutter-x: 0; /* indent via icon padding-right like www */
    --bs-gutter-y: 0;
    align-items: flex-start;
    margin-left: 0;
    margin-right: 0;
}

/* Flat fallback if nested markup not yet loaded */
.flaskbb-layout .category .forum-info:not(:has(> .forum-info-inner)) {
    display: grid;
    grid-template-columns: 2.5em minmax(0, 1fr);
    column-gap: 0;
    align-items: start;
}

.flaskbb-layout .category .forum-info:not(:has(> .forum-info-inner)) > .forum-status {
    grid-row: 1 / -1;
    align-self: start;
}

.flaskbb-layout .category .forum-info:not(:has(> .forum-info-inner)) > .forum-name,
.flaskbb-layout .category .forum-info:not(:has(> .forum-info-inner)) > .forum-description,
.flaskbb-layout .category .forum-info:not(:has(> .forum-info-inner)) > .forum-moderators {
    grid-column: 2;
    min-width: 0;
}

/* Official search/management wrap icon+text in a bare .row; do not leave it in the 2.5em track. */
.flaskbb-layout .category .forum-info:not(:has(> .forum-info-inner)) > .row {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.flaskbb-layout .category .forum-info .forum-status {
    float: none !important;
    height: auto !important;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    font-size: 2em; /* www ≈ 28px */
    line-height: 1.2;
    padding: 0 0.5em 0 0; /* www padding-right .5em ≈ 14px */
    color: #333;
    text-align: center;
}

.flaskbb-layout .category .forum-info .forum-status .fa-fw {
    width: 1.25em;
}

.flaskbb-layout .category .forum-info .forum-unread {
    color: #337ab7;
}

.flaskbb-layout .category .forum-info .min-w-0 {
    min-width: 0;
}

.flaskbb-layout .category .forum-info .forum-description {
    overflow-wrap: anywhere;
    font-size: 14px;
    color: #333;
}

/* www BS3: p { margin: 0 0 10px } — restores ~85px category rows */
.flaskbb-layout .category .forum-info .forum-description > p {
    margin: 0 0 10px;
}

.flaskbb-layout .category .forum-last-post .last-post-title {
    font-size: 14px;
    line-height: 1.3;
}

.flaskbb-layout .category .forum-last-post .last-post-time,
.flaskbb-layout .category .forum-last-post .last-post-author {
    font-size: 12px;
    color: #777;
    line-height: 1.3;
}

/* --- BS3/BS5 modal coexistence --- */
.modal.fade.show {
    opacity: 1;
}

.modal {
    z-index: 2000 !important;
}

.modal-backdrop {
    z-index: 1990 !important;
}

/* --- footer: in-flow bar so short pages (fill_phone) match /forum --- */
.veighna-site-footer {
    display: flex !important;
    flex: 0 0 auto;
    flex-direction: row !important;
    align-items: center;
    align-self: stretch;
    justify-content: center !important;
    flex-wrap: wrap;
    gap: 8px 20px;
    padding: 16px 24px;
    min-height: 50px;
    background-color: #f6f9fc;
    color: rgba(0, 0, 0, 0.4);
    position: relative;
    width: 100% !important;
    text-align: center;
    font-size: 13px;
    box-sizing: border-box;
}

.veighna-site-footer > * {
    display: inline-flex !important;
    align-items: center;
    width: auto !important;
    max-width: none !important;
    float: none !important;
}

.veighna-site-footer img {
    float: none !important;
    margin-right: 6px;
    height: 16px;
    width: auto;
}

.veighna-site-footer a {
    color: inherit;
    text-decoration: none;
}

/* --- rem-based controls (sanity after html font-size:14px) --- */
.flaskbb-layout .btn {
    font-size: 14px;
    line-height: 1.42857143;
}

.flaskbb-layout .form-control {
    font-size: 14px;
    line-height: 1.42857143;
}

.flaskbb-layout .dropdown-menu {
    font-size: 14px;
}

.flaskbb-layout .badge {
    font-size: 12px;
}

.flaskbb-layout .pagination {
    font-size: 14px;
}

.flaskbb-layout .pagination .pages-label {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .flaskbb-layout .pagination .pages-label {
        display: none;
    }

    .flaskbb-layout .pagination .page-item:has(.pages-label) {
        display: none;
    }
}

/* --- inbox / action button spacing --- */
.flaskbb-navbar .nav-link.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.flaskbb-navbar .nav-link .badge {
    margin-left: 0.15em;
}

/* Unicode nicknames can overflow / stack in the profile button. */
.flaskbb-navbar .btn-group > .btn.btn-primary {
    display: inline-flex;
    align-items: center;
    max-width: 14rem;
}

.flaskbb-navbar .flaskbb-navbar-username {
    display: inline-block;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.flaskbb-layout .controls-row .col-auto .btn,
.flaskbb-layout .controls-row .col-auto form.d-inline,
.flaskbb-layout .controls-row .col-auto .dropdown {
    margin-left: 0.35rem;
}

.flaskbb-layout .controls-row .col-auto > :first-child {
    margin-left: 0;
}

/* --- markdown editor: defeat Songti fallback + flush cursor ---
 * FlaskBB 2 uses <markdown-toolbar> + textarea.flaskbb-editor.
 * CDN scripts-5 may still wrap with bootstrap-markdown (.md-editor); style both.
 */
.flaskbb-layout textarea.flaskbb-editor,
.flaskbb-layout .md-editor > textarea,
.flaskbb-layout .editor textarea {
    font-family: "微软雅黑", "Microsoft YaHei", Arial, Helvetica, sans-serif !important;
    font-size: 14px;
    line-height: 1.5;
    padding: 0.5rem 0.75rem !important;
    color: #333;
}

.flaskbb-layout textarea.flaskbb-editor::placeholder,
.flaskbb-layout .md-editor > textarea::placeholder {
    font-family: inherit;
    color: #999;
}

/* Hide legacy bootstrap-markdown chrome if CDN still injects it */
.flaskbb-layout .md-editor > .md-header,
.flaskbb-layout .md-editor > .md-footer {
    display: none !important;
}

/* --- topic post content: www-like quote / code blocks --- */
.flaskbb-layout .post-content blockquote {
    padding: 10px 15px;
    margin: 0 0 20px;
    font-size: 14px;
    border-left: 3px solid #337ab7;
    background-color: #f9f9f9;
}

.flaskbb-layout .post-content pre,
.flaskbb-layout .post-content pre.code {
    display: block;
    padding: 9.5px;
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.42857143;
    color: #333;
    word-break: break-all;
    word-wrap: break-word;
    background-color: #f8f8f8;
    border: 1px solid #e1e1e1;
    border-radius: 4px;
}

/* 管理侧栏：列内纵向排列，文字不得画到 with-left-border 之外 */
.flaskbb-layout .management .settings-col {
    min-width: 0;
    overflow-x: hidden;
}

.flaskbb-layout .nav-sidebar {
    max-width: 100%;
    min-width: 0;
}

.flaskbb-layout .nav-sidebar > .nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.flaskbb-layout .nav-sidebar .nav-item,
.flaskbb-layout .nav-sidebar .nav-link,
.flaskbb-layout .nav-sidebar .nav-header {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.flaskbb-layout .nav-sidebar .nav-link,
.flaskbb-layout .nav-sidebar .nav-header {
    padding-left: 12px;
    padding-right: 10px;
}
