/* Library layout variants: 23 shelves, 35 carousel, 37 split (+ wall in pages-library-wall.css) */

.main-content:has(.sh-stage),
.main-content:has(.cr-stage),
.main-content:has(.ld-stage) {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

/* —— 23 shelves —— */
.sh-stage {
    overflow: auto;
    padding: 8px 24px 72px;
    background: var(--va-bg, #0b0d12);
    min-height: calc(100vh - 140px);
}

.sh-row {
    margin-bottom: 28px;
}

.sh-row h3 {
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--va-text-muted);
    margin: 0 0 10px;
}

.sh-track {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}

.sh-card {
    flex: 0 0 210px;
    height: 118px;
    border-radius: 14px;
    background-size: cover;
    background-position: center;
    background-color: #12151c;
    position: relative;
    border: 1px solid var(--va-border);
    cursor: pointer;
    color: #fff;
    text-align: left;
    padding: 0;
    overflow: hidden;
}

.sh-card:hover,
.sh-card.on {
    border-color: var(--va-accent);
    box-shadow: 0 8px 28px var(--va-glow);
}

.sh-card b {
    position: absolute;
    left: 10px;
    bottom: 10px;
    right: 10px;
    font-size: 0.82rem;
    text-shadow: 0 2px 10px #000;
    z-index: var(--z-base);
}

.sh-card .hrs {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 0.7rem;
    color: #fff;
    opacity: 0.85;
    z-index: var(--z-base);
}

.sh-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.7));
}

/* —— 35 carousel —— */
.cr-stage {
    min-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--va-bg, #08090d);
    overflow: hidden;
    padding: 12px 0 40px;
}

.cr-carousel-wrap {
    position: relative;
    padding-inline: 52px;
    min-height: 380px;
    display: flex;
    align-items: center;
}

.cr-track {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 36px max(4%, calc(50% - 120px));
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 50%;
    scroll-behavior: smooth;
    scrollbar-width: none;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}
.cr-track:has(.cr-card:nth-child(4)) {
    justify-content: flex-start;
}

.cr-track::-webkit-scrollbar {
    display: none;
}

/* Анимируем только transform/opacity: размеры и flex-basis дают дёрганый ререндер */
.cr-card {
    flex: 0 0 240px;
    height: 340px;
    border-radius: 18px;
    background-size: cover;
    background-position: center;
    background-color: #12151c;
    opacity: 0.45;
    transform: scale(0.86);
    transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1),
        opacity 0.28s ease,
        border-color 0.2s ease,
        box-shadow 0.28s ease;
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 0;
    scroll-snap-align: center;
}

.cr-card.on {
    opacity: 1;
    transform: scale(1.1);
    border-color: var(--va-accent);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    z-index: var(--z-base);
}

@media (prefers-reduced-motion: reduce) {
    .cr-card {
        transition: none;
    }
    .cr-track {
        scroll-behavior: auto;
    }
}

.cr-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 40px;
    height: 72px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.92;
    transition: opacity var(--transition-fast, 0.15s ease), background var(--transition-fast, 0.15s ease);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cr-carousel-wrap:hover .cr-nav-btn {
    opacity: 1;
}

.cr-nav-btn:hover {
    background: rgba(0, 0, 0, 0.82);
    border-color: rgba(255, 255, 255, 0.28);
}

.cr-nav-prev { left: 4px; }
.cr-nav-next { right: 4px; }

.cr-meta {
    text-align: left;
    margin-top: 18px;
    width: 100%;
    max-width: none;
    padding: 0 clamp(16px, 3vw, 40px);
    box-sizing: border-box;
}

.cr-meta h1 {
    font-family: var(--va-display, Syne, Inter, sans-serif);
    font-size: 2rem;
    letter-spacing: -0.04em;
    margin: 0 0 6px;
    color: var(--va-text);
}

.cr-meta .cr-sub {
    color: var(--va-text-muted);
    margin: 0;
}

/* legacy centered nav (unused) */
.cr-nav {
    display: none;
}

/* —— 37 list/detail —— */
.library-page--split .lw-toolbar {
    padding-bottom: 14px;
}

