/* Xexle TV */

html.tv-mode body {
    --tv-navigation-width: 230px;
    --tv-content-gap: 36px;
    --tv-edge: 28px;
    --tv-submenu-height: 64px;
    --tv-header-top: calc(var(--tv-edge) + var(--tv-submenu-height) + 12px);
    --tv-content-top: calc(var(--tv-header-top) + 70px);
    --body-padding-left: 0px;
    box-sizing: border-box;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--tv-content-top) var(--tv-edge) 64px calc(var(--tv-navigation-width) + var(--tv-content-gap)) !important;
    overflow-x: hidden;
    overscroll-behavior: none;
    scroll-padding-top: var(--tv-content-top);
}

.tv-mode #bottomMenu,
.tv-mode #bottomMenu_topButton,
.tv-mode #sidebarMenu,
.tv-mode .desktopMenu_overlay {
    display: none !important;
}

/* Эти вкладки уже представлены контекстным TV-подменю. DOM нужен search.js. */
.tv-mode .explore-primary_menu {
    display: none !important;
}

.tv-navigation,
.tv-submenu {
    display: none;
}

.tv-mode .tv-navigation {
    position: fixed;
    z-index: 70;
    inset: 0 auto 0 0;
    display: flex !important;
    flex-direction: column;
    box-sizing: border-box;
    width: var(--tv-navigation-width);
    padding: var(--tv-edge) 16px;
    border-right: 1px solid rgba(128, 128, 128, 0.18);
    text-align: left;
}

.tv-mode .tv-brand {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 12px;
    margin: 0 8px 28px;
    font-size: 1.5rem;
    font-weight: 700;
}

.tv-mode .tv-logo {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
}

.tv-mode .tv-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.4) transparent;
}

.tv-mode .tv-nav_button,
.tv-mode .tv-submenu_button,
.tv-mode .tv-action {
    box-sizing: border-box;
    min-height: 52px;
    padding: 12px 24px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
}

.tv-mode .tv-nav_button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    line-height: 1.3;
    text-align: left;
}

.tv-mode .tv-nav_button span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.tv-mode .tv-nav_icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.tv-mode .tv-nav_button-active,
.tv-mode .tv-submenu_button-active {
    box-shadow: inset 0 0 0 3px rgba(64, 155, 255, 0.72);
}

.tv-mode .tv-submenu {
    position: fixed;
    z-index: 70;
    top: var(--tv-edge);
    left: calc(var(--tv-navigation-width) + var(--tv-content-gap));
    right: var(--tv-edge);
    display: flex !important;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    height: var(--tv-submenu-height);
    padding: 6px 8px;
    border-radius: 14px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.4) transparent;
}

.tv-mode .tv-submenu:empty {
    display: none !important;
}

.tv-mode .tv-submenu_button {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 10px 18px;
    white-space: nowrap;
}

.tv-mode #header {
    position: fixed;
    z-index: 60;
    top: var(--tv-header-top);
    left: calc(var(--tv-navigation-width) + var(--tv-content-gap));
    right: var(--tv-edge);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 50px;
}

.tv-mode #header .top1,
.tv-mode #header .top2,
.tv-mode #header .top3 {
    position: static;
    min-width: 0;
}

.tv-mode #headerLeft {
    padding-left: 0 !important;
}

.tv-mode #headerCenter {
    flex: 1 1 auto;
}

.tv-mode #headerTitle {
    max-width: 100%;
}

.tv-mode #header .top_stylesCenter {
    transform: none;
    -webkit-transform: none;
}

.tv-mode .sections,
.tv-mode #tv_app {
    box-sizing: border-box;
    width: 100%;
    margin-top: 0 !important;
    padding: 0 !important;
    scroll-margin-top: var(--tv-content-top);
}

.tv-mode #tv_app {
    min-height: calc(100vh - var(--tv-content-top) - 64px);
    overflow: visible;
    text-align: left;
}

.tv-mode .tv-content {
    min-height: 420px;
}

.tv-mode .tv-page_title {
    margin: 0 0 24px;
    font-size: 2rem;
    line-height: 1.15;
}

.tv-mode .tv-page_body {
    min-width: 0;
}

.tv-mode .tv-message {
    display: table;
    margin: 30px 0;
    padding: 18px 24px;
    border-radius: 14px;
    font-size: 1.05rem;
}

.tv-mode .tv-account {
    display: flex;
    align-items: center;
    gap: 24px;
    box-sizing: border-box;
    width: min(100%, 720px);
    min-height: 146px;
    padding: 24px;
    border-radius: 18px;
}

.tv-mode :focus-visible {
    outline: 4px solid currentColor !important;
    outline-color: color-mix(in srgb, currentColor 24%, rgb(65, 174, 255)) !important;
    outline-offset: 4px;
    scroll-margin: 12px;
}

.tv-mode .tv-nav_button:focus-visible,
.tv-mode .tv-submenu_button:focus-visible,
.tv-mode .tv-card:focus-visible {
    position: relative;
    z-index: 1;
}

.tv-mode .tv-submenu_button:focus-visible {
    outline-offset: -4px;
}

.tv-mode .welcome_onboarding button:focus-visible {
    outline-width: 6px !important;
    outline-color: rgb(32, 130, 216) !important;
    outline-offset: 5px;
}

.tv-mode .tv-welcome_declined {
    box-sizing: border-box;
    width: min(760px, calc(100% - 100px));
    margin: auto;
    padding: 48px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.88);
    color: #263042;
    text-align: center;
}

.tv-mode .tv-welcome_declined h1 { margin: 0 0 20px; font-size: 2rem; }
.tv-mode .tv-welcome_declined p { margin: 12px 0; font-size: 1.15rem; line-height: 1.5; }

@media (max-width: 1100px), (max-height: 600px) {
    html.tv-mode body {
        --tv-navigation-width: 200px;
        --tv-content-gap: 28px;
        --tv-edge: 20px;
        --tv-submenu-height: 56px;
        --tv-header-top: calc(var(--tv-edge) + var(--tv-submenu-height) + 10px);
        --tv-content-top: calc(var(--tv-header-top) + 60px);
    }
    .tv-mode .tv-brand { margin: 0 6px 18px; font-size: 1.25rem; }
    .tv-mode .tv-logo { width: 40px; height: 40px; border-radius: 10px; }
    .tv-mode .tv-nav { gap: 4px; }
    .tv-mode .tv-nav_button { min-height: 44px; padding: 9px 10px; font-size: 0.95rem; gap: 10px; }
    .tv-mode .tv-nav_icon { width: 22px; height: 22px; }
    .tv-mode .tv-submenu_button { min-height: 44px; padding: 9px 14px; font-size: 0.95rem; }
    .tv-mode #header { min-height: 44px; }
}

@media (max-width: 800px) {
    html.tv-mode body { --tv-navigation-width: 180px; --tv-content-gap: 20px; --tv-edge: 16px; }

}


@media (max-width: 600px) {
    html.tv-mode body { --tv-navigation-width: 72px; --tv-content-gap: 14px; --tv-edge: 12px; }
    .tv-mode .tv-navigation { padding: 12px 6px; }
    .tv-mode .tv-brand { margin: 0 auto 14px; }
    .tv-mode .tv-brand span, .tv-mode .tv-nav_button span { display: none; }
    .tv-mode .tv-nav { padding: 6px; }
    .tv-mode .tv-nav_button { justify-content: center; padding: 10px; }
    .tv-mode .tv-account { flex-direction: column; align-items: flex-start; padding: 16px; }
}
