:root {
  --plex-gold: #e5a00d;
  --plex-gold-hover: #f5b01d;
  --plex-bg: #0f1217;
  --plex-sidebar: #14181f;
  --plex-surface: #1b212a;
  --plex-surface-2: #242c37;
  --plex-border: rgba(255, 255, 255, 0.09);
  --plex-text: #f3f4f6;
  --plex-muted: #9ca3af;
  --plex-danger: #ef4444;
  --plex-success: #10b981;
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--plex-bg);
  color: var(--plex-text);
  overflow-x: hidden;
  width: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.hidden {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--plex-gold);
}

/* App Shell — Fixed Sidebar & Topbar, Only Main Content Scrolls */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 85;
}

.sidebar {
  width: 265px;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  background: var(--plex-sidebar);
  border-right: 1px solid var(--plex-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1);
  z-index: 90;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--plex-border);
}

.sidebar-brand-left {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--plex-border);
  color: var(--plex-text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

.plex-logo-badge {
  background: var(--plex-gold);
  color: #000;
  font-weight: 900;
  font-size: 18px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
}

.brand-sub {
  font-size: 11px;
  color: var(--plex-muted);
}

.sidebar-nav {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  flex: 1;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 4px;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--plex-muted);
  padding: 0 8px 4px;
}

.nav-add-btn {
  background: rgba(229, 160, 13, 0.16);
  color: var(--plex-gold);
  border: 1px solid rgba(229, 160, 13, 0.35);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  cursor: pointer;
}

.nav-add-btn:hover {
  background: var(--plex-gold);
  color: #000;
}

.nav-item,
.nav-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: var(--plex-text);
  border: none;
  padding: 10px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-item:hover,
.nav-item-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active,
.nav-item-row.active {
  background: rgba(229, 160, 13, 0.16);
  color: var(--plex-gold);
  font-weight: 600;
}

.nav-item-row {
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding-right: 4px;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-size: 11px;
  color: var(--plex-muted);
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 6px;
  border-radius: 99px;
}

.nav-item-action {
  background: transparent;
  border: none;
  color: var(--plex-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
}

.nav-item-action:hover {
  color: var(--plex-gold);
  background: rgba(255, 255, 255, 0.08);
}

.nav-empty-hint {
  font-size: 12px;
  color: var(--plex-muted);
  padding: 8px 10px;
}

/* Main Column & Topbar */
.main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  min-height: 64px;
  flex-shrink: 0;
  background: rgba(20, 24, 31, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--plex-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  gap: 12px;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.topbar-back-btn:hover {
  background: rgba(229, 160, 13, 0.18);
  border-color: rgba(229, 160, 13, 0.55);
  color: var(--plex-gold);
}

.topbar-back-btn:active {
  transform: scale(0.95);
}

.detail-back-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 15px 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.detail-back-pill:hover {
  background: var(--plex-gold);
  border-color: var(--plex-gold);
  color: #000000;
}

.detail-back-pill:active {
  transform: scale(0.95);
}

.mobile-menu-btn {
  display: none;
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  color: var(--plex-text);
  width: 38px;
  height: 38px;
  border-radius: 9px;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-brand-logo {
  display: none;
  background: var(--plex-gold);
  color: #000;
  font-weight: 900;
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: -0.5px;
  cursor: pointer;
  flex-shrink: 0;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  border-radius: 999px;
  padding: 7px 14px;
  width: 100%;
  max-width: 460px;
}

.search-input {
  background: transparent;
  border: none;
  color: var(--plex-text);
  width: 100%;
  font-size: 13.5px;
  outline: none;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.scanning {
  background: rgba(229, 160, 13, 0.18);
  color: var(--plex-gold);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.account-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  color: var(--plex-text);
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  cursor: pointer;
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #000;
  flex-shrink: 0;
}

.avatar-circle.lg {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

/* Mobile Bottom Nav (Hidden on Desktop) */
.mobile-bottom-nav {
  display: none;
}

/* Main View — Independent Scroll Container */
.main-view {
  padding: 24px 28px 60px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.Quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

/* Buttons & Inputs */
.btn-primary {
  background: var(--plex-gold);
  color: #000;
  font-weight: 700;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary:hover {
  background: var(--plex-gold-hover);
}

.btn-secondary {
  background: var(--plex-surface-2);
  color: var(--plex-text);
  border: 1px solid var(--plex-border);
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 11.5px;
}

.plex-input,
.plex-select,
.plex-textarea {
  background: var(--plex-bg);
  color: var(--plex-text);
  border: 1px solid var(--plex-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
}

.plex-input:focus,
.plex-select:focus,
.plex-textarea:focus {
  border-color: var(--plex-gold);
}

/* Hero Banner & Empty Card */
.empty-hero-card {
  background: linear-gradient(135deg, #1b222c 0%, #12161d 100%);
  border: 1px solid var(--plex-border);
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 820px;
  margin: 20px auto;
  text-align: center;
}

.empty-hero-badge {
  display: inline-block;
  background: rgba(229, 160, 13, 0.16);
  color: var(--plex-gold);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.empty-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.hero-banner {
  background-size: cover;
  background-position: center;
  border-radius: 16px;
  padding: 40px;
  margin-bottom: 24px;
  border: 1px solid var(--plex-border);
}

.hero-content {
  max-width: 650px;
}

.hero-kicker {
  color: var(--plex-gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.hero-title {
  font-size: 32px;
  margin: 8px 0 12px;
  line-height: 1.15;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--plex-muted);
  margin-bottom: 14px;
}

.hero-summary {
  color: #d1d5db;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Hubs & Poster Cards */
.hub-section {
  margin-bottom: 30px;
}

.hub-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.hub-header h2 {
  font-size: 19px;
  margin: 0;
}

.hub-count {
  font-size: 12px;
  color: var(--plex-muted);
  white-space: nowrap;
}

.poster-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 18px;
}

.poster-card {
  cursor: pointer;
  transition: transform 0.18s ease;
  min-width: 0;
}

.poster-card:hover {
  transform: translateY(-4px);
}

.poster-thumb-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--plex-surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--plex-border);
}

.poster-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Centered Direct-Play Button on Every Movie & Series Card */
.poster-center-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: rgba(12, 15, 22, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.poster-center-play-btn svg {
  margin-left: 2px;
  display: block;
  pointer-events: none;
}

.poster-center-play-btn:hover {
  background: var(--plex-gold);
  border-color: var(--plex-gold);
  color: #000000;
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 8px 24px rgba(229, 160, 13, 0.5);
}

.poster-center-play-btn:active {
  transform: translate(-50%, -50%) scale(0.94);
}

.poster-corner-match-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.poster-card:hover .poster-corner-match-btn {
  opacity: 1;
}

.poster-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  transition: opacity 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.poster-card:hover .poster-overlay {
  opacity: 1;
}

.poster-play-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--plex-gold);
  color: #000;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-match-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-watched-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--plex-gold);
  color: #000;
  font-size: 11px;
  font-weight: 900;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-badge-version {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
}

.poster-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
}

.poster-progress-bar {
  height: 100%;
  background: var(--plex-gold);
}

.poster-meta {
  padding-top: 8px;
}

.poster-title {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poster-sub {
  font-size: 12px;
  color: var(--plex-muted);
}

/* Section Header & Folder Chips */
.section-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--plex-border);
}

.section-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title-row h1 {
  margin: 0;
  font-size: 26px;
}

.section-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.section-controls .plex-select {
  width: auto;
}

.folder-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.folder-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  word-break: break-all;
}

.folder-chip.online {
  border-color: rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}

.folder-chip.missing {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.badge-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(229, 160, 13, 0.18);
  color: var(--plex-gold);
}

.badge-pill.subtle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--plex-muted);
}

.rating-chip {
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 700;
}

.star-rating {
  color: var(--plex-gold);
  font-weight: 700;
}

/* Detail Page */
.detail-page {
  background-size: cover;
  background-position: top center;
  border-radius: 16px;
  padding: 32px;
  border: 1px solid var(--plex-border);
}

.detail-top {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.detail-poster {
  width: 230px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  border: 1px solid var(--plex-border);
}

.detail-info-col {
  flex: 1;
  min-width: 260px;
}

.detail-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--plex-gold);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}

.detail-title {
  font-size: 32px;
  margin: 0 0 6px;
  line-height: 1.15;
}

.detail-tagline {
  color: var(--plex-muted);
  font-style: italic;
  margin: 0 0 14px;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.detail-summary {
  line-height: 1.6;
  color: #e5e7eb;
  margin-bottom: 20px;
}

.detail-credits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  word-break: break-word;
}

.detail-versions-box {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.detail-versions-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.version-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12.5px;
  word-break: break-all;
}

.stream-Inspection-box {
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 16px;
  border-radius: 10px;
}

.stream-box-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--plex-muted);
  margin-bottom: 8px;
}

.stream-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stream-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--plex-surface);
}