.ld-stage {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    min-height: calc(100vh - 140px);
    background: var(--va-bg, #0b0d12);
}

.ld-list {
    border-right: 1px solid var(--va-border);
    overflow: auto;
    padding: 12px 8px 28px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ld-row {
    width: 100%;
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    text-align: left;
    color: inherit;
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.ld-row:hover,
.ld-row.on {
    background: rgba(255, 255, 255, 0.06);
}

.ld-row .ic {
    width: 44px;
    height: 66px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    background-color: #12151c;
    flex-shrink: 0;
}

.ld-row .ld-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.ld-row .ld-hrs {
    color: var(--va-text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.ld-detail {
    position: relative;
    overflow: auto;
    min-height: 360px;
}

.ld-detail .bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.35);
    background-color: #12151c;
}

.ld-detail .in {
    position: relative;
    z-index: var(--z-base);
    padding: 48px 32px 32px;
    max-width: 560px;
}

.ld-detail .in h1 {
    font-family: var(--va-display, Syne, Inter, sans-serif);
    font-size: 2.4rem;
    letter-spacing: -0.04em;
    margin: 6px 0 0;
    color: #fff;
}

.ld-detail .in .ld-desc {
    color: color-mix(in srgb, #fff 82%, transparent);
    margin: 10px 0 18px;
    max-width: 42ch;
    line-height: 1.45;
}

.ld-detail .ld-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

body:has(.sh-stage) .app-footer,
body:has(.cr-stage) .app-footer,
body:has(.ld-stage) .app-footer {
    display: none;
}

/* Settings picker cards */
.uil-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.uil-card {
    text-align: left;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--va-border);
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 110px;
}

.uil-card:hover {
    border-color: color-mix(in srgb, var(--va-accent) 45%, var(--va-border));
}

.uil-card.on {
    border-color: var(--va-accent);
    background: color-mix(in srgb, var(--va-accent) 12%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--va-accent) 30%, transparent);
}

.uil-card strong {
    font-size: 0.95rem;
}

.uil-hint {
    font-size: 0.8rem;
    color: var(--va-text-muted);
    line-height: 1.35;
}

.uil-sketch {
    margin-top: auto;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--va-text-muted);
    opacity: 0.8;
}

@media (max-width: 900px) {
    .ld-stage { grid-template-columns: 1fr; }
    .ld-list { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--va-border); }
    .cr-carousel-wrap { padding-inline: 40px; min-height: 260px; }
    .cr-card { flex-basis: 160px; height: 220px; }
    .cr-nav-btn { width: 32px; height: 56px; font-size: 1.4rem; }
    .lib-shared-media { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
    .cr-meta .library-hub-grid { grid-template-columns: 1fr; }
}

@media (max-width: 639px) {
    .cr-carousel-wrap { padding-inline: 28px; min-height: 220px; }
    .cr-card { flex-basis: min(220px, 72vw); height: 200px; }
    .cr-meta h1 { font-size: clamp(1.1rem, 5vw, 1.4rem); }
}

/* —— Shared library action panel (all layouts) —— */
.lib-shared-panel {
    margin-top: 12px;
    border: 1px solid var(--va-border);
    border-radius: 20px;
    overflow: hidden;
    background: color-mix(in srgb, var(--va-bg-card) 70%, transparent);
}

.lib-shared-media {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 18px;
    padding: 18px;
    align-items: start;
}

.lib-shared-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 14px;
    background-size: cover;
    background-position: center;
    background-color: #12151c;
    border: 1px solid var(--va-border);
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.35));
    flex-shrink: 0;
}

.lib-shared-cover.is-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--va-accent) 22%, transparent), transparent 55%),
        linear-gradient(145deg, #151922 0%, #0c0e14 100%);
}

.lib-shared-cover-ph {
    font-family: var(--va-display, Syne, Inter, sans-serif);
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: color-mix(in srgb, var(--va-accent) 55%, var(--va-text-muted));
}

/* legacy hero kept for any cached HTML */
.lib-shared-hero {
    display: none;
}

.lib-shared-body {
    padding: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lib-shared-body .eyebrow {
    margin: 0;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--va-text-muted);
}

.lib-shared-body h2 {
    margin: 0;
    font-family: var(--va-display, Syne, sans-serif);
    font-size: 1.45rem;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.lib-shared-body .lw-meta {
    margin: 0;
    font-size: 0.85rem;
}

.lib-shared-body .lw-desc {
    margin: 4px 0 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: color-mix(in srgb, var(--va-text) 82%, var(--va-text-muted));
}

.lib-shared-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 10px 0 4px;
}

.lib-install-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.lib-install-controls .btn {
    width: 100%;
    justify-content: center;
}

.lib-shared-body .lw-actions--primary {
    flex-direction: column;
    align-items: stretch;
}

.lib-shared-body .lw-actions--primary .btn-primary,
.lib-shared-body .lw-actions--primary .btn-outline {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-weight: 600;
}

.lib-shared-body .library-web-hint {
    margin: 0;
    width: 100%;
}

.lib-shared-body .lw-actions--toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 0;
    border: 0;
    background: transparent;
}

.lib-shared-body .lw-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--va-border);
    background: color-mix(in srgb, var(--va-bg-card) 70%, transparent);
    color: var(--va-text);
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.lib-shared-body .lw-icon-btn:hover {
    border-color: var(--va-accent);
    color: var(--va-accent);
}

.lib-shared-body .lw-icon-btn.is-on {
    border-color: var(--va-accent);
    background: color-mix(in srgb, var(--va-accent) 18%, transparent);
    color: var(--va-accent);
}

.lib-shared-body .lw-more-wrap {
    position: relative;
    margin-left: auto;
}

.lib-shared-body .lw-more-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    padding: 6px;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--va-border);
    background: var(--va-bg-elevated, #171a21);
    box-shadow: var(--shadow-lg, 0 16px 40px rgba(0, 0, 0, 0.45));
    z-index: var(--z-dropdown, 40);
    display: none;
    flex-direction: column;
    gap: 2px;
}

.lib-shared-body .lw-more-wrap.open .lw-more-menu {
    display: flex;
}

.lib-shared-body .lw-more-menu .btn {
    width: 100%;
    justify-content: flex-start;
    border: 0;
    background: transparent;
    color: var(--va-text);
}

.lib-shared-body .lw-more-menu .btn:hover {
    background: color-mix(in srgb, var(--va-accent) 12%, transparent);
}

.lib-shared-body .lw-more-menu .btn-danger-text {
    color: #f87171;
}

.lib-shared-extra {
    padding: 0 18px 18px;
}

.ld-detail .lib-shared-panel {
    margin: 0;
    border: 0;
    border-radius: 0;
    min-height: 100%;
    background: transparent;
}

.ld-detail .lib-shared-media {
    padding: 28px 28px 12px;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 22px;
}

.cr-meta .lib-shared-panel {
    max-width: min(1280px, calc(100% - 32px));
    width: 100%;
    margin: 0 auto;
}

.cr-meta .library-hub-grid {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.cr-meta .library-game-hub-host {
    padding-inline: 0;
}

.ld-detail {
    min-height: 280px !important;
}
