/* ==========================================================================
   Twilight Global Product Quality & UX Engine v3.4 (Zero-Emoji Hardware UI)
   - Top Laser Progress Bar
   - Zero-CLS First-Paint Glass Skeleton Shell
   - Video Player HUD (2.0x Hold, Double-Tap Seek & Center Play/Pause, PiP, Auto-Resume)
   - Universal Spotlight Search & Watch-History Command Palette (#tw-spotlight-overlay)
   - Late-Night OLED Eye-Care Dimmer Mode & Sleep Timer
   - One-Tap Anti-Loss Permalink Share & Floating Ecosystem Bento Matrix
   - Cross-Portal Continue Watching Capsule
   ========================================================================== */

/* OLED Late-Night Eye-Care Mode */
html.tw-night-dim {
  filter: brightness(0.82) contrast(1.03) sepia(0.06);
  transition: filter 0.25s ease;
}

/* 1. Top Laser Progress Bar */
#tw-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, #6366F1 0%, #EC4899 50%, #F59E0B 100%);
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.65);
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

/* 2. Instant First-Paint App Shell Skeleton (Replaced automatically by React on mount) */
#tw-instant-shell {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
}

.tw-sk-bar {
  height: 44px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.tw-sk-pill {
  width: 96px;
  height: 16px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.11) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: twShimmer 1.4s infinite linear;
}

.tw-sk-hero {
  height: 168px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(90deg, rgba(255,255,255,0.035) 25%, rgba(255,255,255,0.085) 50%, rgba(255,255,255,0.035) 75%);
  background-size: 200% 100%;
  animation: twShimmer 1.4s infinite linear;
}

.tw-sk-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.tw-sk-card {
  height: 196px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.075) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: twShimmer 1.4s infinite linear;
}

@keyframes twShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 3. Video Player Hardware HUD (2.0x Speed / Seek / Resume / Toast Notification) */
#tw-video-hud {
  position: fixed;
  top: 14%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px) scale(0.95);
  background: rgba(6, 8, 17, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #F8FAFC;
  padding: 7.5px 15px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  z-index: 99995;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

#tw-video-hud.tw-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

#tw-video-hud .tw-hud-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #F59E0B;
  box-shadow: 0 0 8px #F59E0B;
  animation: twPulse 0.9s infinite alternate;
}

@keyframes twPulse {
  from { opacity: 0.45; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

/* 4. Floating Right-Side Action Stack (Spotlight Search + Quick-Switch Matrix + Back-to-Top) */
#tw-float-stack {
  position: fixed;
  right: 12px;
  bottom: 82px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9980;
}

.tw-fab-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(13, 17, 30, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.tw-fab-btn:hover {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(23, 29, 50, 0.95);
  color: #FDE68A;
}

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

#tw-float-top {
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
}

#tw-float-top.tw-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 5. Compact Ecosystem Quick-Switch Popover + Utility Bar */
#tw-matrix-popover {
  position: fixed;
  right: 58px;
  bottom: 82px;
  width: 252px;
  background: rgba(11, 14, 26, 0.96);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 15px;
  padding: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.75);
  z-index: 9985;
  opacity: 0;
  transform: translateX(12px) scale(0.95);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#tw-matrix-popover.tw-open {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.tw-mp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: #94A3B8;
  padding: 2px 4px 7px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 7px;
}

.tw-mp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.tw-mp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6.5px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #F8FAFC;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.16s ease;
  white-space: nowrap;
  cursor: pointer;
}

.tw-mp-item:hover, .tw-mp-item.tw-active {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.45);
  color: #FFFFFF;
}

.tw-mp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tw-mp-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.tw-mp-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #CBD5E1;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.tw-mp-tool-btn:hover, .tw-mp-tool-btn.tw-on {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.45);
  color: #FDE68A;
}

/* 6. Smart Continue-Watching / Resume Capsule & Cross-Flagship Omni-Assist Bar */
#tw-resume-capsule,
#tw-omni-assist-bar {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%) translateY(30px);
  max-width: calc(100vw - 28px);
  width: 376px;
  background: rgba(13, 17, 30, 0.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 13px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  z-index: 9975;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#tw-omni-assist-bar {
  border-color: rgba(16, 185, 129, 0.42);
  z-index: 9978;
}