/* Cast Row */
.detail-section {
  margin-top: 32px;
}

.cast-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 14px;
}

.cast-card {
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.cast-avatar,
.cast-avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--plex-surface-2);
  font-weight: 700;
}

.cast-name {
  font-size: 13px;
  font-weight: 600;
}

.cast-role {
  font-size: 11.5px;
  color: var(--plex-muted);
}

/* Modals, Tabs, Folder Browser, Fix Match & Artwork Gallery */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.plex-modal {
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  border-radius: 14px;
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.modal-close {
  background: rgba(255, 255, 255, 0.07);
  border: none;
  color: var(--plex-text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--plex-border);
}

.plex-modal-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--plex-border);
  padding-bottom: 12px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.plex-tab-btn {
  background: var(--plex-surface-2);
  color: var(--plex-muted);
  border: 1px solid var(--plex-border);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.plex-tab-btn.active {
  background: var(--plex-gold);
  color: #000;
  border-color: var(--plex-gold);
}

.lib-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.lib-type-card {
  background: var(--plex-bg);
  border: 2px solid var(--plex-border);
  border-radius: 10px;
  padding: 14px 10px;
  color: var(--plex-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.lib-type-card.selected {
  border-color: var(--plex-gold);
  background: rgba(229, 160, 13, 0.12);
}

.lib-type-icon {
  font-size: 26px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--plex-muted);
  margin-bottom: 6px;
}

.form-help,
.sub-text,
.wizard-hint {
  font-size: 12.5px;
  color: var(--plex-muted);
}

.lib-folders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.lib-folder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.lib-folder-row .lib-folder-input {
  flex: 1;
  min-width: 180px;
}

.lib-folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.server-browser-card {
  background: var(--plex-bg);
  border: 1px solid var(--plex-border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}

.server-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.browser-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip-btn {
  background: var(--plex-surface-2);
  color: var(--plex-text);
  border: 1px solid var(--plex-border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.browser-path-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.browser-current-path {
  flex: 1;
  min-width: 160px;
  background: var(--plex-surface);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  word-break: break-all;
}

.browser-dir-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.browser-dir-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--plex-surface);
  border-radius: 6px;
}

.browser-dir-name {
  cursor: pointer;
  font-size: 13px;
  word-break: break-all;
}

.browser-dir-name:hover {
  color: var(--plex-gold);
}

/* Fix Match & Artwork Gallery */
.fix-match-search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.fix-match-search-bar .plex-input {
  flex: 1;
  min-width: 160px;
}

.fix-match-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
}

.fix-match-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--plex-bg);
  border: 1px solid var(--plex-border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.fix-match-item:hover {
  border-color: var(--plex-gold);
}

.fix-match-thumb {
  width: 54px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--plex-surface);
  flex-shrink: 0;
}

.fix-match-info {
  flex: 1;
  min-width: 0;
}

.fix-match-guid code {
  font-size: 11px;
  color: var(--plex-muted);
  word-break: break-all;
}

.fix-match-summary {
  font-size: 12px;
  color: var(--plex-muted);
  margin: 4px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.artwork-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 12px;
  max-height: 340px;
  overflow-y: auto;
}

.artwork-choice {
  position: relative;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

.artwork-choice.selected,
.artwork-choice:hover {
  border-color: var(--plex-gold);
}

.artwork-choice img {
  width: 100%;
  display: block;
}

.artwork-provider {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Sharing & Dashboard */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.dashboard-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 4px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card,
.dash-card {
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.metric-value {
  font-size: 24px;
  font-weight: 800;
  margin: 6px 0;
}

.metric-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.metric-bar > div {
  height: 100%;
  background: var(--plex-gold);
}

.dash-card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.activity-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.activity-live-pill.realtime {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.activity-live-pill.polling {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.activity-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.activity-filter-chip {
  background: rgba(255, 255, 255, 0.05);
  color: var(--plex-text-muted, #a1a1aa);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.activity-filter-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.activity-filter-chip.active {
  background: rgba(229, 160, 13, 0.2);
  color: #fbbf24;
  border-color: rgba(229, 160, 13, 0.55);
}

.device-sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.device-session-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 14px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.device-session-card.is-online {
  border-color: rgba(16, 185, 129, 0.28);
}

.device-session-card.is-playing {
  border-color: rgba(229, 9, 20, 0.45);
  box-shadow: 0 8px 24px rgba(229, 9, 20, 0.12);
}

.device-session-card.is-idle {
  opacity: 0.78;
}

.device-session-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.device-session-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar-circle.sm {
  width: 34px;
  height: 34px;
  min-width: 34px;
  font-size: 14px;
}

.device-session-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.device-session-name {
  font-size: 12px;
  color: #d4d4d8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.device-status-badge.playing {
  background: rgba(229, 9, 20, 0.18);
  color: #f87171;
}

.device-status-badge.paused {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.device-status-badge.online {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.device-status-badge.idle {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
}

.device-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.device-status-dot.playing {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.9);
  animation: activityPulse 1.6s infinite;
}

.device-status-dot.online {
  background: #10b981;
  box-shadow: 0 0 7px rgba(16, 185, 129, 0.8);
}

.device-status-dot.paused {
  background: #f59e0b;
}

.device-status-dot.idle {
  background: #64748b;
}

@keyframes activityPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.25); }
}

.device-session-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #a1a1aa;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 9px 10px;
}

.device-session-meta span {
  color: #71717a;
}

.device-session-meta code {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
  color: #e4e4e7;
}

.device-session-activity {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e4e4e7;
}

.device-session-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Terminate Stream Custom Message Modal & Viewer Notice */
.terminate-modal-target {
  background: rgba(229, 9, 20, 0.1);
  border: 1px solid rgba(229, 9, 20, 0.3);
  border-radius: 10px;
  padding: 12px 14px;
}

.terminate-target-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}

.terminate-target-sub {
  font-size: 12px;
  color: #d4d4d8;
}

.terminate-presets-wrap {
  margin-top: 12px;
}

.terminate-presets-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a1a1aa;
  margin-bottom: 8px;
}

.terminate-presets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.terminate-preset-chip {
  background: rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.terminate-preset-chip:hover {
  background: rgba(229, 160, 13, 0.18);
  border-color: rgba(229, 160, 13, 0.5);
  color: #fff;
}

.terminated-notice-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.terminated-notice-lead {
  margin: 0;
  font-size: 14px;
  color: #d4d4d8;
  line-height: 1.5;
}

.terminated-notice-message {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-left: 4px solid #f59e0b;
  border-radius: 10px;
  padding: 12px 14px;
}

.terminated-notice-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #fbbf24;
  margin-bottom: 6px;
}

.terminated-notice-text {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Intro / Recap / Credits Markers UI */
.detail-markers-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-marker-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(229, 160, 13, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(229, 160, 13, 0.35);
}

.detail-marker-pill.recap {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.detail-marker-pill.credits {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

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

.markers-editor-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.marker-editor-row {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 12px;
}

.marker-editor-row-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.lib-markers-opt-card {
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: 10px;
  background: rgba(229, 160, 13, 0.08);
  border: 1px solid rgba(229, 160, 13, 0.32);
}

.lib-markers-opt-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  color: #f8fafc;
  font-size: 13px;
}

.lib-markers-opt-label input[type="checkbox"] {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: #e5a00d;
  flex-shrink: 0;
  cursor: pointer;
}

.nf-timeline-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
  overflow: hidden;
}

.nf-timeline-marker-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.55;
}

.nf-timeline-marker-seg.recap {
  background: #38bdf8;
}

.nf-timeline-marker-seg.intro {
  background: #f59e0b;
}

.nf-timeline-marker-seg.credits {
  background: #ef4444;
}

.nf-marker-skip-dock {
  position: absolute;
  right: 28px;
  bottom: 118px;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: markerDockFadeIn 0.25s ease-out;
}

.player-overlay.mode-controls .nf-marker-skip-dock {
  bottom: 162px;
}

.nf-marker-skip-btn {
  background: rgba(15, 18, 26, 0.88);
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nf-marker-skip-btn:hover {
  background: #ffffff;
  color: #0b0e14;
  border-color: #ffffff;
  transform: scale(1.03);
}

.nf-marker-skip-btn.primary {
  background: rgba(229, 9, 20, 0.92);
  border-color: rgba(255, 255, 255, 0.5);
}

.nf-marker-skip-btn.primary:hover {
  background: #ff1e29;
  color: #fff;
}

.nf-marker-dismiss-btn {
  background: rgba(15, 18, 26, 0.78);
  color: #d4d4d8;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  width: 38px;
  height: 42px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.nf-marker-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.nf-autoskip-undo {
  position: absolute;
  right: 28px;
  bottom: 118px;
  z-index: 36;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 18, 26, 0.92);
  color: #f8fafc;
  border: 1px solid rgba(229, 160, 13, 0.55);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.nf-autoskip-undo-btn {
  background: #e5a00d;
  color: #0b0e14;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.nf-autoskip-toggles {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.nf-autoskip-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #fbbf24;
}

.nf-autoskip-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #e4e4e7;
  cursor: pointer;
}

@keyframes markerDockFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .nf-marker-skip-dock,
  .nf-autoskip-undo {
    right: 14px;
    bottom: 96px;
  }
  .player-overlay.mode-controls .nf-marker-skip-dock {
    bottom: 148px;
  }
  .nf-marker-skip-btn {
    padding: 9px 14px;
    font-size: 13px;
  }
}

.plex-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.plex-table th,
.plex-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--plex-border);
}

