/**
 * EPG, Settings, Profile, Search - Page Styles
 */

/* ─── EPG ─────────────────────────────────────────── */
#epg-page { display: flex; flex-direction: column; }

.epg-header {
    height: 60px; background: var(--bg-medium);
    border-bottom: 1px solid var(--bg-light);
    display: flex; align-items: center; padding: 0 24px; gap: 16px;
}

.epg-header h2 { font-size: 18px; font-weight: 700; }
#epg-title { font-size: 16px; color: var(--text-secondary); }

.epg-time-header-row {
    display: flex; background: var(--bg-medium);
    border-bottom: 1px solid var(--bg-light);
}
.epg-channel-col-header {
    width: 200px; min-width: 200px;
    padding: 8px 16px; font-size: 12px;
    color: var(--text-muted); font-weight: 600;
    border-right: 1px solid var(--bg-light);
}
#epg-time-header {
    flex: 1; display: flex; overflow: hidden;
}
.epg-time-slot {
    flex: 1; padding: 8px 12px;
    font-size: 13px; color: var(--text-muted); font-weight: 600;
    border-right: 1px solid var(--bg-light);
}

#epg-content { flex: 1; overflow-y: auto; }
#epg-channels { }

.epg-row {
    display: flex;
    border-bottom: 1px solid var(--bg-light);
    min-height: var(--tv-target-md);
    cursor: pointer;
    transition: background var(--transition);
}
.epg-row:hover { background: rgba(255,255,255,0.03); }
.epg-row.focused {
    background: var(--brand-focus-soft) !important;
    /* Antes: solo un inset de 4px (casi invisible). Ahora borde sólido de marca
       + glow, sin scale (la grilla EPG no debe desbordar). */
    outline: var(--tv-focus-border) solid var(--tv-focus-color) !important;
    outline-offset: calc(-1 * var(--tv-focus-border));
    box-shadow: var(--tv-focus-glow) !important;
    transform: none !important;
    z-index: 2;
}

.epg-channel-cell {
    width: 200px; min-width: 200px;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    border-right: 1px solid var(--bg-light);
    background: var(--bg-medium);
}
.epg-ch-logo { max-width: 40px; max-height: 30px; object-fit: contain; }
.epg-ch-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.epg-programs-row {
    flex: 1; display: flex; overflow: hidden; align-items: stretch;
}
.epg-program-cell {
    flex: 1; padding: 8px 12px;
    border-right: 1px solid var(--bg-light);
    overflow: hidden;
    cursor: pointer;
}
.epg-program-cell.epg-now {
    background: var(--brand-focus-soft);
    border-left: 2px solid var(--brand-color);
}
.epg-prog-time { font-size: 11px; color: var(--brand-color); font-weight: 600; margin-bottom: 2px; }
.epg-prog-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.epg-loading-bar, .epg-no-data { padding: 20px; font-size: 13px; color: var(--text-muted); }

/* ─── Settings ─────────────────────────────────────────
   The live Settings UI is the right-side slide-in panel below (.pm-panel /
   .sm-item). An older full-page layout once lived here; its leftover rules
   (#settings-page{display:flex} and #settings-list{max-width:800px}) leaked
   into the new panel via ID specificity and capped the list ~25px short of
   the panel edge — that was the right-side gap. Removed; the .pm-*/.sm-*
   rules fully style settings now. */

/* ─── Profile menu (right-side slide-in — 1:1 with Android profile.dart) ── */
/* Brand-driven side-panel accents. */
#profile-page {
    background: transparent;
    --pm-accent: var(--brand-color);
    --pm-glow: var(--brand-focus-glow);
    --pm-dlg-accent: var(--brand-color);
}

/* Global background photo behind everything (Android AppBackground) */
.pm-bg-img {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
}

/* Dim layer over the background (Android: Colors.black54) */
.pm-backdrop { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; background: rgba(0,0,0,0.54); }

