/* 全站深色模式覆盖：浅色模式不加 data-theme，原样式 100% 保持不变 */
html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] body {
    background: #0f172a !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] ::selection {
    background: #2563eb;
    color: #fff;
}

/* ---------- 通用文字 ---------- */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] p,
html[data-theme="dark"] li,
html[data-theme="dark"] td,
html[data-theme="dark"] th,
html[data-theme="dark"] .tip,
html[data-theme="dark"] .toast-text,
html[data-theme="dark"] .stats-value,
html[data-theme="dark"] .num,
html[data-theme="dark"] .msg .title,
html[data-theme="dark"] .msg .content,
html[data-theme="dark"] .reply-content {
    color: #e5e7eb !important;
}

html[data-theme="dark"] .form-label,
html[data-theme="dark"] .stats-label,
html[data-theme="dark"] .reply-sender,
html[data-theme="dark"] .sender,
html[data-theme="dark"] .time,
html[data-theme="dark"] .reply-time,
html[data-theme="dark"] .type-display,
html[data-theme="dark"] .selected-count,
html[data-theme="dark"] .lbl,
html[data-theme="dark"] .field label {
    color: #94a3b8 !important;
}

/* 链接默认蓝色；彩色按钮内的白字在下面单独保留 */
html[data-theme="dark"] a {
    color: #7aa2ff !important;
}

html[data-theme="dark"] .login-top a,
html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .batch-btn a,
html[data-theme="dark"] .upload-tab.active,
html[data-theme="dark"] .upload-toggle-btn,
html[data-theme="dark"] .search button,
html[data-theme="dark"] button,
html[data-theme="dark"] input[type="submit"],
html[data-theme="dark"] .btn,
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn-normal,
html[data-theme="dark"] .btn-read,
html[data-theme="dark"] .btn-back,
html[data-theme="dark"] .btn-select,
html[data-theme="dark"] .btn-del,
html[data-theme="dark"] .btn-blue,
html[data-theme="dark"] .btn-save,
html[data-theme="dark"] .btn-home,
html[data-theme="dark"] .btn-audit,
html[data-theme="dark"] .btn-open,
html[data-theme="dark"] .btn-mgtv,
html[data-theme="dark"] .btn-tx,
html[data-theme="dark"] .edit-btn,
html[data-theme="dark"] .open-btn,
html[data-theme="dark"] .btn-base,
html[data-theme="dark"] .verify-submit,
html[data-theme="dark"] .pages a.active,
html[data-theme="dark"] .toast-icon,
html[data-theme="dark"] .msg-dot,
html[data-theme="dark"] .unread-badge {
    color: #fff !important;
}

html[data-theme="dark"] .err,
html[data-theme="dark"] .verify-error {
    color: #fca5a5 !important;
}

html[data-theme="dark"] .success,
html[data-theme="dark"] .success-tip {
    color: #86efac !important;
}

/* ---------- 通用容器/卡片表面 ---------- */
html[data-theme="dark"] .box,
html[data-theme="dark"] .container,
html[data-theme="dark"] .site-declaration,
html[data-theme="dark"] .search-bar,
html[data-theme="dark"] .tip,
html[data-theme="dark"] .search,
html[data-theme="dark"] .verify-box,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .stats-item,
html[data-theme="dark"] .form-item,
html[data-theme="dark"] .reply-item,
html[data-theme="dark"] .tab-con,
html[data-theme="dark"] .batch-bar,
html[data-theme="dark"] .pagination,
html[data-theme="dark"] #singleUpload,
html[data-theme="dark"] #batchUpload,
html[data-theme="dark"] .upload-content,
html[data-theme="dark"] .batch-guide,
html[data-theme="dark"] .login-prompt,
html[data-theme="dark"] .item-poster,
html[data-theme="dark"] .poster-fallback,
html[data-theme="dark"] .nav a:not(.active),
html[data-theme="dark"] .search a,
html[data-theme="dark"] .upload-tab:not(.active),
html[data-theme="dark"] .pages a:not(.active),
html[data-theme="dark"] .tmdb-shortcut,
html[data-theme="dark"] table,
html[data-theme="dark"] th,
html[data-theme="dark"] td {
    background-color: #1b2230 !important;
    color: #e5e7eb !important;
    border-color: #334155 !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .nav a:not(.active) {
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] .nav a.active {
    border: 1px solid #2563eb !important;
}

