/* ==========================================================================
   Nebula Theme Fix
   - html[data-theme] 为唯一主题根
   - --text-primary / --bg-primary / --border-color 为强制规范变量
   - 覆盖旧页面里遗留的硬编码暗色，保证亮色与 admin 对比度
   ========================================================================== */

html[data-theme="dark"] {
    --text-primary: #ffffff;
    --text-secondary: #c9ced8;
    --text-muted: #8f97a3;
    --bg-primary: #0f1115;
    --bg-secondary: #171a20;
    --bg-elevated: #1e222a;
    --border-color: #2a2e35;
    --border-strong: #3b414b;
    --theme-input: #14171d;
    --theme-accent: #8b5cf6;
    --text: var(--text-primary);
    --text-soft: var(--text-secondary);
    --muted: var(--text-muted);
    --faint: #707885;
    --bg: var(--bg-primary);
    --bg-deep: #0a0c10;
    --sidebar: #171a20;
    --sidebar-deep: #12151a;
    --panel: #1b1f27;
    --panel-raised: #21262f;
    --panel-soft: #242a34;
    --input: var(--theme-input);
    --line: var(--border-color);
    --line-strong: var(--border-strong);
}

html[data-theme="light"] {
    --text-primary: #000000;
    --text-secondary: #20242b;
    --text-muted: #4f5662;
    --bg-primary: #ffffff;
    --bg-secondary: #f4f6fa;
    --bg-elevated: #ffffff;
    --border-color: #e0e0e0;
    --border-strong: #c9cdd5;
    --theme-input: #f7f8fb;
    --theme-accent: #4f46e5;
    --text: var(--text-primary);
    --text-soft: var(--text-secondary);
    --muted: var(--text-muted);
    --faint: #69707d;
    --bg: var(--bg-primary);
    --bg-deep: #eef1f6;
    --sidebar: #ffffff;
    --sidebar-deep: #f4f6fa;
    --panel: #ffffff;
    --panel-raised: #f7f8fb;
    --panel-soft: #eef1f7;
    --input: var(--theme-input);
    --line: var(--border-color);
    --line-strong: var(--border-strong);
    --shadow: 0 16px 48px rgba(25, 32, 50, .12);
}

html[data-theme="gradient"] {
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --text-muted: #a8b3c5;
    --bg-primary: #0b1020;
    --bg-secondary: #111a31;
    --bg-elevated: #17213b;
    --border-color: rgba(255, 255, 255, .14);
    --border-strong: rgba(255, 255, 255, .24);
    --theme-input: #0d1528;
    --text: var(--text-primary);
    --text-soft: var(--text-secondary);
    --muted: var(--text-muted);
    --bg: #0b1020;
    --sidebar: #111a31;
    --panel: #17213b;
    --panel-raised: #1c2947;
    --panel-soft: #223255;
    --input: #0d1528;
    --line: var(--border-color);
    --line-strong: var(--border-strong);
}

html[data-theme="glass"] {
    --text-primary: #ffffff;
    --text-secondary: #e5edf8;
    --text-muted: #a9b8ca;
    --bg-primary: #0b1220;
    --bg-secondary: rgba(20, 31, 52, .72);
    --bg-elevated: rgba(30, 43, 68, .76);
    --border-color: rgba(255, 255, 255, .18);
    --border-strong: rgba(255, 255, 255, .3);
    --theme-input: rgba(11, 19, 35, .72);
    --text: var(--text-primary);
    --text-soft: var(--text-secondary);
    --muted: var(--text-muted);
    --bg: #0b1220;
    --sidebar: rgba(20, 31, 52, .74);
    --panel: rgba(25, 38, 62, .7);
    --panel-raised: rgba(40, 56, 86, .66);
    --panel-soft: rgba(55, 73, 107, .48);
    --input: rgba(11, 19, 35, .72);
    --line: var(--border-color);
    --line-strong: var(--border-strong);
}

html,
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

body {
    color: var(--text-primary);
}

body,
button,
input,
textarea,
select {
    color: var(--text-primary);
}

