:root {
  color-scheme: dark;
  --bg: #090a0d;
  --surface: #15171d;
  --surface-raised: #20232b;
  --border: #30343e;
  --text: #f4f5f8;
  --muted: #9ca3b1;
  --accent: #a23354;
  --accent-hover: #bd4268;
  --danger: #e66d77;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-width: 300px; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; min-height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.app-shell { width: 100%; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.topbar { z-index: 2; height: 64px; flex: none; display: grid; grid-template-columns: 48px 1fr 120px; align-items: center; gap: 12px; padding: 0 22px; background: #111318; border-bottom: 1px solid #ffffff13; }
.menu-button, .icon-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: #ffffff08; font-size: 1.25rem; }
.menu-button:hover, .icon-button:hover { background: #ffffff17; }
.brand { justify-self: start; display: inline-flex; gap: 11px; align-items: center; color: var(--text); text-decoration: none; font-size: 1rem; font-weight: 700; letter-spacing: .01em; }
.brand-icon, .dialog-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: white; }
.token-action { justify-self: end; border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; background: transparent; color: var(--muted); font-size: .82rem; }
.token-action:hover { border-color: var(--accent); color: var(--text); }
.player-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; }
.player-stage { position: relative; flex: 1; min-height: 0; width: 100%; overflow: hidden; background: #030304; }
.player-stage video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; background: #030304; object-fit: contain; }
#video::cue { color: #fff; background: rgba(0, 0, 0, .48); font-family: Arial, sans-serif; font-size: .95em; font-weight: 400; text-shadow: 0 1px 2px #000; }
.empty-state { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; background: radial-gradient(ellipse at center, #1c1c22 0%, #08090c 75%); color: var(--muted); pointer-events: none; transition: opacity .2s; }
.empty-state p { margin: 0; font-size: .95rem; }
.player-stage.has-media .empty-state { opacity: 0; }
.player-footer { min-height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 5px 18px; background: #111318; border-top: 1px solid #ffffff13; }
.status { min-width: 0; margin: 0; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.error { color: var(--danger); }
.stop-button { min-height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; background: var(--surface-raised); color: var(--text); font-size: .78rem; font-weight: 650; }
.stop-button:hover:not(:disabled) { border-color: var(--danger); color: #fff; background: #542630; }
.drawer-backdrop { position: fixed; z-index: 5; inset: 0; visibility: hidden; opacity: 0; background: #0009; backdrop-filter: blur(3px); transition: opacity .22s, visibility .22s; }
.channel-drawer { position: fixed; z-index: 6; inset: 0 auto 0 0; display: flex; flex-direction: column; width: min(390px, 88vw); padding: max(18px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(19, 21, 27, .96); border-right: 1px solid #ffffff1a; box-shadow: 18px 0 60px #0008; backdrop-filter: blur(22px); transform: translateX(-105%); transition: transform .24s ease; }
.drawer-open .drawer-backdrop { visibility: visible; opacity: 1; }
.drawer-open .channel-drawer { transform: translateX(0); }
.drawer-heading { min-height: 42px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 1rem; }
.icon-button { width: 36px; height: 36px; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.search-field { height: 46px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: #0c0e12; color: var(--muted); font-size: 1.2rem; }
.search-field:focus-within { border-color: var(--accent-hover); box-shadow: 0 0 0 2px #a2335433; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .9rem; }
.search-field input::placeholder { color: #7f8794; }
.filter-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 13px 0 10px; padding: 4px; border-radius: 10px; background: #0c0e12; }
.filter-tabs button { min-height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: .82rem; }
.filter-tabs button.active { background: #30333c; color: var(--text); font-weight: 650; }
.stream-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 12px; }
.stream-item { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 11px; margin: 2px 0; padding: 8px 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; text-align: left; }
.stream-item:hover { background: #ffffff0b; }
.stream-item.selected { border-color: #a2335477; background: #a2335425; }
.stream-badge { flex: none; min-width: 42px; padding: 4px 6px; border-radius: 5px; text-align: center; font-size: .6rem; font-weight: 800; letter-spacing: .06em; }
.stream-badge.live { background: #8f2c36; color: #ffe4e5; }
.stream-badge.vod { background: #39476d; color: #e2eaff; }
.stream-thumb { width: 30px; height: 30px; flex: none; object-fit: contain; border-radius: 5px; background: #ffffff0a; }
.stream-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.list-message { margin: 18px 8px; color: var(--muted); font-size: .84rem; }
.drawer-logout { flex: none; min-height: 48px; display: flex; align-items: center; gap: 12px; margin-top: 8px; padding: 0 10px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--muted); text-align: left; font-size: .86rem; }
.drawer-logout:hover { color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
dialog { width: min(420px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 25px 90px #000a; }
dialog::backdrop { background: #07080bcc; backdrop-filter: blur(5px); }
dialog form { padding: 28px; }
.dialog-mark { width: 42px; height: 42px; margin-bottom: 20px; font-weight: 800; font-size: 1.2rem; }
dialog h1 { margin: 0 0 6px; font-size: 1.25rem; }
dialog p { color: var(--muted); font-size: .86rem; line-height: 1.5; }
.token-field { display: block; margin-top: 22px; color: var(--muted); font-size: .8rem; }
.token-field input { width: 100%; height: 46px; margin-top: 7px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; background: #0d0f13; color: var(--text); outline: none; }
.token-field input:focus { border-color: var(--accent-hover); }
.remember-row { display: flex; align-items: center; gap: 9px; margin: 13px 0; color: var(--muted); font-size: .8rem; }
.remember-row input { accent-color: var(--accent); }
.dialog-error { min-height: 20px; margin: 5px 0 11px; color: var(--danger); font-size: .8rem; }
.play-button { min-height: 48px; border: 0; border-radius: 9px; padding: 0 18px; background: var(--accent); color: white; font-weight: 700; }
.play-button:hover { background: var(--accent-hover); }
.dialog-submit { width: 100%; }
#playerStage:fullscreen { width: 100vw; height: 100dvh; max-width: none; border: 0; border-radius: 0; }
#playerStage:fullscreen video { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 600px) {
  .topbar { height: 56px; grid-template-columns: 42px 1fr auto; gap: 9px; padding: 0 12px; }
  .menu-button { width: 38px; height: 38px; }
  .brand { gap: 8px; font-size: .91rem; }
  .brand-icon { width: 29px; height: 29px; }
  .token-action { padding: 8px 9px; font-size: .74rem; }
  .player-footer { min-height: 46px; padding-inline: 10px; }
  .status { font-size: .74rem; }
  .channel-drawer { width: min(360px, 88vw); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .topbar { height: 44px; min-height: 44px; }
  .menu-button { width: 34px; height: 34px; }
  .brand-icon { width: 27px; height: 27px; }
  .player-footer { min-height: 38px; }
}

/* w8play authentication and session status, styled to match research/webClient. */
.topbar { grid-template-columns: 48px minmax(0, 1fr) auto; }
.topbar-right { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.connection-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .7rem; white-space: nowrap; }
.connection-state i, .status-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #747984; }
.connection-state.ready i, .status-dot.active { background: #9b3c5a; box-shadow: 0 0 10px #a2335470; }
.connection-state.error i, .status-dot.error { background: var(--danger); }
.account-name { max-width: 100px; overflow: hidden; color: var(--text); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.token-action { justify-self: end; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: transparent; color: var(--muted); font-size: .72rem; }
.token-action:hover { border-color: var(--accent-hover); color: var(--text); }
.player-stage.playing .empty-state { opacity: 0; }
#playerFrame:fullscreen { width: 100vw; height: 100dvh; max-width: none; border: 0; border-radius: 0; }
#playerFrame:fullscreen video { width: 100%; height: 100%; object-fit: contain; }
.empty-state p { padding: 0 20px; text-align: center; }
.player-footer { gap: 12px; }
.status-wrap { min-width: 0; display: flex; align-items: center; gap: 9px; }
.status.error { color: var(--danger); }
.busy-overlay { position: absolute; z-index: 2; inset: 0; display: flex; align-items: center; justify-content: center; gap: 11px; background: #08090dcc; color: var(--text); font-size: .82rem; }
.busy-overlay[hidden] { display: none; }
.spinner { width: 17px; height: 17px; border: 2px solid #ffffff32; border-top-color: var(--accent-hover); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drawer-footer { flex: none; }
.library-footer { min-height: 37px; }
.drawer-logout { width: 100%; margin-top: 0; border-top: 0; }
.drawer-logout[hidden], .token-action[hidden], .account-name[hidden] { display: none; }
.filter-tabs button span { margin-left: 3px; color: #7c818c; font-size: .67rem; }
.filter-tabs button.active span { color: #dfa3b4; }
.channel-drawer { overflow-y: auto; overscroll-behavior: contain; }
.drawer-heading, .search-field, .filter-tabs, .drawer-footer { flex: none; }
.stream-list {
  flex: 1 1 0;
  height: 0;
  min-height: 120px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #55515a #17191f;
}
.stream-list::-webkit-scrollbar { width: 9px; }
.stream-list::-webkit-scrollbar-track { border-radius: 6px; background: #17191f; }
.stream-list::-webkit-scrollbar-thumb { border: 2px solid #17191f; border-radius: 6px; background: #55515a; }
.stream-list::-webkit-scrollbar-thumb:hover { background: #82727c; }
.stream-item:focus-visible, .menu-button:focus-visible, .icon-button:focus-visible,
.token-action:focus-visible, .stop-button:focus-visible, .filter-tabs button:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}
.login-dialog { width: min(430px, calc(100% - 28px)); border: 1px solid #ffffff20; border-radius: 13px; padding: 0; background: rgba(25, 22, 27, .98); color: var(--text); box-shadow: 0 25px 100px #000c; }
.login-dialog::backdrop { background: #08070bd9; backdrop-filter: blur(10px); }
.login-card { padding: 31px 34px 25px; }
.dialog-mark { margin-bottom: 20px; background: var(--accent); color: white; }
.eyebrow { color: #c18b9d; font-size: .62rem; font-weight: 750; letter-spacing: .16em; }
.login-card h1 { margin: 8px 0 5px; font-size: 1.5rem; font-weight: 620; letter-spacing: -.045em; }
.login-copy { margin: 0 0 22px; color: var(--muted); font-size: .77rem; line-height: 1.55; }
.form-field { display: block; margin-top: 14px; color: #babdc5; font-size: .72rem; }
.form-field input { width: 100%; height: 44px; margin-top: 7px; border: 1px solid var(--border); border-radius: 8px; outline: none; padding: 0 11px; background: #0d0f13; color: var(--text); font-size: .86rem; }
.form-field input:focus { border-color: var(--accent-hover); box-shadow: 0 0 0 2px #a2335429; }
.login-error { min-height: 20px; margin: 8px 0 3px; color: var(--danger); font-size: .75rem; }
.login-submit { width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 8px; padding: 0 14px; background: var(--accent); color: #fff; font-size: .82rem; font-weight: 700; }
.login-submit:hover { background: var(--accent-hover); }
.login-submit:disabled { opacity: .6; }
.login-footnote { margin: 14px 0 0; color: #777c85; font-size: .65rem; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
@media (max-width: 600px) {
  .topbar { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .topbar-right { gap: 8px; }
  .connection-state { font-size: 0; }
  .connection-state i { width: 8px; height: 8px; }
  .account-name { max-width: 62px; font-size: .65rem; }
  .token-action { padding: 7px 8px; font-size: .68rem; }
  .login-card { padding: 27px 23px 22px; }
}

/* Full-window playback with a left drawer that opens only from the hamburger. */
.app-shell { position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar { position: relative; inset: auto; z-index: 4; height: 64px; min-height: 64px; padding: 0 16px; background: #111318; border-bottom: 1px solid #ffffff13; }
.player-layout { position: relative; inset: auto; display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-height: 0; height: auto; }
.player-stage { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; width: 100%; height: auto; }
.player-footer { position: relative; inset: auto; z-index: 2; min-height: 50px; flex: none; background: #111318; border-top: 1px solid #ffffff13; pointer-events: auto; }
.channel-drawer { left: 0; right: auto; top: 0; bottom: 0; width: min(360px, 88vw); height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; padding-inline: 12px; overflow: hidden; }
body:not(.drawer-open) .channel-drawer { pointer-events: none; }
body.drawer-open .channel-drawer { pointer-events: auto; }
.stream-list { flex: 1 1 0; height: auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.drawer-heading, .search-field, .filter-tabs, .drawer-footer { flex: none; }
.drawer-backdrop { z-index: 5; }
.channel-drawer { z-index: 6; }
@media (max-width: 600px) {
  .topbar { height: 56px; min-height: 56px; padding-inline: 10px; }
  .player-footer { min-height: 46px; padding-inline: 10px; }
}
