/* =========================================================================
   app.css  -  BrazilStream Universal WebPlayer
   Mobile-first: phone -> tablet -> desktop -> TV.
   Replaces tv.css / style.css / newresponsive.css
   ========================================================================= */

/* ---------- Theme variables (overridden by panel branding) ---------- */
:root {
    --bs-primary: #412b6b;
    --bs-secondary: #5c3e94;
    --bs-accent: #f25912;
    --bs-unfocus: #5c3e94;
    --bs-overlay: rgba(0, 0, 0, .2);
    --bs-bg: url('images/background.png');
    --bs-login-bg: url('images/login_background.png');

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    --sidebar-w: 260px;
    --header-h: 56px;
    --tile-w: 86px;
    --tile-gap: 10px;
    --ease: cubic-bezier(.4, 0, .2, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: #0d0b17;
    color: #fff;
    overflow: hidden;
}

img { max-width: 100%; }
a { color: #fff; text-decoration: none; }
button { font-family: inherit; }

body.attechback {
    background: var(--bs-bg) center/cover no-repeat fixed;
    background-color: #0d0b17;
    color: #fff;
}

/* Focus: subtle on touch, strong on keyboard/remote */
#app-root { position: relative; z-index: 40; height: 100%; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--bs-accent); outline-offset: 3px; }
[tabindex]:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid var(--bs-accent);
    outline-offset: 2px;
}

/* ---------- App shell ---------- */
#shell { display: flex; width: 100%; height: 100%; }

#main-host { flex: 1; min-width: 0; height: 100%; overflow: hidden; }

#side-host {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(78vw, var(--sidebar-w));
    max-width: 85vw;
    background: linear-gradient(180deg, #0b1220, #060a12);
    border-right: 1px solid rgba(255,255,255,.06);
    z-index: 80;
    transform: translateX(-105%);
    transition: transform .28s var(--ease);
    display: flex;
    flex-direction: column;
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 14px calc(var(--safe-bottom) + 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#side-host.open { transform: translateX(0); box-shadow: var(--shadow); }

/* Mobile overlay backdrop */
#side-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 70;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s var(--ease), visibility .25s;
}
#side-backdrop.show { opacity: 1; visibility: visible; }

/* Prevent body scroll while drawer is open */
body.drawer-open { overflow: hidden; }

.sb-logo {
    width: 100%;
    max-width: 180px;
    object-fit: contain;
    margin: 0 auto 20px;
    display: block;
}
.sb-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,.72);
    font-size: 16px;
    font-weight: 600;
    background: transparent;
    border: 2px solid transparent;
    cursor: pointer;
    text-align: left;
    width: 100%;
    min-height: 44px;
}
.sb-item svg { flex-shrink: 0; }
.sb-item img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0) invert(1) opacity(.75);
}
.sb-item.active { background: var(--bs-accent); border-color: var(--bs-accent); color: #fff; }
.sb-item.active img { filter: none; }
.sb-item:focus-visible { border-color: var(--bs-accent); transform: translateX(4px); }
.sb-item:not(.active):focus-visible { background: rgba(242,89,18,.16); color: #fff; }
.sb-bottom {
    padding-top: 14px;
    text-align: center;
    color: rgba(255,255,255,.5);
    font-size: 13px;
}

/* Hamburger button (mobile only, hidden >= tablet) */
#hamburger-host { position: relative; z-index: 60; }
#hamburger-host.visible-hidden { display: none; }
.app-header-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    padding: 4px 10px;
    background: linear-gradient(180deg, rgba(0,0,0,.6), rgba(0,0,0,0));
}
.app-header-mobile .app-header-logo {
    height: 34px;
    max-width: 60%;
    object-fit: contain;
    margin-right: auto;
}
#hamburger-host:empty { display: none; }

#hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    border-radius: 8px;
    flex: none;
    touch-action: manipulation;
}
#hamburger:focus-visible { outline: 3px solid var(--bs-accent); }

