.theme-switcher-slot,
#theme-switcher-container {
    position: relative;
}

.theme-switcher-dropdown {
    position: relative;
}

.theme-switcher-btn-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--color-text-primary, #1e293b);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
    white-space: nowrap;
}

.theme-switcher-btn-nav:hover,
.theme-switcher-btn-nav[aria-expanded="true"] {
    background: var(--color-surface-alt, #f1f5f9);
}

.theme-switcher-emoji {
    font-size: 1rem;
    line-height: 1;
}

.theme-switcher-caret {
    width: 1rem;
    height: 1rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.theme-menu-container {
    position: absolute;
    right: 0;
    margin-top: 0.5rem;
    width: min(calc(100vw - 1.5rem), 20rem);
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid var(--color-border, #e2e8f0);
    background: var(--color-surface, #fff);
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.3);
    z-index: 1080;
}

.theme-menu-container.is-hidden {
    display: none;
}

.theme-menu-heading {
    padding: 0.5rem 0.75rem;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted, #94a3b8);
    border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.theme-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
    max-height: min(16rem, 55vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.625rem 0.5rem;
}

@media (min-width: 576px) {
    .theme-menu-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.theme-option {
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0.75rem;
    border: 1px solid var(--color-border, #e2e8f0);
    background: transparent;
    text-align: left;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.theme-option:hover {
    border-color: color-mix(in srgb, var(--color-primary, #0066cc) 35%, var(--color-border, #e2e8f0));
    background: var(--color-surface-alt, #f1f5f9);
}

.theme-option-active {
    border-color: var(--color-primary, #0066cc);
    background: var(--color-surface-alt, #f1f5f9);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-primary, #0066cc) 25%, transparent);
}

.theme-option-swatch {
    display: block;
    height: 0.5rem;
    width: 100%;
    flex-shrink: 0;
}

.theme-option-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.375rem 0.5rem;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-text-primary, #1e293b);
}

.theme-option-active .theme-option-name {
    color: var(--color-primary, #0066cc);
}

.theme-switcher-dropdown[data-stacked="1"] {
    width: 100%;
}

.theme-switcher-dropdown[data-stacked="1"] .theme-switcher-btn-nav {
    width: 100%;
    min-height: 44px;
    justify-content: space-between;
}

.theme-switcher-light,
.theme-switcher-end-wrap {
    --color-text-secondary: #475569;
    --color-text-primary: #0f172a;
    --color-surface-alt: #f1f5f9;
    --color-border: #e2e8f0;
    --color-surface: #ffffff;
    --color-text-muted: #94a3b8;
}

.theme-switcher-end-wrap {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.theme-switcher-end-wrap .theme-switcher-slot {
    flex: 1;
    min-width: 0;
}

@media (min-width: 768px) {
    .navbar-custom .active-theme-name {
        display: inline;
    }
}

@media (max-width: 767.98px) {
    .navbar-custom .active-theme-name {
        display: none;
    }
}
