
/* Back out of an open playlist: an arrow and the playlist's name. */
.yt-crumb {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; align-self: flex-start;
  min-height: 30px; padding: 0 8px 0 4px; border-radius: 8px; cursor: pointer; font: inherit;
  font-size: 0.76rem; font-weight: 800; max-width: 100%;
  color: var(--text, #e7e9ee); background: none; border: 0;
}
.yt-crumb:hover { background: rgba(255,255,255,0.05); }
.yt-crumb-ico { display: inline-flex; }
.yt-crumb-ico svg { width: 16px; height: 16px; }
.yt-crumb-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A grid that becomes as many columns as the width holds: one in a side column,
   two or three across a wide tile, so the width shows more videos instead of
   stretching a few rows across empty space. */
.yt-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: start; gap: 6px;
}
.yt-list::-webkit-scrollbar { width: 6px; }
.yt-list::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(255,255,255,0.16); }
/* The rows keep a surface of their own, darker than the tile: they are the thing
   you tap, and they have to stay readable over a theme's photo. */
.yt-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0;
  padding: 6px; border-radius: 10px; cursor: pointer; text-align: left; font: inherit;
  border: 1px solid rgba(255,255,255,0.06); background: rgba(0,0,0,0.34);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.yt-row:hover { background: rgba(255,0,0,0.10); border-color: rgba(255,0,0,0.35); }
