*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg-color: #0a1020;
    --surface-color: #16213a;
    --surface-elevated: #1e2944;
    --border-color: #22305a;
    --primary-color: #38bdf8;
    --primary-muted: #227da9; 
    --primary-hover: #0ea5e9;
    --accent-color: #c084fc;
    --accent-hover: #a464e1;
    --text-primary: #f1f5fa;
    --text-secondary: #d8d8d8;
    --text-muted: #6b7fa7;
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.18);
    --radius: 0.8rem;
    --glow-color: rgba(56, 189, 248, 0.2);
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(180deg, #1a237e 0%, var(--bg-color) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow-x: hidden;
    min-width: 350px;
}

label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0; 
    padding-left: 10px;
}

.divider {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), var(--border-color), rgba(0, 0, 0, 0));
    margin: 1.5rem 0; 
}

header {
    background-color: var(--surface-color);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

header nav {
    position: static;
    transform: none;
    top: auto;
    right: auto;
}

.header-logo {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.1;
    white-space: normal;
    text-align: center;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.7); 
}

header nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 200ms ease-in-out;
    text-decoration: none;
}

header nav a:hover {
    color: var(--text-primary);
}

header nav a svg {
    height: 1.5rem;
    width: 1.5rem;
    margin-bottom: 0.25rem;
}

main {
    display: flex;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
}

.main-container {
    width: 100%;
    max-width: 900px;
    background: rgba(22, 33, 58, 0.92);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 0;
    margin-top: 0;
    margin-bottom: 3rem;
    min-height: 110vh;
    overflow: hidden;
}

.content-wrapper {
    padding: 1.5rem 1.5rem 0rem; 
}

.page-title {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.page-title.centered-title {
    text-align: center;
    margin: 0 auto 1.5rem auto; 
    padding-top: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.selection-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 100; /* Главный фикс перекрытия слоев */
}


.custom-dropdown-container {
    position: relative;
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: var(--text-secondary);
    position: relative;
}

.dropdown-header.active {
    border-color: var(--primary-color);
    position: relative;
    z-index: 1200;
}

.dropdown-header.disabled,
.dropdown-header.disabled-control,
.dropdown-header.disabled-button {
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

.dropdown-header .arrow {
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transition: transform 0.2s;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%) rotate(45deg); 
}

.dropdown-header.active .arrow {
    transform: translateY(-50%) rotate(225deg);
}

.dropdown-list {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    z-index: 100;
    padding: 0.5rem;
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
}

.dropdown-list::-webkit-scrollbar {
    width: 8px;
    background-color: transparent;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.dropdown-list.hidden {
    display: none;
}

.dropdown-header.with-search {
    padding: 0;
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    justify-content: space-between;
}

.dropdown-header .dropdown-search {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    outline: none;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.2;
    caret-color: var(--text-primary);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    pointer-events: none;
}

.dropdown-header .selected-value-placeholder {
    position: static;
    transform: none;
    font-size: 0.95rem;
    line-height: 1.2;
    color: var(--text-secondary);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex-grow: 1;
    z-index: 10;
    pointer-events: auto;
    transition: opacity 0.2s;
}

.dropdown-header.open .dropdown-search,
.dropdown-header.value-active .dropdown-search {
    opacity: 1;
    pointer-events: auto;
}

.dropdown-header.open .selected-value-placeholder,
.dropdown-header.value-active .selected-value-placeholder {
    opacity: 0;
    pointer-events: none;
}

.list-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.list-option:hover {
    background-color: var(--surface-color);
}

.option-image {
    width: 35px;
    height: 35px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
    align-self: center;
}

.option-text {
    font-size: 1.05rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.results-initial-hide {
    display: none !important;
}

.results-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    transition: opacity 0.4s ease-in-out; 
}

.results-grid.loading {
    opacity: 0.4;
    pointer-events: none;
}

.loading-container {
    display: none;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--text-primary);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.color-picker {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--accent-color);
    box-shadow: 0 0 0 3px #10182a;
    background: #fff;
    cursor: grab;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
    z-index: 20;
}
.color-picker.dragging {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.33);
    transform: scale(1.15) translate(-50%, -50%);
}

.picker-color-preview {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 4px #0008;
    pointer-events: none;
}

.target-color-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    padding-top: 2rem;
}

