/* ===================================================
   PlayIDTV — Premium Dark Streaming UI
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ======= CSS VARIABLES ======= */
:root {
  --bg-base:         #0a0a0f;
  --bg-card:         #12121a;
  --bg-card-hover:   #1a1a28;
  --bg-modal:        #111119;
  --bg-glass:        rgba(255,255,255,0.04);
  --bg-glass-hover:  rgba(255,255,255,0.08);

  --accent-primary:  #e50914;
  --accent-secondary:#ff4d5a;
  --accent-gold:     #ffd700;
  --accent-pink:     #ff4fa3;

  --text-primary:    #f0f0f8;
  --text-secondary:  #9090aa;
  --text-muted:      #606080;

  --border-subtle:   rgba(255,255,255,0.06);
  --border-glass:    rgba(255,255,255,0.1);

  --gradient-hero:   linear-gradient(135deg, #1a0010 0%, #0d001a 50%, #000d1a 100%);
  --gradient-card:   linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.95) 100%);
  --gradient-accent: linear-gradient(135deg, #e50914, #ff4d5a);

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;

  --shadow-card: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px rgba(229,9,20,0.35);

  --header-h:    calc(70px + env(safe-area-inset-top, 0px));
  --transition:  all 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ======= RESET ======= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ======= SVG ICONS ======= */
.svg-icon {
  width: 1.2em;
  height: 1.2em;
  fill: currentColor;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -1px;
  flex-shrink: 0;
}

/* ======= SCROLLBAR ======= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #333348; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a6a; }

/* ======= HEADER ======= */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 100;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
}
#site-header.scrolled {
  background: rgba(10,10,15,0.97);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--gradient-accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-glow);
}
.logo-icon .svg-icon {
  width: 20px;
  height: 20px;
}
.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #fff 0%, #ffaabb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: var(--transition);
  border: 1px solid transparent;
}
.nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}
.nav-tab.active {
  color: #fff;
  background: var(--gradient-accent);
  border-color: rgba(229,9,20,0.3);
  box-shadow: 0 4px 12px rgba(229,9,20,0.3);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  padding: 8px 36px 8px 38px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  width: 220px;
  transition: var(--transition);
  outline: none;
}
.search-input:focus {
  background: var(--bg-glass-hover);
  border-color: var(--accent-primary);
  width: 280px;
  box-shadow: 0 0 0 3px rgba(229,9,20,0.15);
}
.search-input::placeholder { color: var(--text-muted); }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  opacity: 0.6;
  pointer-events: none;
  fill: currentColor;
  color: var(--text-secondary);
}
/* Clear (x) button inside search bar */
.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--text-muted);
  color: var(--bg-base);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}
.search-clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.search-clear-btn:hover {
  background: var(--accent-primary);
  transform: translateY(-50%) scale(1.15);
}
.btn-source {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-source:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-glass);
}

/* ======= HERO SECTION ======= */
#hero-section {
  position: relative;
  height: 80vh;
  min-height: 500px;
  max-height: 700px;
  overflow: hidden;
  margin-top: var(--header-h);
}
.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  transform: scale(1.05);
  transition: background-image 0.8s ease, transform 12s linear;
  filter: brightness(0.7);
}
.hero-bg.zooming { transform: scale(1.12); }
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(10,10,15,0.95) 0%,
    rgba(10,10,15,0.7) 40%,
    rgba(10,10,15,0.2) 70%,
    transparent 100%
  ),
  linear-gradient(
    to top,
    rgba(10,10,15,1) 0%,
    transparent 50%
  );
}
.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 48px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 700px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gradient-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
  width: fit-content;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}
.hero-title {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 14px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.8);
}
.hero-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-play {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--gradient-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: var(--transition);
  box-shadow: var(--shadow-glow);
  font-family: inherit;
}
.btn-play:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 32px rgba(229,9,20,0.5);
}
.btn-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.15);
  transition: var(--transition);
  font-family: inherit;
}
.btn-info:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

/* ======= MAIN ======= */
#main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ======= SOURCE PANEL ======= */
/* ======= SOURCE MODAL ======= */
.source-modal-content {
  padding: 30px;
}
.source-modal-header-section {
  margin-bottom: 20px;
}
.source-modal-header-section h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px 0;
}
.source-modal-header-section h3 .svg-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-primary);
}
.source-modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.source-search-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}
.source-search-input {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  padding: 10px 16px 10px 42px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: var(--transition);
  outline: none;
}
.source-search-input:focus {
  background: var(--bg-glass-hover);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(229,9,20,0.15);
}
.source-search-input::placeholder {
  color: var(--text-muted);
}
.source-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.6;
  pointer-events: none;
  color: var(--text-secondary);
}
.source-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: var(--transition);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.source-item img {
  width: 36px; height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #12121a;
}
.source-item-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}
.source-item-icon-wrap .svg-icon {
  width: 20px;
  height: 20px;
}
.source-item.active .source-item-icon-wrap {
  color: var(--accent-secondary);
  background: rgba(229,9,20,0.12);
}
.source-item:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(229,9,20,0.3);
}
.source-item.active {
  background: rgba(229,9,20,0.12);
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(229,9,20,0.15);
}
.source-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.source-file {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.source-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.source-badge.m3u {
  background: rgba(0, 172, 193, 0.15);
  color: #00e5ff;
  border: 1px solid rgba(0, 172, 193, 0.3);
}
.source-badge.json {
  background: rgba(229, 9, 20, 0.15);
  color: var(--accent-secondary);
  border: 1px solid rgba(229, 9, 20, 0.3);
}

/* ======= GROUP FILTER ======= */
.group-filter {
  margin-bottom: 28px;
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: linear-gradient(to bottom, var(--bg-base) 80%, transparent);
  padding-top: 10px;
  padding-bottom: 12px;
}
.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  transition: var(--transition);
  font-family: inherit;
  cursor: pointer;
}
.filter-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-glass);
  background: var(--bg-card-hover);
}
.filter-chip.active {
  background: var(--gradient-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(229,9,20,0.3);
}

/* ======= SECTION HEADER ======= */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  scroll-margin-top: 90px;
}
.section-header:focus {
  outline: none;
}
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.video-count {
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
}

/* ======= VIDEO GRID ======= */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

/* ======= VIDEO CARD ======= */
.video-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-subtle);
  animation: fadeInUp 0.4s ease both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.video-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(229,9,20,0.3);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(229,9,20,0.15);
}