/* The video on screen right now. */
.yt-row.is-current { background: rgba(255,0,0,0.13); border-color: rgba(255,0,0,0.5); }
.yt-row-art {
  position: relative; width: 80px; height: 45px; flex: 0 0 auto; border-radius: 6px;
  background: rgba(255,255,255,0.07) center / cover no-repeat;
  display: inline-flex; align-items: center; justify-content: center; color: #ff4d4d;
}
.yt-row--pl .yt-row-art { width: 45px; height: 45px; border-radius: 8px; }
.yt-row-dur {
  position: absolute; right: 3px; bottom: 3px; padding: 0 4px; border-radius: 4px;
  font-size: 0.58rem; font-weight: 800; color: #fff; background: rgba(0,0,0,0.78);
  font-variant-numeric: tabular-nums;
}
.yt-row-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.yt-row-name {
  font-size: 0.78rem; font-weight: 700; line-height: 1.3; color: var(--text, #e7e9ee);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* The channel name gives up its width to the note, not the other way round: the
   note is the short, fixed thing and the one carrying news. */
.yt-row-subline { display: flex; align-items: center; gap: 6px; min-width: 0; }
.yt-row-sub { font-size: 0.67rem; font-weight: 600; color: var(--text-dim, #8b91a1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.yt-row-tag { flex: 0 0 auto; font-size: 0.66rem; font-weight: 800; white-space: nowrap; color: #ff7a7a; }
.yt-row-play {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; color: #fff; background: rgba(255,0,0,0.85);
  opacity: 0; transform: scale(0.8); transition: opacity 0.15s ease, transform 0.15s ease;
}
.yt-row-play svg { width: 15px; height: 15px; margin-left: 1px; }
.yt-row:hover .yt-row-play, .yt-row:focus-visible .yt-row-play { opacity: 1; transform: scale(1); }
.yt-list-note {
  grid-column: 1 / -1;
  font-size: 0.78rem; line-height: 1.4; padding: 8px 10px; border-radius: 10px;
  color: var(--text, #e7e9ee); background: rgba(0,0,0,0.34);
  border: 1px solid rgba(255,255,255,0.07);
}
.yt-list-err { color: var(--color-danger); border-color: rgba(255,90,90,0.32); }

/* ── Wide and short: the list moves beside the video ──────────────────────── */
/* The video's COLUMN is sized from the tile's height, so the picture fills it
   both ways instead of sitting in a taller box: 16:9 of (height minus the seek
   bar and controls), and never so wide that the list drops under 300px. Only
   tiles at least 2.1 times as wide as tall come here — below that stacking gives
   both a bigger video and the full width. */
@container ytw (min-width: 620px) and (min-aspect-ratio: 21 / 10) {
  .yt-wrap[data-view="normal"] .yt-cards:has(> .yt-card--player:not(.is-vacant)) {
    --yt-pw: min(calc((100cqh - var(--yt-bar-h)) * 16 / 9), calc(100cqw - 314px));
    display: grid; overflow: hidden; gap: 10px 14px;
    grid-template-columns: var(--yt-pw) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .yt-wrap[data-view="normal"] .yt-cards:has(> .yt-card--player:not(.is-vacant)) > .yt-card--player { grid-column: 1; grid-row: 1; min-height: 0; justify-content: center; }
  .yt-wrap[data-view="normal"] .yt-cards:has(> .yt-card--player:not(.is-vacant)) > .yt-card--player .yt-stage-wrap { flex: 0 1 auto; height: calc(var(--yt-pw) * 9 / 16); min-height: 0; }
  .yt-wrap[data-view="normal"] .yt-cards:has(> .yt-card--player:not(.is-vacant)) > .yt-card--library { grid-column: 2; grid-row: 1; min-height: 0; }
  /* The list switched off in the layout editor: the video takes the width. */
  .yt-wrap[data-view="normal"] .yt-cards:has(> .yt-card--player:not(.is-vacant)):has(> .yt-card--library[data-system-card-hidden="true"]) {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Cinema: the video and the list, side by side ─────────────────────────── */
/* The list shows here even when its card is off in the layout: picking the next
   video without leaving the big picture is what this view is for. */
.yt-wrap[data-view="cinema"] .yt-card--library[data-system-card-hidden="true"] { display: flex !important; }
@container ytw (min-aspect-ratio: 13 / 10) {
  .yt-wrap[data-view="cinema"] .yt-cards {
    --yt-pw: min(calc((100cqh - var(--yt-bar-h)) * 16 / 9), calc(100cqw - 294px));
    display: grid; overflow: hidden; gap: 0 14px;
    grid-template-columns: var(--yt-pw) minmax(280px, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .yt-wrap[data-view="cinema"] .yt-card--player { grid-column: 1; grid-row: 1; min-height: 0; justify-content: center; }
  .yt-wrap[data-view="cinema"] .yt-card--player .yt-stage-wrap { flex: 0 1 auto; height: calc(var(--yt-pw) * 9 / 16); min-height: 0; }
  .yt-wrap[data-view="cinema"] .yt-card--library { grid-column: 2; grid-row: 1; min-height: 0; }
}

/* ── Fill and full screen: the video owns the space ───────────────────────── */
/* Fill covers the tile; full screen covers the screen. Either way the controls
   float over the picture the way every video player does: stacking the title,
   the seek bar and the transport UNDER it spent a quarter of the height on chrome
   that a 16:9 video can never use. */
.yt-wrap[data-view="fill"] { padding: 0; }
.yt-wrap[data-view="fill"] .yt-setup,
.yt-wrap[data-view="fill"] .yt-card--library { display: none !important; }
.yt-wrap[data-view="fill"] .yt-cards { overflow: hidden; }
.yt-wrap[data-view="fill"] .yt-card--player { flex: 1 1 auto; }

.yt-wrap.is-overlay .yt-card--player { position: relative; min-height: 0; background: #000; gap: 0; overflow: hidden; }
.yt-wrap[data-view="fill"]:not(.is-screen) .yt-card--player { border-radius: inherit; }
.yt-wrap.is-overlay .yt-card--player .yt-stage-wrap { position: absolute; inset: 0; height: auto; min-height: 0; }
.yt-wrap.is-overlay .yt-player-stage { border-radius: 0; }
/* Legible over whatever frame the video happens to be on. .yt-blocked is NOT
   lifted here: it is the layer covering the picture, and giving it a position
   would drop it back behind the frame it has to hide. */
.yt-wrap.is-overlay .yt-card--player::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 190px; z-index: 1;
  background: linear-gradient(to top, rgba(0,0,0,0.88), rgba(0,0,0,0.55) 42%, transparent);
  pointer-events: none;
}
/* On the picture in every appearance: the bar carries its own light ink, or a light
   theme writes dark on dark. */
.yt-wrap.is-overlay .yt-bar {
  --text: #f2f4f7; --text-dim: #c3c8d1;
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 0 18px 14px; flex-wrap: wrap;
}
.yt-wrap.is-overlay .yt-now-title { font-size: 1rem; }
.yt-wrap.is-overlay .yt-ib:not(.yt-playpause) { background: rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.14); }
.yt-wrap.is-overlay .yt-ib.is-on { color: #ff6b6b; border-color: rgba(255,0,0,0.6); }

/* The controls fade out a few seconds into a video and come back on a touch. The
   catcher takes input ONLY while they are hidden, so YouTube's own captions and
   quality menus stay reachable while they are up. */
.yt-idlecatch { display: none; }
.yt-wrap.is-overlay .yt-idlecatch { display: block; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.yt-wrap.is-overlay.is-idle .yt-idlecatch { pointer-events: auto; cursor: none; }
.yt-wrap.is-overlay .yt-bar,
.yt-wrap.is-overlay .yt-card--player::after { transition: opacity 0.35s ease; }
.yt-wrap.is-overlay.is-idle .yt-bar,
.yt-wrap.is-overlay.is-idle .yt-card--player::after { opacity: 0; pointer-events: none; }

/* Full screen. The wrap is only re-positioned, never re-parented: moving the
   iframe in the DOM reloads it and restarts the video. The whole wrap goes, not
   just the player, so the list comes along for "player and list".
   Deliberately not the Fullscreen API: on the kiosk leaving it tore the video
   down and left the Windows taskbar over the dashboard until the app was
   restarted, so the overlay never touches the app's own window. */
.yt-wrap.is-screen {
  position: fixed; inset: 0; z-index: 5000;
  width: auto; height: auto; padding: 0; gap: 0; border-radius: 0;
  background: #05070a;
}
.yt-wrap.is-screen .yt-setup { display: none; }
.yt-wrap.is-screen .yt-cards { overflow: hidden; }
.yt-wrap.is-screen .yt-card--player { flex: 1 1 auto; border-radius: 0; }
.yt-wrap.is-screen .yt-card--library { background: #0c0d12; border-left: 1px solid rgba(255,255,255,0.06); padding: 12px 14px; }
@container ytw (min-aspect-ratio: 13 / 10) {
  /* Video as tall as the screen, list beside it at a width a list reads well at;
     whatever the screen has left is black on both sides. */
  .yt-wrap.is-screen[data-view="cinema"] .yt-cards {
    --yt-pw: min(calc(100cqh * 16 / 9), calc(100cqw - 340px));
    grid-template-columns: var(--yt-pw) minmax(320px, 460px);
    justify-content: center; gap: 0;
  }
}
/* On a phone held upright: video across the top, list under it. */
@container ytw (max-aspect-ratio: 13 / 10) {
  .yt-wrap.is-screen[data-view="cinema"] .yt-card--player { flex: 0 0 auto; height: calc(100cqw * 9 / 16); }
  .yt-wrap.is-screen[data-view="cinema"] .yt-card--library { border-left: 0; border-top: 1px solid rgba(255,255,255,0.06); }
}
/* Two things sit between the wrap and the screen: the shell (z-index 1) holds it
   under the edge rails, which are fixed at 58 on the body, so it is lifted while
   the video is full screen; and a fixed element is trapped by any ancestor that
   becomes its containing block — a tile with glass (backdrop-filter) or a shape
   (clip-path) does exactly that — so the tile drops both for as long as it is
   covering the screen. */
body.yt-expanded .shell { z-index: 60; }
body.yt-expanded .yt-tile-expanded {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  clip-path: none !important; filter: none !important; transform: none !important; contain: none !important;
}

/* Touch surfaces have no hover, so the play affordance must always be visible. */
@media (hover: none) {
  .yt-row-play { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .yt-row, .yt-row-play, .yt-tab, .yt-ib,
  .yt-wrap.is-overlay .yt-bar,
  .yt-wrap.is-overlay .yt-card--player::after { transition: none; }
}
