/* ============================================
   CSS Variables for Theme Support
   ============================================ */
:root {
    --bg-primary: #e2e2e2;
    --bg-secondary: #fff;
    --bg-tertiary: #f9f9f9;
    --bg-input: #fff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --border-color: #e2e2e2;
    --border-dark: rgba(0, 0, 0, 0.22);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --link-color: var(--text-secondary);
    --link-hover: #111827;
    --node-tag-bg: #f5f5f5;
    --code-bg: #f4f4f4;

    /* Rainbow capsule (MinIO-style) */
    --rainbow-color-1: #667eea;
    --rainbow-color-2: #764ba2;
    --rainbow-color-3: #f093fb;
    --rainbow-color-4: #f5576c;
    --rainbow-color-5: #4facfe;
    --rainbow-color-6: #1fc9d2;
    --rainbow-border-size: 2px;
    --rainbow-speed: 6s;
    --rainbow-bg: linear-gradient(270deg,
            var(--rainbow-color-1),
            var(--rainbow-color-2),
            var(--rainbow-color-3),
            var(--rainbow-color-4),
            var(--rainbow-color-5),
            var(--rainbow-color-6),
            var(--rainbow-color-1));
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --bg-input: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #888;
    --border-color: #444;
    --border-dark: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --link-color: #c0c0c0;
    --link-hover: #ffffff;
    --node-tag-bg: #3a3a3a;
    --code-bg: #3a3a3a;
}

/* Global Reset */
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif !important;
    background-color: var(--bg-primary);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--link-color);
    text-decoration: none;
    cursor: pointer;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Layout */
#Wrapper {
    background-color: var(--bg-primary);
    background-repeat: repeat-x;
    text-align: center;
}

.content {
    min-width: 600px;
    max-width: 1100px;
    margin: 0 auto;
    text-align: left;
}

/* Header */
#Top {
    text-align: center;
    background-color: var(--bg-secondary);
    height: 44px;
    font-size: 15px;
    font-weight: 500;
    background-size: 44px 44px;
    border-bottom: 1px solid var(--border-dark);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

#Top .content {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-shrink: 0;
}

.logo {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
}

.logo-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: normal;
    white-space: nowrap;
}

/* Header Boards (N 系列导航) */
.header-boards {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 270px;
    align-items: center;
    column-gap: 20px;
    overflow: visible;
}

.header-boards-primary,
.header-boards-secondary {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.header-boards-secondary {
    justify-content: flex-start;
    gap: 12px;
}

.header-boards-secondary .header-nav {
    margin-left: auto;
}

.header-boards-primary {
    overflow-x: auto;
    scrollbar-width: none;
}

.header-boards-primary::-webkit-scrollbar {
    display: none;
}

.header-boards .nav-board-item {
    margin-right: 0;
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
    min-height: 0;
}

.header-boards .nav-filter-chip {
    min-height: 34px;
    padding: 7px 14px;
    font-size: 13px;
}

.header-boards .header-next-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 999px;
    white-space: nowrap;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.header-boards .header-next-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.header-boards .header-next-link.active,
.header-boards .header-next-link[aria-current="page"] {
    background: var(--link-hover);
    border-color: var(--link-hover);
    color: var(--bg-secondary);
    font-weight: 600;
}

.header-boards .header-next-link.active:hover,
.header-boards .header-next-link[aria-current="page"]:hover {
    background: var(--link-hover);
    color: var(--bg-secondary);
    text-decoration: none;
}

.header-feed,
.header-more {
    display: inline-flex;
    align-items: center;
}

.header-feed-menu a.active {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.header-feed-btn[aria-expanded="true"],
.header-more-btn[aria-expanded="true"] {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
    color: var(--text-primary);
}


/* Next更多 should look distinct from New/Now */
.header-boards-secondary .header-more-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    line-height: 1.2;
}

.header-boards-secondary .header-more-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
    color: var(--text-primary);
    text-decoration: none;
}