/* 暗色关键标题加发光，亮色保持纯黑可读 */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] .auth-hero h1,
html[data-theme="dark"] .admin-hero h1,
html[data-theme="dark"] .channel-head h1 {
    text-shadow: 0 0 8px rgba(255, 255, 255, .4);
}

html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] .auth-hero h1,
html[data-theme="light"] .admin-hero h1,
html[data-theme="light"] .channel-head h1 {
    color: var(--text-primary);
    text-shadow: none;
}

/* 统一页面底色和边框 */
.app,
.auth-shell,
.chat-main,
.sidebar,
.modal,
.admin-body,
.admin-main,
.admin-panel,
.panel-sub,
.stat-card,
.table-wrap,
.data-table,
.forum-body,
.forum-shell,
.album-body,
.album-shell,
.download-body,
.download-shell,
.svip-body,
.svip-shell {
    color: var(--text-primary);
}

html[data-theme="light"] .app,
html[data-theme="light"] .auth-shell,
html[data-theme="light"] .chat-main,
html[data-theme="light"] .sidebar,
html[data-theme="light"] .modal,
html[data-theme="light"] .admin-body,
html[data-theme="light"] .admin-main,
html[data-theme="light"] .admin-panel,
html[data-theme="light"] .panel-sub,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .table-wrap,
html[data-theme="light"] .data-table,
html[data-theme="light"] .forum-body,
html[data-theme="light"] .album-body,
html[data-theme="light"] .download-body,
html[data-theme="light"] .svip-body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

html[data-theme="light"] .sidebar,
html[data-theme="light"] .admin-topbar,
html[data-theme="light"] .forum-topbar,
html[data-theme="light"] .album-topbar,
html[data-theme="light"] .download-topbar,
html[data-theme="light"] .svip-topbar {
    background: #ffffff;
    border-color: var(--border-color);
}

html[data-theme="light"] .admin-panel,
html[data-theme="light"] .panel-sub,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .modal,
html[data-theme="light"] .auth-card,
html[data-theme="light"] .forum-compose,
html[data-theme="light"] .forum-post-row,
html[data-theme="light"] .forum-reply,
html[data-theme="light"] .album-card,
html[data-theme="light"] .download-list,
html[data-theme="light"] .svip-panel {
    border-color: var(--border-color);
    background: #ffffff;
    color: var(--text-primary);
}

html[data-theme="light"] .data-table th,
html[data-theme="light"] .data-table td,
html[data-theme="light"] .forum-post-row,
html[data-theme="light"] .forum-reply,
html[data-theme="light"] .admin-tabs,
html[data-theme="light"] .admin-topbar,
html[data-theme="light"] .modal-head,
html[data-theme="light"] .modal-foot {
    border-color: var(--border-color);
}

html[data-theme="light"] body,
html[data-theme="light"] p,
html[data-theme="light"] span,
html[data-theme="light"] small,
html[data-theme="light"] strong,
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4,
html[data-theme="light"] label,
html[data-theme="light"] th,
html[data-theme="light"] td,
html[data-theme="light"] .message-text,
html[data-theme="light"] .author,
html[data-theme="light"] .admin-message-text,
html[data-theme="light"] .table-name,
html[data-theme="light"] .table-name strong,
html[data-theme="light"] .table-name a,
html[data-theme="light"] .forum-post-title a,
html[data-theme="light"] .forum-thread-content,
html[data-theme="light"] .forum-reply-content,
html[data-theme="light"] .album-photo-title,
html[data-theme="light"] .download-row-main h2 a,
html[data-theme="light"] .download-description,
html[data-theme="light"] .notification-title a,
html[data-theme="light"] .notification-title strong,
html[data-theme="light"] .notification-main p {
    color: var(--text-primary);
}

html[data-theme="light"] .auth-lead,
html[data-theme="light"] .auth-footnote,
html[data-theme="light"] .admin-hero p,
html[data-theme="light"] .forum-post-meta,
html[data-theme="light"] .forum-thread-meta,
html[data-theme="light"] .forum-reply-head,
html[data-theme="light"] .download-meta,
html[data-theme="light"] .album-meta,
html[data-theme="light"] .input-help,
html[data-theme="light"] .table-loading {
    color: var(--text-muted);
}

