html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-left: 10px;
    padding: 6px 8px 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.18);
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.theme-toggle-track {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 78px;
    height: 40px;
    padding: 0 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.92) 100%);
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.08), inset 0 -8px 18px rgba(0, 0, 0, 0.25);
}

.theme-toggle-track::before {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18) 0%, rgba(15, 23, 42, 0.04) 100%);
    transition: opacity 0.35s ease, transform 0.45s ease;
}

.theme-toggle-icon {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 0.82rem;
    transition: color 0.35s ease, opacity 0.35s ease, transform 0.35s ease;
}

.theme-toggle-icon-sun {
    color: #fde68a;
    opacity: 0.75;
}

.theme-toggle-icon-moon {
    color: #cbd5f5;
    opacity: 1;
}

.theme-toggle-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.theme-toggle-thumb-core {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
    color: #0f172a;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.28);
    transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
}

.theme-toggle.is-light .theme-toggle-thumb {
    transform: translateX(38px);
}

.theme-toggle.is-light .theme-toggle-track {
    background: linear-gradient(135deg, #f59e0b 0%, #fcd34d 100%);
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.35), inset 0 -8px 20px rgba(217, 119, 6, 0.2);
}

.theme-toggle.is-light .theme-toggle-track::before {
    opacity: 0.8;
    transform: scale(1.02);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.38) 0%, rgba(254, 240, 138, 0.1) 100%);
}

.theme-toggle.is-light .theme-toggle-thumb-core {
    background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
    color: #f59e0b;
    box-shadow: 0 10px 22px rgba(251, 146, 60, 0.28);
}

.theme-toggle.is-light .theme-toggle-icon-sun {
    color: #ffffff;
    opacity: 1;
    transform: scale(1.05);
}

.theme-toggle.is-light .theme-toggle-icon-moon {
    color: rgba(255, 255, 255, 0.65);
    opacity: 0.55;
    transform: scale(0.9);
}

.theme-toggle:not(.is-light) .theme-toggle-icon-sun {
    opacity: 0.55;
    transform: scale(0.9);
}

.theme-toggle:not(.is-light) .theme-toggle-icon-moon {
    opacity: 1;
    transform: scale(1.05);
}

.theme-toggle-text {
    min-width: 42px;
    text-align: left;
    letter-spacing: 0.01em;
}

html[data-theme="light"] .theme-toggle {
    border-color: rgba(15, 23, 42, 0.2);
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    box-shadow: 0 16px 28px rgba(148, 163, 184, 0.22);
}

html[data-theme="light"] .theme-toggle:hover {
    background: #ffffff;
}

@media (max-width: 768px) {
    .theme-toggle {
        margin-left: 0;
        margin-top: 10px;
        align-self: center;
        justify-content: center;
        width: min(100%, 320px);
        box-sizing: border-box;
    }

    .theme-toggle-text {
        min-width: 38px;
    }
}

html.theme-animating body,
html.theme-animating .project-description,
html.theme-animating .upload-area,
html.theme-animating .file-list,
html.theme-animating .modal-content,
html.theme-animating .dropdown-menu,
html.theme-animating .auth-card,
html.theme-animating .settings-card,
html.theme-animating .mf-table-card,
html.theme-animating .mf-header,
html.theme-animating .settings-header,
html.theme-animating .sidebar,
html.theme-animating .content,
html.theme-animating .table-wrapper,
html.theme-animating .error-container,
html.theme-animating .theme-toggle,
html.theme-animating .theme-toggle-track,
html.theme-animating .theme-toggle-thumb,
html.theme-animating .theme-toggle-thumb-core,
html.theme-animating .feature-card,
html.theme-animating .content-card,
html.theme-animating .hero-card,
html.theme-animating .issue-item,
html.theme-animating .meta-card {
    transition: background 0.45s ease, background-color 0.45s ease, border-color 0.45s ease, color 0.45s ease, box-shadow 0.45s ease, opacity 0.45s ease, transform 0.45s ease !important;
}