.card-thumb {
  position: relative;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: #1a1a28;
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.video-card:hover .card-thumb img {
  transform: scale(1.1);
}
.card-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}
.video-card:hover .card-play-overlay { opacity: 1; }
.card-play-btn {
  width: 52px; height: 52px;
  background: var(--gradient-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 20px rgba(229,9,20,0.5);
  transform: scale(0.8);
  transition: var(--transition);
}
@media (hover: hover) {
  .video-card:hover .card-play-btn { transform: scale(1); }
}
.card-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  z-index: 3;
}
.card-badge.new {
  background: linear-gradient(135deg, #00c853, #00e676);
}

/* Premium 'NEW / มาใหม่' Badge */
.card-badge-new {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #ff1744 0%, #d50000 100%);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 2.5px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(229, 9, 20, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.25);
  z-index: 4;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  line-height: 1.2;
}

.card-badge-new::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

/* When both NEW badge and Code badge exist, offset code badge */
.card-badge-new + .card-badge {
  left: 64px;
}

.related-thumb .card-badge-new {
  top: 4px;
  left: 4px;
  font-size: 9px;
  padding: 1.5px 5px;
  gap: 2.5px;
}
.related-thumb .card-badge-new::before {
  width: 4px;
  height: 4px;
}

.card-duration {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 3;
}

/* ── Source Badge (Global Search) ─────────────────── */
.source-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  z-index: 5;
  letter-spacing: 0.3px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.source-heedeng {
  background: rgba(34, 197, 94, 0.85);
  color: #fff;
}
.source-lovehee {
  background: rgba(236, 72, 153, 0.85);
  color: #fff;
}
.source-homhee {
  background: rgba(139, 92, 246, 0.85);
  color: #fff;
}
.source-warpav {
  background: rgba(234, 179, 8, 0.88);
  color: #1a1000;
}
.source-yesdi {
  background: rgba(14, 165, 233, 0.90);
  color: #fff;
}
.source-taghee {
  background: rgba(249, 115, 22, 0.90);
  color: #fff;
}

/* Hover Preview Video Style */
.card-preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 2;
}

.card-preview-video.loaded {
  opacity: 1;
}

/* Hide play overlay when preview is actively playing */
.video-card.preview-active .card-play-overlay {
  opacity: 0 !important;
  visibility: hidden;
}

.card-body {
  padding: 12px 14px;
}
.card-code {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-group {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 2px 8px;
  border-radius: 4px;
  max-width: 65%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}
.card-group:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.card-group:active {
  transform: scale(0.95);
}
.card-hd {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ======= LOAD MORE ======= */
.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}
.btn-load-more {
  padding: 14px 48px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  transition: var(--transition);
  font-family: inherit;
}
.btn-load-more:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 4px 16px rgba(229,9,20,0.2);
}
.btn-load-more:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ======= SEARCH HIGHLIGHT ======= */
/* Applied by highlightText() to matched query tokens in card titles */
mark.search-highlight {
  background: transparent;
  color: var(--accent-secondary);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

/* Empty state: clear search button */
.btn-empty-clear {
  margin-top: 16px;
  padding: 10px 28px;
  background: var(--gradient-accent);
  border-radius: 99px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(229,9,20,0.3);
}
.btn-empty-clear:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(229,9,20,0.45);
}

/* ======= MODAL ======= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  padding-top: calc(100px + env(safe-area-inset-top, 0px));
  backdrop-filter: blur(8px);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
.modal-container {
  background: var(--bg-modal);
  border-radius: var(--radius-xl);
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-glass);
  position: relative;
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 10;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--accent-primary); transform: scale(1.1); }

/* Video Modal Close Button (Fades out when controls hide) */
#modal-close-btn {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.35s ease, transform 0.35s ease, background 0.2s ease;
}
.player-wrap.controls-visible #modal-close-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#modal-close-btn:hover {
  background: var(--accent-primary);
  transform: scale(1.1) translateY(0);
}
.player-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  cursor: none;
}
.player-wrap.controls-visible { cursor: default; }
#video-player {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
#iframe-player {
  width: 100%; height: 100%;
  border: none;
  display: none;
  background: #000;
}

/* ── Embed Mode (for iframe player) ── */
.player-wrap.embed-mode {
  cursor: default !important;
}

/* ── Pseudo Fullscreen (iOS Safari & Fallback) ── */
.player-wrap.pseudo-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  z-index: 999999 !important;
  background: #000 !important;
  margin: 0 !important;
  padding: 0 !important;
}
.player-wrap.pseudo-fullscreen #video-player,
.player-wrap.pseudo-fullscreen #iframe-player {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: contain !important;
}
body.in-pseudo-fullscreen {
  overflow: hidden !important;
}
.player-wrap.embed-mode #iframe-player {
  display: block !important;
}
.player-wrap.embed-mode #video-player {
  display: none !important;
}
.player-wrap.embed-mode .player-controls,
.player-wrap.embed-mode .gesture-zone,
.player-wrap.embed-mode .skip-overlay,
.player-wrap.embed-mode .swipe-indicator,
.player-wrap.embed-mode .seek-scrub-overlay,
.player-wrap.embed-mode .speed-boost-overlay,
.player-wrap.embed-mode .player-loading {
  display: none !important;
}

/* ── Center click zone ── */
.player-center-click {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

/* ── Ripple on play/pause ── */
.player-ripple {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}
.player-ripple.animate {
  animation: ripplePop 0.5s ease-out forwards;
}
@keyframes ripplePop {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: 0.9; }
  100% { transform: translate(-50%,-50%) scale(2.5); opacity: 0; }
}

/* ── Controls overlay ── */
.player-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 3;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 70%, transparent 100%);
  padding: 0 0 12px;
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 0;
  transform: translateY(8px);
}
.player-wrap.controls-visible .player-controls {
  opacity: 1;
  transform: translateY(0);
}

/* ── Progress bar ── */
.player-progress-wrap {
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  cursor: pointer;
  margin-bottom: 2px;
  touch-action: none;
  z-index: 5;
}
.player-progress-track,
.player-buffered,
.player-progress-fill {
  position: absolute;
  left: 16px;
  height: 5px;
  border-radius: 3px;
  pointer-events: none;
  transition: height 0.15s ease;
}
.player-progress-track {
  background: rgba(255, 255, 255, 0.2);
  right: 16px;
}
.player-buffered {
  background: rgba(255, 255, 255, 0.45);
  width: 0%;
  z-index: 1;
}
.player-progress-fill {
  background: var(--gradient-accent);
  box-shadow: 0 0 8px rgba(229, 9, 20, 0.6);
  width: 0%;
  z-index: 2;
}
.player-progress-thumb {
  position: absolute;
  left: 16px;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--accent-primary);
  border-radius: 50%;
  transform: translateX(-50%) scale(1);
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 0 6px rgba(0,0,0,0.8), 0 0 8px rgba(229, 9, 20, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-left: 0px;
}
.player-progress-wrap:hover .player-progress-thumb,
.player-progress-wrap:active .player-progress-thumb,
.player-progress-wrap.scrubbing .player-progress-thumb {
  transform: translateX(-50%) scale(1.4);
  box-shadow: 0 0 12px rgba(229, 9, 20, 0.9), 0 2px 8px rgba(0,0,0,0.8);
}
.player-progress-wrap:hover .player-progress-track,
.player-progress-wrap:hover .player-buffered,
.player-progress-wrap:hover .player-progress-fill,
.player-progress-wrap.scrubbing .player-progress-track,
.player-progress-wrap.scrubbing .player-buffered,
.player-progress-wrap.scrubbing .player-progress-fill {
  height: 8px;
}
.player-preview-video-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  visibility: hidden;
}