#side-host.visible-hidden { display: none; }

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    height: var(--header-h);
    background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
    gap: 10px;
    position: relative;
    z-index: 50;
}
.app-header .brand-logo { width: 110px; height: auto; }
.app-header .brand-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.app-header .nav-icon-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 10px;
    cursor: pointer;
    min-width: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.app-header img.img-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.6));
}
.app-title {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Screens ---------- */
.screen {
    padding: 12px;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--safe-bottom) + 12px);
}
.screen::-webkit-scrollbar { width: 6px; height: 6px; }
.screen::-webkit-scrollbar-thumb { background: var(--bs-secondary); border-radius: 3px; }

/* ---------- Listing screens ---------- */
.listing-screen { overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.listing-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex: none;
}
.listing-top .section-title { font-size: 20px; font-weight: 700; letter-spacing: .5px; }

/* On mobile: vertical category column beside content (like Roku/mobile IPTV apps) */
.bs-layout { flex: 1; display: flex; flex-direction: row; min-height: 0; gap: 8px; }

/* Categories: vertical column on mobile, tablet+ keeps as sidebar.
   The CatBar markup renders inside <nav class="cat-sidebar">.
   Grid rows of uniform height -> tidy, aligned list on every screen size. */
.cat-sidebar {
    flex: none;
    display: grid;
    grid-auto-rows: 48px;
    gap: 3px;
    width: 96px;
    overflow-x: visible;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(17,0,34,.32);
    border: 2px solid var(--bs-secondary);
    border-radius: var(--radius);
    padding: 6px;
}
.cat-sidebar::-webkit-scrollbar { width: 0; display: none; }
.cat-sidebar .cat-sidebar-title {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--bs-accent);
    font-size: 12px;
    border-bottom: 2px solid var(--bs-secondary);
    margin: 0 2px 2px;
}

.cat-item {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    -webkit-box-pack: center;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: left;
    padding: 6px 6px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: rgba(0,0,0,.28);
    color: #fff;
    font-size: 12px;
    line-height: 1.25;
    cursor: pointer;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.cat-item.active {
    border-color: var(--bs-accent);
    background: var(--bs-primary);
    box-shadow: 0 0 0 3px var(--bs-accent);
}
.cat-item:focus-visible { border-color: var(--bs-accent); }

.content-panel { flex: 1; min-width: 0; overflow-y: auto; padding: 2px; -webkit-overflow-scrolling: touch; }

/* ---------- Cards / tiles ---------- */
.tile-grid, .vod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr));
    gap: var(--tile-gap);
    padding: 4px;
}
.tile {
    position: relative;
    background: linear-gradient(160deg, rgba(65,43,107,.55), rgba(92,62,148,.35));
    border: 2px solid var(--bs-secondary);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: transform .12s var(--ease);
    display: flex;
    flex-direction: column;
}
.tile:active { transform: scale(.97); }
.tile:focus-visible { border-color: var(--bs-accent); background: var(--bs-primary); }
.tile-fav::after {
    content: '\2605';
    position: absolute;
    top: 6px;
    right: 10px;
    color: var(--bs-accent);
    font-size: 18px;
    text-shadow: 0 2px 6px rgba(0,0,0,.9);
    z-index: 2;
    pointer-events: none;
}
.tile img.tile-poster { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; }
.tile .tile-title { margin-top: 7px; font-size: 12px; font-weight: 600; min-height: 30px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .tile-icon { width: 38px; height: 38px; object-fit: contain; margin: 10px auto 4px; display: block; }
.tile .tile-label { font-size: 15px; font-weight: 700; }

.vod-grid .tile img.tile-poster { aspect-ratio: 2/3; }

/* ---------- Details overlay (movies / series) ---------- */
.detail-screen { overflow-y: auto; overscroll-behavior: contain; }
.detail-wrap { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.detail-poster { flex: none; }
.detail-poster img {
    width: 150px;
    max-width: 55vw;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 14px;
    border: 2px solid var(--bs-secondary);
    background: #000;
    display: block;
}
.detail-body { flex: 1; min-width: 0; }
.detail-title { margin: 0 0 8px; font-size: 20px; line-height: 1.2; }
.detail-rating { font-size: 14px; color: rgba(255,255,255,.85); margin-bottom: 12px; }
.detail-desc { font-size: 15px; color: rgba(255,255,255,.78); min-height: 54px; margin: 0 0 6px; }
.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 6px; }
.detail-cast { margin-top: 12px; font-size: 14px; color: rgba(255,255,255,.6); }
.detail-episodes h3 {
    color: var(--bs-accent);
    font-size: 15px;
    margin: 18px 0 8px;
    letter-spacing: 1px;
}
.episode-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 10px;
    border: 2px solid var(--bs-secondary);
    background: rgba(0,0,0,.3);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
}
.episode-btn:focus-visible { border-color: var(--bs-accent); background: var(--bs-primary); }

