html.poster-dialog-open,
html.poster-dialog-open body {
    overflow: hidden;
}

dialog.poster-dialog {
    width: fit-content;
    min-width: min(88vw, 200px);
    max-width: min(92vw, 1100px);
    max-height: 95vh;
    max-height: 95dvh;
    margin: auto;
    padding: 0;
    border: 1px solid rgba(10, 42, 61, 0.16);
    border-radius: 18px;
    background: #ffffff;
    color: #0a2a3d;
    box-shadow: 0 24px 70px rgba(5, 24, 40, 0.35);
    overflow: hidden;
    overscroll-behavior: contain;
}

dialog.poster-dialog[open] {
    display: flex;
    flex-direction: column;
}

dialog.poster-dialog::backdrop {
    background: rgba(6, 22, 36, 0.72);
    backdrop-filter: blur(5px);
}

.poster-dialog [hidden] {
    display: none !important;
}

.poster-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex: 0 0 auto;
    padding: 0.35rem 0.6rem 0.35rem 0.8rem;
    background: #0a2a3d;
    color: #ffffff;
}

.poster-dialog-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.poster-dialog-title {
    margin: 0;
    font-family: 'Sora', 'Inter', sans-serif;
    font-size: 1.05rem;
    line-height: 1.3;
    color: #ffffff;
    overflow-wrap: anywhere;
}

.poster-dialog-status,
.poster-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.poster-dialog-status[data-kind="inactive"],
.poster-status-badge.is-inactive {
    background: #fff3cd;
    color: #7a5200;
}

.poster-dialog-close {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 999px;
    background: transparent;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.poster-dialog-close:hover,
.poster-dialog-close:focus-visible {
    background: #ffffff;
    color: #0a2a3d;
    outline: 3px solid #ffd166;
    outline-offset: 2px;
}

.poster-dialog-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: #eef6fa;
    overflow: hidden;
}

.poster-dialog-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(82vh, calc(95vh - 8rem));
    max-height: min(82dvh, calc(95dvh - 8rem));
    object-fit: contain;
}

.poster-dialog-fallback {
    margin: 0;
    padding: 2rem 1rem;
    text-align: center;
    color: #4e7a94;
    font-weight: 600;
}

.poster-dialog-footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.35rem 0.6rem;
    border-top: 1px solid #dce8f0;
    background: #ffffff;
}

.poster-dialog-cta {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.poster-media-unavailable {
    position: relative;
    display: block;
    cursor: default;
}

.poster-unavailable {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    display: block;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: rgba(10, 42, 61, 0.82);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}

.poster-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-width: 150px;
}

.poster-label {
    overflow-wrap: anywhere;
}

.poster-open-link {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem;
    color: #1d7fd8;
    font-weight: 700;
    text-decoration: none;
}

.poster-open-link .poster-label {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.poster-open-link .poster-open-action {
    padding: 0.12rem 0.42rem;
    border-radius: 999px;
    background: #e8f3ff;
    color: #0a4a77;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.poster-open-link:hover,
.poster-open-link:focus-visible {
    color: #0a4a77;
    outline: 2px solid #1d7fd8;
    outline-offset: 2px;
    border-radius: 4px;
}

.poster-status-badge.is-deleted {
    background: #fde8e8;
    color: #9b1c1c;
}

.poster-status-badge.is-unavailable {
    background: #eef3f8;
    color: #5f6f84;
}

.poster-empty {
    color: #8aa0b2;
}

@media (max-width: 640px) {
    dialog.poster-dialog {
        width: fit-content;
        max-width: 96vw;
        max-height: 94vh;
        max-height: 94dvh;
        border-radius: 12px;
    }

    .poster-dialog-header {
        padding: 0.3rem 0.5rem 0.3rem 0.65rem;
    }

    .poster-dialog-title {
        font-size: 0.95rem;
    }

    .poster-dialog-body {
        padding: 0.4rem;
    }

    .poster-dialog-image {
        max-height: min(78vh, calc(94vh - 7.5rem));
        max-height: min(78dvh, calc(94dvh - 7.5rem));
    }

    .poster-dialog-footer {
        padding: 0.3rem 0.5rem;
    }

    .poster-dialog-footer .poster-dialog-cta {
        width: 100%;
    }
}

@media (orientation: landscape) and (max-height: 560px) {
    dialog.poster-dialog {
        max-width: 96vw;
        max-height: 96vh;
        max-height: 96dvh;
    }

    .poster-dialog-header {
        padding: 0 0.6rem;
    }

    .poster-dialog-title {
        font-size: 0.95rem;
    }

    .poster-dialog-close {
        padding: 0 0.6rem;
    }

    .poster-dialog-body {
        padding: 0.15rem;
    }

    .poster-dialog-image {
        max-height: calc(96vh - 6rem);
        max-height: calc(96dvh - 6rem);
    }

    .poster-dialog-footer {
        padding: 0 0.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    dialog.poster-dialog {
        scroll-behavior: auto;
    }
}