html[data-theme="light"] body {
    background: linear-gradient(135deg, #f8fafc 0%, #e8eff8 100%) !important;
    color: #1f2937 !important;
}

html[data-theme="light"] body::before {
    background: linear-gradient(
        90deg,
        rgba(220, 38, 38, 0.05) 0%,
        rgba(220, 38, 38, 0.02) 15%,
        transparent 30%,
        transparent 70%,
        rgba(220, 38, 38, 0.02) 85%,
        rgba(220, 38, 38, 0.05) 100%
    ) !important;
}

html[data-theme="light"] body::after {
    opacity: 0.4 !important;
}

html[data-theme="light"] .side-decoration,
html[data-theme="light"] .corner-decoration {
    opacity: 0.35 !important;
}

html[data-theme="light"] a {
    color: #b91c1c !important;
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
    background: #ffffff !important;
    color: #111827 !important;
    border-color: #cbd5e1 !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
    color: #64748b !important;
}

html[data-theme="light"] .project-description,
html[data-theme="light"] .upload-area,
html[data-theme="light"] .file-list,
html[data-theme="light"] .modal-content,
html[data-theme="light"] .dropdown-menu,
html[data-theme="light"] .auth-card,
html[data-theme="light"] .settings-card,
html[data-theme="light"] .mf-card,
html[data-theme="light"] .mf-table-card,
html[data-theme="light"] .sidebar,
html[data-theme="light"] .content,
html[data-theme="light"] .table-wrapper,
html[data-theme="light"] .error-container {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #1f2937 !important;
    border-color: rgba(15, 23, 42, 0.12) !important;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.1) !important;
}

html[data-theme="light"] .dropdown-link,
html[data-theme="light"] .user-trigger,
html[data-theme="light"] .auth-buttons .ghost,
html[data-theme="light"] .btn.ghost,
html[data-theme="light"] .admin-btn.ghost {
    color: #1f2937 !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
    background: rgba(15, 23, 42, 0.05) !important;
}

html[data-theme="light"] .dropdown-link:hover,
html[data-theme="light"] .user-trigger:hover,
html[data-theme="light"] .btn.ghost:hover,
html[data-theme="light"] .admin-btn.ghost:hover {
    background: rgba(15, 23, 42, 0.1) !important;
}

html[data-theme="light"] .auth-buttons .solid {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(37, 99, 235, 0.2) !important;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28) !important;
}

html[data-theme="light"] .auth-buttons .solid:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.34) !important;
}

html[data-theme="light"] .subtitle,
html[data-theme="light"] .description,
html[data-theme="light"] .paste-hint,
html[data-theme="light"] .footer,
html[data-theme="light"] .footer p,
html[data-theme="light"] .dropdown-user-info span {
    color: #475569 !important;
}

html[data-theme="light"] table th {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #dbe3ef !important;
}

html[data-theme="light"] table td {
    color: #1f2937 !important;
    border-color: #e2e8f0 !important;
}

/* Strong global light-theme overrides for all pages */
html[data-theme="light"] body {
    background: linear-gradient(135deg, #eef2f8 0%, #e3ebf5 100%) !important;
    color: #1e293b !important;
}

html[data-theme="light"] body,
html[data-theme="light"] p,
html[data-theme="light"] span,
html[data-theme="light"] label,
html[data-theme="light"] li,
html[data-theme="light"] td,
html[data-theme="light"] th,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4,
html[data-theme="light"] h5,
html[data-theme="light"] h6,
html[data-theme="light"] small,
html[data-theme="light"] strong,
html[data-theme="light"] .empty {
    color: #1e293b !important;
}

html[data-theme="light"] h1,
html[data-theme="light"] .logo h1,
html[data-theme="light"] .auth-logo h1,
html[data-theme="light"] .settings-header h1,
html[data-theme="light"] .mf-header h1,
html[data-theme="light"] .section-header h1,
html[data-theme="light"] .section-header h2 {
    color: #b91c1c !important;
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
}

html[data-theme="light"] .container,
html[data-theme="light"] .settings-wrapper,
html[data-theme="light"] .mf-wrapper,
html[data-theme="light"] .content {
    color: #1e293b !important;
}

html[data-theme="light"] .project-description,
html[data-theme="light"] .upload-area,
html[data-theme="light"] .file-list,
html[data-theme="light"] .auth-card,
html[data-theme="light"] .settings-card,
html[data-theme="light"] .settings-header,
html[data-theme="light"] .mf-header,
html[data-theme="light"] .mf-filters,
html[data-theme="light"] .mf-table-card,
html[data-theme="light"] .table-wrapper,
html[data-theme="light"] .section-header,
html[data-theme="light"] .card,
html[data-theme="light"] .sidebar,
html[data-theme="light"] .dropdown-menu,
html[data-theme="light"] .modal-content,
html[data-theme="light"] .admin-modal,
html[data-theme="light"] .admin-modal-content,
html[data-theme="light"] .error-container {
    background: rgba(255, 255, 255, 0.94) !important;
    color: #1e293b !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12) !important;
    backdrop-filter: blur(8px) !important;
}

html[data-theme="light"] .modal,
html[data-theme="light"] .admin-modal-overlay {
    background: rgba(15, 23, 42, 0.35) !important;
}

html[data-theme="light"] .subtitle,
html[data-theme="light"] .description,
html[data-theme="light"] .footer p,
html[data-theme="light"] .footer,
html[data-theme="light"] .mf-header p,
html[data-theme="light"] .auth-card p.subtitle,
html[data-theme="light"] .settings-card p.description,
html[data-theme="light"] .dropdown-user-info span,
html[data-theme="light"] .file-delete-time span {
    color: #475569 !important;
}

html[data-theme="light"] .external-link,
html[data-theme="light"] .email-link,
html[data-theme="light"] a {
    color: #b91c1c !important;
}

html[data-theme="light"] .btn.primary,
html[data-theme="light"] .admin-btn.primary,
html[data-theme="light"] .upload-btn,
html[data-theme="light"] .copy-btn,
html[data-theme="light"] .copy-all-btn,
html[data-theme="light"] .toggle-history-btn,
html[data-theme="light"] .copy-link-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

html[data-theme="light"] .btn.secondary,
html[data-theme="light"] .admin-btn.secondary,
html[data-theme="light"] .btn.ghost,
html[data-theme="light"] .admin-btn.ghost,
html[data-theme="light"] .auth-buttons .ghost,
html[data-theme="light"] .dropdown-link,
html[data-theme="light"] .user-trigger,
html[data-theme="light"] .table-actions .ghost {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
}

html[data-theme="light"] .btn.danger,
html[data-theme="light"] .admin-btn.danger,
html[data-theme="light"] .delete-file-btn,
html[data-theme="light"] .clear-history-btn,
html[data-theme="light"] .table-actions .danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

html[data-theme="light"] .nav-item {
    color: #334155 !important;
}

html[data-theme="light"] .nav-item.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    color: #ffffff !important;
}