/* ── Floating Seek Thumbnail Preview Card above seekbar ── */
.player-preview-card {
  position: absolute;
  bottom: 42px;
  left: 16px;
  transform: translate(-50%, 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.15s;
  z-index: 25;
}
.player-preview-card.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
@media (hover: hover) and (pointer: fine) {
  .player-progress-wrap:hover .player-preview-card {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
  }
}
.player-preview-media {
  position: relative;
  width: 160px;
  height: 90px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.player-preview-poster,
.player-preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.player-preview-poster {
  z-index: 1;
  filter: brightness(0.9);
  background: #111;
}
.player-preview-canvas {
  z-index: 2;
  transition: opacity 0.15s ease;
}
.player-preview-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin-clockwise 0.8s linear infinite;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.player-preview-card.loading .player-preview-spinner {
  opacity: 1;
}
.player-preview-time {
  margin-top: 6px;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .player-preview-media {
    width: 130px;
    height: 74px;
  }
}

.player-progress-tooltip {
  display: none !important;
}
/* invisible range input on top */
.player-seek {
  position: absolute;
  inset: 0;
  width: calc(100% - 32px);
  left: 16px;
  opacity: 0;
  cursor: pointer;
  height: 100%;
  margin: 0;
  z-index: 6;
  touch-action: none;
}

/* ── Bottom bar ── */
.player-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  gap: 4px;
}
.player-left-controls,
.player-right-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── Player buttons ── */
.player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: rgba(255,255,255,0.9);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, color 0.2s;
  flex-shrink: 0;
}
.player-btn .svg-icon {
  width: 22px; height: 22px;
  fill: currentColor;
}
.player-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  transform: scale(1.1);
}
.player-btn:active {
  transform: scale(0.95);
  background: rgba(255,255,255,0.2);
}

/* ── Volume ── */
.player-volume-wrap {
  display: flex;
  align-items: center;
  gap: 0;
}
.player-vol-slider-wrap {
  width: 0;
  overflow: hidden;
  transition: width 0.25s ease;
}
.player-volume-wrap:hover .player-vol-slider-wrap,
.player-volume-wrap:focus-within .player-vol-slider-wrap {
  width: 72px;
}
.player-volume {
  -webkit-appearance: none;
  appearance: none;
  width: 66px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #e50914 0%, #e50914 var(--vol, 100%), rgba(255,255,255,0.25) var(--vol, 100%));
  outline: none;
  cursor: pointer;
  margin: 0 4px;
}
.player-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.player-volume::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}

/* ── Time display ── */
.player-time {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  font-family: 'Inter', monospace;
  letter-spacing: 0.3px;
  padding: 0 6px;
  user-select: none;
}
.player-loading {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 16, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--text-primary);
  z-index: 10;
  transition: opacity 0.3s ease;
}
.player-loading.show { display: flex; }