.header-boards-secondary .header-more-btn[aria-expanded="true"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .header-boards-secondary .header-more-btn[aria-expanded="true"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Next更多 dropdown */
.header-more {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.header-more-caret {
    font-size: 12px;
    opacity: 0.9;
}

.header-more-menu {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 30px var(--shadow-color);
    padding: 6px;
    display: none;
    z-index: 1000;
}

.header-more-menu.show {
    display: block;
}

.header-more-menu a {
    display: block;
    padding: 10px 10px;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    background: transparent;
}

.header-more-menu a:hover {
    background: var(--bg-tertiary);
    text-decoration: none;
}

.header-more-menu .nav-board-item {
    margin-right: 0;
}

.header-more-menu .nav-board-item.active {
    background: #333344;
    color: #fff;
}

/* Search Box */
.header-search {
    --search-inner-bg: var(--bg-input);

    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    /* Align right towards menu */
    margin-right: 0;
    max-width: none;
    min-width: 40px;
    position: relative;
    height: 34px;
    box-sizing: border-box;

    /* Rainbow border on wrapper so autofill can't override it */
    padding: var(--rainbow-border-size);
    border-radius: 999px;
    background: var(--rainbow-bg);
    background-size: 400% 400%;
    background-position: 0% 50%;
    background-repeat: no-repeat;
    animation: rainbow-flow var(--rainbow-speed) linear infinite;
}

/* Magic search icon */
.header-search .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.2s;
}

.header-search .search-icon svg {
    display: block;
}

.header-search .search-icon .search-sparkle {
    fill: var(--rainbow-color-3);
}

/* Using ID selector to override generic input[type="text"] styles (width: 300px) */
#searchInput {
    /* Base State: Half-length pill */
    width: 220px !important;
    height: 100%;
    padding-left: 14px;
    padding-right: 40px;

    /* Formatting */
    border: none;
    border-radius: 999px;
    /* Smooth capsule for 34px height */
    background: var(--search-inner-bg);
    color: var(--text-primary);
    text-overflow: ellipsis;

    font-size: 14px;
    outline: none;
    cursor: text;
    box-sizing: border-box;

    /* Positioning to allow expansion to the LEFT if needed, or just normal expansion */
    float: right;
    /* Keeps it aligned to right side of its container */

    /* Animation */
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
        background-color 0.2s ease,
        border-color 0.2s ease,
        padding-left 0.2s ease,
        color 0.2s ease;
}

/* Hover state */
.header-search:hover {
    box-shadow: 0 6px 18px var(--shadow-color);
}

/* Focus State: Expanded */
#searchInput:focus {
    width: 320px !important;
    /* Fixed expanded width */
    color: var(--text-primary);
    cursor: text;
    padding-left: 15px;
    /* Text padding */
    padding-right: 40px;
    /* Space for icon on right */
}

.header-search:focus-within {
    box-shadow: 0 10px 30px var(--shadow-color);
}

#searchInput::placeholder {
    color: var(--text-muted);
    opacity: 1;
    transition: opacity 0.15s ease, color 0.15s ease;
}

#searchInput:focus::placeholder {
    color: transparent;
    opacity: 0;
}

/* Keep rainbow border when browser auto-fills / picks history value */
#searchInput:-webkit-autofill,
#searchInput:-webkit-autofill:hover,
#searchInput:-webkit-autofill:focus,
#searchInput:-webkit-autofill:active,
#searchInput:-internal-autofill-selected,
#searchInput:-internal-autofill-previewed {
    border-radius: 999px !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary) !important;
    background-color: transparent !important;
    -webkit-box-shadow: 0 0 0 1000px var(--search-inner-bg) inset !important;
    box-shadow: 0 0 0 1000px var(--search-inner-bg) inset !important;
}

#searchInput:-moz-autofill {
    border-radius: 999px !important;
    background-color: transparent !important;
    box-shadow: 0 0 0 1000px var(--search-inner-bg) inset !important;
}

/* Slightly dim icon when focused */
.header-search:focus-within .search-icon {
    opacity: 0.6;
}

@keyframes rainbow-flow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .header-search {
        animation: none;
    }
}

/* Header Navigation */
.header-nav {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
}

/* Mobile Menu Overlay */
.mobile-menu {
    display: none;
    position: fixed;
    top: 45px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 999;
}

.mobile-menu.show {
    display: block;
}

.mobile-menu-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-menu-content a {
    padding: 12px 0;
    font-size: 15px;
    border-bottom: 1px solid var(--border-color);
    display: block;
    text-decoration: none;
    color: var(--text-primary);
}

.mobile-menu-content a:last-of-type {
    border-bottom: none;
}

.mobile-menu-content .theme-toggle {
    margin-top: 10px;
    padding: 12px 0;
    font-size: 20px;
    background: none;
    border: none;
    border-top: 1px solid var(--border-color);
    text-align: left;
    width: 100%;
    color: var(--text-primary);
    cursor: pointer;
}