/* 输入控件与按钮 */
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="light"] .field input,
html[data-theme="light"] .field textarea,
html[data-theme="light"] .admin-select {
    background: var(--theme-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html[data-theme="light"] .btn-primary,
html[data-theme="light"] .btn-primary *,
html[data-theme="light"] .btn-danger,
html[data-theme="light"] .btn-danger *,
html[data-theme="light"] .forum-badge,
html[data-theme="light"] .perm-pill,
html[data-theme="light"] .avatar,
html[data-theme="light"] .brand-mark,
html[data-theme="light"] .orbit-core {
    color: #ffffff !important;
}

html[data-theme="light"] .btn-ghost {
    border-color: var(--border-color);
    background: #ffffff;
    color: var(--text-primary);
}

html[data-theme="light"] .btn-ghost:hover {
    background: var(--bg-secondary);
}

html[data-theme="light"] .admin-tab {
    color: var(--text-muted);
}

html[data-theme="light"] .admin-tab.active {
    color: var(--text-primary);
}

html[data-theme="light"] .admin-tab.active::after {
    background: var(--theme-accent);
}

/* admin 内的深色渐变卡片在亮色下强制改为浅色 */
html[data-theme="light"] .admin-hero,
html[data-theme="light"] .analytics-chart-wrap,
html[data-theme="light"] .system-card,
html[data-theme="light"] .forum-admin-badges,
html[data-theme="light"] .admin-room-card {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
    border-color: var(--border-color);
}

html[data-theme="light"] .admin-hero .eyebrow,
html[data-theme="light"] .stat-card span,
html[data-theme="light"] .setting-item > span {
    color: var(--text-muted);
}

html[data-theme="light"] .data-table tr:hover {
    background: #f7f8fb;
}

html[data-theme="light"] .data-table thead,
html[data-theme="light"] .data-table th,
html[data-theme="light"] .data-table tr,
html[data-theme="light"] .admin-message-card,
html[data-theme="light"] .admin-message-body,
html[data-theme="light"] .admin-room-card,
html[data-theme="light"] .forum-post-row,
html[data-theme="light"] .forum-reply,
html[data-theme="light"] .album-card,
html[data-theme="light"] .download-row,
html[data-theme="light"] .notification-item,
html[data-theme="light"] .svip-progress-card,
html[data-theme="light"] .svip-panel {
    background: #ffffff;
    color: var(--text-primary);
}

html[data-theme="light"] .forum-reply-content,
html[data-theme="light"] .forum-thread-content,
html[data-theme="light"] .admin-message-text {
    color: var(--text-primary) !important;
}

html[data-theme="light"] .admin-message-card,
html[data-theme="light"] .forum-post-row,
html[data-theme="light"] .forum-reply,
html[data-theme="light"] .download-row,
html[data-theme="light"] .notification-item {
    border-color: var(--border-color);
}

/* 液态玻璃/渐变下的可读性 */
html[data-theme="glass"] .modal,
html[data-theme="glass"] .admin-panel,
html[data-theme="glass"] .auth-card {
    background: rgba(17, 27, 46, .86);
    color: var(--text-primary);
}

html[data-theme="gradient"] .modal,
html[data-theme="gradient"] .admin-panel {
    background: rgba(23, 33, 59, .94);
}

/* 首页/全站主题切换按钮 */
.theme-toggle-btn {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .16);
    font-size: 11px;
    cursor: pointer;
}

.theme-toggle-btn:hover {
    border-color: var(--theme-accent);
}

.theme-toggle-btn:focus-visible {
    outline: 2px solid var(--theme-accent);
    outline-offset: 2px;
}

@media (max-width: 760px) {
    .theme-toggle-btn {
        top: 10px;
        right: 10px;
        min-height: 40px;
    }
}


.admin-crumb {
    color: var(--text-muted);
    font-size: 14px;
}

.admin-crumb strong {
    color: var(--text-primary);
}

.crumb-sep {
    color: var(--text-muted);
}