#posterView {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(40px, calc(env(safe-area-inset-top) + 28px)) 8px max(28px, calc(env(safe-area-inset-bottom) + 18px));
  border: none;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#posterView[open] {
  display: flex;
}

#posterView:focus,
#posterView :focus:not(:focus-visible) {
  outline: none;
}

#posterView::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

#posterViewBackdrop {
  position: absolute;
  inset: -20px;
  z-index: -1;
  pointer-events: none;
}

#posterViewBackdrop>div {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#posterViewBackdrop>div.active {
  opacity: 1;
}

#posterViewClose {
  position: fixed;
  top: max(6px, env(safe-area-inset-top));
  right: max(6px, env(safe-area-inset-right));
  z-index: 2;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.35;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: opacity 0.15s ease;
}

#posterViewClose:hover {
  opacity: 0.9;
}


#posterViewStage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, calc(60dvh * 2 / 3), 420px);
  flex: 0 0 auto;
  height: 60dvh;
  touch-action: pan-y;
}

#posterViewStage::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 35%;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

#posterViewTrending {
  z-index: 1;
}

#posterViewImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#posterViewCaption {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: min(100%, calc(60dvh * 2 / 3), 420px);
  flex-shrink: 0;
}

#posterViewTopInfo {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#posterViewBottomMeta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#posterViewBottomMeta[hidden] {
  display: none;
}

#posterViewMeta {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

#posterViewMeta>a {
  pointer-events: auto;
}

#posterViewStageBottom {
  position: absolute;
  inset: auto 12px 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 1;
  pointer-events: none;
}

#posterViewStageBottom>* {
  pointer-events: auto;
}

#posterViewEpisode {
  flex: 1 1 auto;
  min-width: 0;
  align-self: center;
  font-size: 0.95rem;
  padding: 6px 12px;
  color: #fff;
  opacity: 1;
  mix-blend-mode: difference;
}

@media (max-width: 720px) {
  #posterView {
    padding: 0;
    overflow: hidden;
  }

  #posterViewBackdrop {
    display: none;
  }

  #posterViewClose {
    display: none;
  }

  #posterViewStage {
    position: absolute;
    inset: max(110px, calc(env(safe-area-inset-top) + 60px)) 0 max(110px, calc(env(safe-area-inset-bottom) + 60px));
    width: auto;
    height: auto;
    aspect-ratio: unset;
    max-height: none;
    flex: none;
    overflow: hidden;
  }

  #posterViewStage::after {
    display: block;
    inset: 0;
    height: 100%;
    border-radius: 0;
    background: linear-gradient(to bottom, var(--bg) 0%, transparent 22%, transparent 78%, var(--bg) 100%);
  }

  #posterViewImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    box-shadow: none;
  }

  #posterView {
    --poster-pad-right: max(8px, env(safe-area-inset-right));
  }

  #posterViewCaption {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: auto;
    padding: max(20px, env(safe-area-inset-top)) var(--poster-pad-right) 20px max(20px, env(safe-area-inset-left));
    justify-content: flex-start;
    z-index: 2;
  }

  #posterViewMeta {
    order: 1;
    flex: none;
    min-height: 0;
    justify-content: flex-start;
    width: 100%;
  }

  #posterViewTagline {
    order: 2;
  }

  #posterViewBottomMeta {
    order: 4;
    display: block;
    align-self: stretch;
    margin-top: 20px;
    text-align: right;
  }

  #posterViewTopInfo {
    display: block;
  }

  #posterViewRating {
    display: block;
    margin-top: 4px;
  }

  #posterViewMetaInfo {
    display: block;
    margin-top: 4px;
  }

  #posterViewCaption>#posterViewTrending {
    order: 3;
    margin-top: 10px;
    align-self: flex-end;
  }

  #posterViewTitle {
    font-size: clamp(3.6rem, 11.5vw, 5.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 0.95;
    opacity: 0.75;
    text-shadow: 0 2px 32px rgba(0, 0, 0, 0.9), 0 1px 8px rgba(0, 0, 0, 0.8);
    margin-top: 0;
  }

  #posterViewYear {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.32em;
    color: rgba(255, 255, 255, 0.65);
    text-transform: none;
  }

  #posterViewGenres {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
  }

  #posterViewMetaInfo {
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.7);
    text-transform: none;
  }

  #posterViewTagline {
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
    font-size: clamp(0.95rem, 3.5vw, 1.25rem);
    color: rgba(255, 255, 255, 0.82);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
    margin-top: 4px;
  }

  #posterViewStageBottom {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: max(20px, env(safe-area-inset-left));
    top: auto;
    right: auto;
    width: auto;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 10px;
    z-index: 10;
  }

  #posterViewMark {
    order: -1;
    margin-left: 0;
    align-self: flex-start;
  }

  #posterViewEpisode {
    flex: 0 0 auto;
    padding: 0;
    text-align: left;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  }
}

