:root {
  color-scheme: dark;
  --background: #090909;
  --surface: #141414;
  --surface-raised: #1b1b1b;
  --surface-hover: #262626;
  --text: #ffffff;
  --muted: #adadad;
  --border: #343434;
  --success: #34df7e;
  --warning: #ffbf35;
  --danger: #ff5252;
  --brand: #7c3aed;
  --brand-hover: #6d28d9;
  --header-surface: #090909;
  --accent: #ffffff;
  --accent-soft: #202020;
  --header-height: 82px;
  --footer-height: 44px;
  --content-height: calc(100vh - var(--header-height) - var(--footer-height));
  --category-panel-width: clamp(240px, 22vw, 340px);
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(16px, 1.05vw, 20px);
}

:root[data-theme="amethyst"] {
  --background: #100b1b;
  --surface: #1a122a;
  --surface-raised: #251b35;
  --surface-hover: #322442;
  --border: #4b3864;
  --header-surface: #150d24;
  --accent: #923fff;
  --accent-soft: #2b1c42;
}

:root[data-theme="midnight"] {
  --background: #071321;
  --surface: #101f32;
  --surface-raised: #192c45;
  --surface-hover: #243d5a;
  --border: #3b5674;
  --header-surface: #0b1a2d;
  --accent: #388aff;
  --accent-soft: #193957;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 0; background: var(--background); color: var(--text); }
body { min-height: 100vh; }
body.app-fullscreen-active { overflow: hidden; }
h1, h2, p { margin-top: 0; }
button, input, select { font: inherit; border-radius: 0; }
button, select { cursor: pointer; }
button { color: var(--text); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus, input:focus, select:focus { outline: 3px solid #ffffff; outline-offset: 3px; }
input, select {
  min-width: 0;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input::placeholder { color: var(--muted); }
.is-hidden { display: none !important; }
.app-shell, .player-view { min-height: 100vh; }
.player-content { position: relative; height: var(--content-height); min-height: 0; }
.panel-label { margin: 0; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .06em; }
.primary-button, .secondary-button { min-height: 48px; padding: 0 20px; border: 1px solid var(--border); font-weight: 700; }
.primary-button { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #eeeeee; color: #111111; }
.primary-button:hover { background: #ffffff; }
.secondary-button { background: var(--surface-raised); }
.secondary-button:hover { background: var(--surface-hover); }
.feedback, .playback-feedback { min-height: 20px; margin: 12px 0 0; color: var(--muted); line-height: 1.4; }
.feedback.is-error, .playback-feedback.is-error { color: var(--danger); }
.feedback.is-warning, .playback-feedback.is-warning { color: var(--warning); }
.feedback.is-success, .playback-feedback.is-success { color: var(--success); }

/* Parental PIN */
.pin-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 20px; background: rgba(0, 0, 0, .97); }
.pin-card { width: min(440px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; background: var(--surface); border: 1px solid var(--border); }
.pin-card h2 { margin-bottom: 10px; font-size: 1.4rem; }
.pin-card > p { color: var(--muted); line-height: 1.4; }
.pin-digits { padding: 10px; text-align: center; font-size: 2rem; letter-spacing: .2em; }
.pin-feedback { min-height: 2.8em; margin: 8px 0; font-size: .85rem; }
.pin-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 4px; }
.pin-keypad button { min-height: 48px; padding: 8px 2px; background: var(--surface-raised); border: 1px solid var(--border); }
.pin-keypad button[data-pin-key="submit"], .pin-keypad button[data-pin-key="delete"] { font-size: .85rem; }
.pin-card > button { width: 100%; margin-top: 14px; }
#settings-parental-pin { flex-shrink: 0; }

/* Connection */
.connection-view { display: grid; min-height: 100vh; place-items: center; padding: 32px; }
.connection-card { width: min(100%, 600px); padding: 36px; border: 1px solid var(--border); border-top: 3px solid var(--brand); background: var(--surface); }
.connection-logo { display: block; max-width: 100%; height: auto; margin-bottom: 32px; }
.connection-form .primary-button { background: var(--brand); color: #ffffff; }
.connection-form .primary-button:hover { background: var(--brand-hover); }
.connection-form { display: grid; gap: 18px; }
.field-group { display: grid; gap: 8px; }
.device-registration { border-top: 1px solid var(--border); padding-top: 18px; }
.device-registration > p { margin: 0 0 10px; }
.device-registration strong { font-size: inherit; }
.device-registration .secondary-button { width: 100%; }
.connection-footer { margin-top: 24px; color: var(--muted); font-size: .85rem; text-align: center; }

@media (max-height: 760px) {
  .connection-view { padding: 20px; }
  .connection-card { padding: 24px; }
  .connection-logo { width: 198px; margin-bottom: 20px; }
  .connection-form { gap: 12px; }
  .device-registration { padding-top: 12px; }
  .device-registration > p { margin-bottom: 6px; }
}

/* A single header, without duplicate content tabs. */
.top-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; height: var(--header-height); align-items: center; gap: 24px; padding: 0 32px; border-bottom: 1px solid var(--border); background: var(--header-surface); }
.top-bar-identity, .top-bar-brand { display: flex; align-items: center; }
.top-bar-identity { min-width: 0; gap: 24px; }
.top-bar-brand { flex: 0 0 auto; }
.brand-logo { display: block; width: 153px; height: 40px; }
.current-section { min-width: 0; padding-left: 24px; border-left: 1px solid var(--border); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-button, .settings-button { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px; border-color: transparent; background: transparent; }
.settings-button { width: 48px; padding: 0; }
.home-button.is-active, .settings-button.is-active { border-bottom: 3px solid var(--accent); background: var(--surface); }
.home-button:focus, .settings-button:focus { background: var(--text); color: var(--background); }
.device-status { display: flex; align-items: center; gap: 24px; }
.device-network { position: relative; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.device-network svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.network-icon, .network-offline-mark, .network-connected-mark { display: none; }
.device-network[data-network-type="wifi"] .network-wifi,
.device-network[data-network-type="ethernet"] .network-ethernet,
.device-network[data-network-type="cellular"] .network-cellular,
.device-network[data-network-type="unknown"] .network-unknown,
.device-network[data-network-type="mixed"] .network-wifi,
.device-network[data-network-type="mixed"] .network-ethernet { display: block; }
.device-network .network-unknown { stroke-width: 2; }
.device-network.is-offline { color: var(--warning); }
.device-network .network-connected-mark, .device-network .network-offline-mark { position: absolute; right: -5px; bottom: -4px; width: 14px; height: 14px; background: var(--header-surface); }
.device-network[data-network-type="unknown"]:not(.is-offline) .network-connected-mark { display: block; color: var(--success); border-radius: 50%; }
.device-network.is-offline .network-offline-mark { display: block; }
.device-datetime { display: grid; gap: 3px; text-align: right; white-space: nowrap; }
.device-clock { font-size: 1.65rem; line-height: 1; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.device-date { color: var(--muted); font-size: .72rem; line-height: 1.3; }
.menu-button-icon, .settings-icon { display: grid; place-items: center; }
.menu-button-icon svg, .settings-icon svg, .search-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.settings-icon svg { width: 26px; height: 26px; stroke-linecap: round; stroke-linejoin: round; }
.remote-help { display: flex; height: var(--footer-height); align-items: center; gap: 30px; padding: 0 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: .75rem; }
.remote-help span { display: flex; align-items: center; gap: 10px; }
.remote-help kbd { color: var(--text); font: inherit; font-weight: 700; }
.app-fullscreen-active .remote-help { visibility: hidden; }

/* Home */
.home-view { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; align-items: end; gap: 32px 36px; padding: 34px clamp(28px, 5vw, 90px); overflow-y: auto; }
.home-search-results, .home-actions, .home-rails { grid-column: 1 / -1; }
.home-search-button { display: flex; align-items: center; gap: 16px; min-height: 58px; margin-bottom: 5px; padding: 14px 20px; border: 1px solid var(--border); border-bottom: 2px solid var(--border); background: var(--surface); text-align: left; }
.home-search-button .search-icon { color: var(--text); }
.home-search-button kbd { padding: 4px 8px; border: 1px solid var(--border); font-size: .75rem; }
.home-search-button kbd { margin-left: auto; color: var(--muted); }
.home-search-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.home-search-header h2 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
#home-search-controls { display: flex; flex: 0 0 auto; gap: 12px; }
.home-search-progress { color: var(--muted); min-height: 24px; margin: 16px 0; }
.home-search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; padding: 6px; margin: -6px; }
.home-search-pages { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }
.home-search-pages > span { color: var(--muted); font-size: .85rem; }
.search-keyboard-overlay { position: fixed; z-index: 900; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .96); }
.search-keyboard-card { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; background: var(--surface); border: 1px solid var(--border); }
.search-keyboard-card h2 { margin-bottom: 16px; font-size: 1.4rem; }
.search-keyboard-card > input { margin-bottom: 18px; background: var(--background); }
.search-keyboard-letters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 4px; }
.search-keyboard-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 4px; margin-top: 12px; }
.search-keyboard-card button { min-height: 48px; padding: 6px 2px; border: 1px solid var(--border); background: var(--surface-raised); }
.search-keyboard-actions button { font-size: .85rem; }
.search-keyboard-actions .search-keyboard-submit { background: var(--text); color: var(--background); font-weight: 700; }
.search-keyboard-card > p { margin: 14px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.home-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.home-action { position: relative; display: grid; min-height: 208px; align-content: end; justify-items: start; gap: 8px; padding: 28px; overflow: hidden; border: 1px solid var(--border); border-bottom: 4px solid var(--border); background: var(--surface); text-align: left; }
.home-action:hover, .home-action:focus { background: var(--surface-hover); }
.home-action:focus { border-bottom-color: var(--accent); }
.home-action::after { content: ''; position: absolute; top: 0; left: 28px; width: 28px; height: 5px; background: var(--accent); transform: skewX(-24deg); }
.home-action-code { position: absolute; top: 24px; right: 24px; color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .08em; }
.home-action-icon { display: grid; width: 32px; height: 32px; place-items: center; margin-bottom: 12px; color: var(--text); }
.home-action-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }
.icon-live svg path:first-of-type { fill: currentColor; stroke: none; }
.home-action strong { font-size: clamp(1.6rem, 2.4vw, 2.3rem); font-weight: 900; text-transform: uppercase; letter-spacing: -.025em; }
.home-action small { padding-right: 20px; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.home-action-arrow { position: absolute; right: 24px; bottom: 22px; color: var(--text); font-size: 1.4rem; }
.home-rails { display: grid; min-width: 0; gap: 24px; }
.home-rail { display: grid; min-width: 0; gap: 10px; }
.home-rail-header { display: flex; align-items: center; justify-content: space-between; }
.home-rail-header .panel-label { color: var(--text); font-size: .8rem; font-weight: 700; letter-spacing: .09em; }
.home-rail-list { display: grid; grid-auto-flow: column; grid-auto-columns: 220px; gap: 16px; padding: 6px; margin-left: -6px; overflow-x: auto; }
.home-rail-card { display: grid; grid-template-rows: 110px 100px; padding: 0; border: 1px solid var(--border); background: var(--surface); text-align: left; }
.home-rail-card:hover { background: var(--surface-hover); }
.home-rail-visual { display: grid; height: 110px; min-width: 0; min-height: 0; place-items: center; overflow: hidden; background: var(--surface-raised); }
.home-rail-logo { display: block; width: 100%; height: 110px; min-height: 0; padding: 12px; object-fit: contain; }
.home-rail-fallback { font-size: 2rem; color: var(--muted); }
.home-rail-copy { display: grid; min-width: 0; align-content: center; gap: 5px; padding: 10px 12px; }
.home-rail-copy strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9rem; }
.home-rail-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .75rem; }

/* Catalog and channels */
.player-layout { display: grid; height: 100%; min-height: 0; grid-template-columns: var(--category-panel-width) minmax(0, 1fr) 34%; }
.player-layout.is-vod:not(.has-video) { grid-template-columns: var(--category-panel-width) minmax(0, 1fr); }
.player-layout.is-vod:not(.has-video) .video-panel { display: none; }
.player-layout.is-vod .epg-panel { display: none; }
.category-panel, .channel-panel, .video-panel { min-width: 0; min-height: 0; }
.category-panel { display: flex; flex-direction: column; padding: 24px 12px 16px; border-right: 1px solid var(--border); }
.category-panel-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 10px 16px; }
.category-panel-header h2 { margin: 0; font-size: 1.1rem; }
.category-count { color: var(--muted); font-size: .7rem; }
.category-list { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 6px; min-height: 0; padding: 6px; overflow-y: auto; }
.category-button { width: 100%; min-width: 0; min-height: 54px; padding: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); text-align: left; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-button:hover, .category-button:focus { background: var(--surface-hover); color: var(--text); }
.category-button.is-active { border-left-color: var(--accent); box-shadow: inset 2px 0 var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 700; }
.channel-panel { display: flex; flex-direction: column; padding: 24px 18px 10px; overflow: hidden; }
.channel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; }
.channel-toolbar > div { min-width: 0; }
.section-title { margin: 0; font-size: 1.45rem; line-height: 1.25; overflow-wrap: anywhere; }
.catalog-status { margin: 10px 0 16px; color: var(--muted); font-size: .75rem; }
.search-box { display: flex; flex: 0 1 240px; min-width: 0; align-items: center; gap: 8px; padding-left: 12px; border: 1px solid var(--border); background: var(--surface); }
.search-icon { flex: 0 0 20px; }
.search-box input { min-height: 46px; padding-left: 0; border: 0; background: transparent; font-size: .9rem; }
.search-box input:focus { outline-offset: -3px; }
.channel-grid, .episode-grid { display: grid; min-height: 0; align-content: start; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 18px; padding: 6px 6px 14px; overflow-y: auto; }
.channel-grid { flex: 1; }
.channel-card { position: relative; min-width: 0; border: 1px solid var(--border); background: var(--surface); }
.channel-card:hover, .channel-card.is-playing { background: var(--surface-hover); }
.channel-card.is-playing { border-left-color: var(--accent); box-shadow: inset 2px 0 var(--accent); }
.channel-select { display: grid; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.channel-logo { display: grid; width: 100%; height: 300px; place-items: center; background: var(--surface-raised); color: var(--muted); font-size: 2rem; }
img.channel-logo { object-fit: contain; }
.channel-details { display: grid; min-width: 0; align-content: start; gap: 6px; padding: 14px; }
.channel-grid:not(.is-list) .channel-details { min-height: 96px; }
.channel-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); font-size: .95rem; line-height: 1.3; }
.card-badge, .playing-badge, .resume-badge { font-size: .65rem; font-weight: 700; }
.card-badge { color: var(--muted); }
.card-rating { color: var(--muted); font-size: .75rem; }
.resume-badge { color: var(--success); }
.favorite-button { position: absolute; z-index: 1; top: 8px; right: 8px; display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 22px; }
.favorite-button:hover, .favorite-button.is-favorite { color: var(--accent); background: var(--surface-hover); }
.channel-grid.is-list { grid-template-columns: 1fr; gap: 10px; }
.channel-grid.is-list .channel-select { min-height: 92px; grid-template-columns: 62px minmax(0, 1fr) minmax(0, 1.2fr); align-items: stretch; }
.channel-grid.is-list .channel-logo { width: 62px; height: 92px; padding: 10px; background: transparent; }
.channel-grid.is-list .channel-details { align-content: center; padding: 12px 8px; }
.channel-grid.is-list .channel-name { font-size: .9rem; }
.program-column { display: grid; min-width: 0; align-content: center; gap: 6px; padding: 12px 48px 12px 10px; }
.program-current, .program-column small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.program-current { font-size: .8rem; }
.program-column small { color: var(--muted); font-size: .7rem; }
.empty-state { margin: 48px 0; color: var(--muted); text-align: center; }
.catalog-more { margin: 12px 0 6px; font-size: .75rem; }

