/* Watch tab — YouTube dark theme look (player chrome, watch page, live chat). */
body.yt { background: #0f0f0f; color: #f1f1f1; font-family: Roboto, Arial, sans-serif; }
body.yt .top { background: #0f0f0f; border-bottom: 0; min-height: 56px; padding: 8px 24px; }
body.yt .brand { font: 700 19px/1 Roboto, Arial, sans-serif; letter-spacing: -.8px; gap: 4px; }
body.yt .brand-ico { display: none; }
body.yt .yt-logo { display: inline-block; }
body.yt .who { background: rgba(255,255,255,.1); border-color: transparent; }
body.yt #logoutBtn { border-radius: 18px; border-color: rgba(255,255,255,.2); }

.ytw {
  display: grid; grid-template-columns: minmax(0, 1fr) 402px; grid-template-areas: "player side" "below side";
  gap: 0 24px; padding: 0 24px 24px; max-width: 1754px; margin: 0 auto; align-items: start;
  font: 14px/20px Roboto, Arial, sans-serif; color: #f1f1f1;
}
.ytw.theater { max-width: none; grid-template-areas: "player player" "below side"; }
.ytw-below { grid-area: below; min-width: 0; }
.ytw-side { grid-area: side; min-width: 0; }
.ytw button { font-family: inherit; }

/* ---------- player ---------- */
.ytp {
  grid-area: player; position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px;
  overflow: hidden; container-type: inline-size; user-select: none; -webkit-user-select: none; outline: none;
  color: #fff; font-family: Roboto, Arial, sans-serif;
}
.ytw.theater .ytp { margin: 0 -24px 0; width: auto; aspect-ratio: auto; height: min(56.25vw, calc(100vh - 169px)); min-height: 480px; border-radius: 0; }
.ytp:fullscreen { border-radius: 0; width: 100%; height: 100%; aspect-ratio: auto; }
.ytp video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.ytp.autohide { cursor: none; }
.ytp-shade { position: absolute; left: 0; right: 0; bottom: 0; height: 120px; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,.35) 50%, rgba(0,0,0,0)); transition: opacity .25s cubic-bezier(0,0,.2,1); }
.ytp-chrome { position: absolute; z-index: 3; left: 12px; right: 12px; bottom: 0; height: 64px; transition: opacity .25s cubic-bezier(0,0,.2,1); }
.ytp.autohide .ytp-shade, .ytp.autohide .ytp-chrome { opacity: 0; }
.ytp.autohide .ytp-chrome { pointer-events: none; }