.color-swatch {
    width: 70px;
    height: 70px;
    border-radius: 0.7rem;
    border: 3px solid var(--border-color);
    background: #10182a;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    box-shadow: 0 2px 8px 0 rgba(56,189,248,0.08);
    position: relative;
    overflow: hidden;
}

.color-swatch-hex {
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    width: 90%;
    text-align: center;
    padding: 3px 0;
    font-size: 0.8rem;
    font-weight: 600;
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 5px;
}

.hidden {
    display: none !important;
}

.mode-switcher-container {
    width: 100%;
    background-color: transparent;
    padding: 0; 
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.mode-switcher {
    display: flex;
    background: transparent; 
    border-radius: 0;
    padding: 4px; 
    position: relative;
    box-shadow: none;
    height: auto;
    border: none;
}

.mode-switcher::before {
    content: '';
    position: absolute;
    top: 4px; bottom: 4px; left: 4px;
    width: calc((100% - 8px) / 3); 
    background: rgba(56, 189, 248, 0.15); 
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 8px;
    z-index: 1;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.mode-switcher[data-active-mode="findUniversal"]::before {
    transform: translateX(0%);
}
.mode-switcher[data-active-mode="findBgs"]::before {
    transform: translateX(100%);
}
.mode-switcher[data-active-mode="findModels"]::before {
    transform: translateX(200%);
}

.mode-switcher.mode-models::before {
    transform: translateX(100%);
    box-shadow: none;
    border-radius: 0;
}

.mode-switcher.mode-universal::before {
    transform: translateX(200%);
    box-shadow: -2px 0 15px -4px rgba(72, 97, 161, 0.7);
    border-radius: 0 var(--radius) var(--radius) 0;
}

#sort-switcher {
    grid-template-columns: 1fr 1fr;
    height: 2.5rem;
}
#sort-switcher::before {
    width: 50%;
    border-radius: var(--radius) 0 0 var(--radius);
}
#sort-switcher.sort-price::before {
    transform: translateX(100%);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.mode-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.2;
    font-weight: 600;
    padding: 12px 2px;
    z-index: 2;
    transition: color 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-tab.active {
    color: var(--text-primary); 
}

.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#picker-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 1.5rem; 
}

.gift-preview-container {
    position: relative;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.picker-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    width: 90%;
    height: 90%;
    border-radius: var(--radius);
}
.picker-image-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.color-swatch.placeholder {
    background: transparent;
    border-style: dashed;
}

#pickerPreviewImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
}


/* --- ОБНОВЛЕННЫЕ СТИЛИ КАРТОЧКИ (С ДВУМЯ ПЛАШКАМИ ВНИЗУ) --- */
.result-card-bg {
    border-radius: 16px;
    overflow: hidden;
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.result-card-bg:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.result-card-bg .image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10%; 
    box-sizing: border-box;
    z-index: 1;
}

.result-card-bg .model-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.4)); 
}

/* Градиент снизу вверх */
.result-card-bg .info-container {
    padding: 30px 14px 14px 14px; 
    margin-top: -20px; /* Плавный наплыв на картинку */
    position: relative;
    z-index: 2;
    background: linear-gradient(to top, rgba(14, 21, 38, 0.95) 20%, rgba(14, 21, 38, 0.6) 70%, transparent 100%);
    display: flex;
    flex-direction: column;
    gap: 12px; /* Расстояние между текстом и блоком плашек */
}

/* Текстовая часть (Название) */
.info-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center; /* Центрируем текст для красоты */
}