/* Video and EPG */
.video-panel { padding: 24px 18px; border-left: 1px solid var(--border); overflow-y: auto; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--border); background: #000000; }
.video-frame.is-app-fullscreen { position: fixed; z-index: 100; inset: 0; width: 100vw; height: 100vh; aspect-ratio: auto; border: 0; }
#video-player { display: block; width: 100%; height: 100%; min-height: 0; background: #000000; }
.video-placeholder, .video-buffering, .video-error { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); text-align: center; font-size: .85rem; }
.placeholder-icon { font-size: 2rem; }
.video-buffering { z-index: 2; background: rgba(0, 0, 0, .6); pointer-events: none; }
.video-error { z-index: 2; padding: 24px 24px 150px; color: var(--danger); background: #000000; font-size: 1rem; line-height: 1.5; pointer-events: none; }
.video-frame.is-live { cursor: pointer; }
.video-frame.is-live:focus { outline: 3px solid #ffffff; outline-offset: -3px; }
.video-frame.is-live .video-error { padding: 24px; }
.video-frame.is-app-fullscreen:focus { outline: none; }
.video-frame.is-app-fullscreen .video-error { font-size: 1.4rem; }
.video-overlay { position: absolute; z-index: 3; right: 0; bottom: 0; left: 0; padding: 32px 12px 12px; color: #ffffff; background: linear-gradient(transparent, rgba(0, 0, 0, .85) 35%, #000000); }
.video-heading { display: grid; gap: 6px; margin-bottom: 12px; }
.video-content-kind { color: #bdbdbd; font-size: .6rem; font-weight: 700; letter-spacing: .12em; }
.video-control-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; font-weight: 700; }
.video-controls { display: flex; align-items: center; gap: 10px; }
.video-control-button { display: grid; flex: 0 0 auto; width: 44px; height: 44px; place-items: center; border: 1px solid #686868; background: #202020; color: #ffffff; }
.video-control-button:hover { background: #393939; }
.video-control-button:focus { outline: 3px solid #ffffff; outline-offset: 3px; background: #393939; }
.video-control-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.video-control-button svg text { fill: currentColor; stroke: none; font-size: 9px; font-weight: 700; text-anchor: middle; }
.video-play-button { background: #ffffff; color: #111111; border-color: #ffffff; }
.video-play-button:hover, .video-play-button:focus { background: #dedede; }
.video-play-button .icon-play { fill: currentColor; stroke-width: 1; }
.video-play-button .icon-pause { stroke-width: 4; }
.video-play-button .icon-pause, .video-play-button.is-playing .icon-play,
.video-control-button .icon-muted, .video-control-button.is-muted .icon-sound,
.video-control-button .icon-collapse, .video-control-button.is-expanded .icon-expand { display: none; }
.video-play-button.is-playing .icon-pause, .video-control-button.is-muted .icon-muted,
.video-control-button.is-expanded .icon-collapse { display: block; }
.video-controls-spacer { flex: 1; }
.video-seek-help { margin: 12px 0 0; color: #bdbdbd; font-size: .7rem; line-height: 1.4; }
.video-frame.is-app-fullscreen .video-overlay { padding: 64px 48px 32px; }
.video-frame.is-app-fullscreen .video-heading { gap: 8px; margin-bottom: 20px; }
.video-frame.is-app-fullscreen .video-content-kind { font-size: .75rem; }
.video-frame.is-app-fullscreen .video-control-title { font-size: 1.6rem; }
.video-frame.is-app-fullscreen .video-controls { gap: 16px; }
.video-frame.is-app-fullscreen .video-control-button { width: 60px; height: 56px; }
.video-frame.is-app-fullscreen .video-play-button { width: 72px; }
.video-frame.is-app-fullscreen .video-control-button svg { width: 28px; height: 28px; }
.video-frame.is-app-fullscreen:not(.is-live) .video-error { padding-bottom: 250px; }
.video-progress { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.video-progress input { flex: 1; min-width: 0; min-height: 28px; padding: 0; border: 0; accent-color: #ffffff; }
.video-progress-time { min-width: 56px; color: #dedede; font-size: .85rem; font-variant-numeric: tabular-nums; }
.epg-panel { margin-top: 24px; }
.epg-header { display: grid; gap: 10px; margin-bottom: 16px; }
.epg-channel-name { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }
.epg-list { display: grid; gap: 4px; max-height: calc(var(--content-height) - 340px); overflow-y: auto; }
.epg-row { display: grid; min-height: 48px; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 10px; border-left: 2px solid transparent; color: var(--muted); }
.epg-row.is-current { border-left-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.epg-row.is-past { opacity: .6; }
.epg-time { font-size: .8rem; font-variant-numeric: tabular-nums; }
.epg-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.epg-status { font-size: .6rem; font-weight: 700; }
.epg-feedback { margin: 12px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.playback-feedback { font-size: .8rem; }

/* Films and series */
.media-detail, .series-detail { min-height: 0; padding: 6px; overflow-y: auto; }
.media-detail-header, .series-detail-header { display: flex; align-items: start; gap: 24px; margin-bottom: 28px; }
.media-detail-header > div, .series-detail-header > div { min-width: 0; }
.media-detail-header > button, .series-detail-header > button { flex: 0 0 auto; }
.media-rating { margin: 8px 0 0; color: var(--muted); }
.media-detail-body { display: grid; grid-template-columns: minmax(180px, 32%) 1fr; align-items: start; gap: 28px; }
.media-backdrop { display: block; width: 100%; height: auto; max-height: 400px; object-fit: contain; background: var(--surface); }
.media-copy { display: grid; gap: 18px; }
.media-description, .media-metadata, .media-credits { margin: 8px 0; color: var(--muted); font-size: .95rem; line-height: 1.6; overflow-wrap: anywhere; }
.media-description { color: var(--text); }
.media-copy .primary-button { width: min(100%, 280px); min-height: 56px; }
.detail-favorite { width: fit-content; max-width: 100%; }
.detail-favorite[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.series-seasons { display: grid; gap: 8px; margin-bottom: 18px; }
.season-list { display: flex; gap: 12px; max-width: 100%; padding: 6px; overflow-x: auto; }
.season-button { flex: 0 0 auto; min-height: 48px; padding: 0 18px; border: 1px solid var(--border); background: var(--surface); }
.season-button.is-active { background: var(--surface-hover); border-bottom-color: var(--accent); }
.episode-grid { max-height: calc(var(--content-height) - 280px); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.episode-card { display: grid; min-height: 96px; align-content: center; gap: 10px; padding: 18px; border: 1px solid var(--border); background: var(--surface); text-align: left; }
.episode-card:hover { background: var(--surface-hover); }
.episode-number { font-size: .75rem; color: var(--muted); }
.episode-card strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Flat settings rows, in remote-control order. */
.settings-panel { position: absolute; z-index: 5; inset: 0; padding: 32px clamp(28px, 6vw, 110px); background: var(--background); overflow-y: auto; }
.settings-card { width: min(1100px, 100%); margin: 0 auto; }
.settings-header { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.settings-title { margin: 0 0 10px; font-size: 2rem; }
.settings-subtitle { margin: 0; color: var(--muted); }
.settings-content { display: grid; gap: 0; }
.settings-section { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px 24px; padding: 24px 0; border-top: 1px solid var(--border); }
.settings-section-heading { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 12px; padding-top: 12px; }
.settings-section-heading h2 { margin: 0; font-size: 1.2rem; font-weight: 600; }
.settings-section-icon { display: grid; flex: 0 0 28px; place-items: center; color: var(--accent); }
.settings-section-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.settings-section > :not(.settings-section-heading) { grid-column: 2; }
.settings-option { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 24px; padding: 8px 0; }
.settings-option > span { display: grid; gap: 8px; }
.settings-option strong { font-size: 1rem; font-weight: 600; }
.settings-option small, .settings-account p { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.settings-option select { flex: 0 0 190px; width: 190px; }
.settings-section > button { width: min(100%, 320px); }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 6px; }
.theme-option { display: grid; min-width: 0; gap: 10px; padding: 12px; border: 1px solid var(--border); background: var(--surface); text-align: left; }
.theme-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.theme-option:focus { background: var(--surface-hover); }
.theme-option-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.theme-option small { color: var(--muted); font-size: .75rem; }
.theme-selected-mark { visibility: hidden; color: var(--accent); }
.theme-option[aria-pressed="true"] .theme-selected-mark { visibility: visible; }
.theme-preview { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; min-height: 76px; padding: 26px 10px 10px; background: var(--preview-background); }
.theme-preview::before { content: ''; position: absolute; top: 10px; left: 10px; width: 22px; height: 6px; background: var(--preview-accent); }
.theme-preview > span { display: block; min-height: 36px; border-top: 2px solid var(--preview-accent); background: var(--preview-surface); }
.theme-graphite { --preview-accent: #ffffff; --preview-background: #090909; --preview-surface: #141414; }
.theme-amethyst { --preview-accent: #923fff; --preview-background: #100b1b; --preview-surface: #1a122a; }
.theme-midnight { --preview-accent: #388aff; --preview-background: #071321; --preview-surface: #101f32; }
.theme-help { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.settings-option-toggle { padding-right: 6px; }
.settings-toggle { flex: 0 0 auto; width: 28px; height: 28px; min-height: 0; padding: 0; accent-color: var(--accent); }
.settings-session-status { display: flex; align-items: center; gap: 10px; color: var(--success); font-size: .85rem; }
.status-dot { width: 7px; height: 7px; background: currentColor; }
.settings-account > strong { display: none; }
.settings-account p { margin: 0; }

/* Only the currently requested section blocks while loading. */
.loading-overlay { position: absolute; z-index: 200; inset: 0; display: grid; place-content: center; padding: 24px; background: var(--background); }
.loading-card { display: grid; justify-items: center; gap: 24px; padding: 32px; text-align: center; }
.loading-card strong { font-size: 1.4rem; }
.loading-card > span { color: var(--muted); }
.loader-spinner { width: 42px; height: 42px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
.video-buffering .loader-spinner { width: 30px; height: 30px; }
@keyframes spin { to { transform: rotate(360deg); } }

.category-list, .channel-grid, .episode-grid, .season-list, .home-rail-list, .epg-list { scrollbar-width: thin; scrollbar-color: #555555 transparent; overscroll-behavior: contain; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #555555; }

@media (max-width: 1200px) {
  .player-layout { grid-template-columns: var(--category-panel-width) minmax(0, 1fr) 30%; }
  .channel-panel, .video-panel { padding: 20px 12px 10px; }
  .channel-toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .search-box { flex-basis: auto; }
  .channel-grid.is-list .channel-select { grid-template-columns: 48px minmax(0, 1fr); }
  .channel-grid.is-list .channel-logo { grid-row: 1 / span 2; width: 48px; height: 96px; padding: 6px; }
  .channel-grid.is-list .channel-details { padding: 10px 44px 0 8px; }
  .program-column { grid-column: 2; padding: 4px 10px 10px 8px; }
  .program-column small { display: none; }
}

@media (max-width: 820px) {
  :root { --header-height: 72px; --category-panel-width: clamp(160px, 28vw, 220px); }
  .top-bar { padding: 0 16px; gap: 16px; }
  .top-bar-identity, .device-status { gap: 16px; }
  .current-section { padding-left: 16px; }
  .brand-logo { width: 122px; height: 32px; }
  .home-button > span:last-child { display: none; }
  .home-button { width: 48px; padding: 0; }
  .home-view { grid-template-columns: minmax(0, 1fr); padding: 28px; gap: 24px; }
  .home-actions { gap: 16px; }
  .home-action { min-height: 190px; padding: 20px; }
  .home-action-code { right: 12px; top: 16px; font-size: .6rem; }
  .home-action small { display: none; }
  .home-action strong { font-size: 1.3rem; }
  .player-content { height: auto; min-height: var(--content-height); }
  .home-view, .settings-panel { height: var(--content-height); }
  .player-layout, .player-layout.is-vod:not(.has-video) { height: auto; grid-template-columns: var(--category-panel-width) minmax(0, 1fr); }
  .category-panel, .channel-panel { height: var(--content-height); }
  .category-panel { padding: 18px 6px 10px; }
  .category-button { font-size: .85rem; }
  .video-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); padding: 20px; }
  .video-frame { max-width: 600px; margin: 0 auto; }
  .video-frame.is-app-fullscreen { max-width: none; }
  .remote-help { padding: 0 16px; gap: 18px; font-size: .65rem; }
  .settings-panel { padding: 28px; }
  .settings-section { grid-template-columns: 1fr; gap: 16px; }
  .settings-section-heading { grid-row: auto; }
  .settings-section > :not(.settings-section-heading) { grid-column: 1; }
  .settings-option { gap: 16px; }
  .settings-option select { flex-basis: 130px; width: 130px; }
  .media-detail-body { grid-template-columns: 1fr; }
  .media-detail-header, .series-detail-header { flex-direction: column; gap: 16px; }
}

@media (max-width: 640px) {
  .video-frame.is-app-fullscreen .video-overlay { padding: 40px 16px 20px; }
  .video-frame.is-app-fullscreen .video-control-title { font-size: 1.1rem; }
  .video-frame.is-app-fullscreen .video-controls { gap: 10px; }
  .video-frame.is-app-fullscreen .video-control-button { width: 44px; height: 44px; }
  .video-frame.is-app-fullscreen .video-play-button { width: 52px; }
  .video-frame.is-app-fullscreen .video-control-button svg { width: 24px; height: 24px; }
  .video-progress { gap: 8px; }
  .video-progress-time { min-width: 46px; font-size: .75rem; }
  :root { --header-height: 124px; }
  .top-bar { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: 64px 60px; column-gap: 12px; row-gap: 0; }
  .settings-button { grid-column: 3; grid-row: 1; }
  .device-status { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; align-self: stretch; border-top: 1px solid var(--border); }
  .device-clock { font-size: 1.4rem; }
}

@media (max-width: 520px) {
  .home-search-header { align-items: stretch; flex-direction: column; }
  .home-search-pages { flex-wrap: wrap; }
  .home-search-button { padding: 12px; font-size: .9rem; }
  .search-keyboard-overlay { padding: 8px; }
  .search-keyboard-card { padding: 12px; max-height: calc(100vh - 16px); }
  .search-keyboard-actions { gap: 4px; }
  .search-keyboard-actions button { font-size: .75rem; }
  .home-actions { grid-template-columns: 1fr; }
  .home-action { min-height: 120px; grid-template-columns: 56px 1fr; align-items: center; }
  .home-action-icon { margin-bottom: 0; }
  .home-action strong { font-size: 1.3rem; }
  .current-section { font-size: .85rem; }
  .settings-header { flex-direction: column; }
  .settings-option { align-items: start; flex-direction: column; }
  .settings-option select { flex-basis: auto; width: 100%; }
  .theme-options { gap: 8px; }
  .theme-option { padding: 8px; }
  .theme-preview { min-height: 60px; gap: 3px; padding: 23px 6px 6px; }
  .theme-option-name { font-size: .8rem; }
  .theme-option small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-spinner { animation-duration: 2s; }
}
