:root { color-scheme: light; }
html.dark { color-scheme: dark; }

.theme-floating-control {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(79, 70, 229, .3);
    border-radius: 50%;
    background: var(--bg-card, #fff);
    color: var(--accent, #4f46e5);
    box-shadow: 0 4px 16px rgba(15, 23, 42, .16);
    cursor: pointer;
}
.theme-floating-control:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(15, 23, 42, .2); }
html.dark .theme-floating-control { background: var(--bg-card, #1e293b); color: #fcd34d; border-color: #475569; }

.theme-menu {
    position: fixed;
    z-index: 100000;
    width: 224px;
    padding: 8px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1f2937);
    box-shadow: 0 16px 40px rgba(15, 23, 42, .22);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    animation: themeMenuIn .14s ease-out;
}

.theme-menu-heading {
    padding: 7px 9px 8px;
    color: var(--text-secondary, #64748b);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.theme-option {
    width: 100%;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 8px;
    padding: 9px 8px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.theme-option:hover,
.theme-option:focus-visible { background: var(--accent-light, #eef2ff); outline: none; }
.theme-option.is-selected { background: var(--accent-light, #eef2ff); color: var(--accent, #4f46e5); }
.theme-option-icon { display: flex; align-items: center; justify-content: center; font-size: .95rem; }
.theme-option strong { display: block; font-size: .82rem; line-height: 1.25; }
.theme-option small { display: block; margin-top: 2px; color: var(--text-secondary, #64748b); font-size: .65rem; line-height: 1.25; }
.theme-option-check { visibility: hidden; font-size: .72rem; }
.theme-option.is-selected .theme-option-check { visibility: visible; }

html.dark .theme-menu {
    border-color: var(--border-color, #334155);
    background: var(--bg-card, #1e293b);
    color: var(--text-primary, #e2e8f0);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .48);
}

@keyframes themeMenuIn {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@media print {
    .theme-menu, [data-theme-control] { display: none !important; }
}