.info-collection {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.info-model {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* --- КОНТЕЙНЕР ПЛАШЕК --- */
.info-badges {
    display: flex;
    flex-direction: column; /* Стоят друг над другом */
    gap: 4px; /* Компактное расстояние */
    width: 100%;
}

.badge-percent, .badge-price {
    width: 100%;
    text-align: center;
    padding: 4px 0;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff; /* Белый текст */
    background: rgba(0, 0, 0, 0.4); /* Одинаковый черный фон */
    border: 1px solid rgba(255, 255, 255, 0.15); /* Одинаковая рамка */
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px; /* Расстояние между текстом и иконкой */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.badge-price svg {
    color: inherit;
    margin-top: -1px;
}

/* Верхняя плашка (Процент) */
.badge-percent {
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.result-card-bg .bg-name {
    font-size: 0.85rem; 
    font-weight: 500;
    color: var(--text-muted); 
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-card-bg .compat-value {
    font-size: 1.2rem; 
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0; 
}

.color-option .color-swatch-mini {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.monocolor-indicator {
    background-color: #f87171; 
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto; 
}

.monocolor-indicator svg {
    width: 14px;
    height: 14px;
    color: var(--text-primary); 
    stroke-width: 2.5; 
}

#monocolor-alert-wrapper {
    margin-bottom: 1.5rem;
}

.monocolor-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.4rem 1rem;
    background-color: rgba(248, 113, 113, 0.15); 
    border: 1px solid #f87171; 
    color: #f87171; 
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
}

.monocolor-alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.option-image, .model-image {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.option-image.loaded, .model-image.loaded {
    opacity: 1;
}

.loading-spinner-mini {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-muted);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.list-option .option-info-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden; 
}

.list-option .option-text {
    flex-grow: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-option .option-theme-count {
    font-size: 0.8rem; 
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
    text-align: left; 
    white-space: nowrap;
}

.list-option .option-floor-price {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    opacity: 0.75;
}

#model-themes-container {
    margin-top: 1rem; 
}

#show-themes-link {
    display: inline-flex; 
    align-items: center;
    gap: 0.5rem;
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    cursor: pointer;
}

#show-themes-link:hover {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.2);
}

#show-themes-link svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

#modal-themes-container {
    text-align: center;
    margin-top: 1rem; 
}

body.modal-open {
    overflow: hidden;
}

#modal-themes-container:empty {
    margin-top: 0;
    min-height: 0; 
}

#show-themes-link.similar-fallback-style {
    position: relative;
    overflow: hidden;
    justify-content: center; 
    gap: 0.6rem; 
    --similar-color: var(--primary-color);
}

#show-themes-link.similar-fallback-style > svg {
    display: none; 
}

#show-themes-link.similar-fallback-style span {
    color: var(--text-primary); 
}

#show-themes-link.similar-fallback-style:hover {
    border-color: var(--similar-color);
}

.fallback-glow {
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    box-shadow: inset 0 0 12px 3px var(--similar-color);
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1; 
}

#show-themes-link.similar-fallback-style:hover .fallback-glow {
    opacity: 1;
}

.fallback-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    opacity: 0.8;
    pointer-events: none;
    z-index: 2; 
}

#results-wrapper {
    background-color: transparent;
    box-shadow: none;
    /* margin - ВНЕШНИЙ отступ. Именно он отодвинет линию рамки от краев экрана */
    /* padding - ВНУТРЕННИЙ отступ. Задаст "воздух" между рамкой и самими карточками */
    padding: 2.5rem 12px 1.5rem 12px; 
    position: relative;
}

#results-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0; 
    right: 0;
    height: 100%;
    border-radius: 24px; 
    border: 2px solid #6b7fa7; 
    -webkit-mask-image: linear-gradient(to bottom, black 0px, black 1px, transparent 25px);
    mask-image: linear-gradient(to bottom, black 0px, black 1px, transparent 25px);
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

.results-header-label {
    position: absolute;
    top: 0; 
    left: 50%;
    transform: translate(-50%, -50%); 
    background-color: #16213a; 
    padding: 0 16px;
    font-size: 0.95rem;
    font-weight: 600; 
    color: #6b7fa7; 
    text-transform: none; 
    letter-spacing: normal;
    white-space: nowrap;
    z-index: 2;
}