#tw-resume-capsule.tw-show,
#tw-omni-assist-bar.tw-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.tw-rc-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.tw-rc-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(245, 158, 11, 0.18);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
}

.tw-rc-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #F8FAFC;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-rc-btn {
  background: linear-gradient(135deg, #D97706, #F59E0B);
  color: #060811;
  border: none;
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.tw-rc-close {
  background: transparent;
  border: none;
  color: #64748B;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}

/* 7. Universal Spotlight Search & Watch-History Command Palette */
#tw-spotlight-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 99990;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 14px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#tw-spotlight-overlay.tw-open {
  opacity: 1;
  pointer-events: auto;
}

#tw-spotlight-modal {
  width: 100%;
  max-width: 480px;
  background: rgba(12, 16, 30, 0.97);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.82);
  transform: translateY(-10px) scale(0.97);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  color: #F8FAFC;
  font-family: system-ui, -apple-system, sans-serif;
}

#tw-spotlight-overlay.tw-open #tw-spotlight-modal {
  transform: translateY(0) scale(1);
}

.tw-sp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tw-sp-brand {
  font-size: 12px;
  font-weight: 800;
  color: #FDE68A;
  letter-spacing: 0.03em;
}

.tw-sp-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.tw-sp-form {
  display: flex;
  gap: 7px;
  margin-bottom: 9px;
}

.tw-sp-input {
  flex: 1;
  background: rgba(6, 8, 17, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 9px 12px;
  color: #F8FAFC;
  font-size: 13px;
  outline: none;
}

.tw-sp-input:focus {
  border-color: #F59E0B;
}

.tw-sp-submit {
  background: linear-gradient(135deg, #D97706, #F59E0B);
  color: #060811;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.tw-sp-scopes {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.tw-sp-scope {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94A3B8;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.tw-sp-scope.tw-active {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.48);
  color: #FDE68A;
}

.tw-sp-sec-title {
  font-size: 10.5px;
  font-weight: 800;
  color: #64748B;
  margin: 8px 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tw-sp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.tw-sp-tag {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #CBD5E1;
  font-size: 11px;
  font-weight: 600;
  padding: 3.5px 9px;
  border-radius: 7px;
  text-decoration: none;
  transition: all 0.15s;
}

.tw-sp-tag:hover {
  border-color: rgba(245, 158, 11, 0.45);
  color: #FDE68A;
}

.tw-sp-hist-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 165px;
  overflow-y: auto;
}

.tw-sp-hist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6.5px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
  color: #E2E8F0;
  font-size: 11.5px;
  font-weight: 600;
}

.tw-sp-hist-item:hover {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.12);
}

.tw-sp-hist-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.tw-sp-hist-time {
  font-size: 10px;
  font-weight: 800;
  color: #FBBF24;
  white-space: nowrap;
}

/* 8. Spotlight Live Instant Search Dropdown & App v2.7.0 Footer Bar */
#tw-sp-live-wrap {
  display: none;
  margin-bottom: 8px;
}

#tw-sp-live-wrap.tw-has-res {
  display: block;
}

#tw-sp-live-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 210px;
  overflow-y: auto;
}

.tw-sp-live-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.22);
  text-decoration: none;
  color: #F8FAFC;
  transition: all 0.15s ease;
}

.tw-sp-live-item:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.5);
  transform: translateX(2px);
}

.tw-sp-live-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.tw-sp-live-thumb {
  width: 30px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.tw-sp-live-title {
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-sp-live-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6.5px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #FDE68A;
  white-space: nowrap;
  flex-shrink: 0;
}

.tw-sp-app-bar {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(236, 72, 153, 0.14));
  border: 1px solid rgba(139, 92, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-decoration: none;
  color: #F8FAFC;
  transition: all 0.16s ease;
}

.tw-sp-app-bar:hover {
  border-color: rgba(245, 158, 11, 0.55);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.24), rgba(245, 158, 11, 0.18));
}

.tw-sp-app-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tw-sp-app-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.tw-sp-app-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tw-sp-app-name {
  font-size: 11.5px;
  font-weight: 800;
  color: #FFFFFF;
}

.tw-sp-app-sub {
  font-size: 10px;
  color: #CBD5E1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-sp-app-cta {
  font-size: 10.5px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 7px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #FFFFFF;
  white-space: nowrap;
  flex-shrink: 0;
}

