.theme-palette-switcher {
    position: relative;
    z-index: 1065;
    flex: 0 0 auto;
}

.theme-palette-switcher.is-floating {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2070;
}

.theme-palette-toggle {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 10px;
    color: var(--ui-custom-text, #eef6ff);
    background: var(--ui-custom-control, #10223a);
    border: 1px solid var(--ui-custom-border, #31516f);
    border-radius: 9px;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.theme-palette-toggle:hover,
.theme-palette-toggle:focus-visible,
.theme-palette-switcher.is-open .theme-palette-toggle {
    color: var(--ui-custom-text, #ffffff);
    border-color: var(--ui-custom-accent, #22d3ee);
    outline: none;
}

.theme-palette-current-swatch {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 50%;
}

.theme-palette-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(390px, calc(100vw - 24px));
    max-height: min(72vh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px;
    color: var(--ui-custom-text, #f4f8fb);
    background: var(--ui-custom-panel, #0b1a2e);
    border: 1px solid var(--ui-custom-border, #334b68);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, .35);
}

.theme-palette-switcher.is-floating .theme-palette-menu {
    top: auto;
    right: 0;
    bottom: calc(100% + 8px);
}

.theme-palette-menu-header {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 2px 9px;
    color: var(--ui-custom-text, #f4f8fb);
    font-size: 13px;
    font-weight: 900;
}

.theme-palette-close {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: var(--ui-custom-muted, #b9c9d6);
    background: var(--ui-custom-control, #10223a);
    border: 1px solid var(--ui-custom-border, #334b68);
    border-radius: 8px;
    cursor: pointer;
}

.theme-palette-close:hover,
.theme-palette-close:focus-visible {
    color: var(--ui-custom-text, #ffffff);
    border-color: var(--ui-custom-accent, #22d3ee);
    outline: none;
}

.theme-palette-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.theme-palette-group-title {
    grid-column: 1 / -1;
    padding: 5px 2px 1px;
    color: var(--ui-custom-muted, #b9c9d6);
    font-size: 10px;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.theme-palette-group-title:not(:first-child) {
    margin-top: 5px;
    padding-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--ui-custom-border, #334b68) 70%, transparent);
}

.theme-palette-option {
    min-width: 0;
    min-height: 46px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    color: var(--ui-custom-text, #f4f8fb);
    background: var(--ui-custom-control, #10223a);
    border: 1px solid var(--ui-custom-border, #334b68);
    border-radius: 9px;
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}

.theme-palette-option:hover,
.theme-palette-option:focus-visible,
.theme-palette-option.is-active {
    border-color: var(--ui-custom-accent, #22d3ee);
    outline: none;
}

.theme-palette-option.is-active {
    background: var(--ui-custom-table-head, #17304a);
}

.theme-palette-swatches {
    display: inline-flex;
    align-items: center;
}

.theme-palette-swatches i {
    width: 12px;
    height: 12px;
    display: block;
    margin-left: -3px;
    background: var(--theme-swatch);
    border: 1px solid rgba(255, 255, 255, .48);
    border-radius: 50%;
}

.theme-palette-swatches i:first-child { margin-left: 0; }

.theme-palette-check {
    color: var(--ui-custom-accent, #22d3ee);
    opacity: 0;
}

.theme-palette-option.is-active .theme-palette-check { opacity: 1; }

.auth-header .auth-header-link { margin-left: auto; }
.auth-header .theme-palette-switcher { margin-left: 8px; }

@media (max-width: 560px) {
    .theme-palette-toggle-label { display: none; }
    .theme-palette-menu {
        position: fixed;
        top: auto;
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
    .theme-palette-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .theme-palette-switcher * { transition: none !important; }
}