html[data-theme="light"] .role-badge,
html[data-theme="light"] .unverified-badge {
    background: rgba(30, 64, 175, 0.08) !important;
    color: #1e40af !important;
    border-color: rgba(30, 64, 175, 0.25) !important;
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="light"] .section-header input,
html[data-theme="light"] .section-header select,
html[data-theme="light"] .filter-group input,
html[data-theme="light"] .filter-group select,
html[data-theme="light"] .admin-form-input,
html[data-theme="light"] .auth-card input,
html[data-theme="light"] .settings-card input,
html[data-theme="light"] .settings-card textarea,
html[data-theme="light"] .modal input,
html[data-theme="light"] .modal textarea {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
    color: #64748b !important;
}

html[data-theme="light"] select option {
    background: #ffffff !important;
    color: #0f172a !important;
}

html[data-theme="light"] table th {
    background: #f8fafc !important;
    color: #0f172a !important;
    border-color: #dbe3ef !important;
}

html[data-theme="light"] table td,
html[data-theme="light"] table td *,
html[data-theme="light"] .table-actions button,
html[data-theme="light"] .db-table-content table th,
html[data-theme="light"] .db-table-content table td {
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}

/* Upload history area on main page */
html[data-theme="light"] .history-header {
    border-bottom-color: #cbd5e1 !important;
}

html[data-theme="light"] .history-header h4 {
    color: #1e40af !important;
}

html[data-theme="light"] .history-items-wrapper,
html[data-theme="light"] .history-item {
    background: #f8fafc !important;
    border-color: #dbe3ef !important;
}

html[data-theme="light"] .history-item:hover {
    background: #eef2f7 !important;
}

html[data-theme="light"] .file-name,
html[data-theme="light"] .batch-item .file-name,
html[data-theme="light"] .file-meta,
html[data-theme="light"] .file-date,
html[data-theme="light"] .file-delete-time,
html[data-theme="light"] .delete-file-description,
html[data-theme="light"] .delete-option-btn,
html[data-theme="light"] .delete-option-btn strong,
html[data-theme="light"] .delete-option-btn span {
    color: #1e293b !important;
}

html[data-theme="light"] .delete-option-btn {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

html[data-theme="light"] .delete-option-btn:hover {
    background: #eef2f7 !important;
    border-color: #94a3b8 !important;
}

/* Force-fix JS inline dark styles on light theme */
html[data-theme="light"] [style*="color: #fff"],
html[data-theme="light"] [style*="color:#fff"],
html[data-theme="light"] [style*="color: white"],
html[data-theme="light"] [style*="color:white"] {
    color: #1e293b !important;
}

html[data-theme="light"] [style*="background: rgba(15, 23, 42"],
html[data-theme="light"] [style*="background:rgba(15,23,42"],
html[data-theme="light"] [style*="background: rgba(17, 24, 39"],
html[data-theme="light"] [style*="background:rgba(17,24,39"],
html[data-theme="light"] [style*="background: linear-gradient(135deg, #1a1a2e"],
html[data-theme="light"] [style*="background:linear-gradient(135deg,#1a1a2e"] {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

html[data-theme="light"] .file-item,
html[data-theme="light"] .file-item * {
    color: #1e293b !important;
}
