:root {
    --panel-width: 800px;
    color-scheme: dark;
    background: #050505;
    font-family:
        Poppins,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    scrollbar-color: #292929 #050505;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

body {
    min-height: 100vh;
    color: #f4f4f4;
    background: #050505;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

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

.eyebrow {
    margin: 0 0 10px;
    color: #999;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.ambient {
    position: fixed;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    background: #050505;
    contain: strict;
    isolation: isolate;
    pointer-events: none;
}

.ambient::after {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom, rgb(5 5 5 / 34%), rgb(5 5 5 / 58%)),
        radial-gradient(circle at center, transparent 0, rgb(5 5 5 / 24%) 68%);
    content: "";
}

.ambient__image {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(720px, 90vw);
    height: 62vh;
    object-fit: cover;
    object-position: center;
    filter: blur(48px) saturate(1.18);
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.46);
    transition: opacity 700ms ease;
    backface-visibility: hidden;
}

.ambient__image.is-active {
    opacity: 0.58;
}

.reader {
    position: relative;
    z-index: 1;
    width: min(800px, 100%);
    margin-inline: auto;
    overflow: hidden;
    background: #000;
}

.reader[hidden] {
    display: none;
}

/* Every panel and the complete strip use the confirmed 800px native width.
   Only the strip is scaled, preserving exact adjacency between panels. */
.strip {
    width: var(--panel-width);
    /* Scaled via CSS zoom in updateScale() — zoom participates in layout so
       the browser pixel-snaps in the zoomed coordinate system, eliminating
       subpixel seams between panels (unlike transform: scale which composites
       out-of-flow). line-height/font-size: 0 removes inline whitespace nodes. */
    line-height: 0;
    font-size: 0;
}

.strip img,
.panel-unavailable {
    display: block;
    width: var(--panel-width);
}

.strip img {
    height: auto;
    background: #0a0a0a;
}

.panel-unavailable {
    display: grid;
    place-items: center;
    padding: 80px;
    color: #c7c7c7;
    text-align: center;
    background:
        linear-gradient(135deg, rgb(255 255 255 / 3%), transparent 45%), #0b0b0b;
    /* Reset font values inherited from .strip's seam-fix rules. */
    font-size: 1rem;
    line-height: 1.5;
}

.panel-unavailable__content {
    width: min(520px, 100%);
}

.panel-unavailable strong {
    display: block;
    margin-bottom: 14px;
    color: #f2f2f2;
    font-size: 30px;
    font-weight: 600;
}

.panel-unavailable p {
    margin: 0 0 26px;
    color: #8d8d8d;
    font-size: 20px;
    line-height: 1.5;
}

.panel-unavailable button {
    padding: 13px 22px;
    color: #f5f5f5;
    background: #202020;
    border: 1px solid #363636;
    border-radius: 999px;
    cursor: pointer;
}

.viewer-state,
.noscript-state {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: grid;
    place-items: center;
    min-height: 100svh;
    padding: 24px;
    background:
        radial-gradient(
            circle at 50% 42%,
            rgb(90 32 50 / 16%),
            transparent 38%
        ),
        #050505;
    transition:
        opacity 260ms ease,
        visibility 260ms ease;
}

.viewer-state.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.viewer-state__card {
    width: min(420px, 100%);
    padding: clamp(30px, 7vw, 46px);
    text-align: center;
    background: linear-gradient(
        145deg,
        rgb(255 255 255 / 5%),
        rgb(255 255 255 / 2%)
    );
    border: 1px solid rgb(255 255 255 / 9%);
    border-radius: 24px;
    box-shadow: 0 28px 90px rgb(0 0 0 / 42%);
    backdrop-filter: blur(18px);
}

.viewer-state__mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 24px;
    color: #f7e9ed;
    font-size: 14px;
    font-weight: 750;
    letter-spacing: 0.08em;
    background: linear-gradient(145deg, #713348, #351923);
    border: 1px solid rgb(255 255 255 / 13%);
    border-radius: 16px;
    box-shadow: 0 12px 36px rgb(94 34 53 / 32%);
}

.viewer-state h1,
.noscript-state h1 {
    margin: 0;
    color: #f7f7f7;
    font-size: clamp(25px, 7vw, 34px);
    font-weight: 620;
    letter-spacing: -0.035em;
}

.viewer-state__detail {
    max-width: 310px;
    margin: 14px auto 0;
    color: #999;
    font-size: 15px;
    line-height: 1.65;
}

.viewer-state__loader {
    position: relative;
    width: 112px;
    height: 2px;
    margin: 30px auto 0;
    overflow: hidden;
    background: #242424;
    border-radius: 999px;
}