#posterViewEpisode:empty {
  display: none;
}

#posterViewEpisode.one-left {
  color: #fff;
  font-weight: 700;
}

#posterViewTitleRow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

#posterViewTitleRow:empty {
  display: none;
}

#posterViewTitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  mix-blend-mode: difference;
}

#posterViewTitle {
  transition: opacity 0.15s ease;
}

#posterViewTitle[href]:hover {
  opacity: 1;
}

#posterViewTitle:empty {
  display: none;
}

#posterViewYear {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: #fff;
  mix-blend-mode: difference;
}

#posterViewYear:empty {
  display: none;
}

#posterViewTrending {
  padding: 4px 10px;
  font-size: 0.7rem;
  align-self: flex-start;
  margin-bottom: 8px;
}

#posterViewMetaInfo {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: #fff;
  mix-blend-mode: difference;
}

#posterViewMetaInfo:empty {
  display: none;
}

#posterViewGenres {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  mix-blend-mode: difference;
}

#posterViewRating {
  font-size: 0.72rem;
  font-weight: 500;
  color: #fff;
  mix-blend-mode: difference;
}

#posterViewRating:empty {
  display: none;
}

#posterViewGenres:empty {
  display: none;
}

#posterViewMark {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.2s;
}

#posterViewMark:hover {
  opacity: 1;
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.6);
}

#posterViewMark:disabled {
  opacity: 0.4;
  cursor: default;
}

#posterViewMark[hidden] {
  display: none;
}

#posterViewTagline {
  font-size: 0.9rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.35;
  color: #fff;
  mix-blend-mode: difference;
}

#posterViewTagline:empty {
  display: none;
}

#posterViewProgress {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.25);
}

#posterViewProgress>div {
  height: 100%;
  background: rgba(255, 255, 255, 0.55);
  width: var(--progress-pct, 0%);
  transition: width 0.4s ease;
}

@media (pointer: coarse) and (orientation: landscape) {
  #posterView {
    padding: 0;
    overflow: hidden;
  }

  #posterViewClose {
    display: none;
  }

  #posterViewBackdrop {
    inset: 0 max(80px, calc(env(safe-area-inset-right) + 24px)) 0 max(80px, calc(env(safe-area-inset-left) + 24px));
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 88%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 88%, transparent 100%);
  }

  #posterViewStage {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    aspect-ratio: unset;
    max-height: none;
    flex: none;
    overflow: hidden;
  }

  #posterViewStage::after {
    display: block;
    inset: 0;
    height: 100%;
    width: 100%;
    border-radius: 0;
    background: linear-gradient(to right, var(--bg) 0%, rgba(0, 0, 0, 0.55) 30%, transparent 55%);
  }

  #posterViewImg {
    display: none;
  }

  #posterViewCaption {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: max(220px, calc(env(safe-area-inset-left) + 140px));
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    justify-content: flex-start;
    z-index: 2;
  }

  #posterViewMeta {
    order: 1;
    flex: none;
    min-height: 0;
    width: 100%;
    justify-content: flex-start;
  }

  #posterViewTagline {
    order: 2;
  }

  #posterViewCaption>#posterViewTrending {
    order: 3;
  }

  #posterViewBottomMeta {
    order: 4;
    display: block;
    margin-top: auto;
  }

  #posterViewTopInfo {
    display: block;
  }

  #posterViewMetaInfo {
    display: block;
    margin-top: 4px;
  }

  #posterViewRating {
    display: block;
    margin-top: 4px;
  }

  #posterViewStageBottom {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    left: auto;
    bottom: auto;
    width: auto;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 10px;
    z-index: 10;
  }

  #posterViewProgress {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 2px;
    height: auto;
    background: rgba(255, 255, 255, 0.08);
  }

  #posterViewProgress>div {
    width: 100%;
    height: var(--progress-pct, 0%);
    background: rgba(255, 255, 255, 0.28);
    transition: height 0.4s ease;
  }
}