/* Main Box Styles */
.box {
    background-color: var(--bg-secondary);
    border-radius: 3px;
    box-shadow: 0 2px 3px var(--shadow-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
}

.cell {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    line-height: 120%;
    text-align: left;
}

.cell:last-child {
    border-bottom: none;
}

.header {
    padding: 10px;
    font-size: 15px;
    line-height: 120%;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
}

/* Form Styles */
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
    width: 300px;
    padding: 5px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    box-shadow: inset 0 1px 2px var(--shadow-color);
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

button {
    padding: 5px 15px;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: var(--bg-primary);
}

/* Utility */
.fr {
    float: right;
}

.fl {
    float: left;
}

.sep5 {
    height: 5px;
}

.sep10 {
    height: 10px;
}

.sep20 {
    height: 20px;
}

/* Topic List */
.item_title {
    font-size: 15px;
    line-height: 130%;
    word-break: break-word;
}

.topic_content,
.reply_content {
    line-height: 1.75;
}

img.emoji-inline {
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: -3px;
    margin: 0 1px;
}

.item_title a {
    color: var(--text-primary);
}

.topic_meta {
    font-size: 12px;
    color: var(--text-muted);
}

.topic-list-table .topic_meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.topic-list-table .topic-meta-sep {
    color: var(--text-muted);
    opacity: 0.75;
}

.topic-list-table .topic-author {
    color: var(--text-muted);
    font-weight: 500;
}

.topic-list-table .topic-author:hover {
    color: var(--text-secondary);
}

.topic-list-table .topic-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.topic-list-table .topic-time svg {
    width: 16px;
    height: 16px;
    opacity: 0.85;
}

.topic-metrics-inline {
    display: none;
    align-items: center;
    gap: 10px;
}

.topic-metric {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 12px;
    line-height: 1.2;
    min-width: 60px;
    justify-content: center;
}

.topic-metric svg {
    width: 16px;
    height: 16px;
    opacity: 0.85;
}

.topic-metric-number {
    font-variant-numeric: tabular-nums;
}

.topic-avatar {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
}

.node_tag {
    background: rgba(14, 165, 233, 0.12);
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: #0369a1;
    font-size: 10px;
    line-height: 14px;
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    border-radius: 3px;
    text-decoration: none;
    font-weight: 500;
    height: 16px;
    vertical-align: middle;
    transition: all 0.15s ease;
}

.node_tag:hover {
    background: rgba(14, 165, 233, 0.18);
    border-color: rgba(14, 165, 233, 0.45);
}

[data-theme="dark"] .node_tag {
    color: #7dd3fc;
    background: rgba(14, 165, 233, 0.16);
    border-color: rgba(14, 165, 233, 0.4);
}

.op-badge {
    background-color: var(--node-tag-bg);
    border: 1px solid var(--border-color);
    font-size: 10px;
    line-height: 14px;
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    border-radius: 3px;
    color: var(--text-muted);
    margin-left: 6px;
    height: 16px;
    vertical-align: middle;
}

.user-group-badge {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 10px;
    line-height: 14px;
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    border-radius: 3px;
    color: var(--text-muted);
    margin-left: 6px;
    height: 16px;
    vertical-align: middle;
}

.user-group-badge.user-group-admin,
.user-group-badge.user-group-moderator {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-secondary);
    font-weight: 600;
}

.user-group-badge.user-group-pending {
    background-color: transparent;
    border-style: dashed;
}

.admin-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0 5px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    font-size: 10px;
    line-height: 14px;
    vertical-align: text-bottom;
    height: 16px;
    font-weight: 500;
    position: relative;
    top: -1px;
}

.admin-pill.admin-pill-pinned {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.45);
    color: #4338ca;
    font-weight: 600;
}

.admin-pill.admin-pill-locked {
    background: rgba(107, 114, 128, 0.14);
    border-color: rgba(107, 114, 128, 0.45);
    color: #374151;
    font-weight: 600;
}

.admin-pill.admin-pill-icon {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    line-height: 20px !important;
    vertical-align: middle !important;
}

.admin-pill.admin-pill-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.admin-pill.admin-pill-icon.admin-pill-pinned svg {
    width: 22px;
    height: 22px;
}

.admin-pill.admin-pill-icon.admin-pill-pinned {
    color: #0891b2 !important;
}

.admin-pill.admin-pill-icon.admin-pill-locked {
    color: #0891b2 !important;
}

[data-theme="dark"] .admin-pill.admin-pill-pinned {
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(99, 102, 241, 0.16);
}

[data-theme="dark"] .admin-pill.admin-pill-locked {
    color: #cbd5e1;
    border-color: rgba(107, 114, 128, 0.6);
    background: rgba(107, 114, 128, 0.16);
}

[data-theme="dark"] .admin-pill.admin-pill-icon.admin-pill-pinned {
    color: #22d3ee !important;
}

[data-theme="dark"] .admin-pill.admin-pill-icon.admin-pill-locked {
    color: #22d3ee !important;
}

.admin-pill.admin-pill-access {
    background: rgba(234, 179, 8, 0.14);
    border-color: rgba(234, 179, 8, 0.45);
    color: #ca8a04;
    font-weight: 600;
}

.admin-pill.admin-pill-icon.admin-pill-access {
    color: #ca8a04 !important;
}

[data-theme="dark"] .admin-pill.admin-pill-access {
    color: #fde047;
    border-color: rgba(234, 179, 8, 0.6);
    background: rgba(234, 179, 8, 0.16);
}

[data-theme="dark"] .admin-pill.admin-pill-icon.admin-pill-access {
    color: #fde047 !important;
}

.access-label {
    font-size: 12px;
    color: #ca8a04;
    font-weight: 600;
    vertical-align: middle;
}

[data-theme="dark"] .access-label {
    color: #fde047;
}

.reply-form-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(8, 145, 178, 0.35);
    background: rgba(8, 145, 178, 0.12);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.reply-form-notice svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: #0891b2;
}

