/* Главная в один экран: между шапкой и нижней навигацией, без вертикального скролла. */

html:has(body.home-fit),
body.home-fit {
    height: 100%;
    max-height: 100dvh;
    overflow: hidden !important;
}

body.home-fit {
    --home-top: 56px;
    --home-bottom: 0px;
    --home-orange: #ff6b00;
    --home-orange-soft: rgba(255, 107, 0, 0.18);
    background: #121212;
}

body.home-fit .bottom-nav-spacer,
body.home-fit .site-footer,
body.home-fit .footer-div,
body.home-fit .scrollup {
    display: none !important;
}

@media (max-width: 767px) {
    body.home-fit {
        --home-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 360px) {
    body.home-fit {
        --home-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 320px) {
    body.home-fit {
        --home-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
}

body.home-fit .popup-notice {
    bottom: calc(var(--home-bottom) + 16px);
    z-index: 1300;
}

.home-screen {
    position: fixed;
    z-index: 2;
    top: var(--home-top);
    right: 0;
    bottom: var(--home-bottom);
    left: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(900px 220px at 50% -80px, rgba(255, 107, 0, 0.2), transparent 70%),
        #121212;
}

.home-screen *,
.home-sheet *,
.home-rate * {
    max-width: none;
}

.home-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 20px 2px;
}

.home-login {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px 14px;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    background: rgba(255, 107, 0, 0.14);
    border: 1px solid rgba(255, 107, 0, 0.32);
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

.home-login strong {
    font-weight: 650;
    color: #ffb27a;
}

.home-tabs {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.home-tabs::-webkit-scrollbar {
    display: none;
}

.home-tab {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.home-tab svg {
    display: block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    flex: 0 0 18px;
    overflow: visible;
}

.home-tab span {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.home-tab.is-active {
    color: #fff;
    border-color: rgba(255, 107, 0, 0.65);
    background: linear-gradient(180deg, rgba(255, 107, 0, 0.34), rgba(255, 107, 0, 0.14));
    box-shadow: 0 8px 22px rgba(255, 107, 0, 0.16);
}

.home-tab.is-dragging {
    opacity: 0.55;
    transform: scale(0.96);
}

.home-screen[data-can-reorder="1"] .home-tab {
    cursor: grab;
}

.home-panels {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.home-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.home-panel[hidden] {
    display: none !important;
}

.home-panel-head {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 22px 12px;
}

.home-panel-head h1 {
    margin: 0;
    font-size: clamp(22px, 2vw, 32px);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.1;
}

.home-more {
    flex: 0 0 auto;
    color: #ffb27a;
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
}

.home-more:hover {
    color: #fff;
}

.home-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 18px 14px;
    container-type: size;
    container-name: homestage;
}

.home-stage.is-overflowing::before,
.home-stage.is-overflowing::after {
    content: '';
    position: absolute;
    z-index: 3;
    top: 0;
    bottom: 18px;
    width: 64px;
    pointer-events: none;
}

.home-stage.is-overflowing::before {
    left: 0;
    background: linear-gradient(to right, #121212 10%, transparent);
}

.home-stage.is-overflowing::after {
    right: 0;
    background: linear-gradient(to left, #121212 10%, transparent);
}

.home-stage.is-start::before,
.home-stage.is-end::after {
    opacity: 0;
}

.home-grid {
    --rows: 2;
    --gap: 14px;
    --poster-ratio: 0.667;
    height: 100%;
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
    grid-auto-columns: calc((100cqh - (var(--rows) - 1) * var(--gap)) / var(--rows) * var(--poster-ratio));
    justify-content: start;
    align-content: stretch;
    gap: var(--gap);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 2px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 107, 0, 0.45) transparent;
}

.home-grid[data-wide="1"] {
    grid-auto-columns: calc(((100cqh - (var(--rows) - 1) * var(--gap)) / var(--rows) * var(--poster-ratio)) + 230px);
}

@container homestage (min-height: 520px) and (min-width: 720px) {
    .home-grid {
        --rows: 3;
    }
}

@container homestage (min-height: 1080px) and (min-width: 1280px) {
    .home-grid {
        --rows: 4;
    }
}

.home-grid > * {
    min-width: 0;
    min-height: 0;
    max-width: none;
    scroll-snap-align: start;
}

.home-card,
.home-list {
    position: relative;
    height: 100%;
    border-radius: 18px;
    overflow: hidden;
    background: #1b1b1b;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
}

.home-card-link,
.home-list-link,
.home-friend-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.home-friend-link {
    display: flex;
    width: 100%;
    min-width: 0;
}

.home-card-link img,
.home-list-link img,
.home-friend-poster img {
    width: 100%;
    height: 100% !important;
    max-width: none !important;
    object-fit: cover;
    object-position: center center;
    display: block;
}

.home-card-meta,
.home-list-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 28px 10px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
    pointer-events: none;
}

.home-card-title,
.home-list-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.home-card-year,
.home-list-count {
    margin-top: 2px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.72);
}

.home-card-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
    overflow: hidden;
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    font-size: 12px;
    font-weight: 450;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.88);
    transition: max-height 0.22s ease, opacity 0.22s ease, margin-top 0.22s ease;
}

.home-card:hover .home-card-meta,
.home-card:focus-within .home-card-meta {
    padding-top: 56px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.94) 0%, rgba(0, 0, 0, 0.82) 48%, rgba(0, 0, 0, 0.28) 78%, transparent 100%);
}

.home-card:hover .home-card-desc,
.home-card:focus-within .home-card-desc,
.home-friend-poster:hover .home-card-desc,
.home-friend:focus-within .home-friend-poster .home-card-desc {
    max-height: 8.4em;
    margin-top: 6px;
    opacity: 1;
}

.home-badge {
    position: absolute;
    z-index: 2;
    top: 8px;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 750;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
}

.home-badge-kp {
    left: 8px;
}

.home-badge-user {
    left: 8px;
    top: 34px;
}

.home-badge.is-good { background: rgba(46, 160, 67, 0.92); }
.home-badge.is-mid { background: rgba(210, 140, 20, 0.94); }
.home-badge.is-bad { background: rgba(176, 42, 42, 0.94); }

.home-card-actions {
    position: absolute;
    z-index: 3;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.home-action {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(12, 12, 12, 0.72);
    backdrop-filter: blur(10px);
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.home-action svg {
    display: block;
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    max-width: 16px;
    flex: 0 0 16px;
    overflow: visible;
}

.home-action-score {
    display: none;
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
}

.home-action.is-on {
    background: var(--home-orange);
}

.home-action:hover,
.home-action:active {
    background: rgba(255, 107, 0, 0.82);
}

.home-action.is-on:hover,
.home-action.is-on:active {
    background: #ff8124;
}

.home-action[data-home-action="rate"].is-on .home-action-icon {
    display: none;
}

.home-action[data-home-action="rate"].is-on .home-action-score {
    display: block;
}

@media (hover: hover) and (pointer: fine) {
    .home-card-actions {
        opacity: 0;
        transform: translateY(-4px);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .home-card:hover .home-card-actions,
    .home-card:focus-within .home-card-actions,
    .home-friend:hover .home-card-actions,
    .home-friend:focus-within .home-card-actions {
        opacity: 1;
        transform: none;
    }
}

.home-arrow {
    position: absolute;
    z-index: 5;
    top: 50%;
    width: 46px;
    height: 46px;
    margin-top: -28px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(18, 18, 18, 0.82);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.home-arrow:hover {
    background: rgba(255, 107, 0, 0.9);
    border-color: transparent;
}

.home-arrow-prev { left: 14px; }
.home-arrow-next { right: 14px; }

.home-arrow[hidden] {
    display: none !important;
}

@media (max-width: 767px) {
    .home-toolbar {
        flex-wrap: wrap;
        padding: 8px 12px 0;
    }

    .home-tabs {
        order: 2;
        flex: 1 0 100%;
    }

    .home-login {
        order: 1;
        width: 100%;
        justify-content: space-between;
        white-space: normal;
    }

    .home-panel-head,
    .home-stage {
        padding-left: 12px;
        padding-right: 12px;
    }

    .home-arrow {
        display: none !important;
    }

    .home-card-actions {
        opacity: 1;
        transform: none;
    }

    .home-tab span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .home-tab {
        width: 42px;
        padding: 0;
    }
}

.home-friend {
    position: relative;
    height: 100%;
    display: flex;
    min-width: 0;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(180deg, #1c1c1c, #141414);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.home-friend-poster {
    position: relative;
    height: 100%;
    aspect-ratio: 2 / 3;
    flex: 0 0 auto;
    background: #111;
}

.home-friend-poster .home-card-desc {
    position: absolute;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 28px 8px 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0.2));
    pointer-events: none;
}

.home-friend-poster img {
    width: 100%;
    height: 100%;
}

.home-friend-body {
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 48px 10px 12px;
    overflow: hidden;
}

.home-friend-user {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.home-friend-avatar,
.home-friend-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex: 0 0 auto;
    object-fit: cover;
}

.home-friend-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 107, 0, 0.25);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.home-friend-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
}

.home-friend-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
}

.home-friend-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-friend-comment {
    margin: 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-friend .home-badge {
    top: auto;
    bottom: 8px;
    left: 8px;
}

.home-friend .home-card-actions {
    top: 6px;
    right: 6px;
    left: auto;
}

.home-empty {
    margin: auto;
    padding: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}

.home-empty a {
    color: #ffb27a;
}

.home-sheet,
.home-rate {
    position: fixed;
    z-index: 12000;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    padding: 0 0 var(--home-bottom, 0px);
    color: #fff;
    pointer-events: none;
}

.home-sheet[hidden],
.home-rate[hidden] {
    display: none !important;
}

.home-sheet-backdrop,
.home-rate-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.62);
    cursor: pointer;
    pointer-events: auto;
}