/* Horizontal rows (dashboard style) */
.row-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 4px 12px;
    -webkit-overflow-scrolling: touch;
}
.row-track::-webkit-scrollbar { height: 4px; }
.row-track::-webkit-scrollbar-thumb { background: var(--bs-secondary); border-radius: 2px; }
.row-card {
    flex: 0 0 auto;
    width: 150px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(18,14,33,.6);
    border: 2.5px solid transparent;
    cursor: pointer;
    padding: 0;
    text-align: left;
    font-family: inherit;
}
.row-card:active { transform: scale(.97); }
.row-card:focus-visible { border-color: var(--bs-accent); transform: scale(1.03); }
.rc-media { position: relative; }
.rc-poster { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #000; }
.rc-num {
    position: absolute;
    top: 8px; left: 8px;
    font-weight: 800; font-size: 14px;
    color: #fff;
    background: var(--bs-accent);
    border-radius: 6px;
    padding: 3px 8px;
    text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.rc-badge {
    position: absolute;
    top: 8px; left: 8px;
    font-weight: 800; font-size: 11px;
    letter-spacing: 1px;
    color: #fff;
    background: rgba(0,0,0,.6);
    border-radius: 6px;
    padding: 3px 8px;
}
.rc-resume-icon {
    position: absolute;
    bottom: 8px; right: 8px;
    width: 28px; height: 28px;
    display: flex;
    align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(0,0,0,.65);
    color: #fff;
    font-size: 13px;
}
.rc-title { font-size: 14px; font-weight: 600; padding: 8px 10px 9px; color: #fff; line-height: 1.2; }
.rc-resume-min { font-size: 12px; color: var(--bs-accent); padding: 0 10px 8px; font-weight: 700; }

/* ---------- Category chips / EPG bar ---------- */
.category-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.category-chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid var(--bs-secondary);
    background: linear-gradient(135deg, var(--bs-primary), var(--bs-secondary));
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}
.category-chip.active { border-color: var(--bs-accent); box-shadow: 0 0 0 3px var(--bs-accent); }

.epg-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    background: linear-gradient(135deg, rgba(65,43,107,.75), rgba(92,62,148,.5));
    border: 2px solid var(--bs-secondary);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.epg-bar .epg-bar-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #000; }
.epg-bar .epg-bar-name { font-size: 17px; font-weight: 700; }
.epg-bar .epg-bar-now { font-size: 14px; color: #ffe9d2; flex-basis: 100%; }
.epg-bar .epg-bar-now b { color: var(--bs-accent); margin-right: 6px; }
.epg-bar .epg-bar-next { font-size: 13px; color: rgba(255,255,255,.75); margin-top: 2px; flex-basis: 100%; }
.epg-bar .epg-bar-next b { color: rgba(255,255,255,.45); margin-right: 6px; font-weight: 700; }

/* ---------- Login ---------- */
.login-screen {
    display: flex;
    height: 100%;
    min-height: 100vh;
    background: var(--bs-bg) center/cover no-repeat fixed;
    background-color: #17123a;
    background-image: var(--bs-login-bg, var(--bs-bg));
    padding: 20px;
    overflow-y: auto;
}
.login-screen .login-box { margin: auto; }
.login-box {
    width: 100%;
    max-width: 380px;
    padding: 18px 16px 22px;
    border-radius: 16px;
    background: rgba(0,0,0,.5);
    border: 2px solid var(--bs-primary);
    text-align: center;
}
.login-box .login-logo { width: 240px; max-width: 82%; margin-bottom: 12px; object-fit: contain; }
.login-box h1 { font-size: 17px; margin-bottom: 12px; color: #fff; letter-spacing: .5px; }
.login-field {
    width: 100%;
    margin-bottom: 9px;
    padding: 11px 12px;
    font-size: 16px;
    border-radius: 10px;
    border: 2px solid var(--bs-secondary);
    background: rgba(255,255,255,.08);
    color: #fff;
    cursor: text;
    text-align: center;
    -webkit-appearance: none;
}
.login-field::placeholder { color: rgba(255,255,255,.5); }
.login-field:focus { border: 2px solid var(--bs-accent); background: rgba(255,255,255,.14); }
.login-field .fa { margin-right: 8px; }
.login-field input::placeholder { color: rgba(255,255,255,.5); }
.btn-adduser {
    margin-top: 4px;
    width: 100%;
    padding: 13px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--bs-accent), #e65100);
    color: #fff;
    cursor: pointer;
}
.btn-adduser:active { transform: scale(.98); }
.btn-adduser .checkingspin { color: #fff !important; }

/* ---------- Dashboard ---------- */
.screen.dash-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 0;
}
.dash-grid { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.dash-main-tile {
    background: linear-gradient(160deg, var(--bs-primary), var(--bs-secondary));
    border: 2px solid var(--bs-secondary);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 130px;
}
.dash-main-tile:focus-visible { border-color: var(--bs-accent); }
.dash-main-tile img { width: 90px; height: 66px; object-fit: contain; }
.dash-main-tile span { display: block; margin-top: 10px; font-size: 20px; font-weight: 700; }
.dash-sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dash-sub-tile {
    background: linear-gradient(160deg, rgba(65,43,107,.7), rgba(92,62,148,.5));
    border: 2px solid var(--bs-secondary);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.dash-sub-tile:focus-visible { border-color: var(--bs-accent); }
.dash-sub-tile img { width: 64px; height: 64px; object-fit: contain; }
.dash-sub-tile span { display: block; margin-top: 8px; font-size: 16px; font-weight: 600; }
.dash-strip { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.dash-strip-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--bs-primary), var(--bs-secondary));
    border: 2px solid var(--bs-secondary);
    border-radius: var(--radius);
    padding: 14px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    min-height: 48px;
}
.dash-strip-btn img { width: 28px; height: 28px; object-fit: contain; }
.dash-strip-btn:focus-visible { border-color: var(--bs-accent); }
.dash-footer {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    color: rgba(255,255,255,.8);
    font-size: 13px;
    gap: 6px;
}

/* Dash preview (live channel) */
.dash-shell { height: 100%; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.dash-preview { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.dash-info { flex: none; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.dash-ch-logo { width: 90px; height: 90px; object-fit: contain; margin: 0 auto 6px; filter: drop-shadow(0 4px 12px rgba(0,0,0,.6)); }
.dash-ch-num { font-size: 17px; font-weight: 800; color: var(--bs-accent); }
.dash-ch-name { font-size: 24px; font-weight: 800; line-height: 1.12; }
.dash-epg-line { color: rgba(255,255,255,.8); font-size: 14px; line-height: 1.45; }
.dash-epg-line b { color: var(--bs-accent); margin-right: 6px; font-size: 13px; letter-spacing: 1px; }
.dash-user { margin-top: 8px; font-size: 13px; color: rgba(255,255,255,.45); }
.dash-video {
    position: relative;
    flex: 1;
    min-height: 200px;
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    border: 2px solid var(--bs-secondary);
    cursor: pointer;
}
.dash-video video { width: 100%; height: 100%; object-fit: contain; }
.dash-video-hint {
    position: absolute;
    right: 10px; bottom: 8px;
    font-size: 13px;
    color: rgba(255,255,255,.85);
    background: rgba(0,0,0,.55);
    padding: 5px 10px;
    border-radius: 8px;
}
.dash-rows { display: flex; flex-direction: column; gap: 18px; }
.dash-row .row-label { font-size: 18px; font-weight: 800; margin-bottom: 8px; }

/* ---------- Toasts / loading ---------- */
.ui-toast {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 6000;
    width: calc(100% - 32px);
    max-width: 460px;
    padding: 14px 18px;
    border-radius: 10px;
    background: var(--bs-primary);
    border: 2px solid var(--bs-secondary);
    color: #fff;
    font-size: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}
.ui-toast.show { display: block; }
.ui-toast.error { background: #b3261e; }

.ui-loading {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 7000;
    background: rgba(0,0,0,.72);
    display: none;
    align-items: center;
    justify-content: center;
}
.ui-loading[data-show="1"] { display: flex; }
.ui-loading-box { text-align: center; }
.ui-spinner {
    width: 54px; height: 54px;
    margin: 0 auto 14px;
    border-radius: 50%;
    border: 6px solid var(--bs-secondary);
    border-top-color: var(--bs-accent);
    animation: bs-spin .9s linear infinite;
}
@keyframes bs-spin { to { transform: rotate(360deg); } }
.ui-loading-label { color: #fff; font-size: 17px; }

/* ---------- Dialogs ---------- */
.ui-dialog {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 6500;
    background: rgba(0,0,0,.6);
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.ui-dialog.show { display: flex; }
.ui-dialog-box {
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px 18px;
    border-radius: 16px;
    background: #14102a;
    border: 2px solid var(--bs-primary);
    text-align: center;
    color: #fff;
}
.ui-dialog-box h3 { margin: 0 0 10px; font-size: 21px; }
.ui-dialog-box p { margin: 0 0 18px; font-size: 16px; color: rgba(255,255,255,.85); }
.ui-dialog-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ui-btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: 2px solid var(--bs-secondary);
    background: #1c1640;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    min-height: 44px;
}
.ui-btn.primary { background: linear-gradient(90deg, var(--bs-accent), #e65100); border-color: var(--bs-accent); }

/* PIN */
.pin-display { letter-spacing: 12px; font-size: 30px; margin: 12px 0; min-height: 40px; }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.pin-key {
    height: 60px;
    font-size: 22px;
    border-radius: 12px;
    border: 2px solid var(--bs-secondary);
    background: #1c1640;
    color: #fff;
    cursor: pointer;
    min-width: 0;
}
.pin-key:active { background: var(--bs-primary); }

/* Keyboard */
.kb-box { max-width: 640px; }
.kb-input {
    width: 100%;
    padding: 12px;
    font-size: 18px;
    border-radius: 8px;
    border: 2px solid var(--bs-secondary);
    background: rgba(255,255,255,.1);
    color: #fff;
    text-align: center;
    margin-bottom: 12px;
}
.kb-grid .kb-row { display: flex; justify-content: center; gap: 6px; margin: 4px 0; flex-wrap: wrap; }
.kb-key {
    width: auto;
    min-width: 40px;
    height: 44px;
    padding: 0 8px;
    font-size: 16px;
    border-radius: 8px;
    border: 2px solid var(--bs-secondary);
    background: #1c1640;
    color: #fff;
    cursor: pointer;
    flex: 0 0 auto;
}
.kb-key:active { background: var(--bs-primary); }
.kb-key.blank { background: transparent; border-color: transparent; }
.kb-bottom { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.kb-act {
    padding: 10px 20px;
    font-size: 15px;
    border-radius: 8px;
    border: 2px solid var(--bs-secondary);
    background: #1c1640;
    color: #fff;
    cursor: pointer;
    min-height: 42px;
}

/* ---------- EPG ---------- */
.epg-now { display: block; color: var(--bs-accent); font-weight: 700; margin-top: 2px; }
.epg-list-item {
    padding: 12px 14px;
    border-left: 4px solid var(--bs-secondary);
    background: rgba(0,0,0,.3);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}
.epg-list-item:focus-visible { border-left-color: var(--bs-accent); background: var(--bs-primary); }
.epg-list-item .epg-time { font-size: 13px; color: #aaa; }

/* ---------- Player ---------- */
#player-title { text-shadow: 0 2px 8px rgba(0,0,0,.9); font-size: 18px !important; padding: 12px 14px !important; }
#player-video { background: #000; }

.player-controls {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 14px 14px calc(10px + var(--safe-bottom));
    background: linear-gradient(transparent, rgba(0,0,0,.82));
    z-index: 30;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity .15s ease, transform .15s ease;
    pointer-events: none;
}
.player-controls.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.pc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pc-progress {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,.25);
    cursor: pointer;
    position: relative;
}
.pc-fill { height: 100%; border-radius: 3px; background: var(--bs-accent); }
.pc-times { color: rgba(255,255,255,.9); font-size: 13px; font-family: 'Courier New', monospace; white-space: nowrap; }
.pc-slash { margin: 0 4px; color: rgba(255,255,255,.5); }
.pc-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-btn {
    min-width: 46px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,.12);
    border: 2px solid transparent;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    min-height: 42px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.pc-btn:hover { background: rgba(255,255,255,.22); }
.pc-btn:focus-visible { outline: none; border-color: var(--bs-accent); }
.pc-play { flex: 1 1 120px; }
.pc-spacer { flex: 1; }
.pc-hint { margin-top: 8px; color: rgba(255,255,255,.75); font-size: 13px; text-align: center; }
.pc-hint:empty { display: none; }
.pc-hint .ps-ok { color: var(--bs-accent); font-weight: 700; }

/* ---------- Switch user ---------- */
.login-box.switch-box { max-width: 640px; }
.user-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: flex-start;
    max-height: 46vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px;
}
.user-card {
    background: linear-gradient(160deg, rgba(65,43,107,.6), rgba(92,62,148,.4));
    border: 2px solid var(--bs-secondary);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    flex-wrap: nowrap;
    width: 100%;
}
.user-card:focus-visible { border-color: var(--bs-accent); }
.user-card img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.user-card .anyName { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .userlistshowname { font-size: 13px; color: rgba(255,255,255,.75); word-break: break-all; overflow: hidden; text-overflow: ellipsis; }
.user-actions { display: flex; gap: 8px; margin-left: auto; flex: none; }
.user-actions button, .user-actions a { padding: 8px 12px; border-radius: 8px; border: none; font-size: 14px; cursor: pointer; color: #fff; display: inline-flex; align-items: center; }
.user-actions .btn-login { background: linear-gradient(90deg, var(--bs-accent), #e65100); }
.user-actions .btn-del { background: #b3261e; }

/* ---------- Settings ---------- */
.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,.3);
    border: 2px solid var(--bs-secondary);
    border-radius: var(--radius);
    padding: 13px 14px;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 16px;
    min-height: 48px;
}
.setting-row:focus-visible { border-color: var(--bs-accent); }
.setting-row img { width: 30px; height: 30px; object-fit: contain; }
.setting-row .setting-right { margin-left: auto; color: rgba(255,255,255,.7); font-size: 14px; }

/* ---------- Account / user info ---------- */
.ui-account-wrap { display: flex; flex-direction: column; }
.ui-account {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    margin-top: 10px;
    border-radius: var(--radius);
    background: rgba(0,0,0,.28);
    border: 2px solid var(--bs-secondary);
    padding: 20px 16px;
}
.ui-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--bs-secondary);
    object-fit: cover;
    flex: none;
}
.ui-data { flex: 1; min-width: 0; width: 100%; text-align: center; }
.ui-name { margin: 0 0 14px; font-size: 22px; color: #fff; }
.ui-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    text-align: left;
}
.ui-table .k { color: rgba(255,255,255,.6); padding: 9px 12px 9px 0; white-space: nowrap; }
.ui-table .v { padding: 9px 0; word-break: break-all; }

/* ---------- Search ---------- */
.msearch-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.msearch-tabs { margin: 12px 0 8px; }
.tab-btn { color: #fff; font-size: 15px; }
.section-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 20px; font-weight: 700; }
.back-float {
    margin-bottom: 10px;
    background: var(--bs-primary);
    border: 2px solid var(--bs-secondary);
    color: #fff;
    font-size: 15px;
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
}

/* ---------- EPG grid (keep light overrides) ---------- */
.epg-channels { width: 220px; }
.epg-grid, .epg-contents { min-width: 0; max-width: 100%; }
.epg-programmes .programme .title { font-size: 14px; line-height: 1.2; }

/* ============================================================
   TABLET (>= 640px)
   ============================================================ */
@media (min-width: 640px) {
    :root { --tile-w: 160px; --tile-gap: 14px; }

    #hamburger { display: none; }
    #hamburger-host { display: none; }
    #side-host {
        position: relative;
        transform: none;
        width: 210px;
        max-width: 210px;
        box-shadow: none;
    }
    #side-backdrop { display: none; }
    body.drawer-open { overflow: hidden; }

    .app-header { padding: 10px 20px; }
    .app-header .brand-logo { width: 130px; }

    .screen { padding: 20px; }

    .dash-grid { flex-direction: row; flex-wrap: wrap; }
    .dash-main-tile { flex: 1 1 40%; min-width: 220px; }
    .dash-sub-grid { grid-template-columns: 1fr 1fr; flex: 1 1 50%; }
    .dash-strip { flex-direction: row; }

    .bs-layout { flex-direction: row; gap: 14px; }
    .cat-sidebar {
        display: grid;
        grid-auto-rows: 44px;
        gap: 4px;
        align-self: stretch;
        width: 180px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: rgba(17,0,34,.45);
        border: 2px solid var(--bs-secondary);
        border-radius: var(--radius);
        padding: 8px;
    }
    .cat-sidebar::-webkit-scrollbar { width: 6px; height: 8px; }
    .cat-sidebar .cat-sidebar-title {
        display: flex;
        align-items: center;
        padding: 2px 10px;
        font-weight: 700;
        letter-spacing: 1px;
        color: var(--bs-accent);
        font-size: 13px;
        border-bottom: 2px solid var(--bs-secondary);
        margin: 0 2px 4px;
    }
    .cat-sidebar .cat-item {
        display: flex;
        align-items: center;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 100%;
        min-width: 0;
        text-align: left;
        padding: 6px 10px;
        border-radius: 8px;
        border: 2px solid transparent;
        background: rgba(0,0,0,.28);
        color: #fff;
        font-size: 14px;
    }
    .cat-sidebar .cat-item.active {
        border-color: var(--bs-accent);
        background: var(--bs-primary);
        box-shadow: 0 0 0 3px var(--bs-accent);
    }

    .detail-wrap { flex-direction: row; gap: 26px; align-items: flex-start; }
    .detail-body { max-width: 860px; }
    .detail-poster img { width: 190px; max-width: none; }
    .detail-title { font-size: 24px; }
    .detail-desc { font-size: 15px; }
    .detail-actions { margin: 18px 0 8px; }
    .detail-actions .btn-adduser { width: auto; flex: 0 0 auto; padding: 12px 24px; font-size: 15px; min-height: 44px; }
    .detail-episodes { max-width: 720px; }
    .episode-btn { padding: 11px 16px; font-size: 15px; }

    .dash-preview { flex-direction: row; }
    .dash-info { text-align: left; align-items: flex-start; width: 240px; flex: none; }
    .dash-ch-logo { margin: 0 0 6px; }
    .dash-video { aspect-ratio: 16 / 9; align-self: flex-start; min-height: 0; }

    .login-box { padding: 28px 34px 32px; }
    .login-box .login-logo { width: 260px; }

    .ui-account { flex-direction: row; align-items: flex-start; padding: 26px 28px; }
    .ui-data { text-align: left; }
    .ui-avatar { width: 150px; height: 150px; }
    .ui-table { font-size: 17px; }

    .tile-grid, .vod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================================================
   DESKTOP (>= 1024px)
   ============================================================ */
@media (min-width: 1024px) {
    :root { --tile-w: 220px; --tile-gap: 18px; --sidebar-w: 250px; --header-h: 64px; }

    .app-title { font-size: 22px; }
    .screen { padding: 24px 30px; }

    .cat-sidebar { width: 230px; }
    .tile-grid, .vod-grid { gap: var(--tile-gap); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .row-card { width: 190px; }

    .dash-video { max-width: 480px; align-self: center; }

    .tile { padding: 14px; }
    .tile:hover { transform: scale(1.03); border-color: var(--bs-secondary); }
    .row-card:hover { transform: scale(1.03); border-color: var(--bs-accent); }
}

/* ============================================================
   TV (>= 1280px, remote/10-foot UX)
   ============================================================ */
@media (min-width: 1280px) and (pointer: coarse) and (hover: none) {
    :root { --tile-w: 220px; --tile-gap: 20px; }

    /* Sidebar: fits each width, text never wraps */
    #side-host { width: clamp(320px, 22vw, 400px); padding: 24px 18px 18px; }
    .sb-logo { max-width: 260px; margin-bottom: 26px; }
    .sb-nav { gap: 7px; }
    .sb-item { gap: 16px; padding: 15px 18px; font-size: 22px; min-height: 58px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sb-item img { width: 34px; height: 34px; }
    .sb-bottom { font-size: 17px; padding-top: 18px; }

    /* Dashboard: same as laptop - info left, player right, rows below (page scroll) */
    .dash-shell { padding: 24px 30px; }
    .dash-preview { flex-direction: row; align-items: stretch; gap: 26px; margin-bottom: 26px; }
    .dash-info {
        width: 360px;
        flex: none;
        justify-content: flex-start;
        gap: 8px;
        text-align: left;
        align-items: flex-start;
    }
    .dash-ch-logo { width: 130px; height: 130px; margin: 0 0 8px; }
    .dash-ch-num { font-size: 21px; }
    .dash-ch-name { font-size: 32px; }
    .dash-epg-line { font-size: 17px; line-height: 1.45; }
    .dash-epg-line b { font-size: 15px; }
    .dash-user { font-size: 15px; margin-top: auto; }
    .dash-video {
        flex: 1 1 auto;
        max-width: 720px;
        min-width: 0;
        aspect-ratio: 16 / 9;
        min-height: 0;
        align-self: flex-start;
    }
    .dash-video-hint { font-size: 15px; }
    .dash-rows { gap: 26px; }
    .dash-row .row-label { font-size: 21px; margin-bottom: 12px; }
    .row-track { gap: 16px; }

    .tile-grid, .vod-grid { grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr)); }
    .detail-actions .btn-adduser { padding: 14px 30px; font-size: 16px; min-height: 52px; }
    .episode-btn { padding: 13px 18px; font-size: 16px; }
    .tile:focus-visible { transform: scale(1.04); box-shadow: 0 0 0 4px var(--bs-accent); }
    .row-card:focus-visible { transform: scale(1.05); box-shadow: 0 0 0 4px var(--bs-accent); }
    .pc-btn { min-height: 52px; min-width: 64px; font-size: 18px; }
}

/* ============================================================
   SMALL PHONES (<= 400px): always 2 columns so S == M
   ============================================================ */
@media (max-width: 400px) {
    :root { --tile-gap: 8px; }
    .tile-grid, .vod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Legacy web theme overrides (webplayer compatibility) ---------- */
/* Keep the old theme functional when its markup is present */
#turn { display: none; }
.mainBody, .bodyMain { display: block !important; padding: 0 8px; }
.attechback .container-fluid { padding: 0; }
.epgfullmaindiv { height: auto !important; overflow-y: auto; position: static; }
.live_body, .pop_cateScroll, .pop_moviecateScroll, .liveFrameMainscroll, .liveEPGdiv, .msearchscroll {
    position: static !important;
    width: 100% !important;
    overflow: visible !important;
    background: transparent !important;
}
.headerLogo img { width: 120px !important; }
.headerTime { text-align: center; }