[data-theme="dark"] .reply-form-notice {
    border-color: rgba(34, 211, 238, 0.4);
    background: rgba(34, 211, 238, 0.12);
    color: var(--text-primary);
}

[data-theme="dark"] .reply-form-notice svg {
    color: #22d3ee;
}

#ReplyFormBox.reply-form-locked .reply-toolbar,
#ReplyFormBox.reply-form-locked textarea,
#ReplyFormBox.reply-form-locked button[type="submit"] {
    opacity: 0.65;
}

#ReplyFormBox.reply-form-locked .tb-btn,
#ReplyFormBox.reply-form-locked button[type="submit"] {
    cursor: not-allowed;
}

#ReplyFormBox.reply-form-locked textarea {
    background: var(--bg-tertiary);
}

.topic-stats {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.topic-stat {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    min-width: 60px;
    padding: 6px 12px;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.topic-stat svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    opacity: 0.9;
}

.topic-stat-number {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.topic-stat-label {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.2;
    margin-top: 0;
}

@media screen and (max-width: 768px) {
    .topic-list-table .topic-stats-cell {
        display: none;
    }

    .topic-metrics-inline {
        display: inline-flex;
        gap: 8px;
    }

    .topic-meta-sep {
        display: none;
    }

    .topic-metric svg {
        width: 14px;
        height: 14px;
    }

    .topic-metric {
        background: transparent;
        border: none;
        padding: 0;
        min-width: 0;
        color: var(--text-muted);
    }

    .topic-list-table .topic-time svg {
        width: 14px;
        height: 14px;
    }

    .topic-stats {
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
    }

    .topic-stat {
        border-radius: 999px;
        min-width: 52px;
        padding: 3px 8px;
        justify-content: center;
    }

    .topic-stat svg {
        width: 12px;
        height: 12px;
    }

    .topic-stat-number {
        font-size: 11px;
    }

    .topic-stat-label {
        font-size: 11px;
        margin-top: 0;
    }
}

/* Rightbar */
#Rightbar {
    float: right;
    width: 270px;
    margin-left: 20px;
    margin-top: 20px;
}

#Main {
    margin-right: 290px;
}

/* VanillaForums-like wider layout */
@media screen and (min-width: 1025px) {
    #Wrapper.vanilla-layout > .content {
        box-sizing: border-box;
        max-width: 1224px;
        padding-left: 18px;
        padding-right: 18px;
    }

    /* Reduce gap between main and right card */
    #Wrapper.vanilla-layout #Rightbar {
        margin-left: 12px;
    }

    #Wrapper.vanilla-layout #Main {
        margin-right: 282px;
    }

    #Top.vanilla-layout {
        padding-left: 0;
        padding-right: 0;
    }

    #Top.vanilla-layout .header-boards {
        column-gap: 12px;
    }

    #Top.vanilla-layout .content {
        box-sizing: border-box;
        max-width: 1224px;
        padding-left: 18px;
        padding-right: 18px;
    }

    #Bottom.vanilla-layout {
        padding-left: 0;
        padding-right: 0;
    }

    #Bottom.vanilla-layout .content {
        box-sizing: border-box;
        max-width: 1224px;
        padding-left: 18px;
        padding-right: 18px;
    }
}

/* ============================================
   User Card Styles (Rightbar)
   ============================================ */
.user-card {
    margin-bottom: 15px;
}

/* 未登录欢迎区域 */
.user-card-welcome {
    text-align: center;
    padding: 20px 15px !important;
}

.welcome-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.welcome-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* 已登录用户头部 */
.user-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px !important;
}

.user-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
}

.user-info {
    flex: 1;
}

.user-name a {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-name a:hover {
    text-decoration: none;
}

.user-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.user-notif {
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}

.user-notif-right {
    margin-top: 0;
}

.user-notif-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-notif-icon svg {
    display: block;
}

.user-notif-count {
    font-weight: 700;
}

.user-notif-count.has-unread {
    color: #ef4444;
}

.user-logout-link {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.user-logout-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-decoration: none;
}

/* 操作按钮区域 */
.user-card-actions {
    display: flex;
    gap: 10px;
    padding: 12px 15px !important;
    background: var(--bg-tertiary);
}

.user-action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 34px;
    padding: 7px 14px;
    gap: 6px;
    text-align: center;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 999px;
    text-decoration: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.user-action-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    text-decoration: none;
}

.user-action-btn.primary {
    --user-action-primary-bg: #334155;
    --user-action-primary-bg-hover: #1f2937;

    position: relative;
    z-index: 0;
    background: transparent;
    border-color: transparent;
    color: #ffffff;
    font-weight: 600;
}

.user-action-btn.primary:hover {
    --user-action-primary-bg: var(--user-action-primary-bg-hover);
}

[data-theme="dark"] .user-action-btn.primary {
    color: #ffffff;
}

[data-theme="dark"] .user-action-btn.primary:hover {
    --user-action-primary-bg: var(--user-action-primary-bg-hover);
}