/* Premium Glowing Dual-Ring Spinner */
.spinner-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner-outer {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top-color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin-clockwise 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  filter: drop-shadow(0 0 8px var(--accent-primary));
}
.spinner-inner {
  position: absolute;
  width: 70%;
  height: 70%;
  border: 3px solid transparent;
  border-left-color: rgba(255, 255, 255, 0.7);
  border-right-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spin-counter-clockwise 1s linear infinite;
}
@keyframes spin-clockwise {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes spin-counter-clockwise {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

.player-loading p {
  font-family: 'Inter', 'Noto Sans Thai', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  animation: pulse-text 1.5s ease-in-out infinite;
  margin: 0;
}
@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ======= GESTURE ZONES ======= */
.gesture-zone {
  position: absolute;
  top: 0;
  bottom: 74px; /* Ample clearance above the bottom progress bar and controls */
  z-index: 2;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
#gz-left   { left: 0;   width: 28%; }
#gz-center { left: 28%; width: 44%; }
#gz-right  { left: 72%; width: 28%; }

/* ======= SKIP OVERLAY (YouTube double-tap) ======= */
.skip-overlay {
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.skip-overlay.active { opacity: 1; }
.skip-overlay-left  { left: 0; border-radius: 0 100% 100% 0 / 0 50% 50% 0; background: rgba(255,255,255,0.08); }
.skip-overlay-right { right: 0; border-radius: 100% 0 0 100% / 50% 0 0 50%; background: rgba(255,255,255,0.08); }

.skip-rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.skip-ring {
  position: absolute;
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  opacity: 0;
}
.skip-overlay.active .skip-ring:nth-child(1) { animation: skipRing 0.6s 0.00s ease-out forwards; }
.skip-overlay.active .skip-ring:nth-child(2) { animation: skipRing 0.6s 0.12s ease-out forwards; }
.skip-overlay.active .skip-ring:nth-child(3) { animation: skipRing 0.6s 0.24s ease-out forwards; }
@keyframes skipRing {
  0%   { opacity: 0.8; transform: scale(0.4); }
  100% { opacity: 0;   transform: scale(1.8); }
}
.skip-label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  margin-top: 52px;
}
.skip-label .svg-icon { width: 18px; height: 18px; fill: #fff; }

/* ======= SWIPE INDICATOR (vol / brightness) ======= */
.swipe-indicator {
  position: absolute;
  top: 50%; right: 24px;
  transform: translateY(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border-radius: 24px;
  padding: 14px 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  min-width: 44px;
}
.swipe-indicator.show { opacity: 1; }
.swipe-indicator.left-side { right: auto; left: 24px; }
.swipe-ind-icon .svg-icon { width: 20px; height: 20px; fill: #fff; }
.swipe-ind-bar-track {
  width: 4px;
  height: 100px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.swipe-ind-bar-fill {
  width: 100%;
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 2px;
  transform-origin: bottom;
  transition: transform 0.1s;
}
.swipe-ind-label {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

/* ======= SEEK SCRUB OVERLAY ======= */
.seek-scrub-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 8;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  min-width: 190px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.7);
}
.seek-scrub-overlay.show { opacity: 1; }
.seek-scrub-preview {
  width: 150px;
  height: 84px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  position: relative;
  margin-bottom: 4px;
}
.seek-scrub-poster,
.seek-scrub-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.seek-scrub-poster {
  z-index: 1;
  filter: brightness(0.85);
  background: #111;
}
.seek-scrub-canvas {
  z-index: 2;
}
.seek-scrub-delta {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}
.seek-scrub-pos {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}
.seek-scrub-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.seek-scrub-bar-fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 2px;
  transition: width 0.05s;
}

/* ======= SPEED BOOST OVERLAY ======= */
.speed-boost-overlay {
  position: absolute;
  top: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  border-radius: 99px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
}
.speed-boost-overlay.show { opacity: 1; }
.speed-boost-overlay .svg-icon { width: 18px; height: 18px; fill: #ffe082; }

/* ======= LOCK SCREEN OVERLAY ======= */
.lock-screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  align-items: center;
  justify-content: center;
}
.lock-screen-overlay.active { display: flex; }
.lock-unlock-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 99px;
  padding: 12px 24px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  opacity: 0;
  transition: opacity 0.5s;
}
.lock-screen-overlay.active .lock-unlock-btn { opacity: 1; }
.lock-unlock-btn:hover { background: rgba(229,9,20,0.5); transform: scale(1.05); }
.lock-unlock-btn .svg-icon { width: 20px; height: 20px; fill: #fff; }

/* ======= SPEED BUTTON ======= */
.player-btn-speed {
  width: auto !important;
  padding: 0 10px;
  border-radius: 6px !important;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.9) !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
}
.player-btn-speed:hover { background: rgba(229,9,20,0.3) !important; border-color: var(--accent-primary) !important; }

.player-speed-wrap-btn {
  position: relative;
}
.player-speed-menu {
  position: absolute;
  bottom: 48px;
  right: 0;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 6px 0;
  width: 130px;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
}
.player-speed-menu.show {
  display: flex;
}
.speed-menu-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}
.speed-menu-item {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.speed-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.speed-menu-item.active {
  color: var(--accent-primary);
  font-weight: 700;
  background: rgba(229, 9, 20, 0.1);
}

/* ======= QUALITY SELECTOR MENU ======= */
.player-quality-wrap-btn {
  position: relative;
  display: flex;
  align-items: center;
}
.player-btn-quality {
  font-size: 11px;
  font-weight: 700;
  min-width: 42px;
  height: 30px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.3px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  transition: all 0.2s ease;
}
.player-btn-quality:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.player-quality-menu {
  position: absolute;
  bottom: 48px;
  right: 0;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 6px 0;
  min-width: 160px;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
}
.player-quality-menu.show {
  display: flex;
}
.quality-menu-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}
.quality-menu-item {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quality-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.quality-menu-item.active {
  color: var(--accent-primary);
  font-weight: 700;
  background: rgba(229, 9, 20, 0.1);
}
.quality-badge-tag {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 6px;
}
.quality-menu-item.active .quality-badge-tag {
  background: var(--accent-primary);
  color: #fff;
}

/* ======= CENTER ACTION OVERLAY ======= */
.center-action-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.action-icon-wrap {
  width: 64px; height: 64px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transform: translate(0, 0) scale(0.6);
  pointer-events: none;
}
.action-icon-wrap.animate {
  animation: actionIconPop 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes actionIconPop {
  0%   { opacity: 0; transform: scale(0.6); }
  25%  { opacity: 0.9; transform: scale(1.15); }
  45%  { opacity: 0.9; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.4); }
}
.action-icon-wrap .svg-icon {
  width: 32px;
  height: 32px;
  fill: currentColor;
}


.modal-info {
  padding: 24px 28px 28px;
}
.modal-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.badge-hd { background: rgba(255,215,0,0.15); color: var(--accent-gold); border: 1px solid rgba(255,215,0,0.3); }
.badge-free { background: rgba(0,200,83,0.15); color: #00e676; border: 1px solid rgba(0,200,83,0.3); }
.modal-group-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 3px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  user-select: none;
}
.modal-group-tag .modal-group-icon {
  display: inline-flex;
  align-items: center;
}
.modal-group-tag .modal-group-icon .svg-icon {
  width: 13px;
  height: 13px;
  fill: #ff3366;
}
.modal-group-tag .modal-group-arrow {
  font-size: 11px;
  opacity: 0.6;
  transition: transform 0.2s ease;
}
.modal-group-tag:hover {
  background: rgba(255, 51, 102, 0.18);
  border-color: rgba(255, 51, 102, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(255, 51, 102, 0.25);
}
.modal-group-tag:hover .modal-group-arrow {
  opacity: 1;
  transform: translateX(2px);
}
.modal-group-tag:active {
  transform: scale(0.96);
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
}
.modal-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.modal-person-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.person-tag-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.person-tag-label .svg-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 99px;
  color: #c7d2fe;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  user-select: none;
}
.person-chip .person-chip-icon .svg-icon {
  width: 12px;
  height: 12px;
  fill: #818cf8;
  transition: transform 0.2s ease;
}
.person-chip:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(168, 85, 247, 0.35));
  border-color: rgba(168, 85, 247, 0.6);
  color: #ffffff;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.person-chip:hover .person-chip-icon .svg-icon {
  fill: #ffffff;
  transform: scale(1.15);
}
.person-chip:active {
  transform: scale(0.96);
}
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  align-items: center;
}
.btn-modal-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  font-family: inherit;
  cursor: pointer;
  user-select: none;
}

/* PRIMARY HIGHLIGHT: Next Button (ถัดไป) */
#btn-next.btn-modal-action {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 10px 20px;
  box-shadow: 0 4px 12px rgba(229, 9, 20, 0.35);
}
#btn-next.btn-modal-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(229, 9, 20, 0.5);
  filter: brightness(1.1);
  color: #fff;
}
#btn-next.btn-modal-action:active {
  transform: translateY(0);
}

/* SECONDARY NAV: Prev Button (ก่อนหน้า) */
#btn-prev.btn-modal-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}
#btn-prev.btn-modal-action:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}
#btn-prev.btn-modal-action:active {
  transform: translateY(0);
}

/* FAVORITE BUTTON: Custom active pink states */
#btn-modal-fav.btn-modal-action {
  border-color: rgba(255, 79, 163, 0.15);
}
#btn-modal-fav.btn-modal-action:hover {
  color: var(--accent-pink);
  border-color: rgba(255, 79, 163, 0.4);
  background: rgba(255, 79, 163, 0.04);
}
#btn-modal-fav.btn-modal-action.active {
  background: rgba(255, 79, 163, 0.12);
  border-color: rgba(255, 79, 163, 0.4);
  color: var(--accent-pink);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(255, 79, 163, 0.15);
}
#btn-modal-fav.btn-modal-action.active:hover {
  background: rgba(255, 79, 163, 0.18);
  border-color: rgba(255, 79, 163, 0.6);
}

/* UTILITY & CLOSE BUTTONS (Back, Copy Link) */
.btn-modal-action:not(#btn-next):not(#btn-prev):not(#btn-modal-fav):hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}


/* Related */
.related-videos h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.related-card {
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
}
.related-card:hover {
  transform: translateY(-3px);
  border-color: rgba(229,9,20,0.3);
}
.related-thumb {
  position: relative;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: #1a1a28;
}
.related-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.related-card:hover .related-thumb img { transform: scale(1.08); }
.related-title {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ======= TOAST ======= */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-glass);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ======= EMPTY STATE ======= */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state .svg-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--text-muted);
  opacity: 0.7;
}
.empty-state p { font-size: 16px; }

