:root {
  --bg-deep: #0b090e;
  --bg-card: #161320;
  --bg-glass: rgba(18, 14, 26, 0.82);
  --amber-gold: #f59e0b;
  --amber-soft: #fde68a;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --border-subtle: rgba(255, 255, 255, 0.14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
}

/* Main Phone Viewport Shell */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: #09080d;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
}

/* Warm Amber Blue-Light Filter Overlay */
.warm-light-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: rgba(255, 166, 77, 0);
  mix-blend-mode: multiply;
  transition: background 0.4s ease;
}

body.warm-mode .warm-light-overlay {
  background: rgba(255, 175, 95, 0.22);
}

body.warm-mode .persistent-yt-stage,
body.warm-mode .reel-thumb-bg {
  filter: sepia(18%) brightness(91%) contrast(97%);
}

/* Persistent YouTube Player Stage (Behind transparent scroll-snap cards) */
.persistent-yt-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  background: #060509;
  overflow: hidden;
}

.persistent-yt-stage iframe,
#yt-stage-player {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.tap-unmute-banner {
  position: absolute;
  top: 98px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  background: rgba(245, 158, 11, 0.95);
  color: #120c02;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.tap-unmute-banner.hidden {
  display: none;
}

/* ================= 1. PASSWORDLESS PROFILE GATE ================= */
.profile-gate {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: radial-gradient(circle at 50% 20%, #261b3a 0%, #110d1a 65%, #08060c 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 22px;
  text-align: center;
  overflow-y: auto;
}

.profile-gate.hidden {
  display: none;
}

.welcome-icon {
  width: 72px;
  height: 72px;
  margin-bottom: 14px;
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.28);
}

.welcome-title {
  margin: 0 0 8px;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--amber-soft);
}

.welcome-sub {
  margin: 0 0 18px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 350px;
}

.quick-profiles-box {
  width: 100%;
  max-width: 360px;
  margin-bottom: 18px;
}

.quick-profiles-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 8px;
  font-weight: 700;
}