.user-action-btn.primary .ai-sparkle {
    color: currentColor;
}

.user-action-btn.primary::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--user-action-primary-bg);
    z-index: -1;
    transition: background-color 0.2s ease;
}

/* Sidebar: V2EX-like "创作新主题" */
.sidebar-create-topic {
    margin-top: 28px;
}

.sidebar-create-topic-cell {
    padding: 0 !important;
}

.sidebar-create-topic-btn {
    appearance: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
}

.sidebar-create-topic-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-create-topic-btn:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.75);
    outline-offset: 2px;
}

.sidebar-create-topic-btn .create-topic-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-create-topic-btn .create-topic-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.sidebar-create-topic-btn .create-topic-label {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
}

.sidebar-create-topic-btn .create-topic-ai {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #0ea5e9;
    flex-shrink: 0;
}

.sidebar-create-topic-btn .create-topic-ai svg {
    width: 16px;
    height: 16px;
    display: block;
}

[data-theme="dark"] .sidebar-create-topic-btn .create-topic-ai {
    color: #7dd3fc;
}

.sidebar-create-topic .create-dropdown.open .sidebar-create-topic-btn {
    background: var(--bg-tertiary);
    box-shadow: none;
}

.ai-plus,
.ai-sparkle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.ai-sparkle {
    color: #0ea5e9;
}

.ai-plus svg,
.ai-sparkle svg {
    width: 16px;
    height: 16px;
    display: block;
}

[data-theme="dark"] .ai-sparkle {
    color: #7dd3fc;
}

/* Create Dropdown Button */
.create-dropdown {
    position: relative;
    flex: 1;
}

.create-dropdown-toggle {
    width: 100%;
    cursor: pointer;
}

.create-dropdown-toggle .ai-label {
    flex: 1;
    text-align: center;
}

.create-dropdown-caret {
    opacity: 0.7;
    margin-left: 4px;
    font-size: 12px;
}

.create-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    min-width: 100%;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 28px var(--shadow-color);
    z-index: 100;
}

.create-dropdown.open .create-dropdown-menu {
    display: block;
}

.create-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
    transition: background 0.15s ease;
}

.create-dropdown-item:hover {
    background: var(--bg-tertiary);
    text-decoration: none;
}

.create-dropdown-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.create-dropdown.open .create-dropdown-toggle {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Clearfix for content wrapper */
#Wrapper .content::after {
    content: "";
    display: table;
    clear: both;
}

/* Footer */
#Bottom {
    background-color: var(--bg-secondary);
    padding: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    clear: both;
    transition: background-color 0.3s ease;
}

/* ============================================
   Navigation Bar Styles (V2EX-like simple style)
   ============================================ */
.nav-bar {
    background-color: var(--bg-secondary);
    border-radius: 3px;
    box-shadow: 0 2px 3px var(--shadow-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    transition: background-color 0.3s ease;
}

.nav-bar .content {
    display: flex;
    flex-direction: column;
    min-width: auto;
    padding: 0 10px;
}

/* 第一栏：板块导航 - 简洁文本链接风格 */
.nav-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 8px 0;
    font-size: 14px;
}

/* Desktop: primary boards moved to header */
@media screen and (min-width: 769px) {
    .nav-primary {
        display: none;
    }
}

.nav-board-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    margin-right: 4px;
    line-height: 1.2;
    min-height: 30px;
    transition: all 0.15s ease;
}

.nav-board-item:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
    text-decoration: none;
}

.nav-board-item.active {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.45);
    color: #0c4a6e;
}

[data-theme="dark"] .nav-board-item.active {
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(14, 165, 233, 0.55);
    color: #bae6fd;
}

/* 第二栏：标签下拉区域 */
.nav-secondary {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.nav-secondary.show {
    max-height: 200px;
    padding: 8px 0;
    overflow: visible;
}

.nav-secondary-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.nav-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.nav-dropdown {
    position: relative;
}

.nav-filter-chip {
    appearance: none;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    min-width: 60px;
    padding: 7px 14px;
    font-size: 13px;
    line-height: 1.2;
}

.nav-filter-chip:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-dropdown.open .nav-filter-chip {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
    color: var(--text-primary);
}

.nav-filter-chip-label {
    font-weight: 600;
}

.nav-filter-chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    color: var(--text-muted);
    margin-left: 2px;
    cursor: pointer;
}

.nav-filter-chip-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-filter-chip-value {
    color: var(--text-primary);
    font-weight: 600;
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-filter-chip-caret {
    opacity: 0.7;
    margin-left: 2px;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-width: min(360px, calc(100vw - 24px));
    max-height: min(240px, 70vh);
    overflow: auto;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 28px var(--shadow-color);
    z-index: 50;
}

.nav-dropdown-search {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-secondary);
    padding: 10px;
    margin: -6px -6px 6px;
    border-bottom: 1px solid var(--border-color);
}

.nav-dropdown-search-field {
    position: relative;
}

