:root {
  --bg-dark: #0b0e14;
  --bg-card: #121620;
  --bg-card-hover: #181d2a;
  --border-color: #1f2636;
  --accent-light: #3b82f6; /* Blue for Live Text */
  --live-red: #ef4444;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { background-color: var(--bg-dark); color: var(--text-main); font-family: 'Inter', sans-serif; min-height: 100vh; line-height: 1.5; }

/* Hidden utility for toggling views */
.hidden { display: none !important; }

/* -------------------------------------
   MAIN VIEW (Header, Filters, Grid)
------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background-color: rgba(11, 14, 20, 0.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
}
.nav-container { max-width: 1400px; margin: 0 auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.site-brand-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.site-brand { display: flex; align-items: center; cursor: pointer; user-select: none; }
.brand-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.5px; color: #fff; }
.brand-ext { color: var(--accent-light); }

.live-dot-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(239, 68, 68, 0.15); color: var(--live-red);
  font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
}
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background-color: var(--live-red); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(1.3); } 100% { opacity: 1; transform: scale(1); } }

.search-form { display: flex; align-items: center; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px; padding: 4px 10px; width: 100%; }
.search-form input { flex: 1; background: transparent; border: none; outline: none; color: #fff; font-size: 0.9rem; padding: 8px 4px; }
.search-form input::placeholder { color: var(--text-muted); }
.search-form button { background: transparent; border: none; color: var(--text-muted); cursor: pointer; }

/* Filter Navigation */
.filter-navigation { background-color: var(--bg-dark); border-bottom: 1px solid var(--border-color); padding: 10px 0; }
.filter-wrapper { max-width: 1400px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.channel-tabs, .tag-scroller { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.channel-tabs::-webkit-scrollbar, .tag-scroller::-webkit-scrollbar { display: none; }
.nav-pill { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.8rem; font-weight: 600; padding: 6px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; transition: 0.15s; }
.nav-pill.active, .nav-pill:hover { background: #fff; color: #000; border-color: #fff; }
.tag-chip { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tag-chip.active, .tag-chip:hover { border-color: var(--accent-light); color: var(--text-main); background: rgba(59, 130, 246, 0.1); }

.page-container { max-width: 1400px; margin: 0 auto; padding: 0; }
.grid-content-wrapper { padding: 16px; }
.grid-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.grid-header h2 { font-size: 1rem; font-weight: 600; color: #fff; }
.total-rooms { font-size: 0.8rem; color: var(--text-muted); }

/* Grid */
.cam-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .cam-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 1024px) { .cam-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.cam-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: transform 0.15s ease, background 0.15s ease; }
.cam-card:hover { background: var(--bg-card-hover); transform: translateY(-2px); }
.thumb-wrap { width: 100%; aspect-ratio: 16/10; background: #000; position: relative; overflow: hidden; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-live-badge { position: absolute; top: 6px; left: 6px; background: rgba(239, 68, 68, 0.9); color: #fff; font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 3px; }
.card-viewers { position: absolute; bottom: 6px; right: 6px; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 0.68rem; padding: 2px 6px; border-radius: 3px; }
.card-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.card-user-line { display: flex; justify-content: space-between; align-items: center; }
.card-username { font-size: 0.88rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-age { font-size: 0.75rem; color: var(--text-muted); }
.card-subject { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.load-more-wrap { display: flex; justify-content: center; margin: 28px 0; }
.load-more-btn { background: var(--bg-card); border: 1px solid var(--border-color); color: #fff; font-size: 0.85rem; font-weight: 600; padding: 10px 24px; border-radius: 6px; cursor: pointer; transition: background 0.15s; }
.load-more-btn:hover { background: var(--bg-card-hover); }
.grid-loading { grid-column: 1/-1; text-align: center; padding: 40px 16px; color: var(--text-muted); font-size: 0.9rem; }

/* -------------------------------------
   THEATER WATCH STAGE (Half-Screen)
------------------------------------- */
#watchStage {
  width: 100vw;
  min-height: 100vh;
  background-color: #000; /* Cinematic empty space below */
}

/* BORDERLESS, EDGE-TO-EDGE VIDEO CONTAINER */
.video-container {
  width: 100vw;
  aspect-ratio: 16/9;
  background: #000;
  margin: 0; padding: 0; border: none; outline: none;
  position: relative;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Exact aspect ratio without cropping */
  display: block;
  outline: none; border: none;
}

.player-loader { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-muted); font-size: 0.85rem; z-index: 5; }
.spinner { width: 32px; height: 32px; border: 3px solid rgba(255, 255, 255, 0.1); border-top-color: var(--accent-light); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* Seamless Black Meta Bar */
.player-meta-bar {
  width: 100vw;
  background-color: #000;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meta-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.current-model-name { font-size: 1.15rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-viewers { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }

.meta-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 4px;
}
.action-btn:hover { background: rgba(255,255,255,0.1); }

.close-stage-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--live-red);
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}
.close-stage-btn:hover { background: var(--live-red); color: #fff; }