.shared-users-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shared-user-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--plex-bg);
  border: 1px solid var(--plex-border);
  border-radius: 10px;
  padding: 14px 16px;
}

.shared-user-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.shared-user-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.shared-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--plex-bg);
  border: 1px solid var(--plex-border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  margin-bottom: 8px;
}

.checkbox-card.highlight {
  border-color: rgba(229, 160, 13, 0.45);
}

.invite-link-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.invite-link-box .plex-input {
  flex: 1;
  min-width: 200px;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.account-card {
  background: var(--plex-bg);
  border: 2px solid var(--plex-border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
}

.account-card.selected {
  border-color: var(--plex-gold);
}

.logs-console {
  background: #090b0e;
  border-radius: 8px;
  padding: 12px;
  max-height: 420px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 12px;
  word-break: break-word;
}

.log-line {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.log-time {
  color: var(--plex-muted);
  margin-right: 8px;
}

.log-level.INFO {
  color: #34d399;
  margin-right: 8px;
}

.log-level.WARN {
  color: var(--plex-gold);
  margin-right: 8px;
}

/* Video Player Overlay */
.player-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  transition: cursor 0.2s ease;
}

.player-overlay.controls-hidden {
  cursor: none;
}

.player-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: linear-gradient(180deg, rgba(10, 13, 18, 0.95) 0%, rgba(10, 13, 18, 0.6) 80%, transparent 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  gap: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 0.32s ease, transform 0.32s ease, visibility 0.32s ease;
}

.player-overlay.controls-hidden .player-topbar {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  pointer-events: none;
}

.player-controls-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.player-ctrl-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.player-ctrl-label .plex-select {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}

.player-stage {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  background: #000;
  position: relative;
}

.player-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}

/* Ocultar barra y controles nativos del navegador por defecto */
.player-stage video::-webkit-media-controls,
.player-stage video::-webkit-media-controls-enclosure,
.player-stage video::-webkit-media-controls-panel {
  display: none !important;
  -webkit-appearance: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--plex-surface-2);
  border: 1px solid var(--plex-border);
  border-left: 4px solid var(--plex-gold);
  color: var(--plex-text);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success {
  border-left-color: var(--plex-success);
}

.toast-error {
  border-left-color: var(--plex-danger);
}

/* Desktop defaults for new responsive helper elements */
.sidebar-mobile-profile,
.mobile-icon-btn,
.mobile-search-close {
  display: none;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active .nav-icon,
.nav-item-row.active .nav-icon {
  opacity: 1;
}

.nav-item-danger {
  color: #f87171;
}

.nav-item-danger:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.search-icon {
  display: inline-flex;
  align-items: center;
  color: var(--plex-muted);
  flex-shrink: 0;
}

/* ============================================================================
   PLEX SIGN-IN / LOGIN SCREEN & ROLE BADGES
   ============================================================================ */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: radial-gradient(circle at 50% 18%, rgba(229, 160, 13, 0.16) 0%, rgba(11, 14, 19, 0.98) 65%), #0b0e13;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(18, 23, 31, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  color: #fff;
}

.login-subtitle {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--plex-muted);
  text-align: center;
  line-height: 1.45;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-submit-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 6px;
}

.login-roles-info {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--plex-border);
}

.login-role-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--plex-muted);
  line-height: 1.45;
}

.login-role-box strong {
  color: var(--plex-text);
}

.login-role-box ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.login-role-box li {
  margin-bottom: 5px;
}

.role-chip-mini {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(229, 160, 13, 0.2);
  color: var(--plex-gold);
  margin-left: 4px;
  vertical-align: middle;
}

/* ============================================================================
   LOADING SKELETONS, SPINNER, A-Z JUMP BAR & INFINITE SCROLL (25,000+ MOVIES)
   ============================================================================ */

.section-loading-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
  background: rgba(229, 160, 13, 0.1);
  border: 1px solid rgba(229, 160, 13, 0.35);
  border-radius: 12px;
}

.plex-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(229, 160, 13, 0.25);
  border-top-color: var(--plex-gold);
  animation: plexSpin 0.75s linear infinite;
  flex-shrink: 0;
}

.plex-spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--plex-gold);
  animation: plexSpin 0.75s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes plexSpin {
  to { transform: rotate(360deg); }
}

.skeleton-card {
  pointer-events: none;
}

.skeleton-shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.11) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: plexShimmer 1.3s ease-in-out infinite;
}

.skeleton-line {
  height: 11px;
  border-radius: 6px;
  margin-top: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.11) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: plexShimmer 1.3s ease-in-out infinite;
}

.skeleton-title {
  width: 82%;
}

.skeleton-sub {
  width: 45%;
  height: 9px;
}

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

.alpha-jump-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 10px;
  margin-bottom: 18px;
  background: var(--plex-surface);
  border: 1px solid var(--plex-border);
  border-radius: 10px;
  scrollbar-width: thin;
}

.alpha-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--plex-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.alpha-btn:hover {
  color: var(--plex-text);
  background: rgba(255, 255, 255, 0.06);
}

.alpha-btn.active {
  background: var(--plex-gold);
  color: #0b0e13;
  border-color: var(--plex-gold);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 28px 0 18px;
}