/* ======= LOADING SKELETON ======= */
.skeleton {
  background: linear-gradient(90deg, #161624 25%, #222236 50%, #161624 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s infinite linear;
  border-radius: 4px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  animation: skeletonFadeIn 0.3s ease;
}
@keyframes skeletonFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.skeleton-thumb {
  aspect-ratio: 16/10;
  border-radius: 0;
}
.skeleton-body { padding: 16px; }
.skeleton-line {
  height: 12px;
  margin-bottom: 10px;
}
.skeleton-line.short { width: 40%; }

/* Hero Section CSS Loading Skeleton */
#hero-section.loading .hero-bg {
  background: linear-gradient(90deg, #0e0e16 25%, #1d1d2b 50%, #0e0e16 75%) !important;
  background-size: 200% 100% !important;
  animation: skeleton-shimmer 1.8s infinite linear !important;
}
#hero-section.loading .hero-overlay {
  background: rgba(0, 0, 0, 0.55) !important; /* Lighter overlay to show shimmer clearly */
}
#hero-section.loading .hero-badge {
  background: linear-gradient(90deg, #1c1c28 25%, #2a2a3e 50%, #1c1c28 75%) !important;
  background-size: 200% 100% !important;
  animation: skeleton-shimmer 1.8s infinite linear !important;
  color: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
#hero-section.loading .hero-badge svg,
#hero-section.loading .hero-badge span {
  visibility: hidden;
}
#hero-section.loading .hero-title {
  color: transparent !important;
  background: linear-gradient(90deg, #1c1c28 25%, #2a2a3e 50%, #1c1c28 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s infinite linear;
  border-radius: var(--radius-md, 8px);
  width: min(520px, 80%);
  height: 42px;
  margin-bottom: 16px;
  user-select: none;
}
#hero-section.loading .hero-desc {
  color: transparent !important;
  background: linear-gradient(90deg, #1c1c28 25%, #2a2a3e 50%, #1c1c28 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s infinite linear;
  border-radius: var(--radius-sm, 6px);
  width: min(420px, 60%);
  height: 20px;
  margin-bottom: 24px;
  user-select: none;
}
#hero-section.loading .hero-actions {
  pointer-events: none;
}
#hero-section.loading .btn-play,
#hero-section.loading .btn-info {
  color: transparent !important;
  background: linear-gradient(90deg, #1c1c28 25%, #2a2a3e 50%, #1c1c28 75%) !important;
  background-size: 200% 100% !important;
  animation: skeleton-shimmer 1.8s infinite linear !important;
  border: none !important;
  box-shadow: none !important;
  width: 120px;
  height: 40px;
}
#hero-section.loading .btn-play svg,
#hero-section.loading .btn-info svg {
  visibility: hidden;
}

/* ======= RESPONSIVE ======= */
@media (max-width: 900px) {
  .nav-tabs { display: none; }
  .header-actions {
    display: flex;
    align-items: center;
  }
  .header-actions .search-wrap {
    display: none;
  }
  .header-actions .btn-source {
    display: none;
  }
  .header-actions .btn-settings {
    display: inline-flex;
    padding: 6px 12px;
    font-size: 12px;
  }
  .hero-content { padding: 0 24px; max-width: 100%; }
  .header-inner {
    justify-content: space-between;
    padding: 0 16px;
    gap: 0;
  }
  .logo {
    transform: none;
    transition: transform 0.2s ease;
  }
}
@media (max-width: 640px) {
  #hero-section { height: 60vh; }
  .hero-title { font-size: 1.4rem; }
  .search-input { width: 140px; }
  .search-input:focus { width: 170px; }
  .btn-source span:last-child { display: none; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .modal-container { max-height: 95vh; border-radius: var(--radius-lg); }
  .modal-info { padding: 16px 18px 20px; }
  .modal-title { font-size: 16px; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }

  /* Mobile player controls adjustments */
  .player-bottom {
    padding: 0 4px;
    gap: 2px;
  }
  .player-left-controls,
  .player-right-controls {
    gap: 1px;
  }
  .player-btn {
    width: 34px;
    height: 34px;
  }
  .player-btn .svg-icon {
    width: 18px;
    height: 18px;
  }
  .player-time {
    font-size: 10px;
    margin-left: 2px;
    white-space: nowrap;
  }
  .player-volume-wrap {
    display: none;
  }
  #btn-pip {
    display: none;
  }
  .player-btn-quality {
    min-width: 34px;
    height: 28px;
    font-size: 10px;
    padding: 0 4px;
  }
  .player-btn-speed {
    min-width: 28px;
    height: 28px;
    font-size: 10px;
    padding: 0 3px;
  }
  #btn-fullscreen {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    color: #fff;
    flex-shrink: 0 !important;
    display: flex !important;
  }
}

@media (max-width: 420px) {
  #btn-skip-back,
  #btn-skip-fwd {
    display: none;
  }
  #btn-lock {
    display: none;
  }
}

/* ======= SCROLL PROGRESS BAR ======= */
.scroll-progress-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  z-index: 101;
}
.scroll-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--gradient-accent);
  box-shadow: 0 0 8px var(--accent-secondary);
  transition: width 0.1s ease-out;
}

/* ======= PAGINATION ======= */
.pagination-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.btn-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  user-select: none;
}
.btn-page:hover:not(.disabled):not(.active) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-glass);
  transform: translateY(-2px);
}
.btn-page.active {
  background: var(--gradient-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3);
  font-weight: 700;
}
.btn-page.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-page.dots {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}
.btn-page .svg-icon {
  width: 18px;
  height: 18px;
}

/* ======= APPLE-STYLE BOTTOM TAB BAR ======= */
:root {
  --tab-bar-h: 72px;
  --tab-bar-safe: env(safe-area-inset-bottom, 0px);
}

/* Reserve bottom space so content is not hidden behind tab bar */
body {
  padding-bottom: calc(var(--tab-bar-h) + var(--tab-bar-safe));
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--tab-bar-h) + var(--tab-bar-safe));
  padding-bottom: var(--tab-bar-safe);
  display: flex;
  align-items: stretch;
  background: rgba(10, 10, 15, 0.82);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  /* hide on very wide screens where desktop nav tabs are visible */
}

/* Tab bar items */
.tab-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px 6px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  outline: none;
}

.tab-bar-item:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* Icon container with background pill on active */
.tab-bar-icon-wrap {
  position: relative;
  width: 48px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  transition: background 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-bar-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-bar-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.25s ease, font-weight 0.15s ease;
  line-height: 1;
}

/* Active state - Apple pill + accent color */
.tab-bar-item.active {
  color: var(--accent-primary);
}

