/* Watch party page: multi stream grid and the party chat. */
/* Twitch embed rules: official players, nothing on top of them, each at least 400x300 (fitPlayers in public/watch.js
   scales a 400x300 player down on phones). Controls sit in a bar ABOVE each player. */
.wparty { container-type: inline-size; }
.wparty-head .wp-actions { flex-wrap: wrap; }
.wp-endbtn { background: transparent; border: 1px solid #e5534b88; color: #ff8a84; }
.wp-endbtn:hover { background: #e5534b22; border-color: #e5534b; color: #ffb1ad; }

.wp-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 10px 0 16px; align-items: start; }
@container (min-width: 760px) { .wp-stage { grid-template-columns: minmax(0, 1fr) 340px; } }

/* 1 channel = full width; 2 to 4 = two side by side when each still gets 400px, otherwise stacked. */
.wp-players { display: grid; gap: 12px; min-width: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, max(400px, calc(50% - 6px))), 1fr)); }
.wpp { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.wpp-bar { display: flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; }
.wpp-bar .grow { flex: 1; }
.wpp-name { font-weight: 600; color: var(--text); text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpp-name:hover { text-decoration: underline; }
.wpp-listen, .wpp-x { padding: 3px 10px; font-size: 12px; border-radius: var(--r-md); background: var(--panel2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.wpp-listen:hover, .wpp-x:hover { color: var(--text); }
.wpp-listen.on { color: var(--on-accent); background: var(--accent2); border-color: var(--accent2); }
.wparty .wplayer { aspect-ratio: 16 / 9; height: auto; min-height: 300px; border-radius: var(--r-lg); }

/* Party chat: a column next to the players on wide screens (as tall as the players, scrolls inside, box pinned at the
   bottom), under them on phones. Our own look: panel colors, compact "name: message" rows, time on hover. */
.wparty .wpchat { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0; overflow: hidden; height: 400px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }
@container (min-width: 760px) { .wparty .wpchat { position: sticky; top: 70px; height: max(380px, min(var(--wp-h, 520px), calc(100vh - 90px))); } }
.wparty .wpchat-tabs { flex: none; display: flex; border-bottom: 1px solid var(--line); }
.wparty .wpchat-tabs button { flex: 1; padding: 9px 8px; font-size: 13px; border-radius: 0; }
.wparty .wpchat-party { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; }
.wparty .wphere { flex: none; padding: 6px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wparty .wpmsgs { flex: 1; min-height: 0; max-height: none; overflow-y: auto; display: block; padding: 6px 4px; overscroll-behavior: contain; }
.wparty .wpm-empty { padding: 4px 8px; margin: 0; }
.wparty .wpmsg { font-size: 13.5px; line-height: 1.45; padding: 3px 8px; border-radius: var(--r-lg); overflow-wrap: anywhere; word-break: break-word; }
.wparty .wpmsg:hover { background: var(--panel2); }
.wpm-time { display: none; color: var(--muted); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.wpmsg:hover .wpm-time { display: inline; }
.wpm-name { font-weight: 600; text-decoration: none; }
.wpm-name:hover { text-decoration: underline; }
.wpm-sep { color: var(--muted); }
.wpm-body { color: var(--text); }
.wpc-0 { color: #ff7a7a; } .wpc-1 { color: #ffb454; } .wpc-2 { color: #f5d76e; } .wpc-3 { color: #8bd46e; } .wpc-4 { color: #4fd1c5; }
.wpc-5 { color: #5fb3ff; } .wpc-6 { color: #8fa8ff; } .wpc-7 { color: #f08fd8; } .wpc-8 { color: #ff8fab; } .wpc-9 { color: #c3d36b; }
.wparty .wpform { flex: none; display: flex; gap: 6px; margin: 0; padding: 8px; border-top: 1px solid var(--line); background: var(--panel); }
.wparty .wpform input { flex: 1; min-width: 0; padding: 8px 10px; }
.wparty .wpm-login { flex: none; margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); }
.wparty .wpchat-twitch { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wparty .wpchat-twitch iframe { flex: 1; min-height: 0; width: 100%; border: 0; display: block; }
.wpt-pick { flex: none; display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.wpt-pick button { padding: 3px 10px; font-size: 12px; border-radius: var(--r-md); white-space: nowrap; color: var(--muted); }
.wpt-pick button.on { color: var(--text); border-color: var(--accent); }

.wp-ended { text-align: center; padding: 28px 20px; margin: 10px 0 16px; }
.wp-ended h2 { margin: 0 0 6px; }
.wp-ended .row-btns { justify-content: center; }

/* Watch together window (public/partymake.js) */
.pk-card { text-align: left; position: relative; }
.pk-card > .close { position: absolute; top: 12px; right: 12px; font-size: 16px; }
.pk-card .stack { margin-bottom: 10px; }
.pk-for { margin: 0 0 10px; }
.pk-chans { display: flex; flex-direction: column; gap: 6px; }
.pk-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.pk-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 10px; border-radius: var(--r-md); background: var(--panel2); border: 1px solid var(--line); font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.pk-chip button { padding: 0 6px; border: 0; background: none; color: var(--muted); }
.pk-main { font-size: 11px; font-weight: 600; color: var(--muted); }
.pk-search { display: block; }
.pk-search input { width: 100%; }
.pk-results { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px; background: var(--bg); }
.pk-res { display: flex; flex-direction: column; align-items: flex-start; text-align: left; width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: var(--r-lg); }
.pk-res:hover, .pk-res:focus-visible { background: var(--panel2); }
.pk-none { margin: 4px 8px; }
.pk-already { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; margin: 8px 0 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel2); overflow-wrap: anywhere; }
.pk-endrow { justify-content: flex-end; }
.pk-end { max-width: 440px; }
.pk-card .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* "Watch more at once" on stream pages: a slim bar ABOVE the player (never on it) */
.wms-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; min-width: 0; }
.wms-btn { display: inline-flex; align-items: center; gap: 6px; border-color: var(--line); color: var(--text); background: var(--panel2); font-weight: 600; }
.wms-btn:hover { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent); }
.wms-note { min-width: 0; }

/* Channel picker: filter box over a grid of live streams (click to add) */
.pk-pickcard { max-width: 640px; }
.pk-gridhead { margin: 8px 0 4px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 136px), 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
.pk-make .pk-grid { max-height: 220px; }
.pk-live { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 0 0 6px; text-align: left; min-width: 0; border-radius: var(--r-lg); background: var(--panel2); border: 1px solid var(--line); overflow: hidden; font-weight: 600; }
.pk-live:hover, .pk-live:focus-visible { border-color: var(--accent); }
.pk-live.on { border-color: var(--accent2); }
.pk-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #000; }
.pk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pk-v { position: absolute; left: 4px; bottom: 4px; padding: 0 5px; border-radius: var(--r-sm); background: #000c; color: #fff; font-size: 11px; }
.pk-added { position: absolute; inset: 0; display: grid; place-items: center; background: #0f0f11b3; color: var(--accent); font-size: 13px; font-weight: 600; }
.pk-name, .pk-game { padding: 0 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.pk-game { font-weight: 400; font-size: 12px; }
.pk-browse { align-items: center; margin-top: 10px; flex-wrap: wrap; }

/* /watch?add=<party>: the Live page in "adding to my multistream" mode. The bar is fixed at the bottom so results stay
   right under the filters (rule 22). */
.wadd-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 40; display: flex; align-items: center; gap: 12px;
  width: min(560px, calc(100vw - 24px)); padding: 10px 12px 10px 16px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--accent2); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); font-weight: 600; font-size: 14px; }
.wadd-bar .grow { flex: 1; min-width: 0; }
@media (max-width: 760px) { .wadd-bar { bottom: 74px; } }
.wadd-mode main { padding-bottom: 110px; }
.wcard.wadd-card .wthumb::after { content: '+ Add to multistream'; position: absolute; right: 6px; top: 6px; padding: 3px 8px; border-radius: var(--r-lg); background: var(--accent2); color: var(--on-accent); font-size: 12px; font-weight: 600; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.wcard.wadd-card.wadded .wthumb::after { content: 'Added'; background: #0f0f11d9; color: var(--accent); }
.wcard.wadd-card.wadd-full:not(.wadded) .wthumb::after { content: 'Full'; background: #0f0f11d9; color: var(--muted); }
.wp-titlerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.wp-titlerow h1 { min-width: 0; overflow-wrap: anywhere; }
.wp-renameform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; min-width: 0; }
.wp-renameform input { flex: 1 1 240px; min-width: 0; font-size: 18px; font-weight: 600; }
.wadd-bar #wAddCancel { flex: none; }
.wp-vis { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; min-width: 0; }
.wp-vis-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; flex: none; }
.wp-vis-seg button { background: none; border: 0; border-right: 1px solid var(--line); border-radius: 0; color: var(--muted); padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.wp-vis-seg button:last-child { border-right: 0; }
.wp-vis-seg button.on { background: var(--accent2); color: var(--on-accent); }
.wp-vis-pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-sm); background: var(--panel2); border: 1px solid var(--line); }
