/* NEXUS IPTV · "Noir Cinema": cartón oscuro, latón y tipografía editorial. */

:root {
  color-scheme: dark;
  --accent: #6fd6e8;
  --accent-2: #ff9b6a;
  --gold: #f0bd78;
  --ink: #090b0e;
  --bg: #090b0e;
  --bg-2: #0d1015;
  --panel: #12161c;
  --panel-2: #171c24;
  --panel-3: #202733;
  --line: #2b3340;
  --text: #f5f1e9;
  --muted: #98a1ae;
  --danger: #ff6b72;
  --success: #51d6a3;
  --radius: 14px;
  --shadow: 0 18px 42px #0009, 0 2px 8px #0006;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(760px 420px at 88% -12%, #f0bd7814 0%, transparent 64%),
    radial-gradient(680px 460px at -14% 112%, #6fd6e812 0%, transparent 62%),
    repeating-linear-gradient(0deg, #ffffff06 0 1px, transparent 1px 46px),
    repeating-linear-gradient(90deg, #ffffff05 0 1px, transparent 1px 46px),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  letter-spacing: .006em;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #f0bd7855; color: #fff; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
* { scrollbar-color: var(--panel-3) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #303a48; }
::-webkit-scrollbar-track { background: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
a { color: inherit; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 11px; }
kbd { background: #ffffff0a; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; font-size: 10px; font-family: inherit; color: #d7dde6; }

h1, h2, h3, .brand-text strong, .category-title, .panel h3 { font-family: var(--serif); }

/* ---------- Barra superior: 52 px, pieza metálica ---------- */
.topbar {
  height: 52px; display: flex; align-items: center; gap: 10px;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #15191f, #0c0f13);
  border-bottom: 1px solid #f0bd7826;
  box-shadow: 0 6px 22px #0007, inset 0 1px 0 #ffffff0c;
  position: sticky; top: 0; z-index: 30;
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, #f0bd7880 22%, #6fd6e866 68%, transparent);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 175px; }
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px; display: block; border-radius: 8px;
  border: 1px solid #f0bd7866;
  box-shadow: 0 3px 12px #0009, 0 0 18px #f0bd7833;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; font-weight: 600; letter-spacing: .17em; }
.brand-text span { color: var(--gold); font-size: 7.5px; font-weight: 800; letter-spacing: .28em; margin-top: 2px; }

.top-search {
  flex: 1 1 0; min-width: 0; max-width: 480px; display: flex; align-items: center; gap: 8px;
  background: #00000038; border: 1px solid #ffffff14; border-radius: 999px; padding: 0 12px;
  box-shadow: inset 0 1px 5px #0008; transition: border-color .18s, box-shadow .18s;
}
.top-search:focus-within { border-color: #f0bd7880; box-shadow: 0 0 0 3px #f0bd7818, inset 0 1px 5px #0008; }
.top-search span { color: var(--gold); font-size: 18px; line-height: 1; }
.top-search input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); padding: 7px 0; font-size: 12.5px; }
.top-search input::placeholder { color: #7f8996; }

.playlist-picker {
  display: flex; align-items: center; gap: 7px; flex: 0 1 auto; min-width: 0; max-width: 210px;
  background: #ffffff08; border: 1px solid #ffffff1c; color: var(--text);
  border-radius: 999px; padding: 6px 11px; font-size: 11.5px; font-weight: 650;
  box-shadow: inset 0 1px 0 #ffffff0a; transition: border-color .18s, background .18s;
}
.playlist-picker:hover { border-color: #f0bd7880; background: #f0bd7810; }
.playlist-picker #playlistName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); flex: 0 0 7px; }
.status-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.chevron { color: var(--gold); font-size: 10px; }
.icon-btn {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px;
  border: 1px solid #ffffff1c; background: #ffffff08; color: #e8e4dc; font-size: 14px;
  transition: border-color .18s, color .18s, background .18s;
}
.icon-btn:hover { border-color: #f0bd7880; color: var(--gold); background: #f0bd7814; }
.icon-btn.tiny { width: 26px; height: 26px; font-size: 13px; }
.mobile-menu { display: block; }
.install-btn {
  display: flex; align-items: center; gap: 5px; flex: 0 0 auto;
  border: 1px solid #f0bd7880; background: #f0bd781c; color: var(--gold);
  border-radius: 999px; padding: 6px 10px; font-size: 10.5px; font-weight: 800; white-space: nowrap;
}
.install-btn:hover { background: var(--gold); color: var(--ink); }
.install-btn[hidden] { display: none; }
.install-icon { font-size: 14px; }

/* ---------- Estructura ---------- */
.layout { display: block; min-height: calc(100dvh - 52px); }

.sidebar {
  position: fixed; z-index: 50; top: 52px; bottom: 0; left: 0; width: min(340px, 88vw);
  border-right: 1px solid #f0bd7833; background: #0b0e12f7;
  padding: 12px max(12px, env(safe-area-inset-right)) 14px max(12px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 11px;
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-102%); transition: transform .22s ease;
  box-shadow: 16px 0 54px #000b;
}
.sidebar::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: linear-gradient(180deg, var(--gold), transparent 70%);
}
.sidebar.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 2px; }
.drawer-head strong { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.drawer-backdrop { position: fixed; inset: 52px 0 0; z-index: 45; background: #030507c4; backdrop-filter: blur(3px); }
.drawer-backdrop[hidden] { display: none; }
.nav-block { display: flex; flex-direction: column; gap: 4px; }
.nav-block.grow { flex: 1; min-height: 90px; }
.nav-label {
  display: flex; justify-content: space-between; align-items: center;
  color: #7d8794; font-size: 9px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  padding: 0 8px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 10px; background: transparent;
  color: #aab2bd; text-align: left; font-size: 12.5px; font-weight: 600;
}
.nav-item i {
  width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center;
  text-align: center; font-style: normal; font-size: 13px; color: #8e98a5;
  background: #ffffff08; border: 1px solid #ffffff0c; border-radius: 7px;
}
.nav-item b { margin-left: auto; font-size: 9.5px; color: var(--muted); background: #ffffff08; border-radius: 999px; padding: 2px 7px; font-weight: 650; }
.nav-item:hover { background: #ffffff0a; color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, #f0bd7822, transparent); color: var(--gold); }
.nav-item.active i { color: var(--gold); border-color: #f0bd7855; background: #f0bd7818; }
.nav-item.active::before { content: ''; width: 3px; height: 18px; border-radius: 3px; background: var(--gold); margin-left: -10px; }
select {
  width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid #ffffff16;
  background: #00000040; color: var(--text); font-size: 12px; outline: 0;
}
select:focus { border-color: var(--gold); }
.check-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; padding: 6px 8px; cursor: pointer; }
.check-row input { accent-color: var(--gold); }
.link-btn { border: 0; background: none; color: var(--gold); font-size: 10px; font-weight: 800; cursor: pointer; padding: 8px 6px; min-height: 28px; letter-spacing: .06em; }
.playlist-nav { display: flex; flex-direction: column; gap: 4px; }
.playlist-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; font-size: 12px; color: #aab2bd; }
.playlist-row.active { background: #f0bd7814; color: var(--text); }
.playlist-row button { border: 0; background: none; color: inherit; text-align: left; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-row .tag { font-size: 8.5px; color: var(--gold); border: 1px solid #f0bd7855; border-radius: 4px; padding: 1px 4px; letter-spacing: .08em; }
.sidebar-status { display: flex; align-items: center; gap: 7px; padding-top: 12px; border-top: 1px solid #ffffff14; color: var(--muted); font-size: 10.5px; }
.sidebar-status span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Contenido principal ---------- */
.main { padding: 11px 14px 20px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.player-card {
  position: sticky; top: 52px; z-index: 20;
  flex: 0 0 auto; min-width: 0; overflow: hidden; border-radius: 18px; box-shadow: var(--shadow);
  background: linear-gradient(180deg, #151a21, #0d1014);
  border: 1px solid #f0bd7833;
}
.player { position: relative; aspect-ratio: 16 / 8.4; max-height: 50vh; background: #040608; overflow: hidden; }
.player:fullscreen,
.player.simulated-fullscreen { position: fixed; inset: 0; z-index: 9999; width: 100vw; height: 100dvh; aspect-ratio: auto; max-height: none; border-radius: 0; background: #000; display: flex; flex-direction: column; }
.player:fullscreen video,
.player.simulated-fullscreen video { flex: 1 1 auto; min-height: 0; object-fit: contain; }
.player:fullscreen .player-top,
.player.simulated-fullscreen .player-top { padding-top: max(12px, env(safe-area-inset-top)); }
.player:fullscreen .player-bottom,
.player.simulated-fullscreen .player-bottom { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
body.simulated-fs { overflow: hidden; }
body.fs-clean .player-card { position: static; z-index: auto; }
video:-webkit-full-screen { width: 100%; height: 100%; object-fit: contain; background: #000; }

/* Pantalla completa despejada: un toque revela controles 3,2 s. */
body.fs-clean .topbar,
body.fs-clean .now-bar,
body.fs-clean .inline-catalogue,
body.fs-clean .sidebar,
body.fs-clean .side-info,
body.fs-clean .drawer-backdrop { display: none !important; }
.player.clean-view:not(.chrome-visible) .player-top,
.player.clean-view:not(.chrome-visible) .player-bottom,
.player.clean-view:not(.chrome-visible) .tap-hint,
.player.clean-view:not(.chrome-visible) .overlay .btn { opacity: 0; visibility: hidden; pointer-events: none; }
.player.clean-view:not(.chrome-visible) .player-top *,
.player.clean-view:not(.chrome-visible) .player-bottom * { pointer-events: none; }
.player-top, .player-bottom, .tap-hint, .overlay .btn { transition: opacity .18s ease, visibility .18s ease; }

.channel-controls { display: flex; align-items: center; gap: 4px; }
.channel-controls .control { width: 26px; height: 26px; flex-basis: 26px; font-size: 10px; }
.channel-pos { color: #e6dfd2; font-size: 9.5px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 4px #000; }
.tap-hint { position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); background: #000c; border: 1px solid #f0bd7855; color: #f3eadc; border-radius: 999px; padding: 5px 12px; font-size: 10px; pointer-events: none; animation: fade-hint 5s forwards; }
.tap-hint[hidden] { display: none; }
@keyframes fade-hint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* En pantalla completa, un toque despliega los canales desde la izquierda. */
.fs-channel-drawer {
  position: absolute; z-index: 8; top: 0; bottom: 0; left: 0;
  width: min(340px, 86vw); box-sizing: border-box;
  display: flex; flex-direction: column; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: #0b0e12f5; border-right: 1px solid #f0bd7840;
  box-shadow: 16px 0 54px #000b;
  transform: translateX(-102%); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .22s ease, opacity .18s ease, visibility .18s;
}
.fs-channel-drawer.open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; }
.fs-drawer-head { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.fs-drawer-head strong { font-family: var(--serif); color: var(--gold); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
.fs-drawer-head .result-count { margin-left: auto; }
.fs-drawer-head .control { width: 26px; height: 26px; flex-basis: 26px; }
.fs-drawer-list { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.fs-channel-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; flex: 0 0 auto;
  width: 100%; min-height: 44px; max-height: 50px; padding: 5px 10px;
  border: 1px solid #ffffff12; border-radius: 9px; overflow: hidden;
  background: linear-gradient(115deg, #1b212a, #141920); color: var(--text); text-align: left;
}
.fs-channel-row span, .fs-channel-row small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-channel-row span { font-size: 12px; font-weight: 650; }
.fs-channel-row small { color: #8f99a6; font-size: 9.5px; }
.fs-channel-row:hover { border-color: #f0bd7880; }
.fs-channel-row.active { border-color: var(--gold); background: #f0bd7818; }
.fs-channel-drawer .load-more { flex: 0 0 auto; margin-top: 0; }

video { width: 100%; height: 100%; object-fit: contain; display: block; background: #040608; }
.player-top, .player-bottom { position: absolute; z-index: 5; left: 0; right: 0; display: flex; align-items: center; gap: 6px; padding: 8px 10px; pointer-events: none; }
.player-top { top: 0; background: linear-gradient(#000b, transparent); }
.player-bottom { bottom: 0; background: linear-gradient(transparent, #000d); }
.player-top *, .player-bottom * { pointer-events: auto; }
.live-badge { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(135deg, #c62c42, #8e1b30); color: #fff; padding: 4px 8px; border-radius: 5px; font-size: 9px; font-weight: 800; letter-spacing: .12em; box-shadow: 0 2px 8px #0007; }
.live-badge i { width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.quality-badge { background: #000a; border: 1px solid #f0bd7855; color: var(--gold); padding: 3px 6px; border-radius: 5px; font-size: 9px; font-weight: 800; letter-spacing: .06em; }
.clock { color: #e6dfd2; font-size: 11px; font-variant-numeric: tabular-nums; letter-spacing: .06em; text-shadow: 0 1px 4px #000; }
.sleep-chip { position: absolute; z-index: 6; top: 42px; right: 10px; background: #000c; border: 1px solid #f0bd7880; color: var(--gold); border-radius: 999px; padding: 3px 8px; font-size: 10px; font-variant-numeric: tabular-nums; letter-spacing: .04em; pointer-events: none; }
.sleep-chip[hidden] { display: none; }
body.fs-clean .sleep-chip { top: max(52px, calc(env(safe-area-inset-top) + 42px)); }
.control-row { display: flex; align-items: center; gap: 6px; width: 100%; }
.control { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; border: 1px solid #ffffff2b; background: #000a; color: #fff; font-size: 12px; backdrop-filter: blur(4px); transition: background .16s, color .16s, border-color .16s, transform .16s; }
.control:hover:not(:disabled) { background: var(--gold); color: var(--ink); border-color: var(--gold); transform: translateY(-1px); }
.volume { display: flex; align-items: center; gap: 6px; }
.volume input { width: 76px; accent-color: var(--gold); }
.buffer, .source-tag { color: #d2d8e0; font-size: 10px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 4px #000; }
.buffer.good { color: #51d6a3; }
.buffer.warn { color: #ffbd62; }
.source-tag { border: 1px solid #ffffff38; border-radius: 4px; padding: 2px 5px; letter-spacing: .08em; text-transform: uppercase; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2a2119f2, #050709fb 72%); text-align: center; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 7px; max-width: 420px; }
.overlay-mark { width: 52px; height: 52px; border-radius: 12px; box-shadow: 0 8px 24px #0009, 0 0 26px #f0bd7833; }
.overlay-logo { font-size: 9px; letter-spacing: .26em; color: var(--gold); font-weight: 800; }
.overlay h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.overlay p { margin: 0; color: #aab2bd; font-size: 11.5px; line-height: 1.5; }
.spinner { width: 30px; height: 30px; border: 3px solid #ffffff18; border-top-color: var(--gold); border-radius: 50%; animation: spin .9s linear infinite; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.now-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid #f0bd7826; background: linear-gradient(180deg, #ffffff05, transparent); }
.now-logo { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 9px; background: linear-gradient(160deg, #252c36, #11151b); border: 1px solid #f0bd7833; display: grid; place-items: center; overflow: hidden; font-family: var(--serif); font-weight: 600; color: var(--gold); font-size: 11px; letter-spacing: .06em; }
.now-logo img { width: 100%; height: 100%; object-fit: contain; }
.now-text { min-width: 0; flex: 1; }
.now-text h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-text p { margin: 1px 0 0; color: var(--gold); font-size: 9.5px; text-transform: uppercase; letter-spacing: .13em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.btn { border: 1px solid #ffffff1e; background: #ffffff0a; color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 11px; font-weight: 650; text-decoration: none; white-space: nowrap; transition: border-color .16s, color .16s, background .16s, transform .16s; }
.btn:hover:not(:disabled) { border-color: #f0bd7880; color: var(--gold); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--gold), #d99552); border-color: transparent; color: #16110a; font-weight: 800; box-shadow: 0 4px 16px #f0bd7833; }
.btn.primary:hover:not(:disabled) { color: #16110a; filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff9298; border-color: #ff6b7244; }
.btn.danger:hover:not(:disabled) { background: #ff6b7218; color: #ff9298; border-color: var(--danger); }
.btn.icon-only { width: 30px; text-align: center; font-size: 15px; }
.btn.on { color: var(--gold); border-color: #f0bd7880; background: #f0bd7818; }
.sleep-btn.active { color: var(--gold); border-color: #f0bd7899; background: #f0bd7822; font-size: 10px; }
.variant-box { display: flex; flex-direction: column; gap: 2px; }
.variant-box label { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.variant-box select { max-width: 170px; padding: 4px 7px; font-size: 10.5px; }

/* ---------- Catálogo ---------- */
.catalogue { min-height: 120px; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.inline-catalogue {
  background: linear-gradient(180deg, #141920, #0f1318); border: 1px solid #ffffff12;
  border-radius: 16px; padding: 11px 12px 13px; box-shadow: var(--shadow); min-width: 0;
  position: relative;
}
.inline-catalogue::before { content: ''; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: linear-gradient(90deg, transparent, #f0bd7866, transparent); }
.inline-catalogue .catalogue-head h2 { font-size: 18px; }
.inline-catalogue .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 7px; max-height: clamp(240px, 42vh, 440px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.inline-catalogue .card { min-height: 48px; }
.catalogue-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 8px; gap: 8px; }
.catalogue-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.catalogue-head p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.result-count { color: var(--gold); font-size: 9px; background: #f0bd7812; border: 1px solid #f0bd7840; border-radius: 999px; padding: 3px 8px; white-space: nowrap; letter-spacing: .06em; text-transform: uppercase; }
.catalogue-tools { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.group-mode { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #ffffff16; border-radius: 999px; background: #00000045; }
.group-mode button { border: 0; background: none; color: var(--muted); border-radius: 999px; padding: 4px 8px; font-size: 9.5px; font-weight: 750; cursor: pointer; }
.group-mode button:hover { color: var(--text); }
.group-mode button.active { background: var(--gold); color: #17120b; font-weight: 800; }
.nav-block .group-mode { margin-bottom: 7px; }
.cards { display: grid; grid-template-columns: 1fr; gap: 6px; }
.category-chips { display: flex; gap: 5px; overflow-x: auto; padding: 0 0 8px; margin-bottom: 2px; scrollbar-width: thin; }
.chip { flex: 0 0 auto; border: 1px solid #ffffff16; background: #ffffff08; color: #aab2bd; border-radius: 999px; padding: 4px 10px; font-size: 10px; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; transition: border-color .16s, color .16s, background .16s; }
.chip span { color: var(--text); opacity: .55; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: #f0bd7880; color: var(--text); }
.chip.active { background: var(--gold); border-color: var(--gold); color: #17120b; font-weight: 800; }
.chip.active span { color: #17120b; opacity: .7; }
.chip-more { border-style: dashed; }
.cards.grouped { display: block; max-height: clamp(240px, 42vh, 440px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.catalogue .cards.grouped { max-height: none; padding-right: 2px; }
.category-section + .category-section { margin-top: 12px; }
.category-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; }
.category-title { border: 0; background: none; color: var(--gold); font-size: 12px; font-weight: 600; letter-spacing: .04em; padding: 2px 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-title:hover { text-decoration: underline; }
.category-count { color: var(--muted); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.cards.grouped .category-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 7px; }
.catalogue .cards.grouped .category-cards { grid-template-columns: 1fr; gap: 6px; }
.card-type { display: inline-block; margin-left: 5px; font-size: 7.5px; font-weight: 800; letter-spacing: .06em; color: var(--gold); background: #f0bd7814; border: 1px solid #f0bd7840; border-radius: 4px; padding: 1px 4px; vertical-align: middle; text-transform: uppercase; }
.card {
  position: relative; display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 6px 9px 6px 11px;
  background: linear-gradient(115deg, #1b212a, #141920); border: 1px solid #ffffff12;
  border-radius: 10px; text-align: left; color: var(--text); min-height: 48px; overflow: hidden;
  transition: border-color .16s, background .16s, transform .16s, box-shadow .16s;
}
.card::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--gold); opacity: .35; }
.card-info { min-width: 0; flex: 1; }
.card .card-star { position: static; flex: 0 0 auto; }
.card { scroll-margin-top: 64px; }
.card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.card:hover { border-color: #f0bd7880; background: linear-gradient(115deg, #242c37, #171c23); transform: translateY(-2px); box-shadow: 0 8px 18px #0006; }
.card.active { border-color: var(--gold); box-shadow: inset 0 0 0 1px #f0bd7855, 0 0 22px #f0bd7818; }
.card.active::before { opacity: 1; }
.card-logo { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 7px; background: linear-gradient(160deg, #2a323e, #161b22); border: 1px solid #ffffff10; display: grid; place-items: center; overflow: hidden; font-size: 9px; font-weight: 700; color: var(--gold); }
.card-logo img { width: 100%; height: 100%; object-fit: contain; }
.card-name { font-size: 12px; font-weight: 650; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-group { color: #8f99a6; font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-quality { position: absolute; top: 5px; right: 8px; font-size: 7.5px; font-weight: 800; color: var(--gold); background: #f0bd7818; border-radius: 4px; padding: 1px 4px; }
.card-star { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border: 0; background: none; color: #6f7885; font-size: 16px; }
.card-star.on { color: var(--gold); }
.load-more { align-self: center; margin-top: 10px; background: #ffffff08; border: 1px solid #ffffff1e; color: var(--text); border-radius: 8px; padding: 7px 14px; font-size: 11px; }
.load-more:hover { border-color: var(--gold); color: var(--gold); }
.empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 9px; color: var(--muted); text-align: center; padding: 32px 12px; border: 1px dashed #ffffff24; border-radius: 12px; font-size: 12px; }
.empty-action { max-width: 100%; }

/* ---------- Panel derecho ---------- */
.side-info {
  position: fixed; z-index: 50; top: 52px; bottom: 0; right: 0; width: min(320px, 90vw);
  border-left: 1px solid #f0bd7833; background: #0b0e12f7;
  padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(102%); transition: transform .22s ease; box-shadow: -16px 0 54px #000b;
}
.side-info.open { transform: none; }
.panel { background: linear-gradient(160deg, #181d25, #11151b); border: 1px solid #ffffff14; border-radius: 12px; padding: 14px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.panel h3 { margin: 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.epg-item { display: grid; grid-template-columns: 42px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid #ffffff0d; }
.epg-item:last-child { border-bottom: 0; }
.epg-time { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.epg-title { font-size: 11.5px; font-weight: 600; line-height: 1.3; }
.epg-progress { height: 3px; background: #ffffff12; border-radius: 3px; margin-top: 5px; overflow: hidden; }
.epg-progress i { display: block; height: 100%; background: var(--gold); }
.epg-item.now .epg-title { color: var(--gold); }
.empty-mini { color: var(--muted); font-size: 11px; line-height: 1.5; }
.details { display: flex; flex-direction: column; gap: 8px; }
.detail-row { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.detail-row span:first-child { color: var(--muted); }
.detail-row span:last-child { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.shortcuts div { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10.5px; padding: 3px 0; }

/* ---------- Ventanas ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: #030507e6; display: grid; place-items: center; padding: 18px; backdrop-filter: blur(8px) saturate(120%); }
.modal[hidden] { display: none; }
.modal-card {
  width: min(440px, 100%); max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(170deg, #191e26, #0d1116);
  border: 1px solid #f0bd7833; border-radius: 15px; padding: 18px;
  box-shadow: 0 26px 80px #000c, inset 0 1px 0 #ffffff0c;
}
.modal-card.wide { width: min(650px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.modal-head h2 { margin: 0; font-size: 21px; font-weight: 600; }
.modal-sub { color: var(--muted); font-size: 11.5px; margin: 3px 0 12px; }
.add-form { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: end; }
.add-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.add-form input { background: #00000045; border: 1px solid #ffffff1c; border-radius: 8px; padding: 8px; color: var(--text); outline: 0; font-size: 12px; }
.add-form input:focus { border-color: var(--gold); }
.preset-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.feedback { margin-top: 10px; padding: 9px 11px; border-radius: 8px; font-size: 11.5px; }
.feedback.ok { background: #51d6a317; color: var(--success); border: 1px solid #51d6a344; }
.feedback.err { background: #ff6b7217; color: #ff9298; border: 1px solid #ff6b7244; }
.manager-list { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.manager-row { display: flex; align-items: center; gap: 8px; background: #ffffff08; border: 1px solid #ffffff14; border-radius: 10px; padding: 8px 10px; }
.manager-row .info { flex: 1; min-width: 0; }
.manager-row strong { display: block; font-size: 12.5px; }
.manager-row small { display: block; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manager-row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.manager-empty { color: var(--muted); font-size: 12px; padding: 14px; text-align: center; border: 1px dashed #ffffff24; border-radius: 10px; }
.manager-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 11px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid #ffffff14; }
.setting-row strong { display: block; font-size: 12.5px; }
.setting-row small { color: var(--muted); font-size: 10.5px; }
.setting-row input[type=checkbox] { accent-color: var(--gold); width: 18px; height: 18px; }
.setting-row input[type=range] { accent-color: var(--gold); width: 130px; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px #11161d; }
.modal-foot { display: flex; justify-content: space-between; margin-top: 12px; }
.backup-row { align-items: flex-start; }
.backup-row > div:first-child { min-width: 0; }
.backup-actions { display: flex; flex-direction: column; gap: 7px; flex: 0 0 auto; }

/* ---------- Importación de listas .txt ---------- */
.txt-import { margin-top: 14px; padding-top: 13px; border-top: 1px solid #f0bd7833; }
.txt-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 9px; }
.txt-head strong { font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--gold); }
.txt-head small { color: var(--muted); font-size: 10.5px; }
.txt-drop {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px dashed #f0bd7855; border-radius: 11px; background: #f0bd7808;
  transition: background .16s, border-color .16s;
}
.txt-drop.dragover { background: #f0bd781c; border-color: var(--gold); }
.txt-drop-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 9px; background: #f0bd7818; color: var(--gold); font-size: 17px; }
.txt-drop-text { flex: 1; min-width: 0; }
.txt-drop-text strong { display: block; font-size: 11.5px; }
.txt-drop-text small { display: block; color: var(--muted); font-size: 9.5px; margin-top: 2px; }
.txt-result { margin-top: 10px; display: flex; flex-direction: column; gap: 9px; }
.txt-result[hidden] { display: none; }
.txt-file { color: var(--gold); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txt-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 6px; }
.txt-stat { background: #ffffff08; border: 1px solid #ffffff12; border-radius: 9px; padding: 7px 8px; text-align: center; }
.txt-stat b { display: block; font-family: var(--serif); font-size: 17px; color: var(--gold); }
.txt-stat span { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.txt-label { color: #7d8794; font-size: 9px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.txt-theme-list { display: flex; flex-wrap: wrap; gap: 5px; max-height: 92px; overflow-y: auto; }
.txt-theme { border: 1px solid #ffffff1c; background: #ffffff08; color: #9fa8b4; border-radius: 999px; padding: 4px 8px; font-size: 9.5px; cursor: pointer; }
.txt-theme.active { border-color: #f0bd7880; background: #f0bd7818; color: var(--gold); }
.txt-theme span { opacity: .65; font-variant-numeric: tabular-nums; }
.txt-preview { background: #00000045; border: 1px solid #ffffff12; border-radius: 9px; max-height: 124px; overflow-y: auto; }
.txt-preview-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid #ffffff0c; font-size: 10.5px; }
.txt-preview-row:last-child { border-bottom: 0; }
.txt-preview-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txt-preview-theme { color: var(--gold); font-size: 9px; white-space: nowrap; }
.txt-actions { display: flex; align-items: flex-end; gap: 7px; flex-wrap: wrap; }
.txt-name { flex: 1 1 140px; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 9.5px; font-weight: 700; }
.txt-name input { background: #00000045; border: 1px solid #ffffff1c; border-radius: 8px; padding: 7px 9px; color: var(--text); outline: 0; }
.txt-name input:focus { border-color: var(--gold); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 18px); background: #171c24f5; border: 1px solid #f0bd7880; color: var(--text); padding: 10px 17px; border-radius: 10px; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1240px) { .top-search { max-width: 380px; } }
@media (max-width: 860px) {
  .topbar { padding: 0 8px; gap: 6px; }
  .brand { min-width: auto; }
  .brand-text { display: none; }
  .top-search { max-width: none; }
  .top-search kbd { display: none; }
  .playlist-picker { max-width: 110px; }
  .install-btn { padding: 6px 8px; }
  .install-label { display: none; }
  .main { padding: 7px; }
  .now-bar { flex-wrap: wrap; padding: 8px; gap: 7px; }
  .now-actions { width: 100%; justify-content: flex-start; }
  .now-text h1 { font-size: 15px; }
  .add-form { grid-template-columns: 1fr; }
  .tap-hint { bottom: 56px; font-size: 9.5px; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); gap: 6px; }
  .brand { min-width: auto; }
  .brand-text { display: none; }
  .playlist-picker { flex: 0 0 40px; max-width: 40px; padding: 6px; justify-content: center; }
  .playlist-picker #playlistName { display: none; }
  .top-search { padding: 0 8px; }
  .top-search input { font-size: 12px; }
  .top-search input::placeholder { font-size: 10.5px; }
  .install-btn { padding: 6px; }
  .main { padding: 6px; gap: 10px; }
  .player { aspect-ratio: 16 / 9; max-height: none; }
  .player-bottom { padding: 6px 8px; gap: 5px; }
  .control-row { gap: 5px; }
  .volume input { width: 52px; }
  .buffer { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .now-bar { padding: 7px; }
  .channel-pos { display: none; }
  .manager-row { flex-wrap: wrap; }
  .manager-row .actions { width: 100%; justify-content: flex-start; }
  .player:fullscreen .control-row,
  .player.simulated-fullscreen .control-row { flex-wrap: nowrap; }
  .player:fullscreen .buffer,
  .player.simulated-fullscreen .buffer { display: none; }
  .inline-catalogue .cards,
  .cards.grouped .category-cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .txt-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 560px) {
  .now-logo, .tap-hint { display: none; }
  .now-bar { padding: 7px 9px; }
  .sidebar, .side-info { gap: 7px; padding-top: 8px; padding-bottom: 8px; }
  .drawer-head { padding-bottom: 0; }
  .nav-block { gap: 2px; }
  .nav-item { padding: 4px 7px; font-size: 11px; }
  .nav-label { padding-bottom: 3px; }
  .check-row, .sidebar-status { display: none; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .main { padding: 6px; gap: 8px; }
  .now-text p { display: none; }
  .now-actions { flex-wrap: nowrap; width: auto; overflow: hidden; }
  .now-actions .btn { padding: 5px 7px; min-height: 26px; font-size: 9.5px; }
}
