:root {
  --bg-main: #060911;
  --bg-surface: #0f172a;
  --bg-card: #141e33;
  --bg-card-hover: #1e2d4d;
  --accent-cyan: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.45);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 80% 20%, rgba(56, 189, 248, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 40%);
  color: var(--text-primary);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ==================== HARD RULE: .hidden ==================== */
.hidden {
  display: none !important;
}

/* ==================== UNIVERSAL FLOATING BACK BUTTON ==================== */
.floating-back-btn {
  position: absolute;
  top: 24px;
  left: 30px;
  z-index: 150;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(15px);
  color: #ffffff;
  border: 2px solid var(--accent-cyan);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  pointer-events: auto;
}

.floating-back-btn:hover, .floating-back-btn.focused {
  background: var(--accent-cyan);
  color: #030712;
  transform: scale(1.06);
  box-shadow: 0 0 25px var(--accent-cyan);
}

.floating-btn-small {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.floating-btn-small:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== TOP NAVIGATION BAR ==================== */
.top-nav {
  height: 80px;
  padding: 0 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(6, 9, 17, 0.9);
  backdrop-filter: blur(20px);
  z-index: 20;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.brand-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.brand-sub {
  font-size: 13px;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.top-nav-center {
  display: flex;
  gap: 12px;
}

.nav-tab {
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  font-family: inherit;
}

.nav-tab.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.top-nav-info {
  display: flex;
  align-items: center;
  gap: 24px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: #4ade80;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 10px #22c55e;
}

.clock-display {
  text-align: right;
}

.clock-time {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

.clock-date {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== MAIN VIEWPORT ==================== */
.main-viewport {
  height: calc(100vh - 130px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 50px 80px 50px;
  display: flex;
  flex-direction: column;
  gap: 40px;
  scroll-behavior: smooth;
}

.main-viewport::-webkit-scrollbar {
  display: none;
}

/* Spotlight Hero Banner */
.spotlight-banner {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%),
              radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.15) 0%, transparent 60%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px 50px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.spotlight-tags {
  display: flex;
  gap: 10px;
}

.tag {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-live {
  background: #dc2626;
  color: #ffffff;
  animation: pulseLive 1.8s infinite;
}

@keyframes pulseLive {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

.tag-hd {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.spotlight-title {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
}

.spotlight-desc {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 800px;
  line-height: 1.6;
}

.spotlight-actions {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.spotlight-btn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-cyan);
  color: #030712;
  border: 2px solid transparent;
  padding: 14px 32px;
  border-radius: 30px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.spotlight-btn-yt {
  background: #dc2626;
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
}

.spotlight-btn:hover, .spotlight-btn.focused {
  transform: scale(1.06);
  border-color: #ffffff;
  box-shadow: 0 0 30px var(--accent-cyan);
}

.spotlight-btn-yt:hover, .spotlight-btn-yt.focused {
  border-color: #ffffff;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.8) !important;
}

/* Section Wrapper */
.section-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title-text {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cards-row {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 10px 0 20px 0;
  scroll-behavior: smooth;
}

.cards-row::-webkit-scrollbar {
  display: none;
}

/* App Cards */
.app-card {
  min-width: 230px;
  height: 150px;
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.app-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.app-icon {
  font-size: 38px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
}

.app-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

/* Channel Cards */
.channel-card {
  min-width: 200px;
  height: 130px;
  background: var(--bg-card);
  border: 3px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.channel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.channel-num-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 8px;
}

.channel-name {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-top: 4px;
}

.channel-cat {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== FOCUS HIGHLIGHT EFFECT ==================== */
.focusable.focused, .focusable-drawer.focused, .focusable-yt.focused, .focusable-launch.focused, .launch-btn.focused {
  transform: scale(1.08) translateY(-4px);
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 12px 30px var(--accent-glow) !important;
  z-index: 10;
}

/* ==================== FULLSCREEN LIVE PLAYER MODAL ==================== */
#playerView {
  display: none;
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 100;
}

#playerView.active {
  display: block;
}

#tvVideoPlayer {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #000;
}

/* On-Screen Display (OSD) Overlay */
.player-osd {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 30px 50px 30px 240px;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.osd-channel-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.osd-logo {
  font-size: 32px;
  font-weight: 800;
  font-family: 'Space Grotesk', sans-serif;
  background: var(--accent-cyan);
  color: #030712;
  padding: 6px 16px;
  border-radius: 12px;
}

.osd-name {
  font-size: 28px;
  font-weight: 700;
}

.osd-desc {
  font-size: 16px;
  color: var(--text-secondary);
}

.osd-hint {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
}

/* Quick Channel Drawer */
.quick-channel-drawer {
  position: absolute;
  bottom: 40px;
  left: 50px;
  right: 50px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(25px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.3s ease;
  z-index: 110;
}

.quick-channel-drawer.hidden {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}

.drawer-header {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.stream-toast {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 38, 38, 0.9);
  color: white;
  padding: 10px 24px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 120;
}

/* ==================== IN-APP YOUTUBE HUB MODAL ==================== */
.youtube-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: #09090b;
  z-index: 90;
  flex-direction: column;
  padding: 20px 40px;
}

.youtube-modal.active {
  display: flex;
}

.yt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 16px;
}

.yt-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.yt-logo-icon { font-size: 32px; }
.yt-title { font-size: 24px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: #ff0033; }

.yt-search-bar {
  display: flex;
  gap: 10px;
  flex: 1;
  max-width: 720px;
}

.yt-input {
  flex: 1;
  background: #18181b;
  border: 2px solid #27272a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.yt-input.focused {
  border-color: #ff0033;
  box-shadow: 0 0 15px rgba(255, 0, 51, 0.4);
}

.yt-search-submit, .yt-open-direct-btn, .yt-close-btn {
  background: #27272a;
  border: 2px solid transparent;
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.yt-open-direct-btn {
  background: #b91c1c;
}

.yt-close-btn { background: #3f3f46; }

/* YouTube Category Bar */
.yt-category-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.yt-category-bar::-webkit-scrollbar {
  display: none;
}

.yt-cat-pill {
  background: #18181b;
  border: 2px solid #27272a;
  color: var(--text-secondary);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}

.yt-cat-pill.active {
  background: #ff0033;
  color: #ffffff;
  border-color: #ff0033;
  box-shadow: 0 0 15px rgba(255, 0, 51, 0.4);
}

.yt-cat-pill.focused {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 15px var(--accent-glow) !important;
  transform: scale(1.05);
}

.yt-content-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 20px;
}

.yt-card {
  background: #18181b;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.yt-thumb-wrapper {
  position: relative;
  width: 100%;
  height: 140px;
}

.yt-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #27272a;
}

.yt-duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.yt-badge-live {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #dc2626;
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  animation: pulseLive 1.5s infinite;
}

.yt-meta {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.yt-video-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-video-channel {
  font-size: 12px;
  color: var(--text-muted);
}

/* Fullscreen YouTube Video Embed with Floating Header Bar */
.yt-player-container {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.yt-player-container.hidden {
  display: none !important;
}

.yt-floating-bar {
  height: 70px;
  padding: 0 30px;
  background: linear-gradient(180deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
}

.yt-playing-hint {
  font-size: 14px;
  color: #cbd5e1;
  background: rgba(0,0,0,0.6);
  padding: 6px 16px;
  border-radius: 20px;
}

.yt-player-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ==================== APP LAUNCH MODAL (Enhanced) ==================== */
.app-launch-modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 17, 0.88);
  backdrop-filter: blur(25px);
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-launch-modal.hidden {
  display: none !important;
}

.app-launch-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  max-width: 620px;
  width: 92%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.app-launch-header {
  display: flex;
  align-items: center;
  gap: 18px;
}

.app-launch-icon {
  font-size: 52px;
}

.app-launch-title {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
}

.app-launch-sub {
  font-size: 14px;
  color: var(--accent-cyan);
  font-weight: 600;
}

.app-launch-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.app-launch-options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.launch-option-card {
  background: #1e293b;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  color: #fff;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  font-family: inherit;
}

.launch-option-card .option-icon {
  font-size: 28px;
}

.launch-option-card .option-name {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-recommended {
  background: #22c55e;
  color: #030712;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
}

.launch-option-card .option-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.launch-option-card:hover, .launch-option-card.focused {
  background: #334155;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(1.02);
}

.app-launch-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.launch-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  font-family: inherit;
}

.launch-secondary {
  background: #334155;
  color: #ffffff;
}

.launch-secondary:hover, .launch-secondary.focused {
  background: #475569;
  border-color: #94a3b8;
}

/* Launch Toast */
.launch-toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  color: #ffffff;
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px var(--accent-glow);
  z-index: 160;
  animation: slideUpToast 0.3s ease;
}

@keyframes slideUpToast {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ==================== BOTTOM HELP BAR ==================== */
.bottom-help-bar {
  height: 50px;
  padding: 0 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(6, 9, 17, 0.95);
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

.help-keys {
  display: flex;
  gap: 24px;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kbd-badge {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: #fff;
}