.nav-dropdown-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 38px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.nav-dropdown-search-input:focus {
    background: var(--bg-secondary);
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.nav-dropdown-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    color: var(--text-muted);
    pointer-events: none;
}

.nav-dropdown-search-icon svg {
    width: 18px;
    height: 18px;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.nav-dropdown-item:hover {
    background: var(--bg-tertiary);
    text-decoration: none;
}

.nav-dropdown-item.active {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.nav-dropdown-item-icon {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-dropdown-empty {
    padding: 8px 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.nav-breadcrumb {
    display: inline-flex;
    align-items: center;
    font-size: 15px;
    line-height: 1.2;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-breadcrumb .nav-home {
    color: var(--text-secondary);
    font-weight: 600;
}

.nav-breadcrumb .nav-board-current {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Keep secondary nav height consistent on desktop even when a board has no tags (e.g., 全部) */
@media screen and (min-width: 769px) {
    .nav-tags-container {
        min-height: 26px;
    }
}

.nav-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    color: var(--text-secondary);
    font-size: 12px;
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    line-height: 1.2;
    transition: all 0.15s ease;
}

.nav-tag:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
    text-decoration: none;
}

.nav-tag.active {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.45);
    color: #0c4a6e;
    font-weight: 600;
}

[data-theme="dark"] .nav-tag.active {
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(14, 165, 233, 0.55);
    color: #bae6fd;
}

/* Theme Toggle Button */
/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    margin-left: 5px;
    border-radius: 4px;
    color: var(--text-secondary);
    transition: background-color 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.header-boards-secondary .theme-toggle {
    margin-left: 0;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.theme-option {
    padding: 8px 15px;
    font-size: 14px;
}

/* Editor Toolbar Styles */
.editor-toolbar,
.reply-toolbar,
.edit-toolbar,
.reply-edit-toolbar {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
}

.editor-toolbar button,
.reply-toolbar button,
.edit-toolbar button,
.reply-edit-toolbar button,
.tb-btn {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.editor-toolbar button:hover,
.reply-toolbar button:hover,
.edit-toolbar button:hover,
.reply-edit-toolbar button:hover,
.tb-btn:hover {
    background-color: var(--bg-tertiary) !important;
}

/* Emoji Picker */
.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.emoji-picker .emoji-item {
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.emoji-picker .emoji-item:hover {
    background: var(--bg-tertiary);
}

.emoji-picker .emoji-item img {
    width: 24px;
    height: 24px;
    display: block;
}

/* Emoji Picker Dark Mode */
.emoji-picker {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* Input Panels Dark Mode */
.input-panel {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   RESPONSIVE DESIGN - Mobile Support
   ============================================ */

/* Tablet and smaller */
@media screen and (max-width: 1024px) {
    .content {
        min-width: auto;
        max-width: 100%;
        padding: 0 10px;
    }

    .header-boards {
        grid-template-columns: 1fr auto;
    }

    #Rightbar {
        float: none;
        width: 100%;
        margin-left: 0;
        margin-top: 20px;
    }

    #Main {
        margin-right: 0;
    }
}

/* Mobile phones */
@media screen and (max-width: 768px) {
    body {
        font-size: 15px;
    }

    #Top {
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    #Top .content {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
    }

    .header-left {
        flex-shrink: 0;
    }

    .logo {
        font-size: 22px;
    }

    .logo-subtitle {
        display: none;
    }

    .header-boards {
        display: none;
    }

    .header-more {
        display: none;
    }

    .header-search {
        flex: 1;
        min-width: 0;
        max-width: none;
        justify-content: flex-start;
    }

    .search-input {
        padding: 6px 12px;
        font-size: 13px;
    }

    #searchInput {
        float: none;
        width: 100% !important;
        font-size: 16px;
    }

    #searchInput:focus {
        width: 100% !important;
    }

    /* Hide desktop nav, show mobile menu button */
    .header-nav {
        display: none !important;
    }

    #TopNav {
        display: none !important;
    }

    .mobile-menu-btn {
        display: block !important;
        flex-shrink: 0;
    }

    /* Align breadcrumb with box cell padding */
    .nav-bar .content {
        padding: 0 12px;
    }

    .nav-bar {
        border-radius: 0;
    }

    /* Mobile: hide primary nav (replaced by dropdown filters) */
    .nav-primary {
        display: none;
    }

    .nav-board-item {
        flex: 0 0 auto;
        margin-right: 0;
        padding: 7px 14px;
        border-radius: 999px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        color: var(--text-secondary);
        white-space: nowrap;
    }

    .nav-board-item.active {
        background: rgba(14, 165, 233, 0.2);
        border-color: rgba(14, 165, 233, 0.55);
        color: #bae6fd;
    }

    .nav-secondary.show {
        padding: 10px 0;
        border-top: none;
    }

    .nav-filter-chip {
        padding: 8px 14px;
        border-radius: 999px;
    }

    .nav-dropdown-search-input {
        font-size: 16px;
    }

    /* Hide sidebar on mobile */
    #Rightbar {
        display: none;
    }

    #TopNav a {
        padding: 5px 10px;
    }

    .content {
        padding: 0;
        min-width: auto;
    }

    .box {
        border-radius: 0;
        margin-bottom: 10px;
    }

    .cell {
        padding: 12px;
    }

    .header {
        padding: 12px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    textarea {
        width: 100%;
        box-sizing: border-box;
    }

    /* Topic list: author avatar on mobile */
    .topic-list-table td {
        vertical-align: top;
    }

    .topic-list-table td[width="48"] {
        width: 40px;
    }

    .topic-list-table td[width="10"] {
        width: 8px;
    }

    .topic-list-table td[width="140"] {
        width: 64px;
    }

    .topic-list-table .topic-avatar {
        width: 36px;
        height: 36px;
        margin: 0 auto;
        border-radius: 4px;
    }

    /* Hide avatars in other table layouts to save space */
    .cell table:not(.topic-list-table) td[width="48"] {
        display: none;
    }

    .cell table:not(.topic-list-table) td[width="10"] {
        display: none;
    }

    .item_title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .topic_meta {
        font-size: 11px;
    }

    .topic-list-table .topic_meta {
        gap: 5px;
    }

    /* Editor toolbar responsive */
    .editor-toolbar,
    .reply-toolbar,
    .edit-toolbar {
        flex-wrap: wrap;
        gap: 5px;
    }

    /* Reply form */
    #Rightbar .box .cell {
        padding: 10px;
    }
}