.viewer-state__loader span {
    position: absolute;
    inset: 0;
    width: 45%;
    background: linear-gradient(90deg, transparent, #bd6d88, transparent);
    animation: loading-sweep 1.15s ease-in-out infinite;
}

.viewer-state.is-error .viewer-state__loader {
    display: none;
}

.viewer-state__retry {
    margin-top: 28px;
    padding: 12px 22px;
    color: #f7f7f7;
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 999px;
    cursor: pointer;
    transition:
        background 150ms ease,
        border-color 150ms ease,
        transform 150ms ease;
}

.viewer-state__retry:hover {
    background: #2d2d2d;
    border-color: #4a4a4a;
}

.viewer-state__retry:active {
    transform: scale(0.97);
}

.viewer-state__retry:focus-visible,
.panel-unavailable button:focus-visible,
.episode-end__continue:focus-visible {
    outline: 2px solid #cf829c;
    outline-offset: 4px;
}

.episode-end {
    position: relative;
    z-index: 1;
    width: min(800px, 100%);
    min-height: 280px;
    margin-inline: auto;
    padding: clamp(54px, 10vw, 80px) clamp(24px, 7vw, 56px);
    text-align: center;
    background:
        radial-gradient(circle at 50% 0, rgb(113 51 72 / 14%), transparent 48%),
        #080808;
    border-top: 1px solid rgb(255 255 255 / 7%);
}

.episode-end h2 {
    margin: 0;
    color: #f3f3f3;
    font-size: clamp(24px, 6vw, 34px);
    font-weight: 600;
    letter-spacing: -0.035em;
}

.episode-end__detail {
    margin: 12px 0 0;
    color: #8e8e8e;
    font-size: 15px;
    line-height: 1.6;
}

.episode-end__continue {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: min(520px, 100%);
    margin: 34px auto 0;
    padding: 17px 18px 17px 22px;
    color: #f4f4f4;
    text-align: left;
    text-decoration: none;
    background: rgb(255 255 255 / 5%);
    border: 1px solid rgb(255 255 255 / 10%);
    border-radius: 18px;
    transition:
        background 180ms ease,
        border-color 180ms ease,
        transform 180ms ease;
}

.episode-end__continue:hover {
    background: rgb(255 255 255 / 8%);
    border-color: rgb(255 255 255 / 16%);
    transform: translateY(-2px);
}

.episode-end__continue small,
.episode-end__continue strong {
    display: block;
}

.episode-end__continue small {
    margin-bottom: 4px;
    color: #888;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.episode-end__continue strong {
    overflow: hidden;
    font-size: 15px;
    font-weight: 560;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.episode-end__arrow {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 38px;
    height: 38px;
    color: #f5dce4;
    background: #653044;
    border-radius: 12px;
}

.next-episode {
    --pull-progress: 0;
    position: fixed;
    z-index: 20;
    right: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: min(280px, calc(100% - 32px));
    padding: 12px 16px;
    overflow: hidden;
    color: #ddd;
    font-size: 14px;
    font-weight: 560;
    line-height: 1.4;
    text-align: center;
    background: rgb(24 24 24 / 94%);
    border: 1px solid rgb(255 255 255 / 12%);
    border-radius: 999px;
    box-shadow: 0 12px 34px rgb(0 0 0 / 36%);
    opacity: var(--pull-progress);
    transform: translate(50%, calc(24px * (1 - var(--pull-progress))));
    transition:
        opacity 120ms ease-out,
        transform 120ms ease-out;
    pointer-events: none;
}

.next-episode[hidden],
.episode-end[hidden],
.episode-end__continue[hidden],
.viewer-state__retry[hidden] {
    display: none;
}

.next-episode__label {
    position: relative;
    z-index: 1;
}

.next-episode__progress {
    position: absolute;
    inset: 0;
    background: rgb(255 255 255 / 10%);
    transform: scaleX(var(--pull-progress));
    transform-origin: left;
}

.next-episode.is-ready {
    color: #fff;
    background: rgb(42 26 32 / 96%);
    border-color: rgb(207 130 156 / 28%);
}

.next-episode.is-loading {
    --pull-progress: 1;
}

@keyframes loading-sweep {
    from {
        transform: translateX(-120%);
    }
    to {
        transform: translateX(280%);
    }
}

@media (max-width: 520px) {
    .viewer-state,
    .noscript-state {
        padding: 16px;
    }

    .viewer-state__card {
        border-radius: 20px;
    }

    .episode-end {
        min-height: 250px;
    }

}

@media (prefers-reduced-motion: reduce) {
    .ambient__image,
    .viewer-state,
    .viewer-state__retry,
    .episode-end__continue,
    .next-episode {
        transition: none;
    }

    .viewer-state__loader span {
        animation: none;
        transform: translateX(65%);
    }
}
