/* ─── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  --bg:        #08090d;
  --surface:   #0e1018;
  --surface2:  #141720;
  --surface3:  #1b2030;
  --border:    rgba(255,255,255,0.055);
  --border-hi: rgba(255,255,255,0.12);
  --accent:    #e8ff47;
  --accent2:   #4dffb4;
  --live:      #00f080;
  --dead:      #ff4d6d;
  --text:      #f0f2ff;
  --text-2:    #7c8499;
  --text-3:    #3d4255;
  --glow:      rgba(232,255,71,0.18);
  --sidebar-w: 320px;
  --header-h:  58px;
  --footer-h:  32px;
  --radius:    14px;
  --radius-sm: 8px;
}

/* ─── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── LAYOUT SHELL ──────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ─── HEADER ─────────────────────────────────────────────────── */
header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width:16px; height:16px; }

.logo-text em {
  color: var(--accent);
  font-style: normal;
}

.search-wrap {
  flex: 1;
  max-width: 420px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  color: var(--text-2);
  width: 16px;
  height: 16px;
  pointer-events: none;
  flex-shrink: 0;
}

#search {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px 9px 38px;
  color: var(--text);
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#search:focus {
  border-color: var(--border-hi);
  background: var(--surface3);
}
#search::placeholder { color: var(--text-3); }

.header-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.badge-live {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,240,128,0.08);
  border: 1px solid rgba(0,240,128,0.2);
  color: var(--live);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  padding: 5px 11px;
  border-radius: 20px;
  white-space: nowrap;
  text-transform: uppercase;
}
.badge-live .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse-ring 1.6s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,240,128,0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(0,240,128,0); }
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  color: var(--text-2);
}
.btn-icon:hover { background: var(--surface3); border-color: var(--border-hi); color: var(--text); }

/* ─── MAIN ROW ───────────────────────────────────────────────── */
.main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

/* Category scroll */
.cat-scroll {
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
}
.cat-scroll::-webkit-scrollbar { display: none; }

.cat-tabs {
  display: flex;
  gap: 0;
  min-width: max-content;
}

.cat-tab {
  padding: 13px 13px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  user-select: none;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* List header */
.list-header {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.list-header-label {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.list-count {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(232,255,71,0.1);
  border: 1px solid rgba(232,255,71,0.2);
  padding: 2px 8px;
  border-radius: 20px;
}

/* Channel list */
.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 8px;
}
.channel-list::-webkit-scrollbar { width: 3px; }
.channel-list::-webkit-scrollbar-track { background: transparent; }
.channel-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* Channel item */
.ch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
  position: relative;
}
.ch-item:hover { background: var(--surface2); }
.ch-item.active {
  background: var(--surface3);
  border: 1px solid rgba(232,255,71,0.15);
}
.ch-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 3px;
}

.ch-num {
  font-size: 10px;
  color: var(--text-3);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.ch-item.active .ch-num { color: var(--text-2); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}
.status-dot.live   { background: var(--live); box-shadow: 0 0 6px rgba(0,240,128,0.6); }
.status-dot.dead   { background: var(--dead); }
.status-dot.checking { background: #f0c040; animation: blink 0.9s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.ch-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  color: var(--text-2);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.ch-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.ch-item.active .ch-logo { border-color: rgba(232,255,71,0.25); }

.ch-info { flex: 1; min-width: 0; }
.ch-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.ch-cat {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.ch-item.active .ch-cat { color: var(--text-2); }

.ch-arrow {
  color: var(--text-3);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}
.ch-item:hover .ch-arrow,
.ch-item.active .ch-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px;
  gap: 10px;
  color: var(--text-3);
}
.empty-state svg { width: 36px; height: 36px; opacity: 0.35; }
.empty-state p { font-size: 12.5px; }

/* ─── PLAYER SECTION ─────────────────────────────────────────── */
.player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.player-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px;
  background: var(--bg);
}

.video-card {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--border),
    0 24px 60px rgba(0,0,0,0.7);
  aspect-ratio: 16 / 9;
  width: 100%;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* Overlay */
.v-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid rgba(255,255,255,0.06);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  font-weight: 400;
}

/* Player HUD badges */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.hud-live {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,40,70,0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.hud-live::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  animation: pulse-ring 1s infinite;
}

.hud-name {
  background: rgba(8,9,13,0.72);
  backdrop-filter: blur(12px);
  color: rgba(255,255,255,0.88);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

/* Gradient vignette bottom */
.video-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 80px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
  pointer-events: none;
}

/* Now playing bar */
.now-playing {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.np-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 8px rgba(0,240,128,0.7);
  flex-shrink: 0;
  animation: pulse-ring 1.6s ease-in-out infinite;
}

.np-info { flex: 1; min-width: 0; }
.np-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-2);
  margin-bottom: 1px;
}
.np-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-status {
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.np-status.on-air { color: var(--live); }

/* ─── FOOTER ─────────────────────────────────────────────────── */
footer {
  height: var(--footer-h);
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  color: var(--text-3);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
}
footer em { color: var(--accent); font-style: normal; }

/* ─── COPYRIGHT MODAL ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity:0; } }

.modal {
  background: var(--surface2);
  border: 1px solid var(--border-hi);
  border-radius: 18px;
  padding: 28px 28px 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: slide-up 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } }

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.modal-icon {
  width: 34px;
  height: 34px;
  background: rgba(232,255,71,0.1);
  border: 1px solid rgba(232,255,71,0.25);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.modal-icon svg { width:17px; height:17px; }
.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 20px;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.3px;
}
.modal-btn:hover { opacity: 0.9; }
.modal-btn:active { transform: scale(0.99); }

/* ─── MOBILE ─────────────────────────────────────────────────── */
.fab {
  display: none;
  position: fixed;
  bottom: calc(var(--footer-h) + 14px);
  right: 16px;
  width: 46px;
  height: 46px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(232,255,71,0.35);
  transition: transform 0.15s;
  color: #0a0a0a;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 20px; height: 20px; }

/* ─── GESTURE INDICATORS ─────────────────────────────────────── */
#gestureHint {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(8,9,13,0.82);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 10px;
  z-index: 9000;
  pointer-events: none;
  border: 1px solid var(--border-hi);
}
#brightnessLayer {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 8999;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
/* ─── MOBILE BELOW (hidden on desktop) ───────────────────────── */
.mobile-below { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }

  /* Desktop sidebar hidden on mobile */
  .sidebar { display: none !important; }

  /* FAB hidden */
  .fab { display: none; }

  .main {
    flex-direction: column;
    overflow: visible;
    min-height: 0;
  }

  .player-section {
    width: 100%;
    flex-shrink: 0;
  }

  .player-wrap { padding: 10px; }

  /* Mobile below block: visible */
  .mobile-below {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex: 1;
  }

  .mobile-cat-scroll {
    padding: 0 10px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--surface);
    flex-shrink: 0;
  }
  .mobile-cat-scroll::-webkit-scrollbar { display: none; }

  .mobile-cat-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 0;
  }

  .mobile-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-channel-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .badge-live { display: none; }
  .header-end .btn-icon { display: none; }
  .search-wrap { max-width: none; }
  .now-playing { padding: 8px 12px; }
}