/* Small mobile phones */
@media screen and (max-width: 480px) {
    .logo {
        font-size: 20px;
    }

    #TopNav {
        font-size: 13px;
    }

    .item_title {
        font-size: 14px;
    }

    .sep20 {
        height: 10px;
    }

    /* Stack footer links vertically */
    #Bottom .inner {
        line-height: 2;
    }

    /* 导航移动端适配 */
    .nav-board-item {
        padding: 5px 10px;
        font-size: 12px;
        border-radius: 999px;
    }

    .nav-tag {
        font-size: 12px;
    }
}

/* Feedback: Toast + Message Bar */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 10000;
    max-width: min(520px, calc(100vw - 40px));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: rgba(22, 163, 74, 0.95);
}

.toast.error {
    background: rgba(239, 68, 68, 0.95);
}

.toast.warning {
    background: rgba(245, 158, 11, 0.95);
}

.toast.info {
    background: rgba(0, 0, 0, 0.85);
}

@media screen and (max-width: 768px) {
    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
        text-align: center;
    }
}

.message-bar {
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 3px;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 8px;
}

.message-bar.show {
    display: flex;
}

.message-bar.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

[data-theme="dark"] .message-bar.error {
    background: #3a2020;
    border-color: #5c2626;
    color: #fca5a5;
}

.message-bar.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

[data-theme="dark"] .message-bar.success {
    background: #1a3a20;
    border-color: #265c36;
    color: #86efac;
}

.message-bar.warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

[data-theme="dark"] .message-bar.warning {
    background: #3a2f1a;
    border-color: #5c4a26;
    color: #fcd34d;
}

.message-bar.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

[data-theme="dark"] .message-bar.info {
    background: #1e2a3a;
    border-color: #2b4b6b;
    color: #93c5fd;
}

.message-bar-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.message-bar-text {
    flex: 1;
}

.markdown-fallback {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

/* ============================================
   NHT Inspection Card - Professional Style
   ============================================ */

.nht-inspection {
    margin: 16px 0;
}

.nht-inspection-loading,
.nht-inspection-error {
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    font-size: 13px;
    line-height: 1.55;
}

.nht-inspection-loading {
    color: var(--text-secondary);
}

.nht-inspection-error {
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.28);
    background: rgba(185, 28, 28, 0.06);
}

[data-theme="dark"] .nht-inspection-error {
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.22);
    background: rgba(252, 165, 165, 0.08);
}

/* Main Card Container */
.nht-inspection-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .nht-inspection-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Header Section - Score Display */
.nht-inspection-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
}

[data-theme="dark"] .nht-inspection-head {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.nht-inspection-head-left {
    flex: 1;
    min-width: 0;
}

.nht-inspection-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.3;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nht-inspection-title::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    border-radius: 5px;
    flex-shrink: 0;
}