/* Plex Orange Field Lock Button (Metadata Editor) */
.field-lock-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--plex-border);
  color: var(--plex-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.field-lock-btn.locked {
  background: rgba(229, 160, 13, 0.22);
  border-color: var(--plex-gold);
  color: var(--plex-gold);
}

/* Auto-Play Next Episode 10s Countdown Overlay */
.next-ep-overlay {
  position: absolute;
  bottom: 42px;
  right: 36px;
  z-index: 50;
}

.next-ep-card {
  background: rgba(15, 19, 26, 0.96);
  border: 1px solid var(--plex-gold);
  border-radius: 14px;
  padding: 20px 24px;
  min-width: 300px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}

.next-ep-card h3 {
  margin: 6px 0 4px;
  font-size: 18px;
  color: #fff;
}

/* Floating Skip Intro Button (Series Episodes Only) */
.floating-skip-intro-btn {
  position: absolute;
  bottom: 92px;
  right: 36px;
  z-index: 45;
  background: rgba(15, 19, 26, 0.92);
  color: #ffffff;
  border: 2px solid var(--plex-gold);
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
  transition: transform 0.15s ease, background 0.15s ease;
}

.floating-skip-intro-btn:hover {
  background: var(--plex-gold);
  color: #000;
  transform: scale(1.04);
}

/* ============================================================================
   CLEAN CINEMATIC WEB PLAYER (Android TV / Netflix Twin)
   ============================================================================ */

.player-overlay.mode-hidden {
  cursor: none;
}

.nf-top-vignette,
.nf-bottom-vignette,
.nf-shelf-vignette {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 62;
  transition: opacity 0.22s ease;
}

.nf-top-vignette {
  top: 0;
  height: 150px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.34) 55%, rgba(0, 0, 0, 0) 100%);
}

.nf-bottom-vignette {
  bottom: 0;
  height: 270px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.94) 0%, rgba(0, 0, 0, 0.65) 55%, rgba(0, 0, 0, 0) 100%);
}

.nf-shelf-vignette {
  bottom: 0;
  height: 410px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.97) 0%, rgba(0, 0, 0, 0.86) 60%, rgba(0, 0, 0, 0) 100%);
  opacity: 0;
}

/* Controls Layer visibility */
.nf-controls-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  opacity: 1;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.player-overlay.mode-hidden .nf-controls-layer,
.player-overlay.mode-shelf .nf-controls-layer,
.player-overlay.has-subpanel .nf-controls-layer {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.player-overlay.mode-controls:not(.has-subpanel) .nf-controls-layer .nf-player-header,
.player-overlay.mode-controls:not(.has-subpanel) .nf-controls-layer .nf-bottom-zone {
  pointer-events: auto;
}

/* Top Header (Minimal title + subtle icon buttons) */
.nf-player-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 28px 4.5vw 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  z-index: 72;
}

.nf-player-title-wrap {
  min-width: 0;
  flex: 1;
}