html[data-theme="dark"] .pan-tag {
    background-color: #243044 !important;
    color: #cbd5e1 !important;
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] .uploader-tag {
    background-color: #2b1b33 !important;
    color: #f0abfc !important;
    border: 1px solid #4c1d5a !important;
}

html[data-theme="dark"] .uploader-tag:hover {
    background-color: #3b2350 !important;
    color: #f5d0fe !important;
}

html[data-theme="dark"] tr:nth-child(even) td {
    background-color: #18202d !important;
}

html[data-theme="dark"] th {
    background-color: #243044 !important;
}

/* ---------- 输入框 ---------- */
html[data-theme="dark"] input:not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .verify-input,
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-textarea {
    background-color: #111827 !important;
    color: #e5e7eb !important;
    border-color: #334155 !important;
    box-shadow: none !important;
}

html[data-theme="dark"] ::placeholder {
    color: #94a3b8 !important;
    opacity: 1;
}

/* 浮动标签的白底缺口在深色模式下改用输入框同色，避免白块 */
html[data-theme="dark"] .field label {
    background: #111827 !important;
    padding: 0 6px !important;
}

html[data-theme="dark"] .field input:focus + label,
html[data-theme="dark"] .field input:not(:placeholder-shown) + label,
html[data-theme="dark"] .field textarea:focus + label,
html[data-theme="dark"] .field textarea:not(:placeholder-shown) + label {
    color: #7aa2ff !important;
}

html[data-theme="dark"] .search {
    background: #1b2230 !important;
    border-color: #2563eb !important;
}

html[data-theme="dark"] .search input[name="search"] {
    background-color: #111827 !important;
    border-color: #2563eb !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] .search input[name="search"]:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96,165,250,.2) !important;
}

/* 后台搜索栏：标题 / 搜索链接 / 上传用户 / 全部网盘类型 / 搜索 / 重置 */
html[data-theme="dark"] .search-bar,
html[data-theme="dark"] body .search-bar {
    background: #1b2230 !important;
    background-color: #1b2230 !important;
    background-image: none !important;
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] .search-bar input,
html[data-theme="dark"] .search-bar select,
html[data-theme="dark"] .search-bar textarea {
    background-color: #111827 !important;
    color: #e5e7eb !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .search-bar button {
    background-color: #2563eb !important;
    color: #fff !important;
}

html[data-theme="dark"] .search-bar .reset-btn {
    background-color: #243044 !important;
    color: #93c5fd !important;
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] option {
    background-color: #111827 !important;
    color: #e5e7eb !important;
}

/* ---------- 特殊彩色块 ---------- */
html[data-theme="dark"] .moyan-link {
    background-color: #14301f !important;
    color: #86efac !important;
}

html[data-theme="dark"] .qq-group-link,
html[data-theme="dark"] .total-count {
    background-color: #12233d !important;
    color: #93c5fd !important;
}

html[data-theme="dark"] .quark-group-link {
    background-color: #0e3b3f !important;
    color: #67e8f9 !important;
    border: 1px solid #164e63 !important;
}

html[data-theme="dark"] .xunlei-group-link {
    background-color: #1e3a5f !important;
    color: #93c5fd !important;
    border: 1px solid #1e40af !important;
}

html[data-theme="dark"] .daily-update-box {
    background-color: #1b2230 !important;
    color: #e5e7eb !important;
    border: 1px solid #334155 !important;
    border-left: 4px solid #f59e0b !important;
}

html[data-theme="dark"] .daily-update-box h4 {
    color: #fbbf24 !important;
}