.nht-inspection-sub {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

/* Score Display */
.nht-inspection-head-right {
    flex-shrink: 0;
    text-align: right;
}

.nht-inspection-score {
    min-width: 100px;
}

.nht-inspection-score-line {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 10px;
}

.nht-inspection-score-num {
    font-weight: 800;
    font-size: 32px;
    line-height: 1;
    letter-spacing: -0.02em;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.nht-inspection-score-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
}

/* Grade-specific colors */
.nht-inspection-score-grade[data-grade="S"] {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: rgba(245, 158, 11, 0.5);
}

.nht-inspection-score-grade[data-grade="A+"],
.nht-inspection-score-grade[data-grade="A"] {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-color: rgba(139, 92, 246, 0.5);
}

.nht-inspection-score-grade[data-grade="B+"],
.nht-inspection-score-grade[data-grade="B"] {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: rgba(59, 130, 246, 0.5);
}

.nht-inspection-score-grade[data-grade="C+"],
.nht-inspection-score-grade[data-grade="C"] {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: rgba(16, 185, 129, 0.5);
}

.nht-inspection-score-grade[data-grade="D"],
.nht-inspection-score-grade[data-grade="E"] {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: rgba(239, 68, 68, 0.5);
}

.nht-inspection-score-label {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Meta Information Grid - Card Style */
.nht-inspection-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    padding: 0;
    background: var(--border-color);
}

@media (max-width: 640px) {
    .nht-inspection-meta {
        grid-template-columns: repeat(2, 1fr);
    }
}

.nht-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    min-width: 0;
}

.nht-meta-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.nht-meta-icon svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

.nht-meta-k {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.nht-meta-v {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    word-break: break-word;
    line-height: 1.35;
}

.nht-meta-v-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Badges Section */
.nht-inspection-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.nht-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.2;
    font-weight: 600;
}

.nht-badge-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.nht-badge.ok {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
}

[data-theme="dark"] .nht-badge.ok {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.25);
    background: rgba(16, 185, 129, 0.12);
}

.nht-badge.bad {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}

[data-theme="dark"] .nht-badge.bad {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.25);
    background: rgba(239, 68, 68, 0.12);
}

.nht-badge.neutral {
    border-color: rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.08);
    color: #2563eb;
}

[data-theme="dark"] .nht-badge.neutral {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.25);
    background: rgba(59, 130, 246, 0.12);
}

/* Charts Section - 2x2 Grid */
.nht-inspection-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--border-color);
    border-top: 1px solid var(--border-color);
}

@media (max-width: 640px) {
    .nht-inspection-charts {
        grid-template-columns: 1fr;
    }
}

.nht-chart {
    background: var(--bg-secondary);
    padding: 14px 16px;
}

.nht-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.nht-chart-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.nht-chart-unit {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.nht-chart-axis {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.nht-axis-tick {
    flex: 1 1 auto;
    text-align: center;
}

.nht-axis-tick:first-child {
    text-align: left;
}

.nht-axis-tick:last-child {
    text-align: right;
}

.nht-chart-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nht-bar-row {
    display: grid;
    grid-template-columns: 50px 1fr 70px;
    align-items: center;
    gap: 10px;
}

.nht-bar-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.nht-bar-track {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    overflow: hidden;
    position: relative;
}

.nht-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    width: 0%;
    transition: width 0.4s ease;
}

[data-theme="dark"] .nht-bar-fill {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
}

.nht-bar-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: right;
}

/* Traceroute Section */
.nht-traceroute-section {
    border-top: 1px solid var(--border-color);
    padding: 14px 16px;
}

.nht-traceroute-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.nht-traceroute-header svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    stroke-width: 2;
    fill: none;
}

.nht-traceroute-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nht-traceroute-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.nht-traceroute-summary {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.nht-traceroute-summary:hover {
    background: var(--bg-hover);
}

.nht-traceroute-target {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nht-traceroute-host {
    font-size: 11px;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.nht-traceroute-aspath {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    line-height: 1.2;
}

.nht-traceroute-aspath code {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: nowrap;
}

.nht-traceroute-hops {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.nht-traceroute-rtt {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 65px;
    text-align: right;
}

.nht-traceroute-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
}

.nht-traceroute-status.ok {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

[data-theme="dark"] .nht-traceroute-status.ok {
    color: #34d399;
}

.nht-traceroute-status.fail {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

[data-theme="dark"] .nht-traceroute-status.fail {
    color: #f87171;
}

.nht-traceroute-expand {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.nht-traceroute-item.expanded .nht-traceroute-expand {
    transform: rotate(90deg);
}

/* Traceroute Hops Detail */
.nht-traceroute-hops-detail {
    display: none;
    border-top: 1px solid var(--border-color);
    padding: 10px 14px;
    background: var(--bg-secondary);
}

.nht-traceroute-item.expanded .nht-traceroute-hops-detail {
    display: block;
}

.nht-hop-row {
    display: grid;
    grid-template-columns: 28px 1fr 160px 70px;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 11px;
    border-bottom: 1px dashed var(--border-color);
}

.nht-hop-row:last-child {
    border-bottom: none;
}

.nht-hop-ttl {
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
}

.nht-hop-ip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nht-hop-ip.timeout {
    color: var(--text-muted);
}

.nht-hop-as {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nht-hop-rtt {
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* Footer Section */
.nht-inspection-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.nht-inspection-footer-left a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 6px;
    background: #3b82f6;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.nht-inspection-footer-left a:hover {
    background: #2563eb;
    text-decoration: none;
}

.nht-inspection-footer-right {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    opacity: 0.7;
}