/* Panel anchored to the right, ~43% wide (Android: width / 2.3) */
.pm-panel {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 2;
    width: 43%; min-width: 720px;
    background: rgba(0,0,0,0.54);     /* Android inner Colors.black54 */
    display: flex; flex-direction: column;
    overflow: hidden;                 /* keep rows inside the panel (no right-edge spill) */
    /* Android's two BoxShadows: black -8px + orange glow -4px */
    box-shadow: -8px 0 24px 4px rgba(0,0,0,1),
                -4px 0 30px 0 var(--pm-glow);
    animation: pm-slide-in 0.22s ease;
}
@keyframes pm-slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.pm-title {
    background: rgba(0,0,0,0.87);      /* Android Colors.black87 */
    padding: 22px 12px 12px;
    font-size: 22px; font-weight: 900; color: #fff;
    flex-shrink: 0;
}
/* Profile + Settings panel headers carry a close X on the right (pointer affordance). */
.pm-title { display: flex; align-items: center; gap: 10px; }
.pm-title .pm-title-text { flex: 1; min-width: 0; }
.pm-panel-close { color: rgba(255,255,255,0.5); font-size: 26px; cursor: pointer; padding: 2px 8px; transition: color .12s; }
.pm-panel-close { min-width: var(--tv-target-min); min-height: var(--tv-target-min); display: flex; align-items: center; justify-content: center; }
.pm-panel-close:hover, .pm-panel-close.focused { color: #fff; }

.pm-list { flex: 1; overflow-y: auto; background: rgba(0,0,0,0.60); }

/* One menu row: icon + (title / subtitle) */
.pm-item {
    display: flex; align-items: center;
    min-height: var(--tv-target-md); padding: 9px 14px;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.pm-item .pm-icon {
    width: 48px; flex-shrink: 0; text-align: center;
    font-size: 27px; color: rgba(255,255,255,0.7);
}
.pm-item .pm-text { flex: 1; min-width: 0; }
.pm-item .pm-item-title {
    font-size: 17px; font-weight: 400; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pm-item .pm-item-sub {
    font-size: 14px; color: rgba(255,255,255,0.6); margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pm-item.focused {
    background: #2a2a2a;               /* Android Color(0xFF2A2A2A) */
    border-left-color: var(--pm-accent);
}
.pm-item.focused .pm-icon { color: var(--pm-accent); }
.pm-item.focused .pm-item-title { font-weight: 700; }

/* ─── Info dialog (Device Info / App Info) — Android androidInfo overlay ─── */
.pm-dialog {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10;
    background: rgba(0,0,0,0.54);
    display: flex; align-items: center; justify-content: center;
}
.pm-dialog.hidden { display: none; }
.pm-dialog-card {
    width: 83%; height: 83%;          /* Android width/1.2, height/1.2 */
    display: flex; flex-direction: column;
    background: var(--bg-medium);
    border: 1.5px solid #444;
    border-radius: 10px;
    box-shadow: 0 0 20px 4px rgba(0,0,0,0.7);
    overflow: hidden;
}
.pm-dialog-head {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    background: #2a2a2a;
    font-size: 24px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.pm-dialog-head .pm-dialog-head-icon { color: var(--pm-dlg-accent); font-size: 28px; }
.pm-dialog-head .pm-dialog-close { margin-left: auto; color: rgba(255,255,255,0.38); font-size: 26px; cursor: pointer; }
.pm-dialog-head .pm-dialog-close:hover,
.pm-dialog-head .pm-dialog-close.focused { color: #fff; }
.pm-dialog-body { flex: 1; overflow-y: auto; padding: 4px 0; }
.pm-row { display: flex; padding: 11px 20px; }
.pm-row:nth-child(even) { background: var(--bg-light); }
.pm-row:nth-child(odd)  { background: var(--bg-medium); }
.pm-row .pm-row-label {
    width: 280px; flex-shrink: 0;
    color: var(--pm-dlg-accent);      /* Android Color(0xFFFF9800) */
    font-size: 21px; font-weight: 600;
}
.pm-row .pm-row-value {
    flex: 1; color: rgba(255,255,255,0.7); font-size: 21px; word-break: break-all;
}
.pm-dialog-foot {
    padding: 12px; text-align: center;
    background: #2a2a2a; color: rgba(255,255,255,0.38); font-size: 18px;
    flex-shrink: 0;
}

/* Hide scrollbars (Android shows none) */
.pm-list, .pm-dialog-body { scrollbar-width: none; -ms-overflow-style: none; }
.pm-list::-webkit-scrollbar, .pm-dialog-body::-webkit-scrollbar { width: 0; height: 0; display: none; }
.pm-dialog-body { overflow-x: hidden; }

/* ─── Application Info dialog (1:1 with Android AppInfoDialog) ─── */
.pm-ai-card {
    width: 66.7%; height: auto; max-height: 85%;   /* Android width/1.5, maxHeight 0.85 */
    border-radius: 16px;
    box-shadow: 0 0 40px 10px rgba(0,0,0,0.85);
}
.pm-ai-head {
    background: #242424;                            /* Android Color(0xFF242424) */
    border-radius: 16px 16px 0 0;
    padding: 16px 20px;
}
.pm-ai-head-icon { color: var(--pm-accent); font-size: 28px; }
.pm-ai-head-title { flex: 1; }                      /* push the X to the right (Android Spacer) */
.pm-ai-close { color: rgba(255,255,255,0.38); font-size: 26px; cursor: pointer; }
.pm-ai-close:hover { color: #fff; }
.pm-ai-body { padding: 24px; }
.pm-ai-brand {
    color: var(--pm-accent); font-size: 32px; font-weight: 700; margin-bottom: 16px;
}
.pm-ai-row { display: flex; align-items: center; margin-bottom: 10px; }
.pm-ai-row .pm-ai-icon { color: var(--pm-accent); font-size: 24px; width: 24px; margin-right: 12px; flex-shrink: 0; }
.pm-ai-row .pm-ai-label { color: rgba(255,255,255,0.54); font-size: 22px; font-weight: 600; flex-shrink: 0; }
.pm-ai-row .pm-ai-value { color: #fff; font-size: 22px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-ai-disclaimer {
    margin: 20px 0;
    padding: 16px;
    background: #2a2a2a;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: rgba(255,255,255,0.54);
    font-size: 19px; line-height: 1.5;
}
.pm-ai-appbox {
    padding: 16px;
    background: #2a2a2a;
    border-radius: 8px;
}
.pm-ai-appbox .pm-ai-row { margin-bottom: 4px; }
.pm-ai-appbox .pm-ai-row:last-child { margin-bottom: 0; }
.pm-ai-foot { background: #242424; border-radius: 0 0 16px 16px; }

/* Speed-test result shown inline under the Speedtest row */
.pm-item .pm-item-sub.pm-speed-ok   { color: var(--success); }
.pm-item .pm-item-sub.pm-speed-fail { color: var(--error); }

/* ─── Settings menu (right-side slide-in — 1:1 with Android settings.dart) ─── */
#settings-page {
    background: transparent;
    --pm-accent: var(--brand-color);
    --pm-glow: var(--brand-focus-glow);
    --pm-dlg-accent: var(--brand-color);
}
.sm-title-icon { color: rgba(255,255,255,0.85); margin-right: 6px; }

.sm-item {
    display: flex; align-items: center;
    min-height: var(--tv-target-md); padding: 7px 14px;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.sm-item .sm-icon { width: 50px; flex-shrink: 0; text-align: center; font-size: 27px; color: rgba(255,255,255,0.7); }
.sm-item .sm-text { flex: 1; min-width: 0; }
.sm-item .sm-item-title { font-size: 17px; font-weight: 400; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-item .sm-item-sub { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-item.focused { background: #2a2a2a; border-left-color: var(--pm-accent); }
.sm-item.focused .sm-icon { color: var(--pm-accent); }
.sm-item.focused .sm-item-title { font-weight: 700; }

/* The side-panel rows (settings + profile) carry their OWN focus indicator.
   No GLOBAL scale (spills past the panel edge), but the foco debe ser evidente:
   background + accento izquierdo + borde sólido de marca (outline, no ocupa
   layout) + glow. */
#settings-panel .focused,
#profile-panel .focused,
.pm-item.focused,
.sm-item.focused {
    transform: none !important;
    outline: var(--tv-focus-border) solid var(--tv-focus-color) !important;
    outline-offset: calc(-1 * var(--tv-focus-border));
    box-shadow: var(--tv-focus-glow) !important;
    z-index: 2;
}

.sm-trailing { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding-left: 10px; }
.sm-info-val { color: rgba(255,255,255,0.7); font-weight: 700; font-size: 15px; max-width: 130px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-trail-chevron { color: #fff; font-size: 18px; }
.sm-arrow { color: #fff; font-size: 20px; cursor: pointer; padding: 4px; }
.sm-select-val { min-width: 56px; text-align: center; font-weight: 900; font-size: 17px; color: #fff; }
.sm-item.focused .sm-select-val { color: var(--pm-accent); }
.sm-swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.7); }
.sm-swatch-x { display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.7); font-weight: 700; font-size: 14px; background: transparent; }

/* Toggle switch (Android Switch — orange when on) */
.sm-switch { width: 52px; height: 28px; border-radius: 14px; background: rgba(255,255,255,0.45); position: relative; transition: background .15s; }
.sm-switch.on { background: var(--brand-amber); }
.sm-switch-thumb { position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #f5f5f5; transition: left .15s, background .15s; }
.sm-switch.on .sm-switch-thumb { left: 26px; background: var(--brand-color); }

/* Live preview (TV mockup, bottom-left) */
.sm-preview { position: absolute; left: 40px; bottom: 40px; z-index: 3; width: 460px; }
.sm-preview.hidden { display: none; }
.sm-tv { position: relative; width: 100%; height: 0; padding-bottom: 56.25%; background: #000; border: 1.5px solid rgba(255,255,255,0.24); border-radius: 6px; box-shadow: 0 0 14px 2px rgba(0,0,0,0.87); overflow: hidden; }
.sm-tv-screen { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; background: #000; }
.sm-tv-neck { width: 60px; height: 8px; background: rgba(255,255,255,0.12); margin: 0 auto; }
.sm-tv-base { width: 90px; height: 5px; background: rgba(255,255,255,0.10); border-radius: 2px; margin: 0 auto; }
.sm-clock { position: absolute; font-family: var(--font-brand); color: #fff; font-size: 18px; font-weight: 500; }
.sm-clock.tl { top: 10px; left: 12px; } .sm-clock.tr { top: 10px; right: 12px; }
.sm-clock.bl { bottom: 10px; left: 12px; } .sm-clock.br { bottom: 10px; right: 12px; }
.sm-sub-sample { position: absolute; bottom: 14px; left: 10px; right: 10px; margin: 0 auto; text-align: center; padding: 3px 8px; font-weight: 600; line-height: 1.2; }

/* Weather-search dialog */
.sm-wx-card { width: 70%; height: 80%; }
.sm-wx-head { background: #242424; border-radius: 10px 10px 0 0; }
.sm-wx-query { padding: 14px 20px; font-size: 24px; color: #fff; background: #1f1f1f; border-bottom: 1px solid #333; min-height: 30px; }
.sm-wx-ph { color: rgba(255,255,255,0.3); }
.sm-wx-body { flex: 1; display: flex; min-height: 0; }
.sm-kb { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.sm-kb-row { display: flex; gap: 10px; justify-content: center; }
.sm-key { min-width: var(--tv-target-min); height: var(--tv-target-min); display: flex; align-items: center; justify-content: center; background: #2a2a2a; border-radius: 6px; color: #fff; font-size: var(--tv-font-caption); }
.sm-key.focused { background: var(--pm-accent); color: #fff; font-weight: 700; }
.sm-results { width: 42%; border-left: 1px solid #333; overflow-y: auto; padding: 6px 0; }
.sm-result { padding: 12px 18px; font-size: 17px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid transparent; }
.sm-result.focused { background: #2a2a2a; border-left-color: var(--pm-accent); }
.sm-result-empty { padding: 18px; color: rgba(255,255,255,0.4); font-size: 16px; }
.sm-results::-webkit-scrollbar { width: 0; height: 0; }
.sm-results { scrollbar-width: none; }

/* Change-PIN dialog */
.sm-pin-card { width: 420px; height: auto; max-height: 80%; align-items: stretch; }
.sm-pin-stars { display: flex; gap: 16px; justify-content: center; padding: 26px 0 10px; }
.sm-pin-star { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.5); }
.sm-pin-star.filled { background: var(--pm-accent); border-color: var(--pm-accent); }
.sm-pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 16px 40px 26px; }
.sm-pin-key { height: var(--tv-target-min); display: flex; align-items: center; justify-content: center; background: #2a2a2a; border-radius: 8px; color: #fff; font-size: 26px; font-weight: 700; }
.sm-pin-key.focused { background: var(--pm-accent); }

/* ─── Search ─────────────────────────────────────── */
#search-page { display: flex; flex-direction: column; }

.search-header {
    height: 60px; background: var(--bg-medium);
    border-bottom: 1px solid var(--bg-light);
    display: flex; align-items: center; padding: 0 24px;
}
.search-header h2 { font-size: 20px; font-weight: 700; }

#search-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 20px 32px; }

.search-input-area {
    display: flex; align-items: center; gap: 16px;
    background: var(--bg-medium); border-radius: var(--radius-md);
    padding: 12px 20px; margin-bottom: 16px;
    border: 2px solid var(--bg-light);
    flex: 0 0 auto;
}
.search-icon { font-size: 22px; }
.search-query-display {
    flex: 1; font-size: 22px; font-weight: 600;
    min-height: 32px; color: var(--text-primary);
}
.search-query-display.active { color: #fff; }
.cursor {
    display: inline-block;
    animation: blink 1s step-end infinite;
    color: var(--brand-color);
}
@keyframes blink { 50% { opacity: 0; } }
.search-spinner { font-size: 20px; }

/* Content filter pills (ALL / MOVIES / SERIES), right side of the input row */
.search-filter { display: flex; gap: 8px; flex: 0 0 auto; }
.search-filter-pill {
    min-height: var(--tv-target-min); padding: 0 var(--tv-btn-pad-x); border-radius: 999px;
    display: flex; align-items: center;
    background: var(--bg-light); color: var(--text-secondary);
    font-size: 18px; font-weight: 600; white-space: nowrap;
    border: 2px solid transparent; cursor: pointer;
}
.search-filter-pill.active { color: #fff; }
.search-filter-pill.focused { border-color: var(--focus-color); background: var(--bg-hover); color: #fff; }

/* Android arrangement: keyboard band on top, then [suggestions | grid] below */
.search-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; }

/* Single horizontal row (Android search.dart): LANG | SPACE | letters… | ⌫ | ✕ */
.search-keyboard {
    flex: 0 0 auto; overflow: hidden;
    background: var(--bg-medium); border-radius: var(--radius-md);
    padding: 8px 10px; border: 1px solid var(--bg-light);
}
.search-keyboard .keyboard-row {
    flex-wrap: nowrap; justify-content: flex-start; align-items: stretch;
    gap: 5px; margin: 0; overflow-x: auto; scrollbar-width: none;
}
.search-keyboard .keyboard-row::-webkit-scrollbar { display: none; }
.search-keyboard .keyboard-key {
    flex: 0 0 auto; height: var(--tv-target-min); font-size: var(--tv-font-caption); padding: 0;
    min-width: var(--tv-target-min); width: var(--tv-target-min);
}
.search-keyboard .kb-ctrl {
    width: auto; min-width: 0; padding: 0 16px; font-size: 16px; font-weight: 700;
}
.search-keyboard .kb-space { padding: 0 34px; }

/* Lower split-pane: suggestions (left, fixed) | poster grid (right, fills) */
.search-cols { flex: 1; min-height: 0; display: flex; gap: 16px; }

.search-suggests {
    flex: 0 0 340px; min-height: 0; overflow-y: auto;
    background: var(--bg-medium); border-radius: var(--radius-md);
    border: 1px solid var(--bg-light); padding: 8px;
}
.search-suggests:empty { display: none; }
.search-suggests-title { font-size: 16px; color: var(--text-secondary); padding: 8px 10px 12px; text-transform: uppercase; letter-spacing: .04em; }
.search-suggest-item {
    display: flex; align-items: center; gap: 14px;
    min-height: var(--tv-target-min); padding: 13px 14px; border-radius: var(--radius-md);
    font-size: 19px; color: var(--text-primary);
    border: 2px solid transparent; cursor: pointer;
}
.search-suggest-item i { width: 22px; font-size: 18px; text-align: center; color: var(--text-muted); flex: 0 0 auto; }
.search-suggest-item.actor i { color: #ffc04d; }
/* Marquee text: container clips, inner .mq holds the full label and scrolls when focused */
.search-suggest-item .sg-text { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.search-suggest-item .sg-text .mq { display: inline-block; will-change: transform; }
.search-grid .vp-title { text-overflow: clip; }
.search-grid .vp-title .mq { display: inline-block; will-change: transform; }
.search-suggest-item.focused { border-color: var(--focus-color); background: var(--bg-hover); color: #fff; }
.search-suggest-item.focused i { color: #fff; }

/* Results grid — reuses .vod-poster / .vp-* from vod.css, just tighter columns */
.search-grid-wrap { flex: 1; min-width: 0; min-height: 0; display: flex; }
.search-grid {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 4px 6px 16px;
    /* Same poster size as the main VOD grid (vod.3.2.1.css .vod-grid) */
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 22px;
}
.search-status { padding: 32px; text-align: center; font-size: 16px; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════════════════
 * MasTV search redesign — brand-gated. Remote-friendly 2-axis GRID keyboard +
 * instant CHANNEL results (primary) and VOD (secondary). Black + lime + glass.
 * Telco keeps the single-row layout above untouched (these selectors require
 * html[data-brand="mastv"] AND class names only emitted by _renderMastv()).
 * ═══════════════════════════════════════════════════════════════════════════ */
html[data-brand="mastv"] #search-inner.search-mastv { padding: 22px 40px; }

/* Botón visible "‹ Atrás" para volver al inicio (mouse y D-pad). */
html[data-brand="mastv"] .search-back-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 18px; margin-right: 16px; flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,.14); border-radius: 999px;
    background: rgba(255,255,255,.06); color: var(--text-primary);
    font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
html[data-brand="mastv"] .search-back-btn:hover,
html[data-brand="mastv"] .search-back-btn:focus-visible {
    background: var(--brand-color); color: var(--brand-navy);
    border-color: var(--brand-color); box-shadow: var(--tv-focus-glow);
}

/* Input row — translucent glass with a solid fallback. */
html[data-brand="mastv"] .mastv-input {
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.10);
    border-radius: 14px;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    html[data-brand="mastv"] .mastv-input,
    html[data-brand="mastv"] .search-keyboard-grid,
    html[data-brand="mastv"] .search-results {
        -webkit-backdrop-filter: blur(14px) saturate(1.15);
        backdrop-filter: blur(14px) saturate(1.15);
    }
}
html[data-brand="mastv"] .mastv-input .search-icon { color: var(--brand-color); }
html[data-brand="mastv"] .search-ph { color: var(--text-muted); font-weight: 500; }

/* Filter pills row. */
html[data-brand="mastv"] .mastv-filter { margin: 0 0 16px; flex: 0 0 auto; }
html[data-brand="mastv"] .mastv-filter .search-filter-pill {
    background: rgba(255,255,255,0.05); color: var(--text-secondary);
    border: 2px solid transparent;
}
html[data-brand="mastv"] .mastv-filter .search-filter-pill.active {
    color: var(--brand-navy); background: var(--brand-color); font-weight: 800;
}
html[data-brand="mastv"] .mastv-filter .search-filter-pill.focused {
    border-color: var(--brand-color); color: #fff; background: rgba(185,239,0,0.14);
    box-shadow: 0 0 0 4px var(--brand-focus-soft), var(--tv-focus-glow);
}
html[data-brand="mastv"] .mastv-filter .search-filter-pill.active.focused { color: var(--brand-navy); }

/* Two-column body: grid keyboard (left, fixed) | results (right, fills). */
html[data-brand="mastv"] .mastv-body {
    flex: 1; min-height: 0; display: flex; flex-direction: row; gap: 22px;
}

/* ── Grid keyboard ── */
html[data-brand="mastv"] .search-keyboard-grid {
    flex: 0 0 auto; align-self: flex-start;
    display: flex; flex-direction: column; gap: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 18px; padding: 16px;
}
html[data-brand="mastv"] .kb-grid-row { display: flex; gap: 10px; }
html[data-brand="mastv"] .kb-key {
    width: 76px; height: 76px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: 700; color: var(--text-primary);
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 12px; cursor: pointer;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
html[data-brand="mastv"] .kb-key.kb-ctrl { font-size: 22px; color: var(--text-secondary); }
html[data-brand="mastv"] .kb-grid-ctrl .kb-lang  { width: 76px; font-weight: 800; color: var(--brand-color); }
html[data-brand="mastv"] .kb-grid-ctrl .kb-space { flex: 1 1 auto; min-width: 120px; }
html[data-brand="mastv"] .kb-key.focused {
    background: var(--brand-color); color: var(--brand-navy);
    border-color: #fff;
    box-shadow: 0 0 0 4px var(--brand-focus-soft), var(--tv-focus-glow);
    transform: translateY(-2px) scale(1.04);
}
html[data-brand="mastv"] .kb-key.kb-ctrl.focused { color: var(--brand-navy); }

/* ── Results column ── */
html[data-brand="mastv"] .search-results {
    flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px; padding: 10px 18px 24px;
}
html[data-brand="mastv"] .search-results::-webkit-scrollbar { width: 0; height: 0; }
html[data-brand="mastv"] .res-head {
    display: flex; align-items: center; gap: 12px;
    font-size: 20px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    color: #fff; padding: 16px 4px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 16px;
}
html[data-brand="mastv"] .res-head::before {
    content: ''; width: 6px; height: 22px; border-radius: 3px;
    background: var(--brand-color); flex: 0 0 auto;
}
html[data-brand="mastv"] .res-head-vod { margin-top: 24px; }
html[data-brand="mastv"] .res-head-vod::before { background: var(--brand-accent); }
html[data-brand="mastv"] .res-count {
    font-size: 15px; font-weight: 800; color: var(--brand-navy);
    background: var(--brand-color); border-radius: 999px; padding: 3px 12px;
    letter-spacing: 0;
}
html[data-brand="mastv"] .res-none { padding: 14px 6px 8px; color: var(--text-muted); font-size: 18px; }

/* Channel cards. */
html[data-brand="mastv"] .chan-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
html[data-brand="mastv"] .chan-card {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; border-radius: 14px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.08); cursor: pointer;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
html[data-brand="mastv"] .chan-logo {
    width: 64px; height: 64px; flex: 0 0 auto; border-radius: 10px;
    background: rgba(0,0,0,0.45); overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
html[data-brand="mastv"] .chan-logo-img { max-width: 100%; max-height: 100%; object-fit: contain; }
html[data-brand="mastv"] .chan-logo.noimg::before {
    content: attr(data-letter); font-size: 28px; font-weight: 800; color: var(--brand-color);
}
html[data-brand="mastv"] .chan-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
html[data-brand="mastv"] .chan-num {
    font-size: 14px; font-weight: 800; color: var(--brand-color);
    font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
html[data-brand="mastv"] .chan-name {
    font-size: 21px; font-weight: 600; color: #fff;
    overflow: hidden; white-space: nowrap;
}
html[data-brand="mastv"] .chan-name .mq { display: inline-block; will-change: transform; }
html[data-brand="mastv"] .chan-play { font-size: 20px; color: var(--text-muted); flex: 0 0 auto; opacity: 0; transition: opacity .12s ease; }
html[data-brand="mastv"] .chan-card.focused {
    background: rgba(185,239,0,0.12);
    border-color: var(--brand-color);
    box-shadow: 0 0 0 4px var(--brand-focus-soft), var(--tv-focus-glow);
    transform: scale(1.03);
}
html[data-brand="mastv"] .chan-card.focused .chan-play { opacity: 1; color: var(--brand-color); }

/* VOD grid inside results keeps the shared poster look, lime focus. */
html[data-brand="mastv"] .search-results .search-grid { display: grid; }
html[data-brand="mastv"] .search-results .vod-poster.focused {
    box-shadow: 0 0 0 4px var(--brand-focus-soft), var(--tv-focus-glow);
}

/* Empty state. */
html[data-brand="mastv"] .search-empty {
    height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 18px; text-align: center;
    color: var(--text-muted);
}
html[data-brand="mastv"] .search-empty-ic {
    width: 108px; height: 108px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 48px; color: var(--brand-color);
    background: rgba(185,239,0,0.10); border: 1px solid rgba(185,239,0,0.25);
}
html[data-brand="mastv"] .search-empty p { font-size: 22px; font-weight: 500; max-width: 420px; }

/* Narrower TV / 1280-wide: shrink keys and let channels go single-column. */
@media (max-width: 1400px) {
    html[data-brand="mastv"] #search-inner.search-mastv { padding: 18px 28px; }
    html[data-brand="mastv"] .mastv-body { gap: 16px; }
    html[data-brand="mastv"] .kb-key { width: 64px; height: 64px; font-size: 26px; }
    html[data-brand="mastv"] .kb-grid-ctrl .kb-lang { width: 64px; }
    html[data-brand="mastv"] .chan-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* Honor reduced motion: keep focus legible via color/border, drop transforms. */
@media (prefers-reduced-motion: reduce) {
    html[data-brand="mastv"] .kb-key,
    html[data-brand="mastv"] .chan-card,
    html[data-brand="mastv"] .chan-play { transition: none; }
    html[data-brand="mastv"] .kb-key.focused,
    html[data-brand="mastv"] .chan-card.focused { transform: none; }
}

/* Chrome 79 flex-gap fallback for the new rows (gap on flex entered Chrome 84). */
html.no-flex-gap[data-brand="mastv"] .mastv-body > * + * { margin-left: 22px; }
html.no-flex-gap[data-brand="mastv"] .search-keyboard-grid > * + * { margin-top: 10px; }
html.no-flex-gap[data-brand="mastv"] .kb-grid-row > * + * { margin-left: 10px; }
html.no-flex-gap[data-brand="mastv"] .chan-card > * + * { margin-left: 14px; }

/* ─── Speed test page (mirrors Android speed_test.dart) ─── */
#speedtest-page { background: #000; }
.st-wrap { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; }
.st-left { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 50px; }
.st-dl { color: #fff; font-size: 32px; font-weight: 600; }
.st-dl b { font-weight: 800; }
.st-prog { width: 440px; height: 10px; background: #555; border-radius: 5px; overflow: hidden; }
.st-prog-fill { height: 100%; background: #e53935; width: 0; transition: width .2s linear; }
.st-gauge { margin: 8px 0; }
.st-btn { display: flex; align-items: center; width: 440px; height: var(--tv-target-md); border-radius: 54px;
    background: var(--success); border: 1px solid rgba(255,255,255,0.4); overflow: hidden; cursor: pointer; }
.st-btn.testing { background: #e53935; }
.st-btn-ic { width: var(--tv-target-md); height: var(--tv-target-md); flex: 0 0 auto; border-radius: 50%; background: #fff;
    display: flex; align-items: center; justify-content: center; color: var(--success); font-size: 28px; }
.st-btn.testing .st-btn-ic { color: #e53935; }
.st-btn-lbl { flex: 1; text-align: center; color: #fff; font-size: 24px; font-weight: 800; }
.st-ip { background: rgba(255,255,255,0.1); border-radius: 8px; padding: 18px 24px; color: #fff;
    font-size: 22px; text-align: right; line-height: 1.8; }
.st-ip span { font-weight: 300; color: rgba(255,255,255,0.8); }
.st-right { flex: 1; background: rgba(255,255,255,0.06); padding: 26px 28px; overflow-y: auto; }
.st-right::-webkit-scrollbar { width: 0; height: 0; display: none; } .st-right { scrollbar-width: none; }
.st-right pre { color: #fff; font-size: 22px; white-space: pre-wrap; margin: 0; font-family: monospace; line-height: 1.5; }

/* ─── Toast ─────────────────────────────────────── */
#toast-container {
    position: fixed; bottom: 60px; right: 32px;
    z-index: var(--z-toast);
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 14px 22px;
    border-radius: var(--radius-md);
    font-size: 16px; font-weight: 600;
    color: #fff;
    max-width: 400px;
    opacity: 0; transform: translateX(40px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-info    { background: rgba(30,30,30,0.96); border: 1px solid rgba(255,255,255,0.15); }
.toast-success { background: rgba(70,211,105,0.18); border: 1px solid var(--success); }
.toast-error   { background: rgba(229,9,20,0.2); border: 1px solid var(--error); }
.toast-warning { background: rgba(255,165,0,0.18); border: 1px solid var(--warning); }

/* RedHogar: remove inherited Telco orange/purple literals from shared pages. */
html[data-brand="redhogar"] .search-filter-pill.focused,
html[data-brand="redhogar"] .search-suggest-item.focused,
html[data-brand="redhogar"] .vod-poster.focused,
html[data-brand="redhogar"] .epg-row.focused {
    border-color: var(--brand-focus);
    background: var(--brand-focus-soft);
    box-shadow: 0 0 0 4px var(--brand-focus-soft), var(--tv-focus-glow);
}
html[data-brand="redhogar"] .search-suggest-item.actor i { color: var(--brand-amber); }
html[data-brand="redhogar"] .toast-warning { background: rgba(255,209,102,.16); }
html[data-brand="redhogar"] #profile-page,
html[data-brand="redhogar"] #settings-page {
    --pm-accent: var(--brand-focus);
    --pm-glow: var(--brand-focus-glow);
    --pm-dlg-accent: var(--brand-accent);
}

/* Chrome 79 flex-gap fallback. */
html.no-flex-gap .epg-header > * + * { margin-left: 16px; }
html.no-flex-gap .epg-channel-cell > * + * { margin-left: 10px; }
html.no-flex-gap .pm-title > * + * { margin-left: 10px; }
html.no-flex-gap .pm-dialog-head > * + * { margin-left: 12px; }
html.no-flex-gap .sm-trailing > * + * { margin-left: 8px; }
html.no-flex-gap .sm-kb > * + * { margin-top: 10px; }
html.no-flex-gap .sm-kb-row > * + * { margin-left: 10px; }
html.no-flex-gap .sm-pin-stars > * + * { margin-left: 16px; }
html.no-flex-gap .search-input-area > * + * { margin-left: 16px; }
html.no-flex-gap .search-filter > * + * { margin-left: 8px; }
html.no-flex-gap .search-body > * + * { margin-top: 14px; }
html.no-flex-gap .search-cols > * + * { margin-left: 16px; }
html.no-flex-gap .search-suggest-item > * + * { margin-left: 14px; }
html.no-flex-gap .st-left > * + * { margin-top: 26px; }
html.no-flex-gap #toast-container > * + * { margin-top: 8px; }