.tab-bar-item.active .tab-bar-icon-wrap {
  background: rgba(229, 9, 20, 0.15);
  transform: translateY(-1px);
}

.tab-bar-item.active .tab-bar-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 6px rgba(229, 9, 20, 0.6));
}

.tab-bar-item.active .tab-bar-label {
  font-weight: 700;
  color: var(--accent-primary);
}

/* Tap animation — spring bounce */
.tab-bar-item:active .tab-bar-icon-wrap {
  transform: scale(0.88) translateY(-1px);
}

/* Badge (notification dot / count) */
.tab-bar-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 1.5px solid var(--bg-base);
  animation: tab-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes tab-badge-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Search panel overlay (Top-anchored for full visibility above mobile keyboard) */
.tab-search-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 250;
  background: rgba(12, 12, 20, 0.98);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.2s ease;
  max-height: 80vh;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

.tab-search-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Row with input + close button */
.tab-search-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  flex-shrink: 0;
}

/* Input wrapper with icon */
.tab-search-panel-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.tab-search-panel-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.tab-search-panel-input {
  width: 100%;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  padding: 10px 38px 10px 42px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tab-search-panel-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.22);
  background: var(--bg-glass-hover);
}

.tab-search-panel-clear {
  position: absolute;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, color 0.2s;
}

.tab-search-panel-clear.visible {
  display: flex;
}

.tab-search-panel-clear:hover {
  background: rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
}

.tab-search-panel-close {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 99px;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: var(--transition);
  flex-shrink: 0;
  cursor: pointer;
  white-space: nowrap;
}

.tab-search-panel-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ======= SEARCH SUGGESTIONS (mobile) ======= */
.search-suggestions {
  overflow-y: auto;
  max-height: 50vh;
  padding: 6px 16px 14px;
  display: none;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 6px;
  -webkit-overflow-scrolling: touch;
}
.search-suggestions.visible {
  display: flex;
}

.search-recent-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-recent-clear {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.search-recent-clear:hover { background: rgba(255,77,90,0.1); }

.search-suggestion-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  fill: currentColor;
}
.search-suggestion-chip:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}


/* Categories sliding drawer from bottom */
.tab-categories-drawer {
  position: fixed;
  bottom: calc(var(--tab-bar-h) + var(--tab-bar-safe));
  left: 0;
  right: 0;
  z-index: 245;
  background: rgba(12, 12, 20, 0.97);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 0 20px;
  max-height: 60vh;
  overflow-y: auto;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.25s ease;
}

.tab-categories-drawer.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.tab-categories-drawer-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.tab-categories-drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.tab-category-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.18s;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.tab-category-row:hover {
  background: var(--bg-glass-hover);
}

.tab-category-row.active {
  color: var(--accent-primary);
}

.tab-category-row.active .tab-cat-check {
  opacity: 1;
}

.tab-cat-check {
  margin-left: auto;
  opacity: 0;
  color: var(--accent-primary);
  transition: opacity 0.15s;
}

.tab-category-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  margin-right: 8px;
}

/* Drawer backdrop */
.tab-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 240;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tab-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Hide tab bar inside fullscreen video */
.modal-open .tab-bar,
.modal-open .tab-search-panel,
.modal-open .tab-categories-drawer,
.modal-open .tab-drawer-backdrop {
  display: none;
}

/* On desktop (≥ 900px) where we already have nav-tabs, show tab bar only
   on mobile / narrow viewports */
@media (min-width: 900px) {
  .tab-bar {
    display: none;
  }
  .tab-search-panel,
  .tab-categories-drawer,
  .tab-drawer-backdrop {
    display: none;
  }
  body {
    padding-bottom: 0;
  }
}

/* On mobile screens, optimize tab bar proportions for 6 items */
@media (max-width: 480px) {
  .tab-bar-item { padding: 6px 1px 4px; }
  .tab-bar-icon { width: 20px; height: 20px; }
  .tab-bar-label { font-size: 9.5px; }
  .tab-bar-icon-wrap { width: 38px; height: 28px; }
}

/* On very small screens, make icons slightly smaller */
@media (max-width: 360px) {
  .tab-bar-item { padding: 4px 0 3px; }
  .tab-bar-icon { width: 18px; height: 18px; }
  .tab-bar-label { font-size: 8.5px; }
  .tab-bar-icon-wrap { width: 34px; height: 26px; }
}

/* ===================================================
   PlayIDTV — Favorites & Resume Playback Additions
   =================================================== */

/* Card Level Favorite Button */
.card-fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(10, 10, 15, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
}

.card-fav-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Show favorite button by default on mobile since there is no hover */
@media (max-width: 900px) {
  .card-fav-btn {
    opacity: 1;
  }
}

.video-card:hover .card-fav-btn {
  opacity: 1;
}

.card-fav-btn:hover {
  background: rgba(10, 10, 15, 0.85);
  transform: scale(1.12);
}

.card-fav-btn.active {
  color: var(--accent-primary);
  background: rgba(10, 10, 15, 0.75);
  border-color: rgba(229, 9, 20, 0.3);
  opacity: 1;
}

/* Modal Favorite Highlighted Active State */
#btn-modal-fav.active {
  color: var(--text-primary);
  border-color: var(--accent-primary);
  background: rgba(229, 9, 20, 0.15);
}

#btn-modal-fav.active svg {
  color: var(--accent-primary);
  fill: var(--accent-primary);
}