.ytp-btn { position: relative; width: 48px; height: 48px; padding: 0; border: 0; background: none; color: #fff; cursor: pointer; opacity: .9; flex: none; }
.ytp-btn:hover { opacity: 1; }
.ytp-btn svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.ytp-btn:focus-visible, .ytp-chapter:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: -4px; border-radius: 8px; }
.ytp-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 48px; display: flex; justify-content: space-between; }
.ytp-left, .ytp-right { display: flex; align-items: center; min-width: 0; }
.ytp-left { flex: 1; }
.ytp-cc[aria-pressed="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 9px; height: 3px; border-radius: 3px; background: #f00; }

/* progress bar with chapter gaps */
.ytp-progress { position: absolute; left: 0; right: 0; bottom: 46px; height: 18px; cursor: pointer; touch-action: none; outline: none; }
.ytp-segs { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; display: flex; align-items: flex-end; gap: 2px; transition: height .1s cubic-bezier(.4,0,1,1); }
.ytp-progress:hover .ytp-segs, .ytp.dragging .ytp-segs { height: 5px; }
.ytp-seg { position: relative; height: 100%; background: rgba(255,255,255,.2); min-width: 2px; transition: height .1s; }
.ytp-progress:hover .ytp-seg.hot, .ytp.dragging .ytp-seg.hot { height: 180%; }
.ytp-seg i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: 0 0; transform: scaleX(0); }
.ytp-seg .ld { background: rgba(255,255,255,.4); }
.ytp-seg .hv { background: rgba(255,255,255,.5); }
.ytp-seg .pl { background: #f00; }
.ytp-scrub { position: absolute; bottom: -4px; left: 0; width: 13px; height: 13px; border-radius: 50%; background: #f00; transform: translateX(-50%) scale(0); transition: transform .1s cubic-bezier(.4,0,1,1); pointer-events: none; }
.ytp-progress:hover .ytp-scrub, .ytp.dragging .ytp-scrub, .ytp-progress:focus-visible .ytp-scrub { transform: translateX(-50%) scale(1); }
.ytp-tip { position: absolute; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; text-shadow: 0 0 4px rgba(0,0,0,.75); }
.ytp-tip-img { width: 164px; height: 94px; border: 2px solid #fff; border-radius: 8px; background-color: #000; background-repeat: no-repeat; box-sizing: border-box; }
.ytp-tip-ch { margin-top: 6px; font-size: 13px; font-weight: 500; max-width: 220px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ytp-tip-time { font-size: 13px; font-weight: 500; }

/* volume */
.ytp-vol { display: flex; align-items: center; }
.ytp-vol-range { -webkit-appearance: none; appearance: none; width: 0; opacity: 0; height: 3px; margin: 0; cursor: pointer; border-radius: 3px;
  background: linear-gradient(to right, #fff var(--v, 100%), rgba(255,255,255,.2) var(--v, 100%)); transition: width .2s cubic-bezier(0,0,.2,1), opacity .2s, margin .2s; }
.ytp-vol:hover .ytp-vol-range, .ytp-vol:focus-within .ytp-vol-range, .ytp-vol-range:active { width: 52px; opacity: 1; margin-right: 10px; }
.ytp-vol-range::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }
.ytp-vol-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }
.ytp-vol-range::-moz-range-track { background: transparent; }
.ytp-time { font-size: 13px; color: #ddd; padding: 0 8px 0 5px; white-space: nowrap; text-shadow: 0 0 2px rgba(0,0,0,.5); font-variant-numeric: tabular-nums; }
.ytp-chapter { display: flex; align-items: center; min-width: 0; height: 48px; padding: 0 4px 0 0; border: 0; background: none; color: #ddd; font-size: 13px; cursor: pointer; text-shadow: 0 0 2px rgba(0,0,0,.5); }
.ytp-chapter .dot { margin-right: 6px; }
.ytp-chapter span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ytp-chapter svg { width: 24px; height: 24px; fill: #ddd; flex: none; }
.ytp-chapter:hover, .ytp-chapter:hover svg { color: #fff; fill: #fff; }

/* settings menu */
.ytp-menu { position: absolute; right: 12px; bottom: 61px; z-index: 6; min-width: 251px; max-height: calc(100% - 72px); overflow-y: auto; padding: 8px 0;
  background: rgba(28,28,28,.9); border-radius: 12px; font-size: 14px; text-shadow: 0 0 2px rgba(0,0,0,.5); }
.ytp-mi { display: flex; align-items: center; gap: 15px; width: 100%; height: 40px; padding: 0 15px; border: 0; background: none; color: #eee; font: inherit; text-align: left; cursor: pointer; }
.ytp-mi:hover, .ytp-mi:focus-visible { background: rgba(255,255,255,.1); outline: none; }
.ytp-mi svg { width: 24px; height: 24px; fill: #eee; flex: none; }
.ytp-mi .lbl { flex: 1; font-weight: 500; }
.ytp-mi .val { font-size: 13px; color: #eee; }
.ytp-mi .val::after { content: "›"; margin-left: 8px; font-size: 18px; }
.ytp-mi.opt { padding-left: 50px; position: relative; }
.ytp-mi.opt[aria-checked="true"]::before { content: ""; position: absolute; left: 18px; top: 13px; width: 12px; height: 6px; border: solid #eee; border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.ytp-mh { display: flex; align-items: center; gap: 8px; width: 100%; height: 48px; padding: 0 15px 0 8px; margin: -8px 0 8px; border: 0; border-bottom: 1px solid rgba(255,255,255,.2);
  background: none; color: #eee; font: 500 14px Roboto, Arial, sans-serif; cursor: pointer; text-align: left; }
.ytp-mh::before { content: "‹"; font-size: 22px; width: 24px; text-align: center; }

/* overlays */
.ytp-caps { position: absolute; left: 4%; right: 4%; bottom: 3%; z-index: 1; text-align: center; pointer-events: none; transition: bottom .25s cubic-bezier(0,0,.2,1);
  font-size: 20px; font-size: max(13px, calc(2.25cqw * var(--cap, 1))); line-height: 1.32;
  font-family: "YouTube Noto", Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, sans-serif; }
.ytp:not(.autohide) .ytp-caps { bottom: 64px; }
.ytp:has(.ytp-progress:hover) .ytp-caps, .ytp.dragging .ytp-caps { opacity: 0; }   /* keep the seek preview readable */
.ytp-caps div { margin: 0; }
.ytp-caps span { background: rgba(8,8,8,.75); color: #fff; padding: 0 .25em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.ytp-bezel { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; z-index: 2; }
.ytp-bezel svg { width: 36px; height: 36px; margin: 8px; fill: #fff; }
.ytp-bezel.go { animation: ytp-bezel .5s linear forwards; }
@keyframes ytp-bezel { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(2); } }
.ytp-spin { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; z-index: 2; pointer-events: none;
  border: 4px solid rgba(255,255,255,.15); border-top-color: #fff; animation: ytp-spin 1s linear infinite; }
@keyframes ytp-spin { to { transform: rotate(360deg); } }
.ytp-notice { position: absolute; left: 12px; top: 12px; z-index: 3; max-width: calc(100% - 24px); padding: 6px 12px; border-radius: 16px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 13px; font-weight: 500; pointer-events: none; }
.ytp-unmute { position: absolute; left: 12px; top: 12px; z-index: 4; display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 14px 0 4px;
  border: 0; border-radius: 18px; background: #fff; color: #0f0f0f; font: 500 14px Roboto, Arial, sans-serif; cursor: pointer; }
.ytp-unmute svg { width: 32px; height: 32px; fill: #0f0f0f; }
.ytp-unmute path + path { stroke: #0f0f0f; }
.ytp-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; }

/* miniplayer (shown on the Study tab while the video plays) */
.ytw.away { display: block; height: 0; padding: 0; overflow: visible; }
.ytw.away > :not(.ytp) { display: none !important; }
.ytw.away .ytp:not(.mini) { display: none; }
.ytp.mini { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: min(400px, calc(100vw - 32px)); height: auto; aspect-ratio: 16 / 9;
  margin: 0; border-radius: 12px; box-shadow: 0 4px 32px rgba(0,0,0,.6); }
body.mini-on #studyView { padding-bottom: calc(min(400px, 100vw - 32px) * 9 / 16 + 32px); }
.ytp-mini-top { display: none; }
.ytp.mini .ytp-mini-top { display: flex; justify-content: space-between; position: absolute; left: 0; right: 0; top: 0; z-index: 5; transition: opacity .25s; }
.ytp.mini .ytp-mini-top .ytp-btn { width: 40px; height: 40px; padding: 8px; }
.ytp.mini.autohide .ytp-mini-top { opacity: 0; }
.ytp.mini .ytp-right, .ytp.mini #wNext, .ytp.mini .ytp-vol, .ytp.mini .ytp-chapter, .ytp.mini .ytp-tip { display: none; }
.ytp.mini .ytp-caps { font-size: 12px; }

/* ---------- below the player ---------- */
.ytw-title { margin: 12px 0 0; font: 700 20px/28px Roboto, Arial, sans-serif; color: #f1f1f1; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ytw-owner { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.ytw-av { width: 40px; height: 40px; border-radius: 50%; background: #272727; }
.ytw-chan { min-width: 0; }
.ytw-chan a { display: block; color: #f1f1f1; font: 500 16px/22px Roboto, Arial, sans-serif; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ytw-chan small { display: block; color: #aaa; font-size: 12px; line-height: 18px; }
.ytw-pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border: 0; border-radius: 18px; background: rgba(255,255,255,.1);
  color: #f1f1f1; font: 500 14px Roboto, Arial, sans-serif; text-decoration: none; white-space: nowrap; cursor: pointer; }
.ytw-pill:hover { background: rgba(255,255,255,.2); }
.ytw-pill svg { width: 24px; height: 24px; fill: currentColor; margin-left: -6px; }
.ytw-pill.on { background: #f1f1f1; color: #0f0f0f; }
.ytw-pill.warn { background: #3a2f12; color: #ffcc4d; }
.ytw-sub { background: #f1f1f1; color: #0f0f0f; margin-left: 12px; }
.ytw-sub:hover { background: #d9d9d9; }
.ytw-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.ytw-seg { display: flex; }
.ytw-seg .ytw-pill:first-child { position: relative; border-radius: 18px 0 0 18px; }
.ytw-seg .ytw-pill:first-child::after { content: ""; position: absolute; right: 0; top: 6px; bottom: 6px; width: 1px; background: rgba(255,255,255,.2); }
.ytw-seg .ytw-pill:last-child { border-radius: 0 18px 18px 0; padding: 0 16px 0 18px; }
.ytw-desc { margin-top: 12px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.1); cursor: pointer; overflow-wrap: anywhere; }
.ytw-desc:hover { background: rgba(255,255,255,.2); }
.ytw-desc.open { cursor: default; }
.ytw-desc.open:hover { background: rgba(255,255,255,.1); }
.ytw-desc:focus-visible { outline: 2px solid #3ea6ff; }
.ytw-desc-meta { font-weight: 500; }
.ytw-desc-meta span { margin-right: 8px; white-space: nowrap; }
.ytw-desc-meta .tag { color: #aaa; }
.ytw-desc-text { white-space: pre-wrap; }
.ytw-desc:not(.open) .ytw-desc-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ytw-desc a, .ytw-desc .ts { color: #3ea6ff; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.ytw-desc a:hover, .ytw-desc .ts:hover { text-decoration: underline; }
.ytw-more, .ytw-less { margin-top: 8px; padding: 0; border: 0; background: none; color: #f1f1f1; font: 500 14px Roboto, Arial, sans-serif; cursor: pointer; }
.ytw-desc:not(.open) .ytw-more { margin-top: 0; }
.ytw-chapters h3 { margin: 24px 0 12px; font: 700 16px/22px Roboto, Arial, sans-serif; }
.ytw-cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.ytw-card { flex: none; display: flex; gap: 12px; width: 300px; padding: 8px; border: 0; border-radius: 8px; background: rgba(255,255,255,.05); color: #f1f1f1; text-align: left; cursor: pointer; }
.ytw-card:hover { background: rgba(255,255,255,.15); }
.ytw-card.cur { background: rgba(255,255,255,.2); }
.ytw-card img { width: 88px; height: 50px; border-radius: 4px; object-fit: cover; flex: none; }
.ytw-card b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font: 500 14px/20px Roboto, Arial, sans-serif; }
.ytw-card small { color: #3ea6ff; font-size: 12px; font-weight: 500; }

/* ---------- live chat ---------- */
.ytc { position: relative; display: flex; flex-direction: column; height: min(calc(100vh - 136px), 720px); min-height: 420px;
  border: 1px solid rgba(255,255,255,.2); border-radius: 12px; overflow: hidden; background: #0f0f0f; }
.ytw.theater .ytc { margin-top: 24px; }
.ytc-head { display: flex; align-items: center; min-height: 48px; padding: 4px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.ytc-head b { display: block; font: 400 16px/22px Roboto, Arial, sans-serif; }
.ytc-head small { display: block; color: #aaa; font-size: 12px; line-height: 16px; }
.ytc-list { flex: 1; overflow-y: auto; padding: 8px 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #717171 transparent; }
.ytc-msg { display: flex; align-items: flex-start; gap: 16px; padding: 4px 24px; font-size: 13px; line-height: 16px; }
.ytc-av { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--c, #555); color: #0f0f0f; font: 700 12px/1 Roboto, Arial, sans-serif; }
.ytc-body { flex: 1; min-width: 0; padding-top: 4px; overflow-wrap: anywhere; }
.ytc-ts { color: rgba(255,255,255,.5); font-size: 11px; margin-right: 8px; }
.ytc-au { color: rgba(255,255,255,.7); font-weight: 500; margin-right: 8px; }
.ytc-au.me { background: #ffd600; color: #0f0f0f; border-radius: 2px; padding: 1px 4px; }
.ytc-tx { color: #fff; }
.ytc-ev { display: flex; align-items: center; gap: 12px; padding: 6px 24px 6px 28px; color: #aaa; font-size: 12px; line-height: 16px; }
.ytc-ev svg { width: 16px; height: 16px; flex: none; fill: #aaa; }
.ytc-ev .ytc-ts { margin-right: 0; }
.ytc-empty { padding: 16px 24px; color: #aaa; font-size: 13px; }
.ytc-down { position: absolute; left: 50%; bottom: 148px; z-index: 2; width: 36px; height: 36px; margin-left: -18px; padding: 6px; border: 0; border-radius: 50%; background: #3f3f3f; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.ytc-down svg { fill: #fff; width: 24px; height: 24px; }
.ytc-input { position: relative; padding: 16px 24px 8px; border-top: 1px solid rgba(255,255,255,.1); }
.ytc-me { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.ytc-me b { color: rgba(255,255,255,.7); font-weight: 500; }
.ytc-field { margin: 8px 0 0 40px; border-bottom: 1px solid rgba(255,255,255,.3); }
.ytc-field:focus-within { border-bottom: 2px solid #fff; margin-bottom: -1px; }
.ytc-field input { width: 100%; padding: 4px 0 6px; border: 0; border-radius: 0; outline: 0; background: none; color: #fff; font: 15px/21px Roboto, Arial, sans-serif; }
.ytc-field input::placeholder { color: #aaa; }
.ytc-tools { display: flex; align-items: center; margin: 6px 0 0 30px; }
.ytc-ico { width: 40px; height: 40px; padding: 8px; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.ytc-ico svg { width: 24px; height: 24px; fill: #f1f1f1; display: block; }
.ytc-ico:hover { background: rgba(255,255,255,.1); }
.ytc-ico[disabled] { opacity: .3; cursor: default; background: none; }
.ytc-count { margin-left: auto; margin-right: 8px; color: #aaa; font-size: 13px; }
.ytc-count.full { color: #ff4e45; }
.ytc-emoji { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 8px); z-index: 3; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  max-height: 232px; overflow-y: auto; padding: 8px; border-radius: 12px; background: #282828; box-shadow: 0 4px 32px rgba(0,0,0,.6); }
.ytc-emoji button { padding: 4px 0; border: 0; border-radius: 6px; background: none; font-size: 22px; line-height: 30px; cursor: pointer; }
.ytc-emoji button:hover { background: rgba(255,255,255,.1); }
.ytc-toggle { width: 100%; height: 36px; margin-top: 8px; border: 1px solid rgba(255,255,255,.2); border-radius: 18px; background: none; color: #f1f1f1; font: 500 14px Roboto, Arial, sans-serif; cursor: pointer; }
.ytc-toggle:hover { background: rgba(255,255,255,.1); }
.ytw-side.chat-hidden .ytc { display: none; }
.ytw-side.chat-hidden .ytc-toggle { margin-top: 0; }

/* ---------- narrow screens: stacked like YouTube mobile ---------- */
@media (max-width: 1016px) {
  .ytw, .ytw.theater { grid-template-columns: minmax(0, 1fr); grid-template-areas: "player" "below" "side"; padding: 0 0 24px; }
  .ytp, .ytw.theater .ytp { border-radius: 0; margin: 0; width: 100%; height: auto; min-height: 0; aspect-ratio: 16 / 9; }
  .ytw-below, .ytw-side { padding: 0 16px; }
  .ytw-side { margin-top: 16px; }
  .ytc { height: 480px; min-height: 0; }
  .ytw-chan { flex: 1; }
  .ytw-sub { margin-left: 0; }
  .ytw-actions { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  #wTheater { display: none; }
  body.yt .top { padding: 8px 16px; }
}
@media (max-width: 520px) {
  .ytp-time .ytp-sep, .ytp-time #wDur { display: none; }
  .ytp-chapter { display: none; }
  #wMini, #wNext { display: none; }
  .ytc-msg, .ytc-ev { padding-left: 16px; padding-right: 16px; }
  .ytc-input { padding: 12px 16px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .ytp-bezel.go, .ytp-spin { animation-duration: 0s; }
  .ytp-shade, .ytp-chrome, .ytp-caps, .ytp-segs, .ytp-scrub { transition: none; }
}