html[data-theme="dark"] .daily-update-box p {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .daily-update-box p:last-child {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .extract-code-tag {
    background-color: #3b2f13 !important;
    color: #fcd34d !important;
}

html[data-theme="dark"] .tmdb-shortcut {
    background-color: #1e293b !important;
    color: #93c5fd !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .pages a:not(.active) {
    color: #7aa2ff !important;
    border-color: #3b82f6 !important;
}

html[data-theme="dark"] .pagination a,
html[data-theme="dark"] .pagination span,
html[data-theme="dark"] .pagination button {
    background-color: #1b2230 !important;
    color: #7aa2ff !important;
    border-color: #3b82f6 !important;
}

html[data-theme="dark"] .pagination .active,
html[data-theme="dark"] .pagination button {
    background-color: #2563eb !important;
    color: #fff !important;
    border-color: #2563eb !important;
}

html[data-theme="dark"] .btn-gray {
    background-color: #334155 !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] .recycle-btn {
    background-color: #3b1d1d !important;
    color: #fca5a5 !important;
    border-color: #7f1d1d !important;
}

/* 首页底部声明 */
html[data-theme="dark"] .site-declaration {
    border-top-color: #334155 !important;
}

html[data-theme="dark"] .site-declaration strong {
    color: #93c5fd !important;
}

/* 站内信列表行 */
html[data-theme="dark"] .msg,
html[data-theme="dark"] .msg.unread {
    background-color: #1b2230 !important;
    border-bottom-color: #334155 !important;
}

html[data-theme="dark"] .msg.unread {
    background-color: #241f2b !important;
}

html[data-theme="dark"] .msg:hover {
    background-color: #243044 !important;
}

html[data-theme="dark"] button:disabled,
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] textarea:disabled {
    background-color: #243044 !important;
    color: #94a3b8 !important;
}

html[data-theme="dark"] .item-poster,
html[data-theme="dark"] .poster-fallback,
html[data-theme="dark"] .item-poster img {
    background-color: #111827 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .verify-mask {
    background: rgba(0,0,0,.82) !important;
}

/* ---------- Excel 批量上传 ---------- */
html[data-theme="dark"] .excel-upload-row input[type="file"] {
    background-color: #111827 !important;
    color: #e5e7eb !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] input[type="file"]::file-selector-button {
    background-color: #243044 !important;
    color: #e5e7eb !important;
    border: 1px solid #334155 !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    margin-right: 8px !important;
    cursor: pointer !important;
}

html[data-theme="dark"] .btn-excel {
    background-color: #0284c7 !important;
    color: #fff !important;
}

html[data-theme="dark"] .format-hint {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .tpl-download-row {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .tpl-download-row a {
    color: #7aa2ff !important;
}

html[data-theme="dark"] .tpl-sep {
    color: #64748b !important;
}

html[data-theme="dark"] .excel-tip {
    background-color: #12233d !important;
    color: #93c5fd !important;
}

html[data-theme="dark"] .export-xlsx-btn {
    background-color: #047857 !important;
    color: #fff !important;
}

html[data-theme="dark"] .export-xlsx-btn:hover {
    background-color: #065f46 !important;
}

/* ---------- 主题切换按钮 ---------- */
#themeToggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 100000;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(148,163,184,.45);
    background: rgba(15,23,42,.88);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,.25);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform .2s ease, background .2s ease, color .2s ease;
    padding: 0;
    line-height: 1;
}

#themeToggle:hover {
    transform: translateY(-2px);
}

#themeToggle:focus-visible {
    outline: 3px solid #60a5fa;
    outline-offset: 2px;
}

#themeToggle svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

html[data-theme="dark"] #themeToggle {
    background: rgba(226,232,240,.14);
    color: #e5e7eb;
    border-color: rgba(226,232,240,.3);
}

@media (max-width: 768px) {
    #themeToggle {
        right: 14px;
        bottom: 14px;
        width: 42px;
        height: 42px;
    }
    #themeToggle svg {
        width: 20px;
        height: 20px;
    }
}