/* Player Resume Playback Prompt Overlay */
.player-resume-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%) scale(0.95);
  background: rgba(15, 15, 25, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 320px;
  width: calc(100% - 40px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-resume-prompt.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.player-resume-prompt .resume-text {
  font-family: inherit;
  color: var(--text-primary);
  font-size: 14px;
  text-align: center;
  line-height: 1.6;
}

.player-resume-prompt .resume-time {
  color: var(--accent-secondary);
  font-weight: 700;
  background: rgba(255, 77, 90, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  margin-left: 2px;
}

.player-resume-prompt .resume-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.player-resume-prompt .btn-resume-yes,
.player-resume-prompt .btn-resume-no {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.player-resume-prompt .btn-resume-yes {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3);
}

.player-resume-prompt .btn-resume-yes:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(229, 9, 20, 0.45);
}

.player-resume-prompt .btn-resume-no {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.player-resume-prompt .btn-resume-no:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

.player-resume-prompt .btn-resume-yes:active,
.player-resume-prompt .btn-resume-no:active {
  transform: scale(0.97);
}

/* ===== PWA INSTALL BANNER STYLES (iOS OPTIMIZED) ===== */
.pwa-install-banner {
  position: fixed;
  bottom: calc(var(--tab-bar-h) + var(--tab-bar-safe) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  width: calc(100% - 32px);
  max-width: 400px;
  background: rgba(18, 18, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}
.pwa-install-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.pwa-install-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.pwa-install-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.pwa-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
}
.pwa-install-text strong {
  font-weight: 600;
  font-size: 14.5px;
}
.pwa-install-text span {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}
.pwa-install-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.pwa-install-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}
.pwa-install-arrow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(18, 18, 26, 0.92);
}

@media (max-width: 480px) {
  .pwa-install-banner {
    bottom: calc(var(--tab-bar-h) + var(--tab-bar-safe) + 8px);
    width: calc(100% - 16px);
  }
}




/* ======= LAYOUT TOGGLE ======= */
.layout-toggle {
  display: flex;
  gap: 8px;
}
.layout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.layout-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.layout-btn.active {
  background: rgba(229,9,20,0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ======= VIDEO GRID LIST VIEW (1x1) ======= */
.video-grid.layout-list {
  grid-template-columns: 1fr !important;
}

/* ======= PREVIEW LOADING ANIMATION ======= */
.preview-loading .card-play-btn,
.preview-active .card-play-btn {
  opacity: 0 !important;
  transform: scale(0) !important;
  pointer-events: none;
}
.preview-loading .card-thumb::after,
.preview-loading .related-thumb::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.2);
  z-index: 15;
}
.preview-loading .card-thumb::before,
.preview-loading .related-thumb::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--accent-primary);
  z-index: 16;
  animation: loading-line 1.5s ease-out infinite;
}
/* ======= SORT & FILTER COMPONENT ======= */
.sort-filter-btn {
  position: relative;
  gap: 4px;
}
.sort-filter-btn.has-filter {
  border-color: var(--accent-primary) !important;
  color: var(--accent-primary) !important;
  background: rgba(229, 9, 20, 0.15) !important;
}
.sort-filter-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  border-radius: 99px;
  text-align: center;
  padding: 0 4px;
  box-shadow: 0 2px 6px rgba(229, 9, 20, 0.6);
  border: 1.5px solid var(--bg-base);
  animation: badgePop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes badgePop {
  0% { transform: scale(0); }
  80% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Sort & Filter Overlay Backdrop */
.sort-filter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sort-filter-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Sort & Filter Bottom Sheet Panel */
.sort-filter-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 540px;
  background: rgba(18, 18, 28, 0.98);
  border: 1px solid var(--border-glass);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  backdrop-filter: blur(35px);
  -webkit-backdrop-filter: blur(35px);
  z-index: 255;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}
.sort-filter-panel.open {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.sort-filter-header {
  padding: 12px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sort-filter-handle {
  width: 44px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.sort-filter-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sort-filter-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.sort-filter-title svg {
  color: var(--accent-primary);
}
.sort-filter-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.sort-filter-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.sort-filter-body {
  padding: 18px 20px 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sort-filter-body::-webkit-scrollbar {
  width: 5px;
}
.sort-filter-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.sf-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sf-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sf-section-title svg {
  color: var(--accent-secondary);
}

.sf-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  user-select: none;
}
.sf-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}
.sf-chip.active {
  background: rgba(229, 9, 20, 0.2);
  border-color: var(--accent-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(229, 9, 20, 0.3);
}

/* Toggle Switch Section */
.sf-toggle-section {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}
.sf-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sf-toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.sf-toggle-desc {
  font-size: 12px;
  color: var(--text-muted);
}
.sf-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}
.sf-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.sf-slider {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 34px;
  transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.sf-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.sf-switch input:checked + .sf-slider {
  background: var(--gradient-accent);
  border-color: var(--accent-primary);
}
.sf-switch input:checked + .sf-slider:before {
  transform: translateX(20px);
}

/* Bottom Sheet Actions */
.sort-filter-actions {
  display: flex;
  gap: 12px;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-subtle);
  background: rgba(14, 14, 22, 0.95);
  flex-shrink: 0;
}
.sf-btn-reset {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.sf-btn-reset:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.sf-btn-apply {
  flex: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--gradient-accent);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(229, 9, 20, 0.4);
}
.sf-btn-apply:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(229, 9, 20, 0.6);
}
.sf-btn-apply:active {
  transform: translateY(0);
}

.sf-chip svg {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  fill: currentColor;
  opacity: 0.85;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.sf-chip:hover svg {
  opacity: 1;
  transform: scale(1.1);
}
.sf-chip.active svg {
  opacity: 1;
  color: var(--accent-secondary);
}

@media (min-width: 768px) {
  .sort-filter-panel {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -45%);
    border-radius: 20px;
    border: 1px solid var(--border-glass);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  }
  .sort-filter-panel.open {
    transform: translate(-50%, -50%);
  }
  .sort-filter-handle {
    display: none;
  }
}

/* ======= PULL TO REFRESH ======= */
.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate3d(-50%, -120%, 0);
  z-index: 1050;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  transition: transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

.ptr-indicator.pulling {
  transition: none; /* Instant follow finger during touch drag */
}

.ptr-indicator.refreshing {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.ptr-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 14px;
  background: rgba(18, 18, 28, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(229, 9, 20, 0.2);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  user-select: none;
  white-space: nowrap;
}

.ptr-icon-wrap {
  width: 28px;
  height: 28px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(229, 9, 20, 0.15);
  border-radius: 50%;
  border: 1px solid rgba(229, 9, 20, 0.3);
  color: var(--accent-secondary);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.ptr-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.ptr-icon-arrow {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}

.ptr-icon-spinner {
  display: none;
  animation: ptr-spin 0.85s linear infinite;
  transform-origin: center;
}

.ptr-spinner-track {
  stroke: rgba(255, 255, 255, 0.15);
}

.ptr-spinner-head {
  stroke: var(--accent-secondary);
  stroke-dasharray: 45 65;
}

@keyframes ptr-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Threshold reached (ready to release) */
.ptr-indicator.ready .ptr-icon-wrap {
  background: var(--gradient-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 14px rgba(229, 9, 20, 0.6);
  transform: scale(1.08);
}

.ptr-indicator.ready .ptr-icon-arrow {
  transform: rotate(180deg);
}

.ptr-indicator.ready .ptr-content {
  border-color: rgba(229, 9, 20, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 24px rgba(229, 9, 20, 0.35);
}

/* Refreshing state */
.ptr-indicator.refreshing .ptr-icon-arrow {
  display: none;
}

.ptr-indicator.refreshing .ptr-icon-spinner {
  display: block;
}

.ptr-indicator.refreshing .ptr-icon-wrap {
  background: rgba(229, 9, 20, 0.2);
  border-color: rgba(229, 9, 20, 0.4);
  color: var(--accent-secondary);
}

.ptr-text {
  transition: color 0.2s ease;
}

.ptr-indicator.ready .ptr-text {
  color: #fff;
}

/* ======= APP VERSION UPDATE BANNER ======= */
.app-update-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 50%;
  transform: translate3d(-50%, -150%, 0);
  z-index: 1080;
  width: calc(100% - 32px);
  max-width: 520px;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

.app-update-banner.show {
  transform: translate3d(-50%, 0, 0);
  opacity: 1;
  pointer-events: auto;
}

.app-update-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(28, 14, 28, 0.95) 0%, rgba(16, 16, 26, 0.96) 100%);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 77, 90, 0.35);
  border-radius: 18px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.75), 0 0 24px rgba(229, 9, 20, 0.25);
  position: relative;
  overflow: hidden;
}

.app-update-inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #e50914, #ff4fa3, #ffd700, #e50914);
  background-size: 300% 100%;
  animation: updateGlowBar 3s ease infinite;
}

