.tb-cinema {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;
  padding: 0;
  overflow: auto;
  color: #f5f5f7;
  background: #18191c;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 28px 100px rgba(0,0,0,.6);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  color-scheme: dark;
}
.tb-cinema::backdrop { background: rgba(4,8,14,.56); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.tb-cinema-header { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 54px; }
 .tb-cinema-close { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: #e6eef2; width: 28px; height: 28px; padding: 0; cursor: pointer; touch-action: manipulation; }
.tb-cinema-close::before, .tb-cinema-close::after { content: ''; position: absolute; width: 18px; height: 1.8px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
.tb-cinema-close::after { transform: rotate(-45deg); }
.tb-cinema-close:hover { background: rgba(255,255,255,.08); }
.tb-cinema-close:active { opacity: .65; }
@media (pointer: coarse) { .tb-cinema-close { width: 44px; height: 44px; right: 4px; } }

.tb-cinema-heading { margin: 0; flex: 1; text-align: center; font-size: 13px; font-weight: 600; }
.tb-cinema-count { position: absolute; left: 18px; color: #aaaab2; font-size: 11px; }
.tb-cinema-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 200px; max-height: calc(100dvh - 260px); background: #000; }
.tb-cinema-stage iframe { display: block; position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tb-cinema-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; box-sizing: border-box; min-height: inherit; height: 100%; padding: 28px; text-align: center; background: #111215; }
.tb-cinema-placeholder-title { margin: 0; font-size: clamp(18px, 2.5vw, 25px); font-weight: 600; letter-spacing: -.025em; }
.tb-cinema-placeholder-copy { margin: 0; max-width: 420px; color: #a5a6ae; font-size: 14px; line-height: 1.6; }
.tb-cinema-placeholder-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 18px; margin-top: 6px; }
.tb-cinema-placeholder-actions .tb-cinema-link { margin-left: 0; }
.tb-cinema-details { padding: 18px 22px 20px; }
.tb-cinema-meta { display: flex; align-items: center; gap: 12px; color: #b0b0ba; font-size: 11px; margin-bottom: 7px; }
.tb-cinema-city { color: #f5f5f7; font-weight: 600; letter-spacing: .03em; }
.tb-cinema-title { margin: 0 0 5px; font-size: 19px; font-weight: 600; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-cinema-credit { color: #aaaab2; font-size: 12px; }
.tb-cinema-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.tb-cinema button:not(.tb-cinema-close), .tb-cinema-select { min-height: 34px; border: 1px solid #44454b; border-radius: 8px; background: #292a30; color: #f5f5f7; padding: 6px 13px; font: inherit; font-size: 12px; }
.tb-cinema button:not(.tb-cinema-close) { cursor: pointer; }
.tb-cinema button:disabled { opacity: .45; cursor: default; }
.tb-cinema button:hover:not(:disabled):not(.tb-cinema-close) { background: #3a3b43; }
.tb-cinema button:focus-visible, .tb-cinema a:focus-visible, .tb-cinema select:focus-visible { outline: 2px solid #73b5ff; outline-offset: 3px; }
.tb-cinema-select { flex: 1; min-width: 140px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.tb-cinema-link { margin-left: auto; font-size: 12px; color: #a7cfff; text-decoration: none; white-space: nowrap; }
.tb-cinema-link:hover { text-decoration: underline; }
.tb-cinema-status { margin: 12px 0 0; min-height: 17px; color: #aaaab2; font-size: 12px; }

/* Same-origin cover paints while the official player connects or buffers.
   It is the stage background, never a layer over YouTube's controls. */
.tb-cinema-stage { background-size: cover; background-position: center; }
.tb-cinema[data-playback="loading"] .tb-cinema-stage iframe,
.tb-cinema[data-playback="buffering"] .tb-cinema-stage iframe { visibility: hidden; }
.tb-cinema[data-playback="loading"] .tb-cinema-placeholder { background: transparent; }
.tb-cinema[data-playback="loading"] .tb-cinema-placeholder-title,
.tb-cinema[data-playback="loading"] .tb-cinema-placeholder-copy { background: rgba(0,0,0,.65); padding: 8px 12px; border-radius: 8px; }

/* Cinematic reference treatment, scoped entirely to the YouTube popup. */
.tb-cinema { display: grid; grid-template-columns: 250px minmax(0,1fr); background-size: cover; background-position: center; border-radius: 16px; border-color: rgba(255,255,255,.12); }
.tb-cinema:not([open]) { display: none; }
.tb-cinema-header { grid-column: 1 / -1; min-height: 100px; padding: 24px 64px 22px 28px; background: linear-gradient(90deg,rgba(0,0,0,.95),rgba(0,0,0,.72)); box-sizing: border-box; }
.tb-cinema-heading { position: absolute; right: 64px; top: 28px; flex: none; font-size: 12px; font-weight: 400; color: #ddd; }
.tb-cinema-count { position: absolute; left: auto; right: 64px; top: 48px; font-size: 10px; color: #aaa; }
.tb-cinema-watching { min-width: 0; max-width: 78%; }
.tb-cinema-eyebrow { display: block; margin-bottom: 7px; color: #a7a7a7; font-size: 12px; }
.tb-cinema-headline { margin: 0; font-size: clamp(18px,2vw,24px); font-weight: 600; letter-spacing: -.025em; line-height: 1.25; }
.tb-cinema-close { right: 20px; top: 28px; transform: none; }
.tb-cinema-stage { grid-column: 2; grid-row: 2; min-height: 200px; max-height: none; align-self: center; }
.tb-cinema-queue { grid-column: 1; grid-row: 2; padding: 26px 18px 24px 28px; box-sizing: border-box; background: linear-gradient(90deg,rgba(0,0,0,.95),rgba(0,0,0,.83)); }
.tb-cinema-queue-heading { margin: 0 0 22px; font-size: 14px; font-weight: 600; }
.tb-cinema-queue-list { display: grid; gap: 18px; }
.tb-cinema button.tb-cinema-queue-item { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 0; background: transparent; text-align: left; }
.tb-cinema-queue-item img { width: 65px; height: 65px; border-radius: 6px; object-fit: cover; flex: 0 0 65px; }
.tb-cinema-queue-copy { display: grid; gap: 7px; min-width: 0; }
.tb-cinema-queue-copy strong { font-size: 13px; line-height: 1.4; font-weight: 400; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tb-cinema-queue-copy > span { font-size: 11px; color: #aaa; }
.tb-cinema-queue-item:nth-child(3) { opacity: .45; }
.tb-cinema button.tb-cinema-queue-item:hover { background: transparent; opacity: .8; }
.tb-cinema-details { grid-column: 1 / -1; padding: 20px 28px; background: linear-gradient(90deg,rgba(0,0,0,.95),rgba(0,0,0,.8)); }
.tb-cinema-title { display: none; }
.tb-cinema-credit { margin-top: 8px; font-size: 11px; }
.tb-cinema-meta { margin: 0; }
.tb-cinema-actions { margin-top: 16px; }
.tb-cinema button:not(.tb-cinema-close):not(.tb-cinema-queue-item), .tb-cinema-select { border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.07); }
.tb-cinema-link { color: #eee; }
.tb-cinema-status { font-size: 11px; color: #999; }
.tb-cinema-header, .tb-cinema-stage, .tb-cinema-queue, .tb-cinema-details { min-width: 0; }
/* Pinned reference: one immersive frame, floating title and queue. */
.tb-cinema { position: fixed; width: min(960px,calc(100vw - 48px),calc((100dvh - 48px) * 16 / 9)); max-width: none; aspect-ratio: 16 / 9; max-height: calc(100dvh - 48px); display: block; isolation: isolate; overflow: hidden; background-color: #111214; border-radius: 28px; }
.tb-cinema:not([open]) { display: none; }
.tb-cinema-stage { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; max-height: none; }
.tb-cinema-stage iframe { width: 100%; height: 100%; }
.tb-cinema::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(90deg,rgba(0,0,0,.8),rgba(0,0,0,.22) 38%,transparent 64%),linear-gradient(180deg,rgba(0,0,0,.45),transparent 24%,transparent 68%,rgba(0,0,0,.85)); }
.tb-cinema-header { position: absolute; z-index: 2; top: 0; left: 0; right: 0; min-height: 0; padding: 26px 62px 0 26px; background: none; pointer-events: none; }
.tb-cinema-header button { pointer-events: auto; }
.tb-cinema-watching { max-width: 72%; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.tb-cinema-headline { font-size: clamp(18px,2.1vw,27px); }
.tb-cinema-eyebrow { color: #c4c4c4; margin-bottom: 12px; font-size: 13px; }
.tb-cinema-heading { top: 30px; right: 66px; font-size: 15px; color: #f2f2f2; }
.tb-cinema-count { top: 54px; right: 66px; color: #ccc; }
.tb-cinema-close { top: 24px; right: 22px; }
.tb-cinema-queue { position: absolute; z-index: 2; left: 26px; top: 28%; width: 290px; padding: 0; background: none; }
.tb-cinema-queue-heading { font-size: 16px; margin-bottom: 24px; }
.tb-cinema-queue-list { gap: 14px; }
.tb-cinema-queue-item img { width: 78px; height: 78px; flex-basis: 78px; object-fit: cover; }
.tb-cinema-queue-copy strong { font-size: 16px; line-height: 1.3; font-weight: 400; text-shadow: 0 1px 8px #111; }
.tb-cinema-queue-copy > span { font-size: 12px; color: #ddd; }
.tb-cinema-queue-item:nth-child(3) { opacity: .5; }
.tb-cinema-details { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 16px 26px 18px; background: linear-gradient(0deg,rgba(0,0,0,.9),rgba(0,0,0,.45),transparent); }
.tb-cinema-meta { justify-content: space-between; font-size: 11px; color: #ddd; }
.tb-cinema-city { font-size: 14px; }
.tb-cinema-credit { display: none; }
.tb-cinema-actions { margin-top: 12px; gap: 14px; }
.tb-cinema button:not(.tb-cinema-close):not(.tb-cinema-queue-item) { background: transparent; border-color: transparent; padding: 4px 8px; }
.tb-cinema-select { max-width: 260px; background: rgba(0,0,0,.32); }
.tb-cinema-status { margin: 5px 0 0; font-size: 10px; color: #ccc; }
.tb-cinema :is(button,a,select):focus-visible { outline-color: #f4f4f4; }
/* Controls overlay the full-size player; no space is reserved beneath it. */
.tb-cinema-stage { inset: 0; height: 100%; }
.tb-cinema-queue { top: 26%; }

/* Fade the whole chrome together without moving or resizing the video. */
.tb-cinema-header, .tb-cinema-queue, .tb-cinema-details, .tb-cinema::after {
  transition: opacity 180ms ease-out, visibility 180ms;
}
.tb-cinema[data-chrome="hidden"] :is(.tb-cinema-header, .tb-cinema-queue, .tb-cinema-details),
.tb-cinema[data-chrome="hidden"]::after {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.tb-cinema-wake { display: none; position: absolute; inset: 0; z-index: 3; }
.tb-cinema[data-chrome="hidden"] .tb-cinema-wake { display: block; }
@media (prefers-reduced-motion: reduce) {
  .tb-cinema-header, .tb-cinema-queue, .tb-cinema-details, .tb-cinema::after { transition: none; }
}
.tb-cinema-queue-item img { width: 68px; height: 68px; flex-basis: 68px; }
.tb-cinema-queue-list { gap: 12px; }
/* Temporary loading preview; playback always occupies the complete popup. */
.tb-cinema-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; pointer-events: none; display: none; }
.tb-cinema[data-playback="loading"] .tb-cinema-preview { display: block; }
.tb-cinema-stage .tb-cinema-placeholder { position: relative; z-index: 1; }
.tb-cinema[data-playback="loading"] .tb-cinema-placeholder { background: transparent; }
/* Keep the selection row clear of the player's progress controls. */
.tb-cinema-actions { margin-top: 24px; }
.tb-cinema-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 45px 8px 16px;
  background-image: url('../assets/icons/select-chevron.svg');
  background-repeat: no-repeat;
  background-position: right 17px center;
  background-size: 12px 8px;
}
@media (forced-colors: active) {
  .tb-cinema-select { appearance: auto; background-image: none; }
}

/* Lower the control row relative to the embedded player seek bar. */
.tb-cinema-details { padding-bottom: 3px; }

@media (pointer: coarse) {
  .tb-cinema-close,
  .tb-cinema button:not(.tb-cinema-queue-item),
  .tb-cinema-select { min-height: 44px; }
  .tb-cinema-close { width: 44px; height: 44px; }
  .tb-cinema-link { display: inline-flex; align-items: center; min-height: 44px; }
}

/* Square player frame with the desktop widgets' frosted-glass material. */
.tb-cinema {
  border-radius: 0;
  background: rgba(28, 28, 30, 0.55);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}
.tb-cinema-details {
  background: rgba(28, 28, 30, 0.55);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
}
.tb-cinema-select {
  background-color: rgba(28, 28, 30, 0.55);
  border-color: rgba(255, 255, 255, 0.14);
}
@media (prefers-reduced-transparency: reduce) {
  .tb-cinema, .tb-cinema-details { background-color: #1c1c1e; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Mobile keeps our controls outside the native YouTube player. */
@media (max-width: 768px), (max-width: 1024px) and (max-height: 500px) {
  .tb-cinema {
    --cinema-surface: #1c1c1e;
    --cinema-text: #f5f5f7;
    --cinema-border: rgba(255, 255, 255, .14);
    width: min(640px, calc(100vw - 32px));
    height: fit-content;
    aspect-ratio: auto;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--cinema-surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tb-cinema::after, .tb-cinema[data-chrome="hidden"] .tb-cinema-wake { display: none; }
  .tb-cinema-count, .tb-cinema-watching, .tb-cinema-queue,
  .tb-cinema-meta, .tb-cinema-status, .tb-cinema-actions > .tb-cinema-link { display: none; }
  .tb-cinema-header, .tb-cinema-details,
  .tb-cinema[data-chrome="hidden"] :is(.tb-cinema-header, .tb-cinema-details) {
    position: relative;
    inset: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: none;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tb-cinema-header { min-height: 48px; padding: 0 56px 0 16px; }
  .tb-cinema-heading {
    display: block;
    position: static;
    font-size: 14px;
    font-weight: 600;
    color: var(--cinema-text);
    text-align: left;
  }
  .tb-cinema-close {
    top: 2px;
    right: 4px;
    width: 44px;
    height: 44px;
    transform: none;
    -webkit-tap-highlight-color: transparent;
  }
  .tb-cinema .tb-cinema-close:is(:focus, :focus-visible) { outline: none; }
  .tb-cinema-stage { position: relative; inset: auto; height: auto; min-height: 0; aspect-ratio: 16 / 9; }
  .tb-cinema-details { padding: 12px; }
  .tb-cinema-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 0; }
  .tb-cinema-select {
    grid-column: 1;
    grid-row: 1;
    order: initial;
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 44px;
    padding: 8px 32px 8px 12px;
    font-size: 16px;
    color: var(--cinema-text);
    background-color: transparent;
    background-position: right 12px center;
    border-color: var(--cinema-border);
  }
  .tb-cinema-actions > button:not(.tb-cinema-retry) { grid-column: 2; grid-row: 1; min-height: 44px; padding: 8px; font-size: 14px; }
  .tb-cinema-actions > .tb-cinema-retry { grid-column: 1; grid-row: 2; min-height: 44px; }
  .tb-cinema[data-playback="unavailable"] .tb-cinema-actions > .tb-cinema-link { display: inline-flex; grid-column: 2; grid-row: 2; min-height: 44px; align-items: center; font-size: 12px; }
  .tb-cinema[data-playback="unavailable"] .tb-cinema-status { display: block; margin: 8px 0 0; color: var(--cinema-text); }
  .tb-cinema-placeholder { padding: 16px; gap: 8px; }
  .tb-cinema-placeholder-title { font-size: 16px; }
  .tb-cinema-placeholder-copy { font-size: 12px; }
}

@media (max-width: 1024px) and (max-height: 500px) {
  .tb-cinema {
    width: min(640px, calc(100vw - 32px), max(288px, calc((100dvh - 150px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 16 / 9 + 2px)));
  }
}
