:root {
  color-scheme: dark;
  --bg: #080b0f;
  --panel: #101720;
  --panel-2: #151e29;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f7fb;
  --muted: #94a3b8;
  --soft: #cbd5e1;
  --teal: #2dd4bf;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #fb7185;
  --green: #34d399;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.guide-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.guide-topbar {
  min-height: 68px;
  padding: 12px 18px;
  display: grid;
  grid-template-columns: auto minmax(240px, 560px) auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 15, 0.94);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand svg {
  width: 22px;
  height: 22px;
  color: var(--teal);
}

.search-box {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131b;
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: 0 0 auto;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.source-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0d131b;
  color: var(--muted);
  font-size: 0.83rem;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.source-pill.is-live .status-dot {
  background: var(--green);
}

.icon-button,
.jump-button,
.scope-button,
.group-chip,
.program-block,
.channel-button,
.load-more {
  border: 1px solid var(--line);
  background: #0d131b;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.icon-button:hover,
.jump-button:hover,
.scope-button:hover,
.group-chip:hover,
.program-block:hover,
.channel-button:hover,
.load-more:hover {
  border-color: var(--line-strong);
  background: #131c27;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button.is-on {
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--amber);
  background: rgba(251, 191, 36, 0.09);
}

.guide-main {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 14px;
}

.video-frame {
  min-height: clamp(260px, 37vw, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020406;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

.video-frame video {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
  object-fit: contain;
  background: #020406;
}

.video-frame.is-empty video {
  visibility: hidden;
}

.video-empty,
.loading-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
}

.video-empty svg {
  width: 44px;
  height: 44px;
  color: var(--teal);
}

.video-empty strong {
  color: var(--text);
  font-size: 1rem;
}

.loading-layer {
  background: rgba(2, 4, 6, 0.68);
  color: var(--soft);
  z-index: 2;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.now-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.channel-mark {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131b;
  overflow: hidden;
}

.channel-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 9px;
}

.channel-mark svg {
  width: 32px;
  height: 32px;
  color: var(--blue);
}

.now-copy {
  min-width: 0;
}

.now-copy span,
.time-readout span {
  color: var(--muted);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.now-copy h1 {
  margin: 8px 0;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.now-copy p {
  margin: 0;
  color: var(--soft);
  line-height: 1.45;
}

.now-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-controls {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.time-readout {
  min-width: 128px;
}

.time-readout strong {
  display: block;
  margin-top: 2px;
  font-size: 1.05rem;
}

.scope-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.scope-button,
.jump-button,
.group-chip,
.load-more {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  white-space: nowrap;
}

.scope-button svg,
.jump-button svg {
  width: 16px;
  height: 16px;
}

.scope-button.is-active,
.group-chip.is-active,
.jump-button {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.1);
  color: var(--text);
}

.group-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.group-chip {
  font-size: 0.86rem;
}

.group-chip span {
  color: var(--muted);
}

.guide-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.guide-scroll {
  overflow: auto;
  max-height: calc(100vh - 430px);
  min-height: 420px;
}

.time-grid,
.guide-row {
  display: grid;
  grid-template-columns: 224px repeat(6, minmax(168px, 1fr));
  min-width: 1230px;
}

.time-grid {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0b1118;
  border-bottom: 1px solid var(--line);
}

.corner-cell,
.time-cell {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.corner-cell {
  position: sticky;
  left: 0;
  z-index: 12;
  background: #0b1118;
  border-right: 1px solid var(--line);
}

.time-cell {
  border-right: 1px solid var(--line);
}

.guide-row {
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

.guide-row.is-active {
  background: rgba(96, 165, 250, 0.08);
}

.channel-button {
  position: sticky;
  left: 0;
  z-index: 5;
  min-width: 0;
  min-height: 72px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  background: var(--panel-2);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.guide-row.is-active .channel-button {
  background: #172536;
}

.channel-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131b;
  color: var(--teal);
  font-weight: 900;
  overflow: hidden;
}

.channel-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

.channel-copy {
  min-width: 0;
}

.channel-copy strong,
.program-block strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
}

.channel-copy strong {
  font-size: 0.9rem;
}

.channel-copy span,
.program-block span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-number {
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.program-cell {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 8px;
  display: flex;
}

.program-block {
  width: 100%;
  min-height: 56px;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  background: #0d131b;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-color: rgba(255, 255, 255, 0.08);
}

.program-block.is-now {
  border-color: rgba(45, 212, 191, 0.4);
  background: rgba(45, 212, 191, 0.1);
}

.program-block.is-sports {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.09);
}

.program-block strong {
  font-size: 0.88rem;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.load-row {
  min-width: 1230px;
  padding: 14px;
  display: flex;
  justify-content: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131b;
  color: var(--text);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .guide-topbar {
    grid-template-columns: 1fr auto;
  }

  .search-box {
    grid-column: 1 / -1;
    order: 3;
  }

  .player-panel,
  .guide-controls {
    grid-template-columns: 1fr;
  }

  .guide-scroll {
    max-height: none;
  }

  .source-pill {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 620px) {
  .guide-main,
  .guide-topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand span {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .now-panel {
    grid-template-columns: 64px 1fr;
    grid-template-rows: auto auto;
  }

  .channel-mark {
    width: 64px;
    height: 64px;
  }

  .now-actions {
    grid-column: 1 / -1;
  }
}