.nf-player-title {
  color: #ffffff;
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nf-player-subtitle {
  margin-top: 4px;
  color: #d4d4d8;
  font-size: clamp(13px, 1.2vw, 17px);
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nf-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.nf-header-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(24, 24, 27, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nf-header-icon-btn:hover,
.nf-header-icon-btn:focus-visible {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  transform: scale(1.08);
  outline: none;
}

/* Bottom Controls Zone */
.nf-bottom-zone {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 4.5vw 22px;
  z-index: 72;
}

/* Timeline Row (Netflix Red) */
.nf-timeline-wrap {
  margin-bottom: 20px;
  outline: none;
}

.nf-timeline-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nf-time-label {
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  min-width: 58px;
}

.nf-time-label.remaining {
  color: #e4e4e7;
  text-align: right;
  font-weight: 600;
}

.nf-timeline-track {
  position: relative;
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  cursor: pointer;
  transition: height 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.nf-timeline-track::before {
  content: '';
  position: absolute;
  top: -12px;
  bottom: -12px;
  left: 0;
  right: 0;
}

.nf-timeline-track:hover,
.nf-timeline-wrap.nf-focused .nf-timeline-track {
  height: 11px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

.nf-timeline-fill {
  height: 100%;
  background: #e50914;
  border-radius: 999px;
  position: relative;
  pointer-events: none;
}

.nf-timeline-thumb {
  position: absolute;
  top: 50%;
  right: -11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e50914;
  border: 3.5px solid #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
  transform: translateY(-50%) scale(0.75);
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
}

.nf-timeline-track:hover .nf-timeline-thumb,
.nf-timeline-wrap.nf-focused .nf-timeline-thumb {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

.nf-timeline-hover-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2.5px;
  background: #ffffff;
  border-radius: 2px;
  pointer-events: none;
  transform: translateX(-50%);
}

/* Clean BIF Preview Card (White border like Android TV) */
.nf-preview-card {
  position: absolute;
  bottom: calc(100% + 20px);
  transform: translateX(-50%);
  width: 220px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #18181b;
  border: 2px solid #ffffff;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.88);
  pointer-events: none;
  z-index: 78;
}

.nf-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nf-preview-time {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 10px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.45) 60%, transparent 100%);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Icon-Only Circular Controls Row (Zero text tooltips!) */
.nf-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.nf-ctrl-group {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nf-ctrl-group.start {
  flex: 1;
  justify-content: flex-start;
}

.nf-ctrl-group.center {
  justify-content: center;
  gap: 28px;
}

.nf-ctrl-group.end {
  flex: 1;
  justify-content: flex-end;
}

.nf-ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(24, 24, 27, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.nf-ctrl-btn.hero {
  width: 66px;
  height: 66px;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.55);
}

.nf-ctrl-btn:hover,
.nf-ctrl-btn.nf-focused,
.nf-ctrl-btn:focus-visible {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  transform: scale(1.12);
  box-shadow: 0 0 26px rgba(255, 255, 255, 0.55);
}

.nf-ctrl-btn svg {
  display: block;
  pointer-events: none;
}

/* Compact Volume Control */
.nf-volume-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nf-volume-slider {
  width: 82px;
  accent-color: #e50914;
  cursor: pointer;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  outline: none;
}

/* Subtle Down Chevron Cue */
.nf-down-cue {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  height: 16px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.nf-down-cue:hover {
  opacity: 0.9;
  transform: translateY(2px);
}

/* Subtle Icon-Only Skip Cue (-10s / +10s) */
.nf-skip-cue {
  position: absolute;
  top: 50%;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.56);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 82;
  opacity: 0;
  transform: translateY(-50%) scale(0.88);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.nf-skip-cue.pos-left {
  left: 14%;
}

.nf-skip-cue.pos-right {
  right: 14%;
}

.nf-skip-cue.active {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Clean Spinner-Only Buffering Indicator (Zero text!) */
.player-loading-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
}

.player-buffering-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 60;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.player-buffering-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.plex-player-big-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3.5px solid rgba(255, 255, 255, 0.14);
  border-top-color: #e50914;
  animation: plexSpin 0.72s linear infinite;
}

/* ============================================================================
   LAYER 2: RELATED MOVIES / EPISODES HORIZONTAL SHELF
   ============================================================================ */

.nf-shelf-layer {
  position: absolute;
  inset: 0;
  z-index: 75;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
}

.player-overlay.mode-shelf:not(.has-subpanel) .nf-shelf-layer {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.player-overlay.mode-shelf:not(.has-subpanel) .nf-shelf-vignette {
  opacity: 1;
}

.nf-shelf-backdrop-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.nf-shelf-container {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 0 28px;
  z-index: 5;
}

.nf-shelf-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4.5vw 14px;
}

.nf-shelf-header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.nf-shelf-title {
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nf-shelf-sub {
  color: #a1a1aa;
  font-size: 14px;
  font-weight: 600;
}

.nf-shelf-counter {
  color: #a1a1aa;
  font-size: 13px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.nf-shelf-scroll {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 10px 4.5vw 12px;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.nf-shelf-scroll::-webkit-scrollbar {
  display: none;
}

.nf-shelf-empty {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a1a1aa;
  font-size: 15px;
}

/* Episode Cards (16:9 Landscape) */
.nf-ep-card {
  flex: 0 0 246px;
  width: 246px;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.nf-ep-card.active,
.nf-ep-card:hover {
  transform: scale(1.06);
}

.nf-ep-thumb {
  position: relative;
  width: 246px;
  height: 138px;
  border-radius: 10px;
  overflow: hidden;
  background: #18181b;
  border: 2px solid rgba(255, 255, 255, 0.14);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.nf-ep-card.current:not(.active) .nf-ep-thumb {
  border-color: rgba(229, 9, 20, 0.78);
}

.nf-ep-card.active .nf-ep-thumb,
.nf-ep-card:hover .nf-ep-thumb {
  border: 3px solid #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.85);
}

.nf-ep-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nf-ep-code-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.74);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
}

.nf-ep-current-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e50914;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.65);
}

.nf-ep-dur-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.74);
  color: #e4e4e7;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.nf-ep-current-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: #e50914;
}

/* Related Movie Cards (2:3 Poster) */
.nf-movie-card {
  flex: 0 0 140px;
  width: 140px;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.nf-movie-card.active,
.nf-movie-card:hover {
  transform: scale(1.06);
}

.nf-movie-poster {
  position: relative;
  width: 140px;
  height: 206px;
  border-radius: 10px;
  overflow: hidden;
  background: #18181b;
  border: 2px solid rgba(255, 255, 255, 0.14);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.nf-movie-card.active .nf-movie-poster,
.nf-movie-card:hover .nf-movie-poster {
  border: 3px solid #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.85);
}

.nf-movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nf-shelf-item-title {
  margin-top: 8px;
  color: #d4d4d8;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nf-ep-card.active .nf-shelf-item-title,
.nf-movie-card.active .nf-shelf-item-title {
  color: #ffffff;
  font-weight: 700;
}

.nf-shelf-item-meta {
  margin-top: 2px;
  color: #a1a1aa;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================================
   AUDIO & SUBTITLES 2-COLUMN PANEL + COMPACT SETTINGS POPOVER
   ============================================================================ */

.nf-subpanel-backdrop {
  position: absolute;
  inset: 0;
  z-index: 95;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6vh 8vw;
}

.nf-subpanel-backdrop.hidden {
  display: none;
}

.nf-sheet-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  width: 100%;
  max-width: 820px;
  max-height: 78vh;
}

.nf-sheet-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.nf-sheet-heading {
  color: #a1a1aa;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-left: 16px;
}

.nf-sheet-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nf-option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #d4d4d8;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.nf-option-row.selected {
  color: #ffffff;
  font-weight: 700;
}

.nf-option-row:hover,
.nf-option-row:focus-visible {
  background: #ffffff;
  color: #000000;
  transform: scale(1.02);
  outline: none;
}

.nf-option-check {
  width: 20px;
  font-weight: 800;
  opacity: 0;
}

.nf-option-row.selected .nf-option-check {
  opacity: 1;
}

.nf-settings-popover {
  position: absolute;
  top: 84px;
  right: 4.5vw;
  width: 270px;
  background: rgba(18, 18, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 14px;
  z-index: 96;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nf-settings-popover.hidden {
  display: none;
}

.nf-settings-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #a1a1aa;
}

.nf-settings-field .plex-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  padding: 7px 10px;
  border-radius: 8px;
}

.nf-settings-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nf-settings-action-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}

.nf-settings-action-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

@media (hover: none) {
  .nf-timeline-thumb {
    opacity: 1;
    transform: translateY(-50%) scale(0.85);
  }
  .nf-timeline-track {
    height: 7px;
  }
  .nf-timeline-track::before {
    top: -16px;
    bottom: -16px;
  }
}

@media (max-width: 768px) {
  .nf-player-header {
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px;
    gap: 12px;
  }
  .nf-player-title {
    font-size: 18px;
  }
  .nf-player-subtitle {
    font-size: 12.5px;
  }
  .nf-header-icon-btn {
    width: 38px;
    height: 38px;
  }
  .nf-bottom-zone {
    padding: 0 14px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .nf-timeline-wrap {
    margin-bottom: 16px;
  }
  .nf-timeline-row {
    gap: 10px;
  }
  .nf-time-label {
    font-size: 12px;
    min-width: 44px;
  }
  .nf-preview-card {
    width: 156px;
    bottom: calc(100% + 14px);
  }
  .nf-preview-time {
    font-size: 12px;
    padding: 10px 8px 4px;
  }
  .nf-volume-wrap {
    display: none;
  }
  .nf-controls-row {
    gap: 8px;
  }
  .nf-ctrl-group {
    gap: 8px;
  }
  .nf-ctrl-group.center {
    gap: 14px;
  }
  .nf-ctrl-btn {
    width: 42px;
    height: 42px;
  }
  .nf-ctrl-btn.hero {
    width: 56px;
    height: 56px;
  }
  .nf-ctrl-btn svg {
    width: 20px;
    height: 20px;
  }
  .nf-ctrl-btn.hero svg {
    width: 26px;
    height: 26px;
  }
  .nf-down-cue {
    margin-top: 10px;
    height: 20px;
    opacity: 0.65;
  }
  .nf-skip-cue {
    width: 60px;
    height: 60px;
  }
  .nf-skip-cue.pos-left {
    left: 9%;
  }
  .nf-skip-cue.pos-right {
    right: 9%;
  }
  .nf-shelf-container {
    padding: 14px 0 calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .nf-shelf-header {
    padding: 0 16px 10px;
  }
  .nf-shelf-title {
    font-size: 18px;
  }
  .nf-shelf-scroll {
    gap: 12px;
    padding: 6px 16px 10px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .nf-ep-card {
    flex: 0 0 192px;
    width: 192px;
    scroll-snap-align: start;
  }
  .nf-ep-thumb {
    width: 192px;
    height: 108px;
  }
  .nf-movie-card {
    flex: 0 0 112px;
    width: 112px;
    scroll-snap-align: start;
  }
  .nf-movie-poster {
    width: 112px;
    height: 166px;
  }
  .nf-shelf-item-title {
    font-size: 13px;
  }
  .nf-subpanel-backdrop {
    padding: 20px 16px;
  }
  .nf-sheet-columns {
    grid-template-columns: 1fr;
    gap: 24px;
    max-height: 82dvh;
    overflow-y: auto;
  }
  .nf-sheet-heading {
    font-size: 16px;
    margin-bottom: 8px;
    padding-left: 12px;
  }
  .nf-option-row {
    font-size: 15px;
    padding: 9px 14px;
  }
  .nf-settings-popover {
    top: calc(64px + env(safe-area-inset-top, 0px));
    right: 12px;
    width: min(260px, calc(100vw - 24px));
  }
  .next-ep-overlay {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    left: 12px;
  }
  .next-ep-card {
    min-width: 0;
    width: 100%;
    padding: 16px;
  }
}

/* Mobile Landscape Player Adaptation (compact vertical height) */
@media (max-height: 500px) and (pointer: coarse) {
  .nf-player-header {
    padding: 10px max(18px, env(safe-area-inset-left, 18px)) 8px;
  }
  .nf-player-title {
    font-size: 17px;
  }
  .nf-player-subtitle {
    font-size: 12px;
  }
  .nf-bottom-zone {
    padding: 0 max(18px, env(safe-area-inset-left, 18px)) calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .nf-timeline-wrap {
    margin-bottom: 10px;
  }
  .nf-ctrl-btn {
    width: 40px;
    height: 40px;
  }
  .nf-ctrl-btn.hero {
    width: 50px;
    height: 50px;
  }
  .nf-down-cue {
    margin-top: 6px;
    height: 14px;
  }
  .nf-shelf-vignette {
    height: 240px;
  }
  .nf-shelf-container {
    padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .nf-shelf-header {
    padding: 0 max(18px, env(safe-area-inset-left, 18px)) 6px;
  }
  .nf-shelf-title {
    font-size: 16px;
  }
  .nf-shelf-scroll {
    padding: 4px max(18px, env(safe-area-inset-left, 18px)) 6px;
  }
  .nf-ep-card {
    flex: 0 0 164px;
    width: 164px;
  }
  .nf-ep-thumb {
    width: 164px;
    height: 92px;
  }
  .nf-movie-card {
    flex: 0 0 90px;
    width: 90px;
  }
  .nf-movie-poster {
    width: 90px;
    height: 132px;
  }
  .nf-shelf-item-meta {
    display: none;
  }
}

/* ============================================================================
   TV MODE & 10-FOOT LEANBACK UI (FIRESTICK, ANDROID TV, SAMSUNG TIZEN, LG WEBOS)
   ============================================================================ */

.tv-mode {
  font-size: 18px;
  user-select: none;
  overflow: hidden;
  background-color: #0b0e13;
}

.tv-mode.hide-cursor * {
  cursor: none !important;
}

/* Hide desktop topbar & desktop controls in TV mode */
.tv-mode .topbar {
  display: none !important;
}

.tv-mode .Quick-bar {
  display: none !important;
}

.tv-mode .desktop-only-btn {
  display: none !important;
}

/* Fullscreen 10-Foot App Shell */
.tv-mode .app-shell {
  display: flex !important;
  flex-direction: row !important;
  width: 100vw !important;
  height: 100vh !important;
  overflow: hidden !important;
  background: #0b0e13 !important;
}

/* TV Leanback Left Drawer */
.tv-mode .sidebar {
  width: 84px !important;
  min-width: 84px !important;
  max-width: 84px !important;
  height: 100vh !important;
  background: rgba(11, 14, 19, 0.97) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease !important;
  overflow: hidden !important;
  z-index: 500 !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
}

.tv-mode .sidebar.tv-sidebar-expanded {
  width: 270px !important;
  min-width: 270px !important;
  max-width: 270px !important;
  background: #0e1218 !important;
  box-shadow: 14px 0 50px rgba(0, 0, 0, 0.92) !important;
}

.tv-mode .sidebar-brand {
  padding: 24px 16px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.tv-mode .sidebar-brand-left {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
}

.tv-mode .sidebar:not(.tv-sidebar-expanded) .brand-meta {
  display: none !important;
}

.tv-mode .sidebar-close-btn {
  display: none !important;
}

.tv-mode .sidebar-nav {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  padding: 24px 12px !important;
  overflow-y: auto !important;
  scrollbar-width: none !important;
}

.tv-mode .sidebar-nav::-webkit-scrollbar {
  display: none !important;
}

.tv-mode .nav-item,
.tv-mode .nav-item-main {
  padding: 16px 18px !important;
  border-radius: 12px !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  color: #94a3b8 !important;
  background: transparent !important;
  border: none !important;
  width: 100% !important;
  text-align: left !important;
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease !important;
}

.tv-mode .nav-item .nav-icon,
.tv-mode .nav-item-main .nav-icon {
  font-size: 26px !important;
  min-width: 34px !important;
  text-align: center !important;
  display: inline-block !important;
}

.tv-mode .sidebar:not(.tv-sidebar-expanded) .nav-item span:not(.nav-icon),
.tv-mode .sidebar:not(.tv-sidebar-expanded) .nav-item-main span:not(.nav-icon) {
  opacity: 0 !important;
  display: none !important;
}

.tv-mode .nav-item-action {
  display: none !important;
}

.tv-mode .sidebar-section-title {
  display: none !important;
}

/* TV Main Content Viewport */
.tv-mode .main-column {
  flex: 1 !important;
  height: 100vh !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth !important;
  scrollbar-width: none !important;
  background: #0b0e13 !important;
}

.tv-mode .main-column::-webkit-scrollbar {
  display: none !important;
}

.tv-mode .main-view {
  padding: 0 0 100px 0 !important;
}

/* TV Hero Spotlight Banner */
.tv-mode .hero-banner {
  min-height: 52vh !important;
  padding: 40px 60px !important;
  margin-bottom: 24px !important;
  background-size: cover !important;
  background-position: center 25% !important;
  display: flex !important;
  align-items: flex-end !important;
  border-radius: 0 0 20px 20px !important;
}

.tv-mode .hero-content {
  max-width: 900px !important;
}

.tv-mode .hero-kicker {
  font-size: 13px !important;
  font-weight: 800 !important;
  letter-spacing: 0.12em !important;
  color: var(--plex-gold) !important;
  margin-bottom: 8px !important;
}

.tv-mode .hero-title {
  font-size: 44px !important;
  font-weight: 800 !important;
  margin-bottom: 12px !important;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.95) !important;
}

.tv-mode .hero-meta {
  display: flex !important;
  gap: 16px !important;
  align-items: center !important;
  font-size: 16px !important;
  margin-bottom: 14px !important;
  color: #cbd5e1 !important;
}

.tv-mode .hero-summary {
  font-size: 17px !important;
  line-height: 1.55 !important;
  color: #cbd5e1 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 3 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  margin-bottom: 22px !important;
}

.tv-mode .hero-actions {
  display: flex !important;
  gap: 18px !important;
}

.tv-mode .hero-actions button {
  font-size: 18px !important;
  padding: 14px 32px !important;
  border-radius: 12px !important;
  font-weight: 700 !important;
  transition: transform 0.14s ease, box-shadow 0.14s ease !important;
}

/* TV Hubs & Horizontal Carousels */
.tv-mode .hub-section {
  margin-bottom: 36px !important;
  overflow: visible !important;
}

.tv-mode .hub-header {
  padding: 0 60px !important;
  margin-bottom: 14px !important;
  display: flex !important;
  align-items: baseline !important;
  justify-content: space-between !important;
}

.tv-mode .hub-header h2 {
  font-size: 26px !important;
  font-weight: 700 !important;
  color: #f8fafc !important;
  letter-spacing: -0.01em !important;
}

.tv-mode .hub-count {
  font-size: 14px !important;
  color: #64748b !important;
}

.tv-mode .poster-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  overflow-x: scroll !important;
  overflow-y: visible !important;
  gap: 24px !important;
  padding: 24px 60px !important;
  scrollbar-width: none !important;
  scroll-behavior: smooth !important;
}

.tv-mode .poster-row::-webkit-scrollbar {
  display: none !important;
}

.tv-mode .poster-card {
  flex: 0 0 195px !important;
  width: 195px !important;
  max-width: 195px !important;
  position: relative !important;
  border-radius: 14px !important;
  cursor: pointer !important;
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s ease !important;
}

.tv-mode .poster-thumb-wrap {
  width: 100% !important;
  height: 290px !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  background: #141822 !important;
  position: relative !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6) !important;
}

.tv-mode .poster-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.tv-mode .poster-title {
  font-size: 16px !important;
  font-weight: 600 !important;
  margin-top: 10px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: #f1f5f9 !important;
}

.tv-mode .poster-sub {
  font-size: 14px !important;
  color: #94a3b8 !important;
}

/* TV Poster Grid (Section Library View) */
.tv-mode .poster-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)) !important;
  gap: 28px !important;
  padding: 30px 60px !important;
}

/* TV High-Visibility Golden Focus (Leanback style) */
.tv-focused {
  outline: 4px solid var(--plex-gold) !important;
  outline-offset: 3px !important;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.96), 0 0 35px rgba(229, 160, 13, 0.9) !important;
  transform: scale(1.12) translateY(-6px) !important;
  z-index: 100 !important;
}

.tv-mode .sidebar .nav-item.tv-focused {
  transform: scale(1.04) !important;
  background: rgba(229, 160, 13, 0.18) !important;
  color: #fff !important;
  outline: 3px solid var(--plex-gold) !important;
  outline-offset: -2px !important;
  box-shadow: 0 0 25px rgba(229, 160, 13, 0.5) !important;
}

.tv-mode .hero-actions button.tv-focused {
  transform: scale(1.1) !important;
  outline: 4px solid #fff !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 30px rgba(229, 160, 13, 0.8) !important;
}

/* TV Exit Modal */
.tv-exit-card {
  text-align: center;
  padding: 24px 20px;
}

.tv-exit-card h2 {
  font-size: 22px;
  color: #fff;
  margin-bottom: 8px;
}

.tv-exit-card p {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 24px;
}

.tv-exit-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* Server Configuration Modal */
.server-config-card {
  padding: 10px 0;
}

.server-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 16px;
}

.server-status-pill.online {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.server-status-pill.offline {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* TV App Download Modal */
.tv-download-card {
  text-align: center;
  padding: 10px 0;
}

.tv-url-display-box {
  background: #080b0f;
  border: 2px dashed var(--plex-gold);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 18px 0;
}

.tv-url-display-text {
  font-family: monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--plex-gold);
  letter-spacing: 0.04em;
  word-break: break-all;
}

.tv-instructions-list {
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 16px 20px 16px 36px;
  margin: 16px 0;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.6;
}

/* iOS Safari PWA Install Banner */
.ios-install-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  background: rgba(15, 19, 26, 0.96);
  border: 1.5px solid var(--plex-gold);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  animation: slideUpBanner 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.ios-banner-icon {
  font-size: 30px;
  flex-shrink: 0;
}

.ios-banner-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
  color: #e2e8f0;
}

.ios-banner-text strong {
  color: var(--plex-gold);
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.ios-banner-close {
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}

.ios-banner-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   UNIFIED MOBILE & RESPONSIVE DESIGN SYSTEM (Final Cascade Layer)
   Always placed last so NO desktop rule can override mobile responsiveness!
   ============================================================================ */

/* Touch devices: keep posters sharp with ONLY the clean centered Play button */
@media (hover: none) {
  .poster-overlay,
  .poster-corner-match-btn {
    display: none !important;
  }
  .poster-card:hover {
    transform: none;
  }
  .poster-card:active .poster-thumb-wrap {
    transform: scale(0.97);
    border-color: rgba(229, 160, 13, 0.65);
    transition: transform 0.12s ease;
  }
}

/* ---------------- TABLETS & PHONES (<= 900px) ---------------- */
@media (max-width: 900px) {
  /* Native iOS Safari Document Scroll (eliminates 100dvh jump, trapped scroll, & fixed-bar glitches on iPhone) */
  html,
  body {
    overflow-x: clip;
    overscroll-behavior-x: none;
    height: auto;
    min-height: 100%;
  }

  body.drawer-is-open,
  body.player-is-open {
    overflow: hidden !important;
    touch-action: none;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    overflow-y: visible;
  }

  .main-column {
    display: block;
    height: auto;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    overflow-y: visible;
  }

  /* Prevent iOS Safari input auto-zoom */
  .plex-input,
  .plex-select,
  .plex-textarea,
  .search-input {
    font-size: 16px !important;
  }

  .desktop-only-btn {
    display: none !important;
  }

  /* Sleek Off-Canvas Mobile Drawer Menu */
  .sidebar-backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    touch-action: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(305px, 84vw);
    max-width: 84vw;
    height: 100dvh;
    background: linear-gradient(180deg, #131720 0%, #0d1016 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translate3d(-105%, 0, 0);
    -webkit-transform: translate3d(-105%, 0, 0);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.85);
    z-index: 120;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
    overscroll-behavior: contain;
  }

  .sidebar.mobile-open {
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
  }

  .sidebar-brand {
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
  }

  .sidebar-mobile-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 12px 12px 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .smp-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    cursor: pointer;
  }

  .smp-text {
    min-width: 0;
  }

  .smp-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .smp-role {
    font-size: 11.5px;
    color: var(--plex-gold);
    font-weight: 600;
  }

  .smp-logout-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sidebar-nav {
    padding: 12px;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-group {
    gap: 3px;
  }

  .nav-group-title {
    font-size: 10.5px;
    letter-spacing: 0.1em;
    color: #71717a;
    padding: 4px 10px;
  }

  .nav-item,
  .nav-item-main {
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14.5px;
    font-weight: 500;
    border-radius: 10px;
    gap: 12px;
  }

  .nav-item.active,
  .nav-item-row.active {
    background: rgba(229, 160, 13, 0.16);
    color: var(--plex-gold);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--plex-gold);
  }

  .nav-item-action {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
  }

  /* Clean Native-Style Sticky Mobile Topbar */
  .topbar {
    position: sticky;
    position: -webkit-sticky;
    top: 0;
    z-index: 60;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px;
    min-height: calc(56px + env(safe-area-inset-top, 0px));
    background: rgba(15, 18, 24, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    gap: 10px;
  }

  .topbar-left {
    gap: 10px;
    align-items: center;
  }

  .topbar-right {
    gap: 8px;
    align-items: center;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: #f4f4f5;
    padding: 0;
  }

  .mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.09);
  }

  .mobile-brand-logo {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #e50914 0%, #b91c1c 100%);
    color: #ffffff;
    font-weight: 800;
    font-size: 14px;
    padding: 5px 10px;
    border-radius: 7px;
    letter-spacing: -0.02em;
    box-shadow: 0 2px 10px rgba(229, 9, 20, 0.35);
  }

  .mobile-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f4f4f5;
    cursor: pointer;
    padding: 0;
  }

  .mobile-icon-btn:active {
    background: rgba(255, 255, 255, 0.16);
  }

  /* Hide inline search pill by default on mobile; expands cleanly full-width when tapped */
  .topbar .search-wrap {
    display: none;
  }

  .topbar.mobile-search-open .mobile-menu-btn,
  .topbar.mobile-search-open .mobile-brand-logo,
  .topbar.mobile-search-open .topbar-back-btn,
  .topbar.mobile-search-open .topbar-right {
    display: none;
  }

  .topbar-back-btn {
    height: 36px;
    padding: 0 11px 0 7px;
    font-size: 13px;
  }

  .topbar.detail-mode .mobile-brand-logo {
    display: none;
  }

  .topbar.mobile-search-open .search-wrap {
    display: flex;
    flex: 1;
    width: 100%;
    max-width: none;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(229, 160, 13, 0.55);
  }

  .topbar.mobile-search-open .mobile-search-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Clean Circular Avatar Button (no caret or label sticking out) */
  .account-name,
  .account-caret {
    display: none !important;
  }

  .account-switcher-btn {
    padding: 2px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    justify-content: center;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
  }

  .account-switcher-btn .avatar-circle {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  /* Main Scroll Content (flows naturally on iOS Safari) */
  .main-view {
    overflow: visible;
    padding: 14px 14px calc(92px + env(safe-area-inset-bottom, 0px));
  }

  /* Sleek Native-Style Mobile Bottom Tab Bar (GPU pinned for iOS Safari) */
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(62px + env(safe-area-inset-bottom, 0px));
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    background: rgba(13, 16, 22, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    z-index: 80;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.6);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  body.player-is-open .mobile-bottom-nav {
    display: none !important;
  }

  .mobile-bnav-btn {
    position: relative;
    background: transparent;
    border: none;
    color: #8b949e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 2px;
    min-height: 48px;
    cursor: pointer;
    border-radius: 10px;
    transition: color 0.16s ease, transform 0.12s ease;
    appearance: none;
    -webkit-appearance: none;
  }

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

  .mobile-bnav-btn.active {
    color: var(--plex-gold);
  }

  .mobile-bnav-btn.active::before {
    content: '';
    position: absolute;
    top: -4px;
    width: 24px;
    height: 3px;
    border-radius: 999px;
    background: var(--plex-gold);
  }

  .mobile-bnav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
  }

  .mobile-bnav-label {
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mobile-bnav-fab {
    color: #e4e4e7;
  }

  .mobile-bnav-plus {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--plex-gold), #f5b01d);
    color: #0b0e13;
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: -10px;
    box-shadow: 0 4px 14px rgba(229, 160, 13, 0.45);
  }

  .toast-container {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    left: 12px;
  }

  .ios-install-banner {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 24px);
    padding: 10px 14px;
    z-index: 75;
    border-width: 1px;
  }
  .ios-banner-icon {
    font-size: 22px;
  }
  .ios-banner-text {
    font-size: 12px;
  }
  .ios-banner-text strong {
    font-size: 13px;
  }
}

