:root {
  color-scheme: dark;
  --bg: #000; --bg-elev: #151618; --bg-elev-2: #202224; --bg-inset: #000;
  --line: #2a2c2e; --line-soft: #222426;
  --text: #e8e9eb; --text-dim: #a1a4a9; --text-mute: #777d84;
  --accent: #b4c5d8; --accent-2: #cbd5df; --accent-glow: #b4c5d81a; --on-accent: #15191e;
  --yt: #ed7e7e; --twitch: #b9a0e2; --kick: #a5cb91; --vaughn: #d9bc88; --custom: #8cbbcc;
  --ok: #8bbf9c; --warn: #d9bc88; --err: #ef9393;
  --radius: 8px; --radius-sm: 6px; --chat-w: 340px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, .player-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn, .pc-btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text-dim);
  font: inherit; font-weight: 500; padding: 7px 12px; white-space: nowrap; transition: background .15s, color .15s;
}
.btn:hover, .pc-btn:hover, .icon-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.btn-primary { background: #e0e4e9; color: #171a1e; border-color: transparent; }
.btn-primary:hover { background: #fff; color: #171a1e; }
.btn-sm { padding: 5px 9px; font-size: 13px; }
.btn-ghost, .icon-btn { border-color: transparent; }
.icon-btn { width: 30px; height: 30px; padding: 0; }
.layout { display: flex; width: 100%; height: 100dvh; overflow: hidden; }
.layout.chat-left { flex-direction: row-reverse; }
.stream-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 0 20px 12px; gap: 10px; overflow: hidden; }
.watch-header { display: flex; align-items: center; justify-content: space-between; min-height: 52px; flex: 0 0 auto; }
.wordmark { font-size: 16px; font-weight: 650; letter-spacing: -.5px; }
.wordmark span { font-weight: 400; color: var(--text-mute); }
.player-controls { display: flex; }
.pc-btn { font-size: 13px; padding: 5px 9px; border: 0; }
.pc-ico { font-size: 17px; }
.paste-input { min-width: 0; flex: 1; border: 1px solid var(--line); background: #161719; color: var(--text); border-radius: 6px; padding: 7px 11px; outline: none; }
.paste-input::placeholder { color: var(--text-mute); }
.paste-input:focus { border-color: #738495; }
.form-error { width: 100%; margin: 0; color: var(--err); font-size: 13px; }
.player-shell { display: flex; flex: 0 1 auto; min-height: 120px; }
.player-frame { position: relative; width: 100%; aspect-ratio: 16/9; max-height: max(140px, calc(100dvh - 160px)); background: #000; border-radius: 8px; overflow: hidden; }
.player-frame iframe, .player-frame video, .player-frame img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; background: #000; }
.player-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; }
.player-empty-inner { max-width: 340px; text-align: center; }
.player-empty-icon { color: var(--text-mute); font-size: 32px; margin-bottom: 12px; }
.player-empty-title { font-size: 16px; font-weight: 500; margin: 4px 0; }
.player-empty-sub { color: var(--text-mute); font-size: 13px; margin: 8px 0 0; }
.now-playing { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; min-height: 42px; }
.np-badge { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.np-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.np-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { color: var(--text-mute); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-actions { display: flex; gap: 3px; margin-left: auto; }
.embed-help { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; flex: 0 0 auto; color: var(--text-dim); font-size: 12px; }
.embed-help span { flex: 1 1 200px; }
.embed-help a { color: var(--accent); text-underline-offset: 3px; }
.paste-form { display: flex; gap: 8px; padding: 0 0 4px; flex-shrink: 0; }
.chat-col { flex: 0 0 var(--chat-w); min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line-soft); background: var(--bg); overflow: hidden; }
.layout.chat-left .chat-col { border-left: 0; border-right: 1px solid var(--line-soft); }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; height: 52px; flex-shrink: 0; border-bottom: 1px solid var(--line-soft); }
.chat-channel { color: var(--text-dim); font-weight: 500; }
.chat-head-actions { margin-left: auto; display: flex; gap: 2px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-mute); flex-shrink: 0; }
.status-dot[data-status="connected"] { background: var(--ok); }
.status-dot[data-status="connecting"] { background: var(--warn); }
.status-dot[data-status="error"], .status-dot[data-status="closed"] { background: var(--err); }
.chat-frame { position: relative; flex: 1; min-height: 0; }
.chat-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.chat-col.empty .chat-head, .chat-col.empty .chat-frame, .chat-col.active .channel-picker { display: none; }
.channel-picker { flex: 1; display: grid; place-items: center; padding: 24px; }
.picker-card { width: 100%; max-width: 280px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.picker-icon { color: var(--text-mute); font-size: 26px; }
.picker-title { margin: 0; font-size: 17px; font-weight: 500; }
.picker-sub { margin: 0 0 8px; color: var(--text-mute); font-size: 13px; }
.picker-field { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #161719; }
.picker-field:focus-within { border-color: #738495; }
.picker-hash { color: var(--text-mute); }
.picker-input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.picker-input::placeholder { color: var(--text-mute); }
/* Custom controls for direct video; platform iframes retain their own controls. */
.video-ui { position: absolute; bottom: 0; left: 0; right: 0; z-index: 2; padding: 35px 16px 10px; background: linear-gradient(transparent, #000c); opacity: 0; transition: opacity .2s; pointer-events: none; }
.show-video-ui .video-ui, .is-paused .video-ui, .video-ui:focus-within { opacity: 1; pointer-events: auto; }
.video-toolbar { display: flex; gap: 8px; align-items: center; min-height: 36px; }
.video-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; background: transparent; border: 0; color: #fff; border-radius: 5px; }
.video-button:hover { background: #ffffff20; }
.video-ui input[type="range"] { appearance: none; height: 3px; border-radius: 4px; background: linear-gradient(to right, #d9e1eb var(--fill, 0%), #ffffff40 var(--fill, 0%)); accent-color: #e3e8ef; cursor: pointer; }
.video-ui input[type="range"]::-webkit-slider-thumb { appearance: none; width: 10px; height: 10px; border-radius: 50%; background: #e3e8ef; }
.video-ui input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: #e3e8ef; }
.video-volume { width: 64px; margin-right: 12px; }
.video-seek { display: block; width: 100%; margin: 0 0 6px; }
.video-live { display: inline-flex; gap: 7px; align-items: center; border: 0; padding: 8px 2px; background: transparent; color: #eee; font-size: 11px; font-weight: 600; letter-spacing: .06em; }
.video-live i { width: 5px; height: 5px; background: #e0918c; border-radius: 50%; }
.video-state, .video-time { font-size: 12px; color: #c5c7cb; }
.video-state { flex: 1; text-align: right; padding-right: 8px; }
.video-fullscreen { margin-left: auto; }
.layout.theater .paste-form, .layout.theater .now-playing { display: none; }
.layout.theater .stream-col { padding: 0; gap: 0; }
.layout.theater .watch-header { display: none; }
.layout.theater .player-shell { flex: 1; min-height: 0; }
.layout.theater .player-frame { height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; }
.layout.theater .embed-help { padding: 6px 12px; }
@media (hover: none) { .video-ui { opacity: 1; pointer-events: auto; } .mc-actions { opacity: 1; } }
@media (max-width: 900px) {
  body { overflow: auto; }
  .layout, .layout.chat-left { height: auto; min-height: 100dvh; flex-direction: column; overflow: visible; }
  .stream-col { flex: none; padding: 0 14px 14px; overflow: visible; }
  .player-shell { flex: none; }
  .player-frame { max-height: none; }
  .chat-col { flex: none; height: 65dvh; border-left: 0; border-top: 1px solid var(--line-soft); }
  .layout.chat-left .chat-col { border-right: 0; }
  .layout.theater .player-frame { height: 60dvh; }
}
@media (max-width: 520px) {
  .np-badge { display: none; }
  .np-actions .btn { font-size: 12px; padding: 5px; }
  .video-volume { width: 44px; margin-right: 4px; }
  .video-toolbar { gap: 3px; }
  .video-state { font-size: 11px; }
  .player-empty-icon { display: none; }
  .player-empty-sub { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* Fullscreen owns the entire watch area so chat stays alongside the video. */
.layout:is(:fullscreen, .expanded-layout) { position: fixed; inset: 0; z-index: 100; width: 100%; height: 100dvh; min-height: 0; background: var(--bg); overflow: hidden; }
.layout:is(:fullscreen, .expanded-layout) .stream-col { flex: 1; min-height: 0; padding: 0; gap: 0; overflow: hidden; }
.layout:is(:fullscreen, .expanded-layout) :is(.watch-header, .paste-form, .now-playing, .embed-help, .chat-head) { display: none; }
.layout:is(:fullscreen, .expanded-layout) .player-shell { flex: 1; min-height: 0; }
.layout:is(:fullscreen, .expanded-layout) .player-frame { height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; }
.layout:is(:fullscreen, .expanded-layout) .embed-help { padding: 6px 12px; }
@media (max-width: 900px) {
  .layout:is(:fullscreen, .expanded-layout) .chat-col { flex: 0 0 38%; height: auto; min-height: 0; }
}
.chat-platform { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-elev); color: var(--text); font: inherit; }
.chat-platform:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.icon-btn { text-decoration: none; }

/* An unobtrusive divider; capture the pointer even when dragging over iframes. */
.chat-resize { flex: 0 0 6px; position: relative; cursor: col-resize; touch-action: none; background: #000; outline-offset: -2px; }
.chat-resize::after { content: ""; position: absolute; inset: 0 2px; background: var(--line-soft); transition: background .15s; }
.chat-resize:hover::after, .chat-resize:focus-visible::after, .resizing-chat .chat-resize::after { background: var(--accent); }
.resizing-chat { cursor: col-resize; user-select: none; }
.resizing-chat iframe { pointer-events: none; }
.chat-col, .layout.chat-left .chat-col { border-left: 0; border-right: 0; }
.stream-col { position: relative; }
.theater-exit { display: none; }
.layout.theater .theater-exit { display: block; position: absolute; top: 10px; left: 12px; z-index: 5; opacity: 0; background: #000c; }
.layout.theater .stream-col:hover .theater-exit, .layout.theater .theater-exit:focus-visible { opacity: 1; }
.layout:is(:fullscreen, .expanded-layout) .theater-exit { display: none; }
@media (hover: none) { .layout.theater .theater-exit { opacity: 1; } }
@media (max-width: 900px) { .chat-resize { display: none; } }

.provider-player { position: absolute; inset: 0; }
.provider-player iframe { width: 100%; height: 100%; }

.stream-suggestions { flex-shrink: 0; }
.suggestion-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; color: #7d8088; font-size: 9px; letter-spacing: .09em; }
.suggestion-heading a { margin-left: auto; color: #777b85; font-size: 10px; letter-spacing: 0; text-decoration: none; }
.suggestion-refresh { border: 0; padding: 0 3px; color: #9498a1; background: transparent; cursor: pointer; font-size: 16px; }
.suggestion-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 160px; overflow-y: auto; scrollbar-width: thin; }
.suggestion-card { display: grid; grid-template-columns: 1fr auto; gap: 5px 16px; flex: 1 1 200px; text-align: left; padding: 12px 14px; min-width: 0; border: 1px solid #25262b; background: #0b0c0e; border-radius: 7px; cursor: pointer; color: #c7c8ce; }
.suggestion-card:hover { border-color: #61566f; background: #111015; }
.suggestion-card strong { font-size: 12px; font-weight: 500; }
.suggestion-platform { font-size: 9px; color: #a79bb8; }
.suggestion-title { grid-column: 1 / -1; font-size: 10px; color: #727681; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.suggestion-status { font-size: 11px; color: #777b85; margin: 0; }
.suggestion-status:empty { display: none; }
.layout.theater .stream-suggestions, .layout:is(:fullscreen, .expanded-layout) .stream-suggestions { display: none; }
.wordmark { display: flex; align-items: center; gap: 4px; }
.wordmark-symbol { object-fit: contain; margin-right: 5px; flex-shrink: 0; }