.quick-profiles-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.btn-quick-profile {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(253, 230, 138, 0.35);
  color: var(--amber-soft);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-profile:hover, .btn-quick-profile:active {
  background: var(--amber-gold);
  color: #120c02;
}

.profile-form-card {
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 16px;
  padding: 16px;
}

.profile-input {
  width: 100%;
  background: #0d0a14;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  padding: 12px 14px;
  border-radius: 11px;
  font-size: 1rem;
  margin-bottom: 10px;
  text-align: center;
}

.btn-primary-amber {
  width: 100%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #120c02;
  border: none;
  border-radius: 11px;
  padding: 13px 20px;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

/* ================= 2. HOME SCREEN (5 VISUAL CATEGORY BOXES) ================= */
.home-screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #0b0910;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.home-screen.hidden {
  display: none;
}

.home-header {
  padding: calc(env(safe-area-inset-top, 12px) + 8px) 16px 12px;
  background: rgba(16, 13, 24, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-brand {
  display: flex;
  flex-direction: column;
}

.home-brand-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--amber-soft);
}

.home-brand-sub {
  font-size: 0.75rem;
  color: #94a3b8;
}

.home-user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f1f5f9;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.category-cards-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 20px) + 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cat-box-card {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #171424;
  border: 2px solid rgba(241, 245, 249, 0.48);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition: transform 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.cat-box-card:hover {
  border-color: rgba(253, 230, 138, 0.85);
}

.cat-box-banner {
  position: relative;
  height: 184px;
  width: 100%;
  overflow: hidden;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.cat-box-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cat-box-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 6, 12, 0.12) 0%, rgba(12, 10, 18, 0.86) 100%);
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cat-box-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cat-box-title {
  margin: 0;
  font-size: 1.38rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-box-state-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--amber-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.cat-box-desc {
  margin: 6px 0 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #e2e8f0;
}

.cat-box-body {
  padding: 14px 16px 16px;
  background: #14111d;
}

.cat-active-filters-summary {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cat-active-filters-summary strong {
  color: #fde68a;
}

.cat-box-actions {
  display: flex;
  gap: 10px;
}

.btn-watch-cat {
  flex: 1;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #120c02;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.94rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-customize-cat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #f8fafc;
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

/* ================= 3. REELS PLAYER VIEW ================= */
.top-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: calc(env(safe-area-inset-top, 10px) + 4px) 10px 10px;
  background: linear-gradient(180deg, rgba(9, 7, 14, 0.92) 0%, rgba(9, 7, 14, 0.5) 72%, rgba(9, 7, 14, 0) 100%);
}

.top-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.btn-back-home {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.active-cat-header-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--amber-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-top-filter {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(253, 230, 138, 0.35);
  color: var(--amber-soft);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.select-filter-bar {
  display: flex;
  gap: 8px;
  width: 100%;
}

.select-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}

.hud-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(18, 15, 28, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(253, 230, 138, 0.42);
  color: #f8fafc;
  padding: 8px 28px 8px 11px;
  border-radius: 11px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23fde68a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.hud-select:focus {
  outline: none;
  border-color: #f59e0b;
}

.hud-select option,
.hud-select optgroup {
  background: #161220;
  color: #f8fafc;
  font-weight: 600;
}

/* Vertical Scroll-Snap Reels Feed Container */
.reels-scroller {
  position: absolute;
  inset: 0;
  z-index: 15;
  width: 100%;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: transparent;
}

.reels-scroller::-webkit-scrollbar {
  display: none;
}

.reel-card {
  position: relative;
  width: 100%;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: transparent;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-thumb-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
  background: #08070b;
  transition: opacity 0.22s ease;
  z-index: 6;
}

.reel-card.is-playing .reel-thumb-bg {
  opacity: 0;
  pointer-events: none;
}

.reel-player-mount {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

.reel-player-mount iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.reel-swipe-shield {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 64px;
  z-index: 12;
  background: transparent;
  cursor: pointer;
}

.reel-Info-footer {
  position: absolute;
  left: 12px;
  right: 74px;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 18px);
  z-index: 20;
  background: rgba(12, 10, 18, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  padding: 10px 13px;
}

.reel-badge-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.reel-cat-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.22);
  color: var(--amber-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.reel-channel-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.reel-title-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: #e2e8f0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Right-Side Floating Action Rail */
.side-rail {
  position: absolute;
  right: 10px;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 18px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rail-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(18, 15, 26, 0.84);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  font-size: 1.02rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: transform 0.14s ease, background 0.14s ease;
}

.rail-btn:active {
  transform: scale(0.92);
}

.rail-btn.liked-active {
  background: rgba(225, 29, 72, 0.32);
  border-color: #fb7185;
  color: #fda4af;
}

.rail-btn.active-amber {
  background: rgba(245, 158, 11, 0.28);
  border-color: var(--amber-soft);
  color: var(--amber-soft);
}

.rail-btn span.rail-lbl {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ================= 4. 3-TIER TOPIC & SUB-FILTER DRAWER MODAL ================= */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 75;
  background: rgba(5, 4, 8, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.drawer-backdrop.open {
  display: flex;
}

.drawer-sheet {
  width: 100%;
  max-height: 88dvh;
  background: #161220;
  border-top: 1px solid rgba(253, 230, 138, 0.28);
  border-radius: 22px 22px 0 0;
  padding: 18px 16px 26px;
  overflow-y: auto;
  color: var(--text-main);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.12rem;
  color: var(--amber-soft);
}

.btn-close-drawer {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.topic-group-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 13px;
  margin-bottom: 11px;
}

.topic-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.topic-group-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fde68a;
}

.btn-topic-toggle-all {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

.subtags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.subtag-checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(12, 10, 18, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.subtag-checkbox-pill.checked {
  background: rgba(245, 158, 11, 0.24);
  border-color: #f59e0b;
  color: #fff;
}

/* Feedback Toast (Dislike & Block Channel Option) */
.feedback-toast {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 92px);
  z-index: 65;
  background: rgba(18, 14, 24, 0.95);
  border: 1px solid rgba(253, 230, 138, 0.35);
  border-radius: 13px;
  padding: 10px 13px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65);
}

.feedback-toast.visible {
  display: flex;
}

.btn-toast-action {
  background: rgba(239, 68, 68, 0.22);
  border: 1px solid #f87171;
  color: #fecaca;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