/* ---------------- PHONES (<= 640px) ---------------- */
@media (max-width: 640px) {
  /* Quick-bar horizontal pill strip */
  .Quick-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    margin: 0 -14px 16px;
    padding: 0 14px 2px;
    scrollbar-width: none;
  }
  .Quick-bar::-webkit-scrollbar {
    display: none;
  }
  .Quick-bar .btn-secondary {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 7px 12px;
    border-radius: 999px;
  }

  /* Cinematic Mobile Hero Card */
  .hero-banner {
    position: relative;
    min-height: 270px;
    display: flex;
    align-items: flex-end;
    padding: 20px 16px 16px;
    border-radius: 16px;
    margin-bottom: 20px;
    overflow: hidden;
    background-position: center 20%;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .hero-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(11, 14, 19, 0.1) 0%, rgba(11, 14, 19, 0.72) 52%, rgba(11, 14, 19, 0.97) 100%);
    pointer-events: none;
  }

  .hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 100%;
  }

  .hero-kicker {
    font-size: 10px;
  }

  .hero-title {
    font-size: 22px;
    margin: 4px 0 8px;
  }

  .hero-meta {
    gap: 8px;
    font-size: 12px;
    margin-bottom: 10px;
  }

  .hero-summary {
    font-size: 12.5px;
    line-height: 1.45;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 10px;
  }

  .hero-actions .btn-secondary:nth-child(n + 3) {
    grid-column: 1 / -1;
    font-size: 12px;
    padding: 8px 10px;
  }

  /* Edge-to-Edge Hub Carousels */
  .hub-section {
    margin-bottom: 24px;
  }

  .hub-header {
    margin-bottom: 10px;
  }

  .hub-header h2 {
    font-size: 16.5px;
    font-weight: 700;
  }

  .poster-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0 -14px;
    padding: 2px 14px 6px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .poster-row::-webkit-scrollbar {
    display: none;
  }

  .poster-row .poster-card {
    flex: 0 0 122px;
    width: 122px;
    scroll-snap-align: start;
  }

  /* Crisp 3-Column Library Grid */
  .poster-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .poster-thumb-wrap {
    border-radius: 9px;
  }

  .poster-center-play-btn {
    width: 38px;
    height: 38px;
  }

  .poster-center-play-btn svg {
    width: 17px;
    height: 17px;
  }

  .poster-meta {
    padding-top: 6px;
  }

  .poster-title {
    font-size: 12px;
    line-height: 1.25;
  }

  .poster-sub {
    font-size: 11px;
  }

  /* Library Section Header & Clean Filters */
  .section-header-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .section-title-row h1 {
    font-size: 20px;
  }

  .section-title-row .badge-pill.subtle,
  .folder-chips-row {
    display: none;
  }

  .section-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .section-controls .plex-select,
  .section-controls .btn-primary,
  .section-controls .btn-secondary {
    width: 100%;
    font-size: 13px !important;
    padding: 8px 10px;
    border-radius: 9px;
  }

  /* Clean Edge-to-Edge A-Z Jump Bar */
  .alpha-jump-bar {
    margin: 0 -14px 14px;
    padding: 7px 12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .alpha-jump-bar::-webkit-scrollbar {
    display: none;
  }
  .alpha-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Detail Page Mobile Layout */
  .detail-page {
    padding: 16px 14px 24px;
    border-radius: 14px;
  }

  .detail-top {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .detail-poster {
    width: 150px;
    border-radius: 12px;
  }

  .detail-info-col {
    min-width: 0;
    width: 100%;
  }

  .detail-breadcrumbs {
    justify-content: center;
    margin-bottom: 10px;
  }

  .detail-title {
    font-size: 22px;
    text-align: center;
  }

  .detail-tagline {
    font-size: 13px;
    text-align: center;
  }

  .detail-badges {
    justify-content: center;
    gap: 6px;
    margin-bottom: 14px;
  }

  .detail-badges .badge-pill.subtle {
    display: none;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-bottom: 16px;
  }

  .detail-actions .btn-primary {
    grid-column: 1 / -1;
    width: 100%;
    padding: 12px 16px;
    font-size: 14.5px;
    border-radius: 10px;
  }

  .detail-actions .btn-secondary,
  .detail-actions .btn-danger {
    width: 100%;
    padding: 9px 10px;
    font-size: 12px;
    border-radius: 9px;
    text-align: center;
  }

  .detail-summary {
    font-size: 13.5px;
    line-height: 1.55;
  }

  .detail-credits-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
    font-size: 12.5px;
  }

  .cast-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0 -14px;
    padding: 0 14px 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cast-row::-webkit-scrollbar {
    display: none;
  }

  .cast-card {
    flex: 0 0 102px;
    width: 102px;
    padding: 10px 8px;
  }

  /* Dashboard & Tables on Mobile (Zero Overflow!) */
  .dashboard-header {
    gap: 10px;
    margin-bottom: 16px;
  }

  .dashboard-header h1 {
    font-size: 20px;
    margin: 0 0 4px;
  }

  .dashboard-tabs {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 0 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .dashboard-tabs::-webkit-scrollbar {
    display: none;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .metric-card,
  .dash-card {
    padding: 14px;
    margin-bottom: 14px;
    overflow-x: auto;
  }

  .metric-value {
    font-size: 20px;
  }

  .live-sessions-grid,
  .device-sessions-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .activity-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .activity-filter-bar::-webkit-scrollbar {
    display: none;
  }

  .activity-filter-chip {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .shared-user-card {
    padding: 12px;
    gap: 10px;
  }

  .shared-user-actions {
    width: 100%;
  }

  .shared-user-actions button {
    flex: 1;
  }

  /* Bottom-sheet Modals on Phones */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .plex-modal {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }

  .plex-modal::before {
    content: '';
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    margin: 10px auto 2px;
    flex-shrink: 0;
  }

  .modal-header {
    padding: 10px 16px 12px;
  }

  .modal-body {
    padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .lib-type-grid {
    gap: 8px;
  }

  .lib-type-card {
    padding: 10px 6px;
    font-size: 12px;
  }

  .modal-footer .btn-primary,
  .modal-footer .btn-secondary {
    flex: 1;
  }

  .fix-match-item {
    flex-wrap: wrap;
  }

  .fix-match-item .btn-primary {
    width: 100%;
  }

  /* Clean Mobile Login Screen */
  .login-screen {
    padding: 16px;
    align-items: center;
  }

  .login-card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .empty-hero-card {
    padding: 22px 16px;
    margin: 8px auto;
  }

  .empty-hero-card h1 {
    font-size: 20px;
  }

  .empty-hero-actions .btn-primary,
  .empty-hero-actions .btn-secondary {
    width: 100%;
  }
}

/* Ultra-narrow phones (<= 350px) */
@media (max-width: 350px) {
  .poster-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nf-ctrl-btn {
    width: 38px;
    height: 38px;
  }
  .nf-ctrl-btn.hero {
    width: 50px;
    height: 50px;
  }
}