@media (min-width: 721px) and (pointer: fine) {
  #posterView {
    padding: 0;
    overflow: hidden;
  }

  #posterViewStage {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    flex: none;
  }

  #posterViewImg {
    display: none;
  }

  #posterViewStage::after {
    display: none;
  }

  #posterViewStageBottom {
    inset: auto max(28px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) auto;
    width: auto;
    gap: 16px;
  }

  #posterViewMark {
    margin-left: 0;
    align-self: flex-end;
  }

  #posterViewEpisode {
    flex: 0 1 auto;
    align-self: center;
    font-size: 1rem;
    letter-spacing: 0.1em;
    padding: 0;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: none;
    text-align: right;
    max-width: none;
    display: block;
    -webkit-line-clamp: unset;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s ease;
  }

  #posterViewEpisode:hover {
    color: #fff;
  }

  #posterViewEpisode.one-left {
    color: #fff;
    font-weight: 700;
  }

  #posterViewTagline {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.1rem, 1.9vw, 2.1rem);
    font-style: italic;
    font-weight: 400;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
    margin-top: 8px;
  }

  #posterViewCaption {
    position: absolute;
    top: max(28px, env(safe-area-inset-top));
    left: max(28px, env(safe-area-inset-left));
    right: calc(min(38%, 420px) + max(28px, env(safe-area-inset-right)));
    bottom: max(28px, env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    justify-content: flex-start;
    gap: 0;
    z-index: 1;
  }

  #posterViewBottomMeta {
    gap: 4px;
    margin-bottom: 16px;
  }

  #posterViewTitleRow #posterViewYear {
    order: -1;
  }

  #posterViewMeta {
    order: 2;
    flex: none;
    min-height: 0;
    justify-content: flex-start;
    gap: 0;
    max-width: 880px;
    width: 100%;
    margin-top: auto;
  }

  #posterViewCaption>#posterViewTrending {
    order: 1;
  }

  #posterViewTagline {
    order: 4;
  }

  #posterViewTitleRow {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  #posterViewYear,
  #posterViewMetaInfo,
  #posterViewGenres,
  #posterViewRating,
  #posterViewEpisode {
    mix-blend-mode: normal;
    paint-order: stroke fill;
    -webkit-text-stroke: 0.09em rgba(0, 0, 0, 0.85);
  }

  #posterViewTagline {
    mix-blend-mode: normal;
  }

  #posterViewTitle {
    font-size: clamp(3.5rem, 7.5vw, 6.4rem);
    line-height: 0.95;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-left: -0.05em;
    color: #fff;
    opacity: 0.55;
    mix-blend-mode: normal;
    text-shadow: 0 2px 32px rgba(0, 0, 0, 0.9), 0 1px 8px rgba(0, 0, 0, 0.8);
  }

  #posterViewYear {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.32em;
    color: rgba(255, 255, 255, 0.78);
    transition: color 0.15s ease;
  }

  #posterViewYear:hover {
    color: #fff;
  }

  #posterViewTopInfo {
    display: block;
  }

  #posterViewRating {
    display: block;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.88);
  }

  #posterViewMetaInfo {
    display: block;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.88);
    transition: color 0.15s ease;
    margin-top: 4px;
  }

  #posterViewMetaInfo:hover {
    color: #fff;
  }

  #posterViewGenres {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.88);
    transition: color 0.15s ease;
  }

  #posterViewGenres:hover {
    color: #fff;
  }
}

@media (max-width: 680px) {
  #posterViewEpisode {
    font-size: 1.1rem;
  }
}