.sub-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 16, 32, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10000; 
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sub-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.sub-modal {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.sub-modal-overlay.active .sub-modal {
    transform: scale(1);
}

.sub-icon {
    width: 100px;
    height: 100px;
    background: rgba(56, 189, 248, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    overflow: hidden;
}

.sub-icon svg {
    width: 32px;
    height: 32px;
}

.sub-icon.channel-avatar {
    background: transparent;
    border: 3px solid rgba(56, 189, 248, 0.3);
    padding: 0;
}

.sub-icon.channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sub-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
}

.sub-text {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.sub-btn {
    background: var(--primary-color);
    color: #0a1020;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    transition: filter 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sub-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.sub-btn.check-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    margin-top: -0.5rem;
}

.sub-btn.check-btn:hover {
    background: var(--surface-color);
}

header.safe-area-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px; 
    z-index: 10;
    background: linear-gradient(180deg, #0a1020 20%, rgba(10, 16, 32, 0) 100%);
    pointer-events: none;
    padding: 0;
    border: none;
    backdrop-filter: none;
}

header .header-logo, 
header nav {
    display: none;
}

main {
    padding-top: 100px; 
    padding-bottom: 80px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.sub-avatar-container {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem auto;
    border-radius: 50%;
    background: var(--surface-elevated);
    border: 3px solid var(--primary-color);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.3);
}

.sub-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sub-icon-fallback {
    color: var(--text-muted);
    width: 40px;
    height: 40px;
}

/* --- СТИЛИ УНИВЕРСАЛЬНОГО ФИЛЬТРА И ВЫПАДАЮЩИХ СПИСКОВ --- */

/* 1. Обновленный дизайн выпадающих списков (чтобы всегда были поверх всего) */
.dropdown-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: var(--surface-color); /* Плотный темный фон */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(56, 189, 248, 0.15); /* Глубокая тень и легкое свечение */
    z-index: 9999 !important; /* Жестко выводим на самый передний план */
    padding: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.dropdown-header {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.dropdown-header.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); /* Эффект фокуса */
}

/* Красивое выделение активного элемента списка */
.list-option.selected {
    background-color: rgba(56, 189, 248, 0.15);
    border-left: 3px solid var(--primary-color);
    border-radius: 8px;
}

.list-option.selected .option-text {
    color: var(--text-primary);
    font-weight: 700;
}

/* 2. Обертка фильтров с затухающей рамкой */
.filter-wrapper {
    background-color: rgba(22, 33, 58, 0.4);
    padding: 2.5rem 1.5rem 1.5rem 1.5rem;
    position: relative;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 1px 2px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
}

/* Врезанный заголовок */
.filter-header-label {
    position: absolute;
    top: 0; 
    left: 50%;
    transform: translate(-50%, -50%); 
    background-color: rgba(22, 33, 58, 1); /* Фон подложки, чтобы перекрыть границу */
    padding: 0 16px;
    font-size: 0.85rem;
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    letter-spacing: 1.5px;
    white-space: nowrap;
    z-index: 2;
    margin: 0;
}

/* 3. Строки фильтров и ИЕРАРХИЯ СЛОЕВ (Stacking Context) */
.filter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    position: relative;
}

/* САМОЕ ВАЖНОЕ: верхний ряд жестко "выше" нижних, чтобы списки падали поверх слайдеров и кнопок */
.dropdowns-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    z-index: 100;
}

.sorting-row {
    justify-content: flex-start;
    align-items: flex-end;
    z-index: 50; 
}

.filter-row-slider {
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
}

.sort-group-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.filter-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    padding-left: 4px;
}

.highlight-val {
    color: var(--text-primary);
    font-weight: 800;
}

/* 4. Переключатели сортировки (Новый объемный стиль) */
.mini-switcher {
    display: flex;
    background: rgba(0, 0, 0, 0.3); 
    padding: 4px;
    border-radius: 10px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    border: none;
}

.mini-tab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-align: center;
}
.mini-tab.active {
    background: var(--surface-elevated);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.direction-toggle-btn {
    background: rgba(0, 0, 0, 0.3);
    border: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    height: 100%;
}

.direction-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.direction-toggle-btn svg {
    transition: transform 0.3s ease;
}
.direction-toggle-btn.asc svg {
    transform: rotate(180deg);
}



/* 5. Слайдер */
.slider-header {
    margin-bottom: 12px;
}
.modern-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 8px;
    border-radius: 4px;
    outline: none;
    transition: background 0.1s;
}
.modern-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--glow-color);
}

/* 6. Кнопка Поиска */
.primary-search-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0284c7 100%);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.primary-search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(56, 189, 248, 0.5);
}

.primary-search-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}
/* 7. Адаптив для телефонов */
@media (max-width: 600px) {
    .dropdowns-row {
        grid-template-columns: 1fr;
    }
    .sorting-row {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sort-group-col {
        width: auto;
        flex-grow: 1;
    }
    .mini-tab {
        padding: 8px 12px;
    }
    .direction-toggle-btn {
        padding: 8px 12px;
    }
}