:root {
  color-scheme: dark;
  --page: #0b1016;
  --surface: #121922;
  --surface-2: #17212c;
  --surface-3: #1d2936;
  --line: #283545;
  --line-soft: rgba(255, 255, 255, .06);
  --text: #f5f7fa;
  --muted: #8e9bad;
  --accent: #ff3b57;
  --accent-soft: rgba(255, 59, 87, .18);
  --live: #ff4763;
  --channel-width: 264px;
  --row-height: 72px;
  --header-height: 56px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
/* Garantiza que los estados ocultos no ocupen espacio aunque una clase defina display:flex. */
[hidden] { display: none !important; }

html, body { min-height: 100%; }
body { margin: 0; background: radial-gradient(circle at 50% -20%, #182331 0, var(--page) 42%); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
.guide-page { min-width: 320px; }
.guide-topbar {
  height: 72px; padding: 0 clamp(16px, 3vw, 42px); display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft); background: rgba(11, 16, 22, .88); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20;
}
.guide-brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
.guide-brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, #ff3151, #b91331); font-weight: 900; font-size: 21px; box-shadow: 0 10px 28px rgba(255, 49, 81, .22); }
.guide-brand-logo-frame { min-width: 38px; max-width: clamp(58px, 9vw, 128px); height: 48px; display: flex; align-items: center; justify-content: flex-start; overflow: hidden; flex: 0 1 auto; }
.guide-brand-logo { display: block; width: auto; height: auto; max-width: 100%; max-height: 48px; object-fit: contain; object-position: left center; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .22)); }
.guide-brand-copy { min-width: 0; }
.guide-top-actions { display: flex; align-items: center; gap: 12px; }
.fullscreen-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: #dbe4ee; cursor: pointer; font-size: 18px; line-height: 1; display: grid; place-items: center; transition: .18s ease; }
.fullscreen-button:hover { border-color: #52677f; background: var(--surface-2); transform: translateY(-1px); }
.guide-brand strong, .guide-brand small { display: block; }
.guide-brand strong { font-size: 17px; letter-spacing: .01em; }
.guide-brand small { margin-top: 1px; color: var(--muted); font-size: 12px; }
.guide-clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.guide-main { width: min(100%, 1920px); margin: 0 auto; padding: 18px clamp(10px, 2vw, 28px) 28px; }
.guide-controls { display: grid; grid-template-columns: auto minmax(260px, 480px) 1fr; gap: 14px; align-items: center; margin-bottom: 14px; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.icon-button, .today-button, .guide-error button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 44px; cursor: pointer; transition: .18s ease;
}
.icon-button { width: 42px; font-size: 26px; line-height: 1; }
.today-button { padding: 0 16px; font-weight: 700; }
.icon-button:hover, .today-button:hover, .guide-error button:hover { border-color: #45586e; background: var(--surface-2); transform: translateY(-1px); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.date-field { min-width: 190px; height: 48px; border: 1px solid var(--line); background: var(--surface); border-radius: 13px; padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; }
.date-field span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.date-field input { color: var(--text); border: 0; outline: 0; padding: 1px 0 0; background: transparent; font-weight: 680; color-scheme: dark; }
.search-field { height: 48px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 0 12px; }
.search-field > span { color: var(--muted); font-size: 24px; transform: rotate(-15deg); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-field input::placeholder { color: #8b99ab; }
kbd { border: 1px solid #506176; color: var(--muted); border-radius: 7px; min-width: 27px; height: 27px; display: grid; place-items: center; font-size: 12px; }
.guide-summary { justify-self: end; color: var(--muted); font-size: 13px; text-align: right; }
.guide-panel { min-height: 400px; border: 1px solid var(--line-soft); border-radius: 16px; overflow: hidden; background: rgba(13, 19, 26, .72); box-shadow: 0 20px 70px rgba(0, 0, 0, .22); }
.guide-loading, .guide-error { min-height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; padding: 32px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.guide-error strong { color: var(--text); }
.guide-error button { padding: 10px 16px; }
.epg-scroll { width: 100%; height: calc(100vh - 190px); min-height: 450px; max-height: 900px; overflow: auto; scrollbar-color: #46566a #101720; scrollbar-width: thin; overscroll-behavior: contain; }
.epg-canvas { display: grid; grid-template-columns: var(--channel-width) auto; position: relative; min-height: 100%; background: var(--page); }
.epg-corner, .timeline-header { position: sticky; top: 0; z-index: 9; height: var(--header-height); background: #101720; border-bottom: 1px solid var(--line); }
.epg-corner { left: 0; z-index: 12; display: flex; align-items: center; padding: 0 18px; border-right: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.timeline-header { display: flex; overflow: hidden; }
.time-slot { height: 100%; flex: 0 0 var(--slot-width); padding: 13px 0 0 12px; border-left: 1px solid var(--line); color: #dfe5ec; font-size: 13px; font-weight: 760; font-variant-numeric: tabular-nums; }
.time-slot small { display: block; color: var(--muted); font-size: 10px; font-weight: 500; margin-top: 3px; }
.channel-cell { position: sticky; left: 0; z-index: 6; height: var(--row-height); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #111922; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-soft); }
.channel-cell:nth-of-type(4n+3) { background: #131c26; }
.channel-logo { width: 44px; height: 44px; object-fit: contain; border: 1px solid #48576a; background: #202a35; border-radius: 10px; padding: 4px; flex: 0 0 auto; }
.channel-logo-fallback { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid #48576a; font-size: 11px; font-weight: 900; color: #dbe2ea; }
.channel-meta { min-width: 0; }
.channel-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 760; }
.channel-id { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.program-track { position: relative; height: var(--row-height); border-bottom: 1px solid var(--line-soft); background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(var(--slot-width) - 1px), rgba(255,255,255,.055) calc(var(--slot-width) - 1px), rgba(255,255,255,.055) var(--slot-width)); }
.program-track.alt { background-color: rgba(255, 255, 255, .012); }
.programme-card { position: absolute; top: 6px; height: calc(var(--row-height) - 12px); border: 1px solid #2b3a4b; border-radius: 11px; background: linear-gradient(145deg, #1a2531, #17212b); padding: 8px 12px; overflow: hidden; cursor: pointer; color: var(--text); text-align: left; transition: border-color .16s ease, filter .16s ease, transform .16s ease; box-shadow: 0 7px 20px rgba(0, 0, 0, .12); }
.programme-card:hover { z-index: 4; border-color: #596d84; filter: brightness(1.08); transform: translateY(-1px); }
.programme-card.live { border-color: var(--live); background: linear-gradient(145deg, rgba(255, 61, 91, .24), #1c2631 60%); box-shadow: inset 3px 0 0 var(--live), 0 8px 24px rgba(255, 61, 91, .08); }
.programme-card.live::after { content: "EN VIVO"; position: absolute; right: 9px; top: 8px; color: #fff; background: var(--live); border-radius: 999px; padding: 2px 6px; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.live-progress { position: absolute; left: 0; bottom: 0; height: 3px; max-width: 100%; background: var(--live); box-shadow: 0 0 10px rgba(255, 71, 99, .65); pointer-events: none; }
.programme-title { display: block; max-width: calc(100% - 2px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 760; padding-right: 48px; }
.programme-card:not(.live) .programme-title { padding-right: 0; }
.programme-time { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; font-variant-numeric: tabular-nums; }
.no-programmes { display: flex; align-items: center; height: 100%; padding-left: 18px; color: #5f6d7d; font-size: 12px; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--live); z-index: 5; pointer-events: none; box-shadow: 0 0 12px rgba(255, 71, 99, .45); }
.now-line::before { content: ""; position: absolute; top: -1px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--live); }
.timeline-header .now-line { z-index: 10; }
.programme-dialog { width: min(540px, calc(100vw - 30px)); border: 1px solid #39495c; border-radius: 18px; padding: 26px; background: #131c26; color: var(--text); box-shadow: 0 30px 90px rgba(0, 0, 0, .65); }
.programme-dialog::backdrop { background: rgba(3, 6, 10, .72); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; right: 14px; top: 12px; width: 34px; height: 34px; border: 0; border-radius: 10px; background: #202b38; cursor: pointer; font-size: 22px; }
.dialog-channel { color: var(--accent); text-transform: uppercase; font-size: 11px; font-weight: 900; letter-spacing: .09em; padding-right: 38px; }
.programme-dialog h2 { margin: 10px 36px 5px 0; font-size: 24px; }
.dialog-time { color: var(--muted); margin: 0 0 13px; font-variant-numeric: tabular-nums; }
.dialog-category { display: inline-flex; border: 1px solid #435368; border-radius: 999px; padding: 4px 9px; color: #cbd5df; font-size: 11px; }
.dialog-description { color: #c6d0db; line-height: 1.55; white-space: pre-line; }
@media (max-width: 1040px) {
  .guide-controls { grid-template-columns: 1fr 1fr; }
  .guide-summary { grid-column: 1 / -1; justify-self: start; text-align: left; }
}
@media (max-width: 700px) {
  :root { --channel-width: 170px; --row-height: 68px; }
  .guide-topbar { height: 62px; padding: 0 13px; }
  .guide-brand-logo-frame { max-width: 82px; height: 40px; }
  .guide-brand-logo { max-height: 40px; }
  .guide-brand-copy small { display: none; }
  .fullscreen-button { width: 34px; height: 34px; }
  .guide-clock { font-size: 11px; }
  .guide-main { padding: 10px 7px 16px; }
  .guide-controls { grid-template-columns: 1fr; gap: 9px; }
  .date-nav { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px auto; }
  .date-field { min-width: 0; }
  .search-field { width: 100%; }
  .guide-summary { display: none; }
  .guide-panel { border-radius: 11px; }
  .epg-scroll { height: calc(100vh - 206px); min-height: 380px; }
  .channel-cell { gap: 8px; padding: 0 8px; }
  .channel-logo, .channel-logo-fallback { width: 37px; height: 37px; border-radius: 8px; }
  .channel-name { font-size: 12px; }
  .programme-card { padding: 8px; }
}
.guide-powered{position:fixed;right:14px;bottom:10px;z-index:25;padding:6px 10px;border:1px solid #273548;border-radius:999px;background:rgba(13,18,24,.88);backdrop-filter:blur(8px);font-size:11px;color:#8fa3bb}.guide-powered a{color:#dbeafe;font-weight:800;text-decoration:none}
@media(max-width:620px){.guide-powered{right:8px;bottom:6px;font-size:10px;padding:5px 8px}}