@keyframes updateGlowBar {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.app-update-icon-wrap {
  width: 44px;
  height: 44px;
  background: var(--gradient-accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 4px 16px rgba(229, 9, 20, 0.45);
}

.app-update-icon-wrap .app-update-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  position: relative;
  z-index: 2;
}

.app-update-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 18px;
  border: 2px solid rgba(255, 77, 90, 0.6);
  animation: updatePulseRing 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes updatePulseRing {
  0% { transform: scale(0.95); opacity: 0.8; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.3); opacity: 0; }
}

.app-update-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.app-update-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-update-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.app-update-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(229, 9, 20, 0.25);
  color: #ff6b78;
  border: 1px solid rgba(229, 9, 20, 0.4);
  padding: 1px 6px;
  border-radius: 6px;
  letter-spacing: 0.4px;
}

.app-update-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  white-space: normal;
}

.app-update-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.app-update-btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--gradient-accent);
  color: #fff;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(229, 9, 20, 0.4);
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}

.app-update-btn-refresh:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(229, 9, 20, 0.6);
}

.app-update-btn-refresh:active {
  transform: translateY(0);
}

.app-update-btn-refresh.loading .btn-spin-icon {
  animation: ptr-spin 0.8s linear infinite;
}

.app-update-btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.app-update-btn-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

@media (max-width: 480px) {
  .app-update-banner {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    width: calc(100% - 20px);
  }
  .app-update-inner {
    padding: 12px 14px;
    gap: 10px;
  }
  .app-update-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  .app-update-icon-wrap .app-update-icon {
    width: 18px;
    height: 18px;
  }
  .app-update-title {
    font-size: 13px;
  }
  .app-update-desc {
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .app-update-btn-refresh {
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* ======= SETTINGS BUTTON ======= */
.btn-settings {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.btn-settings:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: rgba(0, 242, 254, 0.4);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.15);
}

.btn-settings-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-settings-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  transition: transform 0.4s ease;
}

.btn-settings:hover .btn-settings-icon svg {
  transform: rotate(45deg);
  color: #00f2fe;
}

.btn-settings-badge {
  font-size: 11px;
  background: linear-gradient(135deg, #00f2fe, #4facfe);
  color: #000;
  border-radius: 99px;
  padding: 1px 5px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.85; }
}

/* ======= SETTINGS MODAL CONTAINER ======= */
.settings-modal-container {
  max-width: 680px;
  max-height: 88vh;
  background: rgba(18, 18, 30, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 242, 254, 0.12);
  overflow-y: auto;
  padding: 28px 24px;
}

.settings-modal-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.settings-header-section {
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 16px;
}

.settings-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.25);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #00f2fe;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.settings-pulse-dot {
  width: 7px;
  height: 7px;
  background: #00f2fe;
  border-radius: 50%;
  box-shadow: 0 0 8px #00f2fe;
  animation: pulseGlow 1.5s infinite;
}

.settings-modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px 0;
}

.settings-modal-title .title-icon {
  width: 26px;
  height: 26px;
  fill: #00f2fe;
}

.settings-modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* Status Card */
.settings-status-card {
  background: linear-gradient(145deg, rgba(26, 26, 44, 0.85), rgba(15, 15, 26, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.status-indicator-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-glow-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 10px #10b981;
}

.status-text-live {
  font-size: 13px;
  font-weight: 600;
  color: #34d399;
}

.status-env-pill {
  font-size: 11px;
  font-weight: 600;
  background: rgba(246, 130, 31, 0.15);
  color: #f6821f;
  border: 1px solid rgba(246, 130, 31, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
}

.status-grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.metric-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 14px;
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.metric-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.metric-val.primary {
  color: #00f2fe;
}

.metric-val.accent {
  color: #a78bfa;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Action Box */
.settings-action-box {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(124, 58, 237, 0.15));
  border: 1px solid rgba(0, 242, 254, 0.3);
  border-radius: 18px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.action-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.action-box-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.action-box-title svg {
  fill: #facc15;
}

.action-box-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(250, 204, 21, 0.2);
  color: #fde047;
  border: 1px solid rgba(250, 204, 21, 0.4);
}

.action-box-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
  margin: 0 0 16px 0;
}

.action-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.scan-depth-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.scan-select {
  background: rgba(15, 15, 26, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.btn-trigger-update {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  color: #0a0a14;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 242, 254, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-trigger-update:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(0, 242, 254, 0.5);
  background: linear-gradient(135deg, #38f9d7 0%, #43e97b 100%);
}

.btn-trigger-update:active {
  transform: translateY(0);
}

.btn-trigger-update:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-trigger-spinner .btn-spin-icon {
  animation: spin 1s infinite linear;
}

/* PAT Details */
.github-pat-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.pat-summary {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.pat-summary:hover {
  color: #00f2fe;
}

.pat-input-wrap {
  margin-top: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
}

.pat-help {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.pat-field-row {
  display: flex;
  gap: 8px;
}

.pat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  font-family: monospace;
}

.btn-pat-save {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pat-save:hover {
  background: rgba(255, 255, 255, 0.2);
}

.pat-status {
  font-size: 11px;
  margin-top: 6px;
  color: #34d399;
}

/* Sub Sections */
.section-sub-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px 0;
}

.section-sub-heading svg {
  fill: #a78bfa;
}

.sources-breakdown-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.source-breakdown-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.source-breakdown-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.source-bc-info {
  display: flex;
  flex-direction: column;
}

.source-bc-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.source-bc-count {
  font-size: 11px;
  color: var(--text-secondary);
}

.source-bc-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Maintenance Grid */
.maintenance-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.btn-maint, .btn-maint-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-maint:hover, .btn-maint-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

@media (max-width: 600px) {
  .btn-settings {
    padding: 6px 10px;
    gap: 6px;
    font-size: 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
  }
  .btn-settings span.btn-settings-label {
    display: inline;
    font-size: 12px;
  }
  .settings-modal-container {
    padding: 20px 16px;
    border-radius: 20px;
    width: 95%;
    max-height: 88vh;
  }
  .status-grid-metrics {
    grid-template-columns: 1fr;
  }
  .action-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-trigger-update {
    width: 100%;
  }
  .sources-breakdown-list {
    grid-template-columns: 1fr;
  }
}