.home-sheet-card,
.home-rate-card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(480px, 100%);
    max-width: 100%;
    max-height: min(78dvh, 680px);
    min-height: 0;
    margin: 0;
    overflow: hidden;
    background: #171717;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
}

.home-sheet-head,
.home-sheet-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px;
}

.home-sheet-head h2 {
    margin: 0;
    font-size: 18px;
}

.home-sheet-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.home-sheet-close:hover,
.home-sheet-close:active {
    background: rgba(255, 255, 255, 0.14);
}

.home-sheet-head h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-sheet-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.home-sheet-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
}

.home-sheet-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-sheet-item input {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin: 0;
    accent-color: var(--home-orange);
}

.home-sheet-empty {
    padding: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.home-sheet-empty a {
    color: #ffb27a;
}

.home-sheet-save {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #ff8a2a, #ff6b00);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
}

.home-sheet-save:hover,
.home-sheet-save:active {
    background: linear-gradient(180deg, #ff9740, #ff7a1a);
}

.home-sheet-save:disabled {
    opacity: 0.6;
    cursor: default;
}

.home-rate-card {
    width: min(360px, 100%);
}

.home-rate-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 4px 16px 16px;
}

.home-rate-grid button {
    height: 44px;
    min-width: 0;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.home-rate-grid button:hover,
.home-rate-grid button:active {
    background: rgba(255, 107, 0, 0.35);
}

.home-rate-grid button.is-on,
.home-rate-grid button.is-on:hover,
.home-rate-grid button.is-on:active {
    background: var(--home-orange);
}

@media (min-width: 768px) {
    .home-sheet,
    .home-rate {
        align-items: center;
        padding: 24px;
    }

    .home-sheet-card,
    .home-rate-card {
        width: min(460px, calc(100vw - 48px));
        border-radius: 22px;
    }

    .home-card-title,
    .home-list-title {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-tab,
    .home-card-actions {
        transition: none;
    }
}
