:root {
  --bg: #0a0a0f;
  --bg-elevated: #14141c;
  --bg-card: #1c1c28;
  --border: #2a2a3a;
  --text: #f0f0f5;
  --text-dim: #9090a5;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  /* Premium admin design tokens — radii, shadows, glass, layered surfaces. */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --glass: rgba(26, 26, 38, 0.72);
  --card-hover: #22222f;
  --admin-sidebar-w: 244px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Navbar */
.navbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  user-select: none;
}

.navbar-actions { display: flex; gap: 1rem; align-items: center; }
.user-name { color: var(--text-dim); font-size: 0.95rem; }

/* Buttons */
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #0d9f6e; }

/* Suspension screen — forced logout for a blocked account */
.suspended-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-block { width: 100%; }

/* Inputs */
.input, select.input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.95rem;
  width: 100%;
  font-family: inherit;
}
.input:focus { outline: none; border-color: var(--primary); }
select.input { cursor: pointer; }

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}
.auth-card h1 { font-size: 2rem; margin-bottom: 0.4rem; }
.auth-card .subtitle { color: var(--text-dim); margin-bottom: 2rem; }

/* ─── Profiles: picker, manager, modals, avatar menu ────────────────── */
.ks-picker {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  gap: 2rem;
}
.ks-picker-title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.ks-picker-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  max-width: 880px;
}
.ks-picker-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  border-radius: var(--ks-radius-md);
  padding: 0.5rem;
  transition: transform 0.15s ease;
  outline: none;
}
.ks-picker-tile:hover,
.ks-picker-tile:focus-visible { transform: scale(1.06); }
.ks-pavatar {
  width: 116px;
  height: 116px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  user-select: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}
.ks-picker-tile:hover .ks-pavatar,
.ks-picker-tile:focus-visible .ks-pavatar {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.ks-pavatar--add {
  background: var(--ks-bg-2) !important;
  color: var(--ks-text-dim);
  font-size: 3.4rem;
  font-weight: 300;
  border: 2px dashed rgba(255, 255, 255, 0.25);
}
.ks-pavatar--header { width: 40px; height: 40px; border-radius: 8px; font-size: 1.1rem; }
.ks-picker-name {
  font-size: 1.05rem;
  color: var(--ks-text-dim);
  font-weight: 600;
}
.ks-picker-tile:hover .ks-picker-name { color: var(--ks-text); }
.ks-picker-kidstag {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
}
.ks-picker-editbadge {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  font-size: 0.95rem;
  z-index: 2;
}
.ks-picker-manage {
  background: transparent;
  border: 1px solid var(--ks-text-faded);
  color: var(--ks-text-dim);
  padding: 0.6rem 1.6rem;
  border-radius: var(--ks-radius-sm);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ks-picker-manage:hover { color: var(--ks-text); border-color: var(--ks-text); }
.ks-pin-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--ks-bg-1);
  border: 1px solid var(--border);
  border-radius: var(--ks-radius-md);
  padding: 1rem 1.4rem;
  max-width: 560px;
  width: 100%;
}
.ks-pin-info { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.ks-pin-info strong { color: var(--ks-text); font-size: 0.95rem; }
.ks-pin-info span { color: var(--ks-text-dim); font-size: 0.8rem; }
.ks-pin-btn {
  background: var(--ks-bg-2);
  border: 1px solid var(--border);
  color: var(--ks-text);
  padding: 0.5rem 1rem;
  border-radius: var(--ks-radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.ks-pin-btn:hover { border-color: var(--ks-text); }

/* Profile / PIN modals */
.ks-pmodal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
}
.ks-pmodal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.8rem;
  width: 100%;
  max-width: 420px;
}
.ks-pmodal h2 { font-size: 1.3rem; margin-bottom: 1.1rem; color: var(--ks-text); }
.ks-pmodal-hint { color: var(--ks-text-dim); font-size: 0.85rem; margin-bottom: 1rem; }
.ks-pmodal-msg { color: var(--ks-red); font-size: 0.8rem; min-height: 1rem; }
.ks-avatar-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ks-swatch {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.ks-swatch--on { border-color: #fff; outline: 2px solid rgba(255, 255, 255, 0.35); }
.ks-pmodal-kids {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.3rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--ks-text-dim);
  cursor: pointer;
}
.ks-pmodal-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.4rem;
}
.ks-pmodal-spacer { flex: 1; }
.ks-pbtn {
  border: 0;
  padding: 0.5rem 1.1rem;
  border-radius: var(--ks-radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.14s, opacity 0.14s;
}
.ks-pbtn:disabled { opacity: 0.5; cursor: default; }
.ks-pbtn--primary { background: var(--ks-red); color: #fff; }
.ks-pbtn--primary:hover:not(:disabled) { filter: brightness(1.12); }
.ks-pbtn--ghost { background: var(--ks-bg-2); color: var(--ks-text); }
.ks-pbtn--danger { background: transparent; color: var(--ks-red); border: 1px solid var(--ks-red); }
.ks-pbtn--danger:hover { background: rgba(229, 9, 20, 0.14); }

/* Header avatar dropdown */
.ks-avmenu { position: relative; }
.ks-avmenu-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  width: 230px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--ks-radius-md);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  padding: 0.4rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  z-index: 60;
}
.ks-avmenu--open .ks-avmenu-panel { opacity: 1; visibility: visible; transform: translateY(0); }
.ks-avmenu-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.3rem;
}
.ks-avmenu-head .ks-pavatar { width: 38px; height: 38px; border-radius: 8px; font-size: 1.05rem; }
.ks-avmenu-head strong { font-size: 0.9rem; color: var(--ks-text); }
.ks-avmenu-kids { font-size: 0.72rem; color: var(--ks-text-dim); }
.ks-avmenu-item {
  padding: 0.6rem;
  border-radius: var(--ks-radius-sm);
  font-size: 0.88rem;
  color: var(--ks-text-dim);
  cursor: pointer;
}
.ks-avmenu-item:hover { background: var(--ks-bg-2); color: var(--ks-text); }

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
}

.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* Sections */
.section { margin-bottom: 2.5rem; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.section-header h2 { font-size: 1.5rem; font-weight: 600; }

/* Library cards */
.libraries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.library-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.15s;
}
.library-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.library-card h3 { margin-bottom: 0.4rem; font-size: 1.15rem; }
.library-card .meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: capitalize;
}

/* Series detail view */
.series-banner {
  position: relative;
  height: 240px;
  margin: -1rem -1.5rem 0;
  background-size: cover;
  background-position: center 30%;
  border-radius: 0;
}
.series-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, var(--bg) 95%);
}
.series-header {
  display: flex;
  gap: 1.75rem;
  margin-bottom: 2rem;
  margin-top: -120px;
  position: relative;
  z-index: 1;
  align-items: flex-end;
}
.series-header-no-banner {
  margin-top: 1rem;
  align-items: flex-start;
}
.series-poster {
  flex: 0 0 200px;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.series-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.series-poster .placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 4rem; opacity: 0.3;
}
.series-info {
  flex: 1;
  min-width: 0;
  padding-bottom: 0.5rem;
}
.series-info h1 {
  font-size: 2rem;
  margin-bottom: 0.6rem;
  line-height: 1.15;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.series-meta-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
}
.series-meta-row .pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}
.series-overview {
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 1rem;
  max-width: 80ch;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.season-section { margin-bottom: 3rem; }
.season-title {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin-bottom: 1rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}
.season-count {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-dim);
}

/* Netflix-style horizontal scroll for episodes inside a season. */
.episodes-row {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-overflow-scrolling: touch;
}
.episodes-row::-webkit-scrollbar { height: 8px; }
.episodes-row::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.episodes-row::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
.episodes-row::-webkit-scrollbar-track { background: transparent; }
.episodes-row > .item-card {
  flex: 0 0 280px;
  scroll-snap-align: start;
}
.episodes-row > .item-card:hover {
  /* horizontal-scroll context clips translateY; keep the border + shadow. */
  transform: none;
}
@media (max-width: 720px) {
  .episodes-row > .item-card { flex: 0 0 220px; }
}
.orphans-title {
  font-size: 0.9rem;
  margin: 2.5rem 0 1rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

@media (max-width: 720px) {
  .series-banner { height: 160px; }
  .series-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: -80px;
  }
  .series-poster { flex: 0 0 auto; max-width: 160px; }
  .series-overview { -webkit-line-clamp: unset; }
}

/* Item cards (poster style) */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
}
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.item-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}
.poster-frame {
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #1c1c28, #2a2a3a);
  position: relative;
  overflow: hidden;
}
.poster-frame-still {
  aspect-ratio: 16 / 9;
}
.poster-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster-frame .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.3;
}
.poster-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Netflix-style progress bar overlay on Continue Watching cards. */
.progress-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}
.progress-bar {
  height: 100%;
  background: #e50914;
  transition: width 0.3s ease;
}
.item-info { padding: 0.7rem 0.8rem; }
.item-info .title {
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.item-info .meta { color: var(--text-dim); font-size: 0.78rem; }

/* Detail view */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 90;
  overflow-y: auto;
}
.detail-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  filter: blur(4px);
  z-index: 0;
}
.detail-content {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
}
.detail-poster {
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--bg-card);
}
.detail-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-info h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.detail-meta-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}
.detail-meta-row .pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.detail-overview {
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 1.5rem;
}
.detail-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.close-btn-fixed {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

@media (max-width: 720px) {
  .detail-content {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  .detail-poster { max-width: 200px; margin: 0 auto; }
}

/* Admin panel */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-table th, .admin-table td {
  padding: 0.9rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.admin-table th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.admin-table tbody tr { transition: background 0.13s; }
.admin-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .status-active { color: var(--success); font-weight: 500; }
.admin-table .status-expired { color: var(--danger); font-weight: 500; }
.admin-table .status-permanent { color: var(--text-dim); }

/* Premium user rows — avatar, status pills, expiration chips */
.admin-user-cell { display: flex; align-items: center; gap: 0.8rem; }
.admin-user-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.admin-user-ident { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.admin-user-name { font-weight: 600; font-size: 0.95rem; }
.admin-user-tags { display: flex; gap: 0.35rem; }
.badge-you {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.42rem;
  border-radius: 5px;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.admin-pill-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.admin-pill--ok      { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.28); }
.admin-pill--ok      .admin-pill-dot { background: var(--success); box-shadow: 0 0 7px rgba(16, 185, 129, 0.7); }
.admin-pill--warn    { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border-color: rgba(245, 158, 11, 0.28); }
.admin-pill--warn    .admin-pill-dot { background: var(--warning); box-shadow: 0 0 7px rgba(245, 158, 11, 0.7); }
.admin-pill--danger  { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.28); }
.admin-pill--danger  .admin-pill-dot { background: var(--danger); box-shadow: 0 0 7px rgba(239, 68, 68, 0.7); }
.admin-pill--neutral { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); border-color: var(--border); }
.admin-pill--neutral .admin-pill-dot { background: var(--text-dim); }

.admin-exp { display: flex; flex-direction: column; gap: 0.22rem; }
.admin-exp-date { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.admin-exp-chip {
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  padding: 0.1rem 0.42rem;
  width: fit-content;
}
.admin-exp-chip--soon { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.admin-exp-none { color: var(--text-dim); font-size: 0.88rem; }

/* ============================================================
   Admin panel — tabbed layout
   ============================================================ */

.admin-container { max-width: 1280px; }

.admin-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.admin-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.85rem 1.25rem;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.admin-tab:hover { color: var(--text); }
.admin-tab--active {
  color: var(--text);
  border-bottom-color: #6366f1;
}
.admin-tab-icon {
  font-size: 0.95rem;
  opacity: 0.85;
}

.admin-tab-content {
  min-height: 200px;
}
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.section-toolbar-title {
  font-size: 1.1rem;
  font-weight: 600;
}
/* Title-less toolbar — the topbar already names the tab, so this row
   just carries the actions. */
.section-toolbar--actions { justify-content: flex-start; gap: 0.85rem; }

/* Config tab — labelled section groups */
.admin-config-group { margin-bottom: 2.1rem; }
.admin-config-group:last-child { margin-bottom: 0; }
.admin-config-group-head { padding: 0 0.15rem; }
.admin-config-group-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.admin-config-group-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* ============================================================
   Premium admin shell — fixed sidebar + clean topbar
   ============================================================ */

.admin-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  width: var(--admin-sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.85rem;
  gap: 0.15rem;
}
.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.6rem 1.15rem;
}
.admin-brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.admin-brand-text { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.admin-brand-text small {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.admin-nav-item:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
.admin-nav-item--active {
  background: rgba(99, 102, 241, 0.14);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--primary);
}
.admin-nav-icon { font-size: 1rem; width: 1.25rem; text-align: center; opacity: 0.9; }
.admin-sidebar-spacer { flex: 1; }
.admin-sidebar-back {
  margin-top: 0.4rem;
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.9rem;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.admin-topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.admin-topbar-title .admin-topbar-icon { opacity: 0.6; }
.admin-content { padding: 1.9rem; flex: 1; min-width: 0; }
.admin-content > * { animation: adminFadeIn 0.28s ease; }
@keyframes adminFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    overflow-x: auto;
    padding: 0.6rem 0.8rem;
  }
  .admin-sidebar-brand { padding: 0.4rem 0.6rem; }
  .admin-sidebar-spacer { display: none; }
  .admin-sidebar-back { border-top: none; padding-top: 0; margin-top: 0; }
  .admin-nav-item { width: auto; }
  .admin-content { padding: 1.1rem; }
  .admin-topbar { padding: 1rem 1.1rem; }
}

/* ============================================================
   Dashboard tab — metric cards
   ============================================================ */

#dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 1.05rem;
}
.metric-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.6));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}
.metric-card:hover {
  border-color: rgba(255, 255, 255, 0.13);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.metric-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.metric-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.metric-dot--ok   { background: var(--success); box-shadow: 0 0 9px rgba(16, 185, 129, 0.65); }
.metric-dot--warn { background: var(--warning); box-shadow: 0 0 9px rgba(245, 158, 11, 0.65); }
.metric-dot--err  { background: var(--danger);  box-shadow: 0 0 9px rgba(239, 68, 68, 0.65); }
.metric-dot--idle { background: var(--text-dim); }
.metric-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.metric-value {
  font-size: 1.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.metric-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.metric-badge {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.metric-badge--live {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(110, 231, 183, 0.3);
}
.metric-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.metric-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ============================================================
   Health Center + admin sections + activity chart (Fase 2)
   ============================================================ */

.health-center {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(192px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.8rem;
}
.health-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.82rem 0.95rem;
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, transform 0.16s;
}
.health-chip:hover { transform: translateY(-1px); }
.health-chip-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.health-chip--ok   .health-chip-dot { background: var(--success); box-shadow: 0 0 9px rgba(16, 185, 129, 0.7); }
.health-chip--warn .health-chip-dot { background: var(--warning); box-shadow: 0 0 9px rgba(245, 158, 11, 0.7); }
.health-chip--err  .health-chip-dot { background: var(--danger);  box-shadow: 0 0 9px rgba(239, 68, 68, 0.7); }
.health-chip--warn { border-color: rgba(245, 158, 11, 0.3); }
.health-chip--err  { border-color: rgba(239, 68, 68, 0.32); }
.health-chip-body { min-width: 0; }
.health-chip-label { font-size: 0.87rem; font-weight: 600; }
.health-chip-detail {
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-section { margin-bottom: 1.9rem; }
.admin-section:last-child { margin-bottom: 0; }
.admin-section-head { margin-bottom: 0.9rem; }
.admin-section-title { font-size: 1.06rem; font-weight: 700; letter-spacing: -0.01em; }
.admin-section-sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.15rem; }
.admin-section-desc {
  font-size: 0.84rem;
  color: var(--text-dim);
  margin: -0.35rem 0 1.15rem;
  max-width: 760px;
  line-height: 1.55;
}
.admin-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(222px, 1fr));
  gap: 1.05rem;
}
.admin-section-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.activity-chart-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.5rem;
}
.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 120px;
}
.activity-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.activity-bar-track { width: 100%; height: 100%; display: flex; align-items: flex-end; }
.activity-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary), #ec4899);
  border-radius: 5px 5px 0 0;
  min-height: 4px;
  transition: height 0.45s ease, filter 0.13s;
}
.activity-col:hover .activity-bar { filter: brightness(1.25); }

/* ── Fase 3A — health 'na' state, queues, events, automations ── */
.health-chip--na { opacity: 0.72; }
.health-chip--na .health-chip-dot { background: var(--text-dim); box-shadow: none; }

.queue-strip { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-bottom: 1.1rem; }
.queue-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.queue-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.queue-pill--active .queue-pill-dot {
  background: var(--primary);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.7);
}
.queue-pill-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-pill-label { font-size: 0.82rem; color: var(--text-dim); }

.activity-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.05rem;
}
@media (max-width: 860px) { .activity-layout { grid-template-columns: 1fr; } }
.activity-chart-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 0.95rem;
}
.events-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.5rem;
}
.event-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.58rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}
.event-row:last-child { border-bottom: none; }
.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.32rem;
  flex-shrink: 0;
}
.event-dot--auth   { background: var(--primary); }
.event-dot--job    { background: var(--success); }
.event-dot--danger { background: var(--danger); }
.event-dot--info   { background: var(--text-dim); }
.event-body { min-width: 0; }
.event-action { font-size: 0.9rem; font-weight: 600; }
.event-meta { font-size: 0.76rem; color: var(--text-dim); margin-top: 0.12rem; }

.admin-empty {
  padding: 1.7rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.automation-list {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.automation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.3rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.13s;
}
.automation-row:last-child { border-bottom: none; }
.automation-row:hover { background: rgba(255, 255, 255, 0.022); }
.automation-name { font-weight: 600; font-size: 0.95rem; }
.automation-detail { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.15rem; }

/* ============================================================
   System tab — info cards (key / value pairs)
   ============================================================ */

.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.system-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.35rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.system-card:hover { border-color: rgba(255, 255, 255, 0.1); box-shadow: var(--shadow); }
.system-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.system-card-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.system-card-status {
  font-size: 0.72rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.system-card-status--ok {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(110, 231, 183, 0.3);
}
.system-card-status--err {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(252, 165, 165, 0.3);
}
.system-card-rows {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.system-card-row {
  display: grid;
  grid-template-columns: 0.85fr 1.4fr;
  gap: 0.5rem;
  font-size: 0.85rem;
  align-items: baseline;
}
.system-card-row-label {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.system-card-row-value {
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Scan jobs (Bibliotecas tab) — live progress cards
   ============================================================ */

.scan-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0.5rem 0 0.65rem;
}
.scan-section-title--muted { opacity: 0.7; }

.scan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
/* Recent scans grid: una card por library, sin logs, más respiro. */
.scan-grid--recent {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0;
}

/* Bucket header (Última hora / Hoy / Esta semana / Anterior).
 * Tipografía pequeña y discreta para no competir con los cards. */
.scan-time-group { margin-bottom: 1.25rem; }
.scan-time-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  opacity: 0.7;
  margin: 0 0 0.5rem 0.15rem;
}

/* Recent card: slim, single-line summary, sin progress / sin logs.
 * Background un escalón más oscuro que las cards activas para que el
 * scan en curso (si lo hay) tenga claro protagonismo visual. */
.scan-card--recent {
  padding: 0.85rem 1rem;
  gap: 0.35rem;
  background: var(--bg-elevated);
  border-color: rgba(255, 255, 255, 0.04);
}
.scan-card--recent .scan-card-title  { font-size: 1rem; }
.scan-card--recent .scan-card-summary {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.scan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* Fase B: padding matched to lib-card para ritmo vertical compartido */
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.scan-card--running {
  border-color: rgba(99, 102, 241, 0.35);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.04) 0%, var(--bg-card) 30%);
}

.scan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.scan-card-title { font-size: 1rem; font-weight: 600; }
.scan-card-meta  { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.15rem; }

.scan-status {
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.scan-status--running {
  color: #c4b5fd;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(196, 181, 253, 0.3);
}
.scan-status--ok {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(110, 231, 183, 0.3);
}
.scan-status--err {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(252, 165, 165, 0.3);
}
.scan-status--warn {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(252, 211, 77, 0.3);
}
.scan-card-stop {
  margin-top: 0.6rem;
  width: 100%;
  font-size: 0.82rem;
  padding: 0.4rem 0.6rem;
}
.scan-card-stop:disabled { opacity: 0.55; cursor: default; }

.scan-progress-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.scan-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.scan-progress-pct {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 3em;
  text-align: right;
}
/* Indeterminate variant — used during the pre-walk "counting" phase. */
.scan-progress-bar--indet { position: relative; }
.scan-progress-fill--indet {
  width: 30%;
  position: absolute;
  animation: scan-indet 1.3s ease-in-out infinite;
}
@keyframes scan-indet {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(170%); }
  100% { transform: translateX(-100%); }
}

.scan-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.scan-stat-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.scan-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}

.scan-current {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
}
.scan-current-label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  opacity: 0.75;
}
/* .scan-current-value deprecated — the current-folder display now uses
 * renderTwoLinePath / .path-two-line so the long Z:\🎬PACK… roots
 * break into parent (dim, fade-out) + tail (strong, ellipsis). */

/* ── Fase B: type-icon prefix en el title de scan cards ─────────────
 * NEUTRAL on purpose: type is communicated by the GLYPH shape (▶ ▤ ♪ ▢),
 * not by color. Keeps the palette restraint that lets the brand yellow
 * (Fase Z) ANCHOR as accent without competing with category colors. */
.scan-card-title-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.scan-card-title-text {
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scan-card-type-icon {
  display: inline-flex;
  width: 1.55rem;
  height: 1.55rem;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  line-height: 1;
}
.scan-card--recent .scan-card-title-text { font-size: 0.98rem; }
.scan-card--recent .scan-card-type-icon  {
  width: 1.35rem; height: 1.35rem; font-size: 0.82rem;
}

/* ── Fase B: two-line path (parent dim + tail strong + fade overflow) */
.path-two-line {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.path-two-line-parent {
  color: var(--text-dim);
  opacity: 0.6;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  /* Fade-out smooth on the right edge — more premium than the abrupt
   * ellipsis. Tail line below still uses ellipsis because the tail is
   * the IMPORTANT info we can't visually drop. */
  -webkit-mask-image: linear-gradient(to right, black 70%, transparent 100%);
          mask-image: linear-gradient(to right, black 70%, transparent 100%);
}
.path-two-line-tail {
  color: var(--text);
  font-weight: 500;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-logs {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  max-height: 110px;
  overflow-y: auto;
}
.scan-log-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-error {
  padding: 0.55rem 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(252, 165, 165, 0.3);
  border-radius: 6px;
  color: #fca5a5;
  font-size: 0.82rem;
}

/* ============================================================
   Bibliotecas tab — library cards with path-status indicators
   ============================================================ */

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1rem;
}
.lib-empty {
  padding: 2rem;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.lib-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Fase B: padding consolidated with scan-card for shared rhythm */
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}
.lib-card:hover {
  border-color: rgba(255, 255, 255, 0.13);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.lib-card--warn { border-color: rgba(252, 165, 165, 0.35); }
.lib-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.lib-card-title  { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.lib-card-meta   { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.3rem; }
.lib-card-warn-pill {
  color: #fca5a5;
  font-weight: 500;
  margin-left: 0.3rem;
}
.lib-card-type-pill {
  font-size: 0.72rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  white-space: nowrap;
}
/* (Variantes per-type neutralizadas — disciplina cromática premium.
 * El tipo se identifica por el ICONO de forma en el title, no por
 * color. Reservamos el color de marca (amarillo en Fase Z) para
 * accents brand puntuales, no como rainbow de categorías.) */
.lib-card-type-movies,
.lib-card-type-shows,
.lib-card-type-music,
.lib-card-type-photos {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.lib-paths {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.lib-path {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.84rem;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  transition: background 0.13s;
}
.lib-path:hover { background: rgba(255, 255, 255, 0.035); }
.lib-path-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.lib-path-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.lib-path-dot--ok  { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
.lib-path-dot--off { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }
.lib-path-remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.3rem;
  line-height: 1;
  font-family: inherit;
}
.lib-path-remove:hover { color: #fca5a5; }
.lib-path-add {
  align-self: flex-start;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
}

.lib-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border);
}

/* Compact "Más acciones" dropdown on library cards */
.lib-more { position: relative; }
.lib-more-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 232px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}
.lib-more--open .lib-more-menu { display: flex; animation: adminFadeIn 0.16s ease; }
.lib-more-menu .btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
}
.lib-more-menu .btn:hover { background: rgba(255, 255, 255, 0.055); }
.lib-more-menu .btn-danger { color: #fca5a5; }
.lib-more-menu .btn-danger:hover { background: rgba(239, 68, 68, 0.12); }
.lib-more-divider { height: 1px; background: var(--border); margin: 5px 4px; }

/* ============================================================
   Orphans modal + TMDB picker
   ============================================================ */

.modal-help {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
}

.orphan-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 60vh;
  overflow-y: auto;
}
.orphan-empty {
  color: var(--text-dim);
  padding: 1.5rem;
  text-align: center;
  font-style: italic;
}
.orphan-group {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.orphan-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.orphan-group-title {
  font-weight: 600;
  font-size: 0.98rem;
}
.orphan-group-year { color: var(--text-dim); font-weight: 400; }
.orphan-group-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  word-break: break-all;
}
.orphan-group-sample {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  opacity: 0.8;
}

.modal-overlay--top { align-items: flex-start; padding-top: 4rem; }

.tmdb-search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tmdb-search-bar .input { flex: 1; }

.tmdb-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
}
.tmdb-empty {
  color: var(--text-dim);
  padding: 1.5rem;
  text-align: center;
  font-style: italic;
}
.tmdb-result {
  display: flex;
  gap: 0.85rem;
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tmdb-result:hover {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.08);
}
.tmdb-result-poster {
  width: 60px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.tmdb-result-poster--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 1.2rem;
}
.tmdb-result-body { flex: 1; min-width: 0; }
.tmdb-result-title { font-weight: 600; font-size: 0.95rem; }
.tmdb-result-year  { color: var(--text-dim); font-weight: 400; }
.tmdb-result-orig {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
  font-style: italic;
}
.tmdb-result-overview {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  line-height: 1.4;
}
.tmdb-result-id {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  opacity: 0.6;
}

/* ============================================================
   Modal-wide + folder picker
   ============================================================ */

.modal-wide { max-width: 640px; }
.modal-picker { max-width: 720px; }

.modal-paths-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.025);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 0.25rem;
  min-height: 60px;
}
.modal-path-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
}
.modal-path-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

.picker-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.picker-current {
  flex: 1;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-list {
  max-height: 420px;
  min-height: 260px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.picker-entry {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}
.picker-entry:hover { background: rgba(255, 255, 255, 0.05); }
.picker-entry:last-child { border-bottom: none; }
.picker-entry-icon { opacity: 0.7; }
.picker-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* ============================================================
   Now-playing (live admin view) — Netflix-style activity cards
   ============================================================ */

.np-pill {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.np-pill--live {
  color: #6ee7b7;
  border-color: rgba(110, 231, 183, 0.35);
  background: rgba(16, 185, 129, 0.08);
  position: relative;
}
.np-pill--live::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 999px;
  background: #10b981;
  margin-right: 0.45rem;
  vertical-align: middle;
  animation: np-pulse 1.6s ease-in-out infinite;
}
@keyframes np-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.3); }
}

.np-empty {
  color: var(--text-dim);
  padding: 2rem 1rem;
  text-align: center;
  background: var(--bg-card);
  border-radius: 8px;
  font-size: 0.95rem;
}

.np-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.85rem;
}
@media (max-width: 720px) { .np-grid { grid-template-columns: 1fr; } }

.np-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.6));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.np-card:hover { border-color: rgba(255, 255, 255, 0.13); box-shadow: var(--shadow); }
.np-card--kicked { opacity: 0.5; }
.np-card--expanded { border-color: rgba(99, 102, 241, 0.4); }

/* Compact main row — poster · what's playing · who */
.np-main { display: flex; gap: 0.75rem; align-items: flex-start; }
.np-main-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.np-who { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; min-width: 0; }
.np-who-name { font-weight: 600; white-space: nowrap; }
.np-who-dev {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status + actions */
.np-status { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.np-actions { display: flex; gap: 0.5rem; align-items: center; }
.np-actions .btn { margin-left: auto; }
.np-detail-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.34rem 0.72rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.13s, border-color 0.13s, background 0.13s;
}
.np-detail-toggle:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

/* Collapsible advanced panel */
.np-adv {
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: adminFadeIn 0.18s ease;
}
.np-adv--hidden { display: none; }

/* Jellyfin-style summary header */
.np-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.np-summary-count { font-size: 1.05rem; color: var(--text-dim); }
.np-summary-count strong {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text);
  margin-right: 0.15rem;
}
.np-summary-chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.np-sumchip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.78rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: 0.84rem;
}
.np-sumchip-label { color: var(--text-dim); }
.np-sumchip-n { font-weight: 800; font-variant-numeric: tabular-nums; }
.np-sumchip--zero { opacity: 0.45; }

.np-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.np-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.np-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: #fff;
  flex-shrink: 0;
}
.np-username {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.np-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.np-card-body { display: flex; gap: 0.95rem; align-items: flex-start; }
.np-now-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.np-poster {
  width: 54px;
  flex-shrink: 0;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-sm);
}
.np-poster--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  opacity: 0.5;
}
.np-title    { font-size: 1.02rem; font-weight: 600; }
.np-subtitle { font-size: 0.85rem; color: var(--text-dim); }

/* Playback-state detail block */
.np-detail {
  margin-top: 0.95rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.np-detail-desc { font-size: 0.82rem; color: var(--text-dim); }
.np-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.45rem 1rem;
}
.np-detail-row { display: flex; flex-direction: column; gap: 0.15rem; }
.np-detail-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.np-conv { font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.np-from { color: var(--text-dim); }
.np-arrow { color: var(--primary); margin: 0 0.32rem; font-weight: 700; }
.np-to { color: var(--text); font-weight: 600; }
.np-direct-facts {
  font-size: 0.86rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.np-reasons { display: flex; flex-direction: column; gap: 0.4rem; }
.np-reasons-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.np-reason-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.np-reason-chip {
  font-size: 0.74rem;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #fca5a5;
}

.np-ffmpeg {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.np-ffmpeg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
  animation: npPulse 1.6s ease-in-out infinite;
}
@keyframes npPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.np-ffmpeg-label { font-weight: 600; }
.np-ffmpeg-bits { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.np-tag--strong { font-weight: 700; }

.np-progress { display: flex; flex-direction: column; gap: 0.35rem; }
.np-progress-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.np-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.np-time {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.np-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.np-tag {
  font-size: 0.74rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.np-tag--direct     { color: #6ee7b7; border-color: rgba(110, 231, 183, 0.3); background: rgba(16, 185, 129, 0.08); }
.np-tag--remux      { color: #fcd34d; border-color: rgba(252, 211, 77, 0.3); background: rgba(234, 179, 8, 0.08); }
.np-tag--transcode  { color: #93c5fd; border-color: rgba(147, 197, 253, 0.3); background: rgba(59, 130, 246, 0.08); }

/* Source-cache summary card — five labeled stats in a responsive grid. */
.cache-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.cache-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.cache-stat-value {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.25rem;
  word-break: break-all;
}
.admin-table .row-actions {
  display: flex;
  gap: 0.4rem;
}
.admin-table .row-actions .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}
.badge-admin {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.4rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.search-bar { width: 280px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
}
.empty h2 { color: var(--text); margin-bottom: 0.5rem; }
.empty p { margin-bottom: 1.5rem; }

/* Player */
.player-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.player-card {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  max-width: 1280px;
  /* Reserve a comfortable margin around the player so the controls bar
     reads as a clearly separate UI element instead of being squashed
     against the screen edge. */
  max-height: 88vh;
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
@media (max-width: 720px) {
  .player-overlay { padding: 0.75rem; }
  .player-card { max-height: 92vh; aspect-ratio: auto; }
}
.player-header {
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.player-header h2 {
  font-size: 1.1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Stage = the area that hosts the video + the controls overlay. In a card
   it caps to a sensible 16:9 size so the controls bar isn't dwarfed by the
   video. Fullscreen blows it up to fill the viewport. */
.player-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  min-height: 0;                 /* let flexbox actually shrink */
}

/* Netflix-style back button — minimalist white arrow, top-left, no heavy
   background. Inside the stage it auto-hides with the controls; the
   --static variant (error / image screens) stays visible. */
.ks-player-back {
  position: absolute;
  top: 1.2rem;
  left: 1.5rem;
  z-index: 30;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.12s ease;
}
.ks-player-back svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.9));
}
.ks-player-back:hover { transform: scale(1.12); }
.player-stage--cursor-on .ks-player-back { opacity: 1; pointer-events: auto; }
.ks-player-back--static { opacity: 1; pointer-events: auto; }
.player-stage video,
.player-stage audio {
  max-width: 100%;
  max-height: 100%;
  outline: none;
  display: block;
}

/* Suppress every native media-control overlay we can target via CSS.
   Browsers (Edge especially) sometimes inject a floating toolbar with
   "Picture in picture", "Translate audio", "Enhance video", etc., even
   when the <video> has no `controls` attribute. Hiding the shadow-DOM
   pseudo-elements that back those overlays takes care of Chromium /
   WebKit. Edge's AI-features overlay is enforced outside the page and
   cannot be hidden from the document — see notes in the JS file. */
.player-stage video::-webkit-media-controls,
.player-stage video::-webkit-media-controls-panel,
.player-stage video::-webkit-media-controls-enclosure,
.player-stage video::-webkit-media-controls-overlay-enclosure,
.player-stage video::-webkit-media-controls-overlay-play-button,
.player-stage video::-webkit-media-controls-start-playback-button,
.player-stage video::-internal-media-controls-overflow-button,
.player-stage video::-internal-media-controls-download-button,
.player-stage video::-internal-media-controls-overflow-menu-list {
  display: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.player-stage video { width: auto; height: 100%; }
.player-stage audio { width: 100%; max-width: 600px; }

/* Seek/restart spinner — shown while restartSession is in flight. Hidden
   by [hidden] attribute toggled from JS. Pointer-events: none so the user
   can still click controls underneath. */
.player-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  pointer-events: none;
  z-index: 5;
}
.player-spinner[hidden] { display: none; }
.player-spinner__ring {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  border-radius: 50%;
  animation: player-spinner-rot 0.9s linear infinite;
}
.player-spinner__label {
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  opacity: 0.9;
}
@keyframes player-spinner-rot {
  to { transform: rotate(360deg); }
}

/* Real fullscreen (Fullscreen API on stageEl). Both vendor prefixes are
   listed so older Safari / WebKit also get it. Cursor hide while controls
   are hidden mirrors the Netflix UX. */
.player-stage:fullscreen:not(.player-stage--cursor-on) video,
.player-stage:-webkit-full-screen:not(.player-stage--cursor-on) video {
  cursor: none;
}
.player-stage:fullscreen,
.player-stage:-webkit-full-screen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  background: #000;
}
.player-stage:fullscreen video,
.player-stage:-webkit-full-screen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ====================================================================
   Custom video controls — Netflix-style overlay
   ==================================================================== */

/* Controls bar — hidden by default in both modes; the `--visible` class
   (added by JS on mousemove / pause / hover) fades it in. Auto-hide is the
   same in normal mode and fullscreen so the UX is consistent. */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1.5rem 1rem;
  background: linear-gradient(to top,
    rgba(0,0,0,0.92) 0%,
    rgba(0,0,0,0.65) 50%,
    rgba(0,0,0,0.0) 100%);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  z-index: 5;
  user-select: none;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.player-controls--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.pc-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pc-buttons-row { gap: 0.35rem; }
.pc-spacer { flex: 1; }

/* ---- timeline ---- */
.pc-timeline {
  position: relative;
  width: 100%;
  height: 18px;                /* big hitbox, the visual track is centered */
  cursor: pointer;
  display: flex;
  align-items: center;
  touch-action: none;          /* let pointermove control the seek */
}
.pc-tl-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  overflow: hidden;
  transition: height 0.15s ease;
}
.pc-tl-buffer {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgba(255, 255, 255, 0.45);
}
.pc-tl-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: #e50914;          /* Netflix red */
  border-radius: 2px;
}
.pc-tl-thumb {
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e50914;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 0 0 4px rgba(229, 9, 20, 0.18);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.pc-timeline:hover .pc-tl-track,
.pc-timeline:focus-within .pc-tl-track {
  height: 6px;
}
.pc-timeline:hover .pc-tl-thumb {
  transform: translate(-50%, -50%) scale(1);
}

/* ---- buttons ---- */
.pc-btn {
  background: transparent;
  border: 0;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  font-family: inherit;
  line-height: 0;              /* no extra height around the SVG */
  transition: background 0.12s, transform 0.08s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pc-btn:hover { background: rgba(255, 255, 255, 0.18); }
.pc-btn:active { transform: scale(0.92); }
.pc-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pc-btn-lg { padding: 0.55rem; }     /* the play/pause is slightly larger */

/* ---- time + select ---- */
.pc-time {
  color: white;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  margin-left: 0.6rem;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
/* The right-cluster contains mute/vol + audio + subs + quality + fullscreen.
   It's its own flex box so the group never breaks apart, and is pinned to
   the right with `margin-left: auto`. */
.pc-right-cluster {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ---- track-picker (audio / subtitles / quality) popups ---- */
.pc-track-wrap {
  position: relative;            /* anchor for the popup */
  display: inline-flex;
}
.pc-btn--open { background: rgba(255, 255, 255, 0.22); }

.pc-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);     /* float just above the controls bar */
  background: rgba(20, 20, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0.35rem 0;
  min-width: 220px;
  max-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  z-index: 10;
}
.pc-menu[hidden] { display: none !important; }

.pc-menu-header {
  padding: 0.5rem 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pc-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.pc-menu-item:hover { background: rgba(255, 255, 255, 0.1); }
.pc-menu-item--active { color: #e50914; }
.pc-menu-check {
  display: inline-block;
  width: 1em;
  text-align: center;
  font-size: 0.85em;
}

/* ---- volume slider ---- */
.pc-volume {
  width: 100px;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  margin: 0 0.25rem;
}
.pc-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  border: 0;
  cursor: pointer;
}
.pc-volume::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  border: 0;
  cursor: pointer;
}

@media (max-width: 720px) {
  .player-controls { padding: 0.5rem 0.75rem 0.75rem; gap: 0.4rem; }
  .pc-buttons-row { flex-wrap: wrap; gap: 0.15rem; }
  .pc-volume { width: 60px; }
  .pc-time { font-size: 0.8rem; margin-left: 0.3rem; }
  .pc-menu { min-width: 180px; max-width: calc(100vw - 2rem); }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 480px;
}
.modal h2 { margin-bottom: 1.5rem; font-size: 1.4rem; }
.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
}

/* ============================================================
   Resume-or-restart modal
   ============================================================ */

.modal--resume {
  max-width: 420px;
}
.modal-actions--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}
.modal-actions--stack .btn {
  width: 100%;
  justify-content: center;
  display: inline-flex;
  gap: 0.35em;
}

/* ============================================================
   Pre-transcode admin section
   ============================================================ */

.pretranscode-section { margin-top: 2.5rem; }
.pretranscode-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.pretranscode-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.pretranscode-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pretranscode-stat-label {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.pt-status--queued   { color: #f59e0b; }
.pt-status--encoding { color: #6366f1; }
.pt-status--ready    { color: #22c55e; }
.pt-status--failed   { color: #ef4444; }
.pt-status--neutral  { color: var(--text); }

.pretranscode-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pretranscode-table thead th {
  text-align: left;
  padding: 0.65rem 0.85rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.pretranscode-table tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.pretranscode-title { font-weight: 500; }
.pretranscode-size,
.pretranscode-date { color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pretranscode-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.pt-status-pill {
  display: inline-block;
  padding: 0.2em 0.55em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ============================================================
   Config tab (admin settings)
   ============================================================ */

.config-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(20, 20, 28, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin: 1.1rem 0;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.config-card:hover { border-color: rgba(255, 255, 255, 0.1); box-shadow: var(--shadow); }
.config-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.7rem;
  margin-bottom: 0.95rem;
  gap: 0.75rem;
}
.config-card-title {
  font-weight: 600;
  font-size: 1.05rem;
}
.config-source-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2em 0.55em;
  border-radius: 999px;
}
.config-source-tag--db      { background: rgba(99, 102, 241, 0.18); color: #c7c8ff; }
.config-source-tag--env     { background: rgba(255, 255, 255, 0.06); color: var(--text-dim); }
.config-source-tag--default { background: rgba(255, 255, 255, 0.04); color: var(--text-dim); }

.config-card-body { display: flex; flex-direction: column; gap: 0.85rem; }
.config-help {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.45;
}
.config-help a { color: #6366f1; text-decoration: none; }
.config-help a:hover { text-decoration: underline; }
.config-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.config-row label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.config-current {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  padding: 0.4em 0.7em;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  display: inline-block;
}
.config-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.3rem;
}
.config-test-result {
  min-height: 1.2em;
  font-size: 0.88rem;
}

/* ============================================================
   Library auto-scan schedule strip
   ============================================================ */

.schedule-strip {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.schedule-strip__status {
  flex: 1;
  min-width: 200px;
}
.schedule-strip__title {
  font-weight: 600;
  font-size: 0.95rem;
}
.schedule-strip__sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}
.schedule-strip__controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.schedule-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.88rem;
}
.schedule-toggle input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: #6366f1;
  cursor: pointer;
}
@media (max-width: 640px) {
  .schedule-strip__controls { width: 100%; }
}

/* ============================================================
   Watch history dashboard
   ============================================================ */

.history-container {
  padding-bottom: 4rem;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.history-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: left;
}
.history-stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.history-stat-label {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.history-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 1.5rem 0 0.75rem;
}
.history-top-series { margin-bottom: 1.5rem; }
.history-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}
.history-top-card {
  display: flex;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  align-items: center;
}
.history-top-poster {
  width: 56px; height: 84px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
}
.history-top-poster--empty { background: rgba(255, 255, 255, 0.06); }
.history-top-body { min-width: 0; flex: 1; }
.history-top-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-top-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.history-list-wrap { margin-top: 1rem; }
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.history-row {
  display: flex;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.history-row:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.history-poster {
  width: 100px; height: 56px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
}
.history-poster--empty { background: rgba(255, 255, 255, 0.06); }
.history-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.history-title {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.history-meta-sep { opacity: 0.5; }
.history-bar {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 0.25rem;
  overflow: hidden;
}
.history-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: 3px;
}
.history-bar--partial { background: linear-gradient(90deg, #6366f1, #818cf8); }
.history-bar--done    { background: linear-gradient(90deg, #16a34a, #22c55e); }
.history-bar-label {
  position: absolute;
  right: 6px;
  top: -16px;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .history-poster { width: 80px; height: 45px; }
  .history-title { font-size: 0.92rem; }
  .history-subtitle { font-size: 0.8rem; }
}

/* ============================================================
   Backup admin section
   ============================================================ */

.backup-section {
  margin-top: 2rem;
}
.backup-schedule {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin: 0.75rem 0;
  font-size: 0.92rem;
}
.backup-schedule .muted { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.3rem; }
.backup-schedule code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.85em;
}
.backup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.backup-table thead th {
  text-align: left;
  padding: 0.65rem 0.85rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.backup-table tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.backup-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.backup-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}
.backup-date {
  white-space: nowrap;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.backup-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* ============================================================
   Cast + AirPlay buttons
   ============================================================

   Both buttons reuse the .pc-btn base. The connected-cast state
   tints the icon so the user can spot at a glance that a remote
   device is in charge of playback.
*/
.pc-cast-btn,
.pc-airplay-btn {
  /* No structural overrides — the .pc-btn base covers sizing. */
}
.pc-cast-btn--connected {
  color: #4dabf7;
  /* Pulse the icon while a cast session is live. Subtle so it
     doesn't distract during playback. */
  animation: castPulse 2.2s ease-in-out infinite;
}
@keyframes castPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

/* ============================================================
   Audit log tab
   ============================================================ */

.audit-filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1.2rem;
  align-items: flex-end;
  padding: 1rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.audit-filter-label {
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  gap: 0.35rem;
  font-weight: 600;
}
.audit-filter-select {
  min-width: 210px;
}

.audit-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.audit-table thead th {
  text-align: left;
  padding: 0.7rem 0.85rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  position: sticky;
  top: 0;
  z-index: 1;
}
.audit-table tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: top;
}
.audit-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
.audit-cell-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.audit-cell-action { white-space: nowrap; }
.audit-action {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.audit-action--auth        { background: rgba(99,  102, 241, 0.18); color: #c7c8ff; }
.audit-action--destructive { background: rgba(239, 68,  68,  0.18); color: #ffc7c7; }
.audit-action--job         { background: rgba(34,  197, 94,  0.18); color: #c8ffd6; }
.audit-action--info        { /* default neutral */ }
.audit-cell-target {
  white-space: nowrap;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}
.audit-cell-ip {
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.audit-cell-detail {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.audit-anon { color: var(--text-dim); font-style: italic; }

/* ============================================================
   Skip-intro button + Next-episode card
   ============================================================

   Both live inside `.player-stage` (so they participate in
   fullscreen) and sit above the video but below the controls
   bar / spinner (z=4 vs the bar's z=5).
*/

.player-skip-intro {
  position: absolute;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(5rem, 12vh, 7rem);   /* above the controls bar */
  z-index: 4;
  padding: 0.75rem 1.4rem;
  background: rgba(20, 20, 28, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.player-skip-intro:hover {
  background: rgba(99, 102, 241, 0.85);
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.player-next-card {
  position: absolute;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(5rem, 12vh, 7rem);
  z-index: 4;
  max-width: 360px;
  background: rgba(15, 15, 22, 0.92);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  animation: nextCardSlideIn 0.25s ease-out;
}
.player-next-card--countdown {
  /* Countdown mode promotes the card slightly so the user notices
     the auto-advance is about to fire. */
  max-width: 420px;
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.25);
}
.player-next-card__inner {
  display: flex;
  gap: 0.85rem;
  align-items: stretch;
}
.player-next-card__poster {
  width: 88px;
  height: 132px;
  object-fit: cover;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}
.player-next-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
}
.player-next-card__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.player-next-card__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  /* Two-line clamp keeps the card from stretching on long titles. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.player-next-card__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  flex-wrap: wrap;
}
.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

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

/* On phones the card moves to the top so it doesn't overlap the
   tall mobile controls bar. */
@media (max-width: 640px) {
  .player-next-card,
  .player-skip-intro {
    right: 0.75rem;
    bottom: auto;
    top: 0.75rem;
  }
  .player-next-card { max-width: calc(100vw - 1.5rem); }
  .player-next-card__poster { width: 64px; height: 96px; }
}

/* ============================================================
   Movie outro — minimised player + "what's next" card
   ============================================================

   When a film hits the credits the stage gets `--outro`: the <video>
   shrinks into the bottom-left corner (transform animated), an ambient
   blurred backdrop fades in, the controls bar fades out, and a big
   recommendation card slides up. Everything is GPU-cheap (transform +
   opacity) so the player stays smooth.
*/

/* The video tucked into the corner. The actual translate+scale transform
   is set inline from live geometry; CSS only owns the transition + chrome. */
.player-stage--outro video {
  z-index: 6;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7);
  cursor: pointer;
}
.player-stage video {
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ambient backdrop: a blurred still of the recommended title behind a
   dark gradient. `--outro-art` is set inline (or stays unset → plain dim). */
.player-outro-dim {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    linear-gradient(105deg, rgba(8, 8, 12, 0.97) 0%, rgba(8, 8, 12, 0.6) 55%, rgba(8, 8, 12, 0.85) 100%),
    #07070b;
  animation: outroDimIn 0.5s ease-out;
}
.player-outro-dim::before {
  content: '';
  position: absolute;
  inset: -40px;                 /* overscan so the blur has no hard edge */
  background-image: var(--outro-art, none);
  background-size: cover;
  background-position: center;
  filter: blur(34px) brightness(0.45) saturate(1.1);
  opacity: 0.55;
  z-index: -1;
}
@keyframes outroDimIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Controls bar fades away in outro mode (whatever its own class is). */
.player-controls--hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.35s ease;
}

/* The post-credits trailer carousel — a big panel on the right that
   auto-plays each suggestion's trailer and cycles through them. */
.player-rec-card {
  position: absolute;
  z-index: 7;
  right: clamp(1rem, 4vw, 4rem);
  top: 50%;
  transform: translateY(-50%);
  width: clamp(340px, 46vw, 680px);
  background: rgba(16, 16, 24, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(14px);
  animation: recCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes recCardIn {
  from { opacity: 0; transform: translateY(-50%) translateX(34px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* 16:9 trailer stage — backdrop image by default, YouTube trailer on top. */
.player-rec-card__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.player-rec-card__art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}
.player-rec-card__video {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.player-rec-card--playing .player-rec-card__video { opacity: 1; }
/* Over-scan the iframe so YouTube's title bar / watermark sit off-screen. */
.player-rec-card__video iframe {
  position: absolute;
  top: -7%;
  left: -7%;
  width: 114%;
  height: 114%;
  border: 0;
  pointer-events: none;
}
.player-rec-card__badge {
  position: absolute;
  top: 0.8rem;
  left: 0.9rem;
  z-index: 2;
  background: rgba(99, 102, 241, 0.95);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.34rem 0.72rem;
  border-radius: 6px;
}
.player-rec-card__mute {
  position: absolute;
  bottom: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.player-rec-card__mute:hover { background: rgba(0, 0, 0, 0.85); transform: scale(1.06); }

.player-rec-card__body {
  padding: 1rem 1.3rem 0.6rem;
  color: #fff;
}
.player-rec-card__title {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.player-rec-card__meta {
  font-size: 0.86rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}
.player-rec-card__overview {
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  margin-top: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.player-rec-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

/* Carousel position dots. */
.player-rec-card__dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0.3rem 0 0.9rem;
}
.player-rec-card__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: width 0.25s ease, background 0.25s ease;
}
.player-rec-card__dot.is-active {
  width: 18px;
  border-radius: 4px;
  background: #fff;
}

/* On phones the panel spans the width along the bottom. */
@media (max-width: 720px) {
  .player-rec-card {
    right: 0.6rem;
    left: 0.6rem;
    top: auto;
    bottom: 0.6rem;
    width: auto;
    transform: none;
    animation: recCardInMobile 0.4s ease-out;
  }
  .player-rec-card__title { font-size: 1.15rem; }
  .player-rec-card__overview { -webkit-line-clamp: 2; }
}
@keyframes recCardInMobile {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Subtitles — custom JS-rendered overlay
   ============================================================

   The native `<track>` rendering is bypassed (track.mode = 'hidden').
   The active cues are written into `.player-subs-overlay` so we can
   style them freely. Size / color / background / outline are all
   class variants; position offset is a CSS variable.
*/

.player-subs-overlay {
  position: absolute;
  left: 0;
  right: 0;
  /* `--sub-offset-y` is set per-user via JS (default 5%). The bottom
     padding lifts subs off the controls bar without overlapping the
     video itself. */
  bottom: var(--sub-offset-y, 5%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  padding: 0 5%;
  pointer-events: none;          /* never block clicks on the video / controls */
  z-index: 4;                    /* above video, below controls (z=5) */
  text-align: center;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.005em;
  user-select: none;
}
.player-subs-line {
  /* Background variants below add their own padding; this is the base. */
  padding: 0.15em 0.55em;
  border-radius: 4px;
  /* The natural line break behaviour for VTT cues: respect <br> from
     sanitizeWebVttText but never overflow horizontally. */
  max-width: 100%;
  word-wrap: break-word;
}
/* Italic / bold preserved from VTT — selectors target our sanitized output. */
.player-subs-line i, .player-subs-line em { font-style: italic; }
.player-subs-line b, .player-subs-line strong { font-weight: 800; }

/* Size variants. Each is a viewport-relative `clamp()` so subs scale
   gracefully on a 5" phone screen and a 27" TV monitor alike, with
   sensible floors and ceilings. */
.sub-size-sm { font-size: clamp(13px, 1.8vw, 20px); }
.sub-size-md { font-size: clamp(15px, 2.4vw, 26px); }
.sub-size-lg { font-size: clamp(18px, 3.2vw, 34px); }
.sub-size-xl { font-size: clamp(22px, 4.2vw, 44px); }

/* Color variants — yellow is the classic SDH choice, cyan the gaming pick. */
.sub-color-white  { color: #ffffff; }
.sub-color-yellow { color: #ffd954; }
.sub-color-cyan   { color: #5ee8ff; }

/* Background variants — `dim` is the most readable default over varied
   scenes; `solid` is for video that has bright/textured backgrounds. */
.sub-bg-none   .player-subs-line { background: transparent; }
.sub-bg-dim    .player-subs-line { background: rgba(0, 0, 0, 0.55); }
.sub-bg-solid  .player-subs-line { background: rgba(0, 0, 0, 0.85); }

/* Outline variant. text-shadow with a 4-corner ring is the cheap way
   to keep light text readable over light backgrounds without needing
   a stroke that browsers handle inconsistently. */
.sub-outline .player-subs-line {
  text-shadow:
    -1px -1px 0 #000, 1px -1px 0 #000,
    -1px  1px 0 #000, 1px  1px 0 #000,
     0px -2px 4px rgba(0,0,0,0.6),
     0px  2px 4px rgba(0,0,0,0.6);
}

/* Font family — kept generic so it falls back to the platform's UI font. */
.sub-font-sans  { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.sub-font-serif { font-family: Georgia, 'Times New Roman', serif; }

/* ============================================================
   Subtitle settings modal — radio pills + slider
   ============================================================ */

.sub-settings-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.5rem 0;
}
.sub-setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sub-setting-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.sub-setting-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.sub-setting-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.sub-setting-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.sub-setting-pill--active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.6);
  color: #fff;
}
.sub-setting-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.sub-setting-slider {
  flex: 1;
  accent-color: #6366f1;
}
.sub-setting-value {
  font-variant-numeric: tabular-nums;
  min-width: 3em;
  text-align: right;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Track-picker menu divider + meta item used by the "⚙ Personalizar" entry */
.pc-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.5rem;
}
.pc-menu-item--meta {
  color: var(--text-dim);
  font-size: 0.88rem;
}
.pc-menu-item--meta:hover { color: var(--text); }

/* ============================================================
   Mobile responsive — phone + tablet
   ============================================================

   Two breakpoints:
     - ≤ 1024px (tablet / smaller laptops): tighten gaps, hide a few
       chrome elements that compete for space.
     - ≤ 640px (phone portrait): touch-first — 44px+ tap targets,
       stacked controls, single-column grids, full-bleed modals.

   The mobile player is the highest-impact bit. The default player
   bar at 32px buttons is unusable on a phone — phones get 48px
   touch targets and chunky spacing. Native fullscreen + landscape
   lock is recommended (handled by the JS on `f` key / button tap).
*/

@media (max-width: 1024px) {
  .container { padding: 1.25rem; }
  .libraries-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.85rem;
  }
  .admin-tabs {
    /* Already scrollable horizontally via overflow-x: auto from the
       desktop styles; just nudge spacing for tablet. */
    padding-bottom: 2px;
  }
}

@media (max-width: 640px) {
  /* ── Layout ──────────────────────────────────────────────────────── */
  .container { padding: 0.75rem; }
  .navbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .navbar h1 { font-size: 1.1rem; }
  .navbar-actions { gap: 0.4rem; }
  .navbar-actions .btn { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

  .search-bar { width: 100%; }
  .auth-card { padding: 1.25rem; }

  .section-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .section-header h2 { font-size: 1.1rem; }
  .toolbar { width: 100%; flex-wrap: wrap; }
  .toolbar .btn { flex: 1 1 auto; min-height: 40px; }

  /* ── Library grids → 2 cols on phones ───────────────────────────── */
  .libraries-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }
  /* Smaller poster cards so they actually fit. */
  .library-card { padding: 0.75rem; }
  .library-card-title { font-size: 0.9rem; }

  /* ── Item / poster grids → 3 cols, no chrome bloat ──────────────── */
  [class*="-grid"]:not(.libraries-grid):not(.admin-tabs):not(.dashboard-grid):not(.np-grid):not(.lib-grid):not(.system-grid):not(.scan-grid) {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    gap: 0.5rem !important;
  }
  /* Now-playing + library admin: 1 column on phone — cards are too
     content-dense to share a row. */
  .np-grid, .lib-grid, .system-grid, .scan-grid {
    grid-template-columns: 1fr !important;
  }
  /* Dashboard metric cards: 2 cols (was 4-5 desktop). */
  #dashboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .metric-value { font-size: 1.4rem; }

  /* ── Admin tabs: bigger, horizontally scrollable ─────────────────── */
  .admin-tabs {
    /* Snap to button starts so the user can flick through tabs naturally. */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .admin-tab {
    padding: 0.95rem 1rem;
    font-size: 0.88rem;
    scroll-snap-align: start;
    min-height: 44px;
  }

  /* ── Modals: full-bleed on phone ────────────────────────────────── */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal, .modal-wide, .modal-picker {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    padding: 1rem;
    overflow-y: auto;
  }
  .modal h2 { font-size: 1.1rem; }
  .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    padding: 0.75rem 0;
    margin: 0.5rem -1rem -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-top: 1px solid var(--border);
  }
  .modal-actions .btn { flex: 1; min-height: 44px; }

  /* ── Form inputs need to be 16px+ to avoid iOS zoom-on-focus ───── */
  .input, input, select, textarea { font-size: 16px !important; min-height: 44px; }

  /* ── Player controls — touch-first ──────────────────────────────── */
  .pc-bar {
    /* Stack controls vertically: timeline on top, button row below. */
    padding: 0.75rem 0.85rem 1rem;
    gap: 0.6rem;
  }
  .pc-btn, .pc-btn-lg {
    /* Apple HIG / Material both recommend 44px minimum for tap targets.
       Default `.pc-btn` at desktop is 32-36px. Bump explicitly. */
    min-width: 44px;
    min-height: 44px;
    padding: 0.55rem;
  }
  .pc-btn-lg { min-width: 56px; min-height: 56px; padding: 0.75rem; }
  .pc-btn svg { width: 24px; height: 24px; }
  .pc-btn-lg svg { width: 32px; height: 32px; }

  /* Timeline: taller hit area for finger dragging. */
  .pc-timeline {
    height: 14px;
    padding: 8px 0;
  }
  .pc-timeline-fill { height: 4px; }
  .pc-timeline-thumb {
    width: 16px; height: 16px;
    /* Bigger invisible hit area around the thumb */
    box-shadow: 0 0 0 8px transparent;
  }

  /* Volume slider hidden on phone — flip mute / use device volume. */
  .pc-volume-wrap { display: none; }

  /* Track-picker menus: drop-up sheet style instead of cramped tooltip */
  .pc-menu {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 60vh;
    border-radius: 12px 12px 0 0;
    padding: 0.75rem 0.5rem 1.25rem;
    overflow-y: auto;
  }
  .pc-menu-item { padding: 0.85rem 1rem; min-height: 44px; }

  /* Title meta in the player header — give it more breathing room */
  .player-header h2 { font-size: 1.05rem; }
  .player-header .meta { font-size: 0.78rem; }

  /* ── Now-playing card stays scannable on a small screen ─────────── */
  .np-card { padding: 0.85rem; }
  .np-title { font-size: 0.95rem; }
  .np-tags { gap: 0.3rem; }
  .np-tag { font-size: 0.7rem; padding: 0.2rem 0.5rem; }

  /* ── Tables (admin) become scroll-x containers ─────────────────── */
  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ── Landscape phone tweaks (limited vertical real estate) ─────────── */
@media (max-width: 920px) and (orientation: landscape) and (max-height: 500px) {
  /* Hide non-essential player chrome to maximise video viewport. */
  .player-header .meta { display: none; }
  .pc-bar { padding: 0.4rem 0.6rem 0.6rem; }
  .pc-timeline { height: 10px; }
}

/* ── Reduce-motion respect (a11y baseline) ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════════════════════════════════════════
   PREMIUM KINGSNET THEME — Netflix-vibe rework
   Dark + crimson + blue glow. Full-app shell with sidebar + header,
   hero, horizontal rows. Layered ON TOP of the legacy styles above;
   the legacy `.navbar`, `.libraries-grid`, etc. are kept intact so the
   routes I haven't rebuilt yet (admin, library detail) keep working.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Override the legacy palette with the premium one. Class-based
     selectors above still use --bg/--text/etc., so they pick these up. */
  --bg: #08080c;
  --bg-elevated: #11111a;
  --bg-card: #18182a;
  --border: #22223a;
  --text: #f5f5fa;
  --text-dim: #a0a0b5;
  --primary: #e50914;
  --primary-hover: #c20810;
  --danger: #ef4444;
  --success: #10b981;

  /* Premium-theme-only tokens (`ks-` prefix). */
  --ks-bg-0: #08080c;
  --ks-bg-1: #11111a;
  --ks-bg-2: #18182a;
  --ks-bg-3: #232338;
  --ks-bg-hover: #2a2a44;
  --ks-red: #e50914;
  --ks-red-deep: #b81d24;
  --ks-red-glow: rgba(229, 9, 20, 0.35);
  --ks-blue-glow: rgba(64, 156, 255, 0.28);
  --ks-text: #f5f5fa;
  --ks-text-dim: #a0a0b5;
  --ks-text-faded: #6c6c80;
  --ks-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);
  --ks-radius-sm: 6px;
  --ks-radius-md: 10px;
  --ks-radius-lg: 14px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--ks-bg-0);
}

/* Hide scrollbars across the whole app — Netflix-style. */
* { scrollbar-width: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ─── App shell ──────────────────────────────────────────────────────── */
.ks-app {
  display: grid;
  grid-template-columns: 88px 1fr;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(229, 9, 20, 0.08), transparent 60%),
    radial-gradient(900px 700px at -10% 30%, rgba(64, 156, 255, 0.04), transparent 60%),
    var(--ks-bg-0);
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.ks-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--ks-bg-1), var(--ks-bg-0));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0 1rem;
  gap: 0.25rem;
  z-index: 20;
}
.ks-sidebar-logo {
  width: 44px;
  height: 44px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ks-red), var(--ks-red-deep));
  color: white;
  font-weight: 800;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--ks-red-glow);
  transition: transform 0.18s;
}
.ks-sidebar-logo:hover { transform: scale(1.06); }
.ks-sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.4rem 0.4rem;
  margin: 0 0.5rem;
  border-radius: var(--ks-radius-md);
  color: var(--ks-text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  gap: 0.25rem;
  text-align: center;
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  user-select: none;
  text-transform: uppercase;
}
.ks-sidebar-item:hover { background: var(--ks-bg-2); color: var(--ks-text); }
.ks-sidebar-item--active {
  background: linear-gradient(180deg, rgba(229, 9, 20, 0.15), rgba(229, 9, 20, 0.05));
  color: var(--ks-red);
  position: relative;
}
.ks-sidebar-item--active::before {
  content: "";
  position: absolute;
  left: -0.5rem;
  top: 22%;
  bottom: 22%;
  width: 3px;
  background: var(--ks-red);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--ks-red-glow);
}
.ks-sidebar-item--disabled { opacity: 0.4; cursor: not-allowed; }
.ks-sidebar-icon { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.ks-sidebar-spacer { flex: 1; }

/* ─── Sidebar "Plataformas" collapsible dropdown ────────────────────── */
.ks-sidebar-group { display: flex; flex-direction: column; gap: 0.25rem; }
.ks-sidebar-caret {
  width: 12px; height: 12px; fill: currentColor; opacity: 0.55;
  transition: transform 0.22s ease;
}
.ks-sidebar-group--open .ks-sidebar-caret { transform: rotate(180deg); }
.ks-sidebar-sub {
  display: flex; flex-direction: column; gap: 0.15rem;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.28s ease, opacity 0.2s ease;
}
.ks-sidebar-group--open .ks-sidebar-sub { max-height: 460px; opacity: 1; }
.ks-sidebar-subitem {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.22rem;
  padding: 0.4rem 0.3rem;
  margin: 0 0.4rem;
  border-radius: var(--ks-radius-md);
  color: var(--ks-text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-size: 0.54rem;
  letter-spacing: 0.02em;
  text-align: center;
  user-select: none;
}
.ks-sidebar-subitem:hover { background: var(--ks-bg-2); color: var(--ks-text); }
.ks-sidebar-subempty {
  font-size: 0.55rem; color: var(--ks-text-dim); opacity: 0.6;
  text-align: center; padding: 0.3rem 0.4rem;
}
.ks-plat-ico,
.ks-plat-ico-img {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.ks-plat-ico {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800; color: #fff;
}
.ks-plat-ico-img { object-fit: cover; }
/* Compact variant — card badges, modal pills, editor chips. */
.ks-plat-ico--mini,
.ks-plat-ico-img--mini {
  width: 20px; height: 20px; border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.ks-plat-ico--mini { font-size: 0.62rem; }

/* ─── Main column ───────────────────────────────────────────────────── */
.ks-main { min-width: 0; position: relative; }

/* ─── Header ────────────────────────────────────────────────────────── */
.ks-header {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  padding: 0.85rem 2rem;
  background: linear-gradient(180deg, rgba(8,8,12,0.85) 0%, rgba(8,8,12,0.4) 60%, transparent 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.25s;
}
.ks-header--solid {
  background: rgba(8, 8, 12, 0.92);
  border-bottom: 1px solid var(--border);
}
.ks-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.ks-brand-icon {
  width: 28px;
  height: 28px;
  fill: var(--ks-red);
  filter: drop-shadow(0 0 8px var(--ks-red-glow));
}
.ks-brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ks-red);
  text-transform: uppercase;
}
.ks-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
}
.ks-nav-link {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ks-text-dim);
  cursor: pointer;
  position: relative;
  padding: 0.4rem 0;
  transition: color 0.15s;
  user-select: none;
}
.ks-nav-link:hover { color: var(--ks-text); }
.ks-nav-link--active { color: var(--ks-text); font-weight: 600; }
.ks-nav-link--active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  height: 2px;
  background: var(--ks-red);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--ks-red-glow);
}
.ks-nav-link--disabled { opacity: 0.45; cursor: not-allowed; }

.ks-header-actions { display: flex; align-items: center; gap: 1rem; }
.ks-header-iconbtn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ks-text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ks-header-iconbtn:hover {
  background: var(--ks-bg-2);
  color: var(--ks-text);
  border-color: var(--border);
}
.ks-header-iconbtn svg { width: 20px; height: 20px; fill: currentColor; }
.ks-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ks-red), var(--ks-red-deep));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
  user-select: none;
}
.ks-avatar:hover { border-color: var(--ks-red); transform: scale(1.05); }

/* ─── Search ────────────────────────────────────────────────────────── */
/* Wrapper owns the width + width animation and anchors the dropdown. */
.ks-search-wrap {
  position: relative;
  width: 220px;
  transition: width 0.2s;
}
.ks-search-wrap:focus-within { width: 280px; }
.ks-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  width: 100%;
  transition: background 0.15s;
}
.ks-search:focus-within {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--ks-red);
  box-shadow: 0 0 0 3px var(--ks-red-glow);
}
.ks-search svg { width: 16px; height: 16px; fill: var(--ks-text-dim); flex-shrink: 0; }
.ks-search input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ks-text);
  font-family: inherit;
  font-size: 0.88rem;
  width: 100%;
}
.ks-search input::placeholder { color: var(--ks-text-faded); }

/* Autocomplete dropdown — quick suggestions below the search bar. */
.ks-search-dd {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 60;
  width: min(400px, 86vw);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.35rem;
  background: rgba(16, 16, 20, 0.98);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.78);
  display: none;
}
.ks-search-wrap--open .ks-search-dd { display: block; }
.ks-search-empty {
  padding: 1.1rem;
  text-align: center;
  color: var(--ks-text-dim);
  font-size: 0.88rem;
}
.ks-search-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.5rem 0.55rem;
  border-radius: 7px;
  cursor: pointer;
}
.ks-search-row:hover,
.ks-search-row--active { background: rgba(255, 255, 255, 0.09); }
.ks-search-thumb {
  flex-shrink: 0;
  width: 74px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  background: var(--ks-bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ks-search-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ks-search-info { min-width: 0; }
.ks-search-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ks-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ks-search-meta { margin-top: 0.12rem; font-size: 0.74rem; color: var(--ks-text-dim); }

/* ─── Hero ───────────────────────────────────────────────────────────── */
.ks-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;   /* content sits low — Netflix-style */
  width: 100%;
  height: 78vh;
  min-height: 460px;
  max-height: 780px;
  margin-top: -68px;
  overflow: hidden;
}
.ks-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
  z-index: 0;
  animation: ksHeroKenBurns 30s ease-in-out infinite alternate;
}
@keyframes ksHeroKenBurns {
  from { transform: scale(1.0) translateX(0); }
  to   { transform: scale(1.06) translateX(-1.5%); }
}
.ks-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* Darken mainly the lower-left so the text stays legible while the
     trailer keeps breathing room on the right. */
  background:
    linear-gradient(90deg, rgba(8,8,12,0.9) 0%, rgba(8,8,12,0.45) 30%, rgba(8,8,12,0) 62%),
    linear-gradient(0deg, rgba(8,8,12,0.95) 0%, rgba(8,8,12,0.35) 26%, rgba(8,8,12,0) 52%);
}
/* While the trailer plays the overlay eases off — the video is the star. */
.ks-hero.is-trailer::before {
  background:
    linear-gradient(90deg, rgba(8,8,12,0.78) 0%, rgba(8,8,12,0.3) 28%, rgba(8,8,12,0) 56%),
    linear-gradient(0deg, rgba(8,8,12,0.92) 0%, rgba(8,8,12,0.25) 20%, rgba(8,8,12,0) 42%);
}
.ks-hero-content {
  position: relative;
  z-index: 2;
  max-width: 620px;
  padding: 0 3rem 6.5rem 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.1rem;
}
.ks-hero-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ks-red);
  text-transform: uppercase;
}
.ks-hero-title {
  font-size: clamp(2rem, 4.5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.05;
  text-shadow: 0 6px 24px rgba(0,0,0,0.6);
}
/* Compact one-line metadata — small, clean, no boxed pills. */
.ks-hero-meta {
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ks-text-dim);
}
.ks-hero-overview {
  font-size: 0.92rem;
  color: var(--ks-text);
  opacity: 0.82;
  line-height: 1.5;
  max-width: 30rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ks-hero-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.ks-hero-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  background: white;
  color: black;
  font-weight: 700;
  font-size: 0.98rem;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.ks-hero-btn-primary:hover { background: rgba(255,255,255,0.85); }
.ks-hero-btn-primary svg { width: 22px; height: 22px; fill: currentColor; }
.ks-hero-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  background: rgba(120, 120, 130, 0.4);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  backdrop-filter: blur(4px);
}
.ks-hero-btn-secondary:hover { background: rgba(120, 120, 130, 0.6); }
.ks-hero-btn-secondary svg { width: 20px; height: 20px; fill: currentColor; }

/* ─── Hero trailer (inline auto-play) ───────────────────────────────── */
.ks-hero-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
  opacity: 0;
  /* Fast fade-OUT so a YouTube pause/buffer overlay vanishes in a blink;
     the slow cinematic fade-IN lives on the .ks-hero--playing rule. The
     layer is only ever shown while the trailer is genuinely PLAYING, so
     YouTube's center play/pause UI is never on screen. */
  transition: opacity 0.28s ease;
  overflow: hidden;
  pointer-events: none;
}
.ks-hero.ks-hero--playing .ks-hero-video {
  opacity: 1;
  transition: opacity 1.1s ease;
}
.ks-hero.ks-hero--playing .ks-hero-bg {
  opacity: 0;
  transition: opacity 1.1s ease;
}
/* The iframe (created by the YouTube IFrame API) COVERS the hero box like
   a cinematic background video — full-bleed, no letterbox.
     · `height:auto` overrides YouTube's hard-coded height attribute so
       `aspect-ratio` drives the height from the width.
     · the 16:9-of-100vh width over-scans vertically, pushing any YouTube
       chrome (title bar, watermark) off-screen at the top/bottom. */
.ks-hero-video iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max(100%, 177.78vh);
  min-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  min-height: 100%;
  border: 0;
  pointer-events: none;
}

/* Poster→trailer transition: title shrinks, eyebrow + synopsis recede so
   the video becomes the protagonist. */
.ks-hero-title { transition: font-size 0.6s ease; }
.ks-hero-eyebrow,
.ks-hero-overview {
  overflow: hidden;
  max-height: 8rem;
  transition: opacity 0.5s ease, max-height 0.5s ease, margin 0.5s ease;
}
.ks-hero.is-trailer .ks-hero-title {
  font-size: clamp(1.4rem, 2.6vw, 2.3rem);
}
.ks-hero.is-trailer .ks-hero-eyebrow,
.ks-hero.is-trailer .ks-hero-overview {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}
.ks-hero-content {
  transition: gap 0.5s ease, opacity 0.55s ease, transform 0.55s ease;
}
.ks-hero.is-trailer .ks-hero-content { gap: 0.65rem; }
.ks-hero-bg { transition: opacity 0.32s ease; }

/* Cinematic cross-fade while the carousel swaps to the next title:
   the content lifts + fades out and the backdrop dims, then eases back. */
.ks-hero--switching .ks-hero-content {
  opacity: 0;
  transform: translateY(16px);
}
.ks-hero--switching .ks-hero-video { opacity: 0; }
.ks-hero--switching .ks-hero-bg { opacity: 0.18; }
.ks-hero.is-trailer .ks-hero-btn-primary,
.ks-hero.is-trailer .ks-hero-btn-secondary {
  padding-top: 0.68rem;
  padding-bottom: 0.68rem;
  font-size: 0.9rem;
  transition: padding 0.4s ease, font-size 0.4s ease, background 0.15s;
}
.ks-hero.is-trailer .ks-hero-btn-secondary { background: rgba(120, 120, 130, 0.28); }

/* Official transparent title logo (replaces the text <h1> when present). */
.ks-hero-logo {
  align-self: flex-start;
  max-width: min(420px, 100%);
  max-height: 172px;
  width: auto;
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.7));
  transition: max-width 0.6s ease, max-height 0.6s ease;
}
.ks-hero.is-trailer .ks-hero-logo {
  max-width: min(290px, 80%);
  max-height: 116px;
}

/* "Más información" — a quiet text button beside the loud ones. */
.ks-hero-btn-tertiary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 1.1rem;
  background: transparent;
  color: var(--ks-text-dim);
  font-weight: 600;
  font-size: 0.92rem;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}
.ks-hero-btn-tertiary:hover { color: #fff; }
.ks-hero-btn-tertiary svg { width: 18px; height: 18px; fill: currentColor; }

/* Sound toggle — a labelled pill (speaker icon + text) inline at the end
   of the hero action row, beside "Reproducir / Mi lista / Más
   información". Revealed once a trailer is playing. */
.ks-hero-mute {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: center;
  flex-shrink: 0;
  padding: 0.78rem 1.3rem;
  border-radius: 6px;
  background: rgba(120, 120, 130, 0.42);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  transition: opacity 0.4s ease, transform 0.4s ease, background 0.15s, border-color 0.15s;
  backdrop-filter: blur(4px);
}
.ks-hero.is-trailer .ks-hero-mute {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.ks-hero-mute:hover {
  background: rgba(140, 140, 150, 0.62);
  border-color: #fff;
}
.ks-hero-mute:active { transform: scale(0.96); }
.ks-hero-mute svg { width: 20px; height: 20px; fill: currentColor; }

/* ─── Rows ──────────────────────────────────────────────────────────── */
.ks-row {
  margin: 1.4rem 0 0;
  padding: 0 0 0 3rem;
  position: relative;
}

/* ─── Notifications bell ──────────────────────────────────────────────── */
.ks-notif { position: relative; }
.ks-notif-btn { position: relative; }
.ks-notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ks-red);
  box-shadow: 0 0 7px var(--ks-red);
  display: none;
}
.ks-notif-dot--on { display: block; }
.ks-notif-panel {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 60;
  width: min(348px, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(16, 16, 20, 0.98);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.78);
  display: none;
}
.ks-notif--open .ks-notif-panel { display: block; }
.ks-notif-head {
  padding: 0.9rem 1rem 0.65rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ks-text);
  border-bottom: 1px solid var(--border);
}
.ks-notif-empty {
  padding: 1.5rem 1rem;
  color: var(--ks-text-dim);
  font-size: 0.88rem;
}
.ks-notif-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.13s;
}
.ks-notif-row:last-child { border-bottom: 0; }
.ks-notif-row:hover { background: rgba(255, 255, 255, 0.06); }
.ks-notif-thumb {
  flex-shrink: 0;
  width: 80px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  background: var(--ks-bg-2);
}
.ks-notif-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ks-notif-thumb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ks-notif-info { min-width: 0; }
.ks-notif-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ks-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ks-notif-sub {
  margin-top: 0.15rem;
  font-size: 0.74rem;
  color: var(--ks-text-dim);
}

/* ─── Platforms hub ───────────────────────────────────────────────────── */
.ks-plat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
  padding: 1rem 3rem 2rem;
}
.ks-plat-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--ks-radius-md);
  background: linear-gradient(135deg, var(--plat-color, #333), rgba(0, 0, 0, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.ks-plat-tile:hover,
.ks-plat-tile:focus-visible {
  transform: scale(1.045);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.62);
  outline: none;
}
.ks-plat-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.ks-plat-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}
/* Real platform logo (drop one at /icons/platforms/<slug>.png) — when it
   loads it replaces the wordmark text on the tile. */
.ks-plat-logo {
  max-width: 62%;
  max-height: 46%;
  object-fit: contain;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.55));
}

/* Search-page hint message (empty / too-short query). */
.ks-search-hint {
  padding: 3rem;
  color: var(--ks-text-dim);
  font-size: 1.02rem;
}

/* ─── Detail modal (Netflix-style content sheet) ──────────────────────── */
.ks-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.82);
  overflow-y: auto;
  padding: 3rem 1rem 4rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ks-modal-overlay--open { opacity: 1; }
.ks-modal {
  width: min(900px, 100%);
  margin: 0 auto;
  background: #141414;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  transform: translateY(28px) scale(0.97);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
}
.ks-modal-overlay--open .ks-modal { transform: translateY(0) scale(1); opacity: 1; }
.ks-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(12, 12, 14, 0.85);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ks-modal-close:hover { background: #000; }
.ks-modal-close svg { width: 22px; height: 22px; fill: currentColor; }

/* Hero */
.ks-modal-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.ks-modal-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 0.6s ease;
}
.ks-modal-video {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.ks-modal--playing .ks-modal-video { opacity: 1; }
.ks-modal--playing .ks-modal-bg { opacity: 0; }
.ks-modal-video iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 138%;
  height: 138%;
  border: 0;
  pointer-events: none;
}
.ks-modal-hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, #141414 2%, rgba(20,20,20,0.35) 32%, transparent 68%);
}
.ks-modal-hero-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 2.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.ks-modal-titleslot {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.015em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}
.ks-modal-logo {
  display: block;
  max-width: 46%;
  max-height: 116px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 3px 14px rgba(0, 0, 0, 0.85));
}
.ks-modal-actions { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.ks-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ks-modal-btn:active { transform: scale(0.96); }
.ks-modal-btn--play {
  padding: 0.72rem 1.7rem;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 1rem;
}
.ks-modal-btn--play:hover { background: rgba(255, 255, 255, 0.82); }
.ks-modal-btn--play svg { width: 22px; height: 22px; fill: currentColor; }
.ks-modal-btn--icon {
  width: 44px;
  height: 44px;
  justify-content: center;
  border-radius: 50%;
  background: rgba(42, 42, 48, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
}
.ks-modal-btn--icon:hover { border-color: #fff; background: rgba(64, 64, 72, 0.85); }
.ks-modal-btn--icon svg { width: 22px; height: 22px; fill: currentColor; }
/* 👍 liked — red icon + border for the "Me gusta" state. */
.ks-modal-btn--icon.ks-modal-btn--liked {
  color: var(--ks-red);
  border-color: var(--ks-red);
  background: rgba(229, 9, 20, 0.18);
}
.ks-modal-sound {
  position: absolute;
  right: 2.5rem;
  bottom: 1.8rem;
  z-index: 4;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 14, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  cursor: pointer;
}
.ks-modal--playing .ks-modal-sound { display: flex; }
.ks-modal-sound:hover { border-color: #fff; }
.ks-modal-sound svg { width: 20px; height: 20px; fill: currentColor; }

/* Body */
.ks-modal-body { padding: 1.5rem 2.5rem 2.5rem; }
.ks-modal-meta { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.85rem; }
.ks-modal-rating {
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 0.05rem 0.42rem;
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #fff;
}
.ks-modal-metatext { color: var(--ks-text-dim); font-size: 0.9rem; font-weight: 600; }
.ks-modal-synopsis { color: var(--ks-text); line-height: 1.55; font-size: 0.97rem; }
.ks-modal-genres { margin-top: 0.9rem; font-size: 0.85rem; color: var(--ks-text-dim); }
.ks-modal-cast { margin-top: 0.45rem; font-size: 0.85rem; color: var(--ks-text-dim); }
.ks-modal-genres-label { color: var(--ks-text-faded); }

/* ─── Platform row (read-only) + admin override editor ──────────────── */
.ks-modal-plats {
  margin-top: 0.55rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.85rem; color: var(--ks-text-dim);
}
.ks-modal-plat-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--ks-bg-2);
  padding: 0.2rem 0.55rem 0.2rem 0.25rem;
  border-radius: 999px;
  font-size: 0.78rem; color: var(--ks-text);
}
.ks-modal-platedit { margin-top: 1.6rem; }
.ks-platedit-chips {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: 0.7rem;
}
.ks-platedit-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--ks-bg-2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ks-text-dim);
  padding: 0.34rem 0.7rem 0.34rem 0.4rem;
  border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s, opacity 0.14s;
  opacity: 0.55;
}
.ks-platedit-chip:hover { opacity: 0.85; }
.ks-platedit-chip--on {
  background: rgba(229, 9, 20, 0.16);
  border-color: var(--ks-red);
  color: var(--ks-text);
  opacity: 1;
}
.ks-platedit-foot {
  display: flex; align-items: center; gap: 1rem;
  margin-top: 0.9rem;
}
.ks-platedit-hint { font-size: 0.76rem; color: var(--ks-text-faded); }
.ks-platedit-save {
  background: var(--ks-red);
  color: #fff;
  border: 0;
  padding: 0.45rem 1.2rem;
  border-radius: var(--ks-radius-md);
  font-size: 0.82rem; font-weight: 700;
  cursor: pointer;
  transition: filter 0.14s, opacity 0.14s;
}
.ks-platedit-save:hover:not(:disabled) { filter: brightness(1.12); }
.ks-platedit-save:disabled { opacity: 0.45; cursor: default; }

/* Episodes */
.ks-modal-episodes { margin-top: 1.9rem; }
.ks-modal-ep-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
.ks-modal-section-title { font-size: 1.2rem; font-weight: 700; color: var(--ks-text); }
.ks-modal-season {
  background: var(--ks-bg-2);
  color: var(--ks-text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.ks-modal-ep {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 0.4rem;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.13s;
}
.ks-modal-ep:hover,
.ks-modal-ep:focus-visible { background: rgba(255, 255, 255, 0.05); outline: none; }
.ks-modal-ep-num {
  flex-shrink: 0;
  width: 1.7rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ks-text-dim);
}
.ks-modal-ep-thumb {
  position: relative;
  flex-shrink: 0;
  width: 150px;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  overflow: hidden;
  background: var(--ks-bg-2);
}
.ks-modal-ep-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ks-modal-ep-thumb-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ks-text-faded); font-size: 1.3rem;
}
.ks-modal-ep-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ks-modal-ep-play svg { width: 30px; height: 30px; fill: currentColor; }
.ks-modal-ep:hover .ks-modal-ep-play,
.ks-modal-ep:focus-visible .ks-modal-ep-play { opacity: 1; }
.ks-modal-ep-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.28);
}
.ks-modal-ep-progress > div { height: 100%; background: var(--ks-red); }
.ks-modal-ep-info { flex: 1; min-width: 0; }
.ks-modal-ep-title {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ks-text);
}
.ks-modal-ep-dur { flex-shrink: 0; color: var(--ks-text-faded); font-weight: 500; }
.ks-modal-ep-desc {
  margin-top: 0.3rem;
  color: var(--ks-text-dim);
  font-size: 0.85rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Similar titles row inside the modal */
.ks-modal-similar { margin-top: 1.6rem; }
.ks-modal-similar .ks-row { margin: 0; padding-left: 0; }
.ks-modal-similar .ks-row-header { padding-right: 0; }
.ks-modal-similar .ks-row-scroller { padding-right: 1rem; }

@media (max-width: 640px) {
  .ks-modal-overlay { padding: 1.5rem 0 3rem; }
  .ks-modal { border-radius: 0; }
  .ks-modal-hero-content { padding: 0 1.2rem 1.3rem; }
  .ks-modal-sound { right: 1.2rem; bottom: 1.3rem; }
  .ks-modal-body { padding: 1.2rem 1.2rem 2rem; }
  .ks-modal-ep-thumb { width: 108px; }
}

/* Browse-page heading (Películas / Series / Kids / Mi lista). */
.ks-browse-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ks-text);
  padding: 1.5rem 3rem 0.2rem;
}

/* ─── Catalog page (Series / Películas) ───────────────────────────────── */
.ks-catalog-bar {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  padding: 1.4rem 3rem 0.4rem;
}
.ks-catalog-title {
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ks-text);
}
/* Catalog hero sits below the title bar — no slide-under-header offset,
   and a touch shorter than the home billboard. */
.ks-hero.ks-hero--catalog {
  margin-top: 0.4rem;
  height: 62vh;
  min-height: 380px;
}

/* "Géneros" dropdown */
.ks-genre-dd { position: relative; }
.ks-genre-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  color: var(--ks-text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ks-genre-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: #fff; }
.ks-genre-caret { font-size: 0.66rem; transition: transform 0.18s ease; }
.ks-genre-dd--open .ks-genre-caret { transform: rotate(180deg); }
.ks-genre-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 40;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 0.12rem;
  min-width: 260px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 0.4rem;
  background: rgba(16, 16, 20, 0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.72);
}
.ks-genre-dd--open .ks-genre-panel { display: grid; }
.ks-genre-opt {
  padding: 0.5rem 0.7rem;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ks-text-dim);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}
.ks-genre-opt:hover,
.ks-genre-opt:focus-visible {
  background: var(--ks-red);
  color: #fff;
  outline: none;
}
.ks-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.85rem;
  padding-right: 3rem;
}
.ks-row-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.ks-row-explore {
  font-size: 0.82rem;
  color: var(--ks-text-dim);
  cursor: pointer;
  transition: color 0.15s;
}
.ks-row-explore:hover { color: var(--ks-red); }
.ks-row-scroller {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  /* Generous vertical padding gives the hover-scaled card room to grow
     without being clipped by the horizontal scroller; the negative
     margin reclaims most of that space visually. */
  padding: 46px 3rem 46px 0;
  margin: -30px 0 -24px;
  scroll-behavior: smooth;
}

/* Poster card */
.ks-card {
  flex: 0 0 auto;
  width: 180px;
  scroll-snap-align: start;
  cursor: pointer;
  position: relative;
  transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.ks-card:hover { transform: scale(1.06) translateY(-4px); z-index: 5; }
.ks-card-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(180deg, var(--ks-bg-2), var(--ks-bg-1));
  border-radius: var(--ks-radius-md);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: box-shadow 0.22s, outline 0.15s;
}
.ks-card:hover .ks-card-poster {
  box-shadow: 0 14px 32px rgba(0,0,0,0.65), 0 0 0 1px rgba(229, 9, 20, 0.6), 0 0 28px var(--ks-red-glow);
}
.ks-card-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ks-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--ks-text-faded);
}
.ks-card--still { width: 320px; }
.ks-card--still .ks-card-poster { aspect-ratio: 16 / 9; }
.ks-card-progress {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(255,255,255,0.18);
}
.ks-card-progress-fill {
  height: 100%;
  background: var(--ks-red);
  box-shadow: 0 0 12px var(--ks-red);
}
.ks-card-badges {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  pointer-events: none;
}
.ks-card-badge {
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.18em 0.45em;
  border-radius: 3px;
  backdrop-filter: blur(2px);
  text-transform: uppercase;
}
.ks-card-badge--hd  { background: rgba(229, 9, 20, 0.85); }
.ks-card-badge--4k  { background: linear-gradient(135deg, #e50914, #b81d24); box-shadow: 0 0 10px var(--ks-red-glow); }
.ks-card-badge--hdr { background: linear-gradient(135deg, #4a8eff, #1a56db); box-shadow: 0 0 8px var(--ks-blue-glow); }
.ks-card-info { padding: 0.5rem 0 0.25rem; }
.ks-card-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ks-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ks-card-meta {
  font-size: 0.74rem;
  color: var(--ks-text-faded);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Wide content card (Netflix-style 16:9) ──────────────────────────── */
.ks-wcard {
  flex: 0 0 auto;
  width: 300px;
  scroll-snap-align: start;
  cursor: pointer;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.ks-wcard:hover,
.ks-wcard:focus-within {
  transform: scale(1.4);
  /* Above the sidebar (z-index: 20) so an expanded card is never
     covered — paired with the inward-expand origin in app.js, which
     keeps the card from being clipped in the first place. */
  z-index: 30;
}
.ks-wcard:focus-visible { outline: none; }
.ks-wcard-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(180deg, var(--ks-bg-2), var(--ks-bg-1));
  border-radius: var(--ks-radius-md);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.3s;
}
.ks-wcard:hover .ks-wcard-media,
.ks-wcard:focus-within .ks-wcard-media {
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.78),
              0 0 0 1px rgba(229, 9, 20, 0.5),
              0 0 32px var(--ks-red-glow);
}
.ks-wcard-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ks-wcard-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--ks-text-faded);
}
.ks-wcard-video {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
.ks-wcard.ks-wcard--playing .ks-wcard-video { opacity: 1; }
/* Over-scaled so YouTube's start-up title bar ("Trailer de la Serie | …")
   is cropped clean off the top/bottom — a borderless background trailer. */
.ks-wcard-video iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 138%;
  height: 138%;
  border: 0;
  pointer-events: none;
}
/* Continue-watching progress — a thin red bar at the bottom edge of the
   card, kept above the hover overlay so it stays visible (Netflix-style). */
.ks-wcard-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  height: 4px;
  background: rgba(255, 255, 255, 0.28);
}
.ks-wcard-progress-fill {
  height: 100%;
  background: var(--ks-red);
  box-shadow: 0 0 8px var(--ks-red);
}
.ks-wcard-badges {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  z-index: 2;
  pointer-events: none;
}
.ks-wcard-badge {
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.18em 0.45em;
  border-radius: 3px;
  text-transform: uppercase;
}
.ks-wcard-badge--hd  { background: rgba(229, 9, 20, 0.85); }
.ks-wcard-badge--4k  { background: linear-gradient(135deg, #e50914, #b81d24); }
.ks-wcard-badge--hdr { background: linear-gradient(135deg, #4a8eff, #1a56db); }
.ks-wcard-overlay {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.5rem 0.6rem 0.55rem;
  background: linear-gradient(0deg, rgba(0,0,0,0.95) 6%, rgba(0,0,0,0.45) 58%, transparent 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.ks-wcard:hover .ks-wcard-overlay,
.ks-wcard:focus-within .ks-wcard-overlay {
  opacity: 1;
  pointer-events: auto;
}
.ks-wcard-actions { display: flex; align-items: center; gap: 0.4rem; }
.ks-wcard-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(42, 42, 48, 0.55);
  color: #fff;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, background 0.15s, border-color 0.15s;
}
.ks-wcard-btn:hover {
  transform: scale(1.15);
  border-color: #fff;
  background: rgba(64, 64, 72, 0.9);
}
.ks-wcard-btn:active { transform: scale(1.04); }
.ks-wcard-btn svg { width: 16px; height: 16px; fill: currentColor; display: block; }
/* ▶ Reproducir — solid white circle with a dark icon. */
.ks-wcard-btn--play {
  background: #fff;
  color: #111;
  border-color: #fff;
}
/* 👍 liked — red icon + border so the "Me gusta" state reads at a glance. */
.ks-wcard-btn.ks-wcard-btn--liked {
  color: var(--ks-red);
  border-color: var(--ks-red);
  background: rgba(229, 9, 20, 0.16);
}
.ks-wcard-btn--play:hover {
  transform: scale(1.15);
  background: #fff;
  border-color: #fff;
}
/* "Más información" (chevron) sits apart, at the far right — Netflix-style. */
.ks-wcard-btn--more { margin-left: auto; }
/* Sound toggle floats at the card's top-right while the trailer plays. */
.ks-wcard-sound {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 3;
  display: none;
}
.ks-wcard.ks-wcard--playing .ks-wcard-sound { display: flex; }
.ks-wcard-tags {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.88);
  overflow: hidden;
}
.ks-wcard-metatext {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Maturity-rating badge — small bordered box, Netflix-style. */
.ks-wcard-rating {
  flex-shrink: 0;
  padding: 0.05rem 0.34rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
}

/* Base-state caption — the title's official logo (text fallback) shown
   over a soft bottom gradient BEFORE hover, so content is recognisable at
   a glance. Fades out when the expanded panel takes over on hover. */
.ks-wcard-caption {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  min-height: 40%;
  padding: 1.6rem 0.7rem 0.62rem;
  background: linear-gradient(0deg,
    rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.32) 52%, transparent 100%);
  transition: opacity 0.25s ease;
}
.ks-wcard:hover .ks-wcard-caption,
.ks-wcard:focus-within .ks-wcard-caption { opacity: 0; }
.ks-wcard-caption-text {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}
.ks-wcard-caption-logo {
  display: block;
  max-width: 72%;
  max-height: 34px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85));
}
/* Title slot in the expanded card — the official transparent logo, or a
   clean text fallback when TMDB has no logo. */
.ks-wcard-logo {
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
/* Netflix behaviour: once the trailer is playing, the big logo/name
   fades away so the video becomes the protagonist — the buttons and
   metadata below stay put. */
.ks-wcard.ks-wcard--playing .ks-wcard-logo {
  opacity: 0;
  transform: translateY(-8px);
}
.ks-wcard-logo-img {
  display: block;
  max-width: 66%;
  max-height: 30px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 2px 7px rgba(0, 0, 0, 0.78));
}

/* Library tile (used in the "Bibliotecas" row) */
.ks-lib-tile {
  flex: 0 0 auto;
  width: 240px;
  scroll-snap-align: start;
  cursor: pointer;
  background: linear-gradient(135deg, var(--ks-bg-2), var(--ks-bg-1));
  border: 1px solid var(--border);
  border-radius: var(--ks-radius-lg);
  padding: 1.5rem 1.25rem;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.ks-lib-tile:hover {
  transform: translateY(-3px);
  border-color: var(--ks-red);
  box-shadow: 0 12px 30px rgba(0,0,0,0.5), 0 0 24px var(--ks-red-glow);
}
.ks-lib-tile-icon { width: 36px; height: 36px; fill: var(--ks-red); margin-bottom: 0.5rem; }
.ks-lib-tile-name { font-size: 1.05rem; font-weight: 700; }
.ks-lib-tile-type {
  font-size: 0.78rem;
  color: var(--ks-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Footer ────────────────────────────────────────────────────────── */
.ks-footer {
  margin: 4rem 0 2rem;
  padding: 2.5rem 3rem 1rem;
  border-top: 1px solid var(--border);
}
.ks-footer-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem 2rem;
  margin-bottom: 2rem;
}
.ks-footer-feature {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--ks-text-dim);
}
.ks-footer-feature svg {
  width: 28px;
  height: 28px;
  fill: var(--ks-red);
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px var(--ks-red-glow));
}
.ks-footer-feature-label { font-size: 0.88rem; font-weight: 600; color: var(--ks-text); }
.ks-footer-feature-sub { font-size: 0.78rem; color: var(--ks-text-faded); }
.ks-footer-legal {
  font-size: 0.75rem;
  color: var(--ks-text-faded);
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ─── Toast ─────────────────────────────────────────────────────────── */
.ks-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ks-bg-3);
  border: 1px solid var(--border);
  color: var(--ks-text);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.ks-toast--visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .ks-nav { gap: 1rem; }
  .ks-search-wrap { width: 160px; }
  .ks-search-wrap:focus-within { width: 200px; }
}
@media (max-width: 880px) {
  .ks-app { grid-template-columns: 64px 1fr; }
  .ks-sidebar { padding-top: 0.75rem; }
  .ks-sidebar-item { padding: 0.55rem 0.3rem 0.3rem; font-size: 0.58rem; }
  .ks-sidebar-icon { width: 20px; height: 20px; }
  .ks-row { padding-left: 1.5rem; }
  .ks-row-scroller { padding-right: 1.5rem; }
  .ks-row-header { padding-right: 1.5rem; }
  .ks-wcard { width: 256px; }
  .ks-hero-content { padding: 0 1.5rem 4rem; }
  .ks-footer { padding: 2rem 1.5rem 1rem; }
}
@media (max-width: 640px) {
  .ks-app { grid-template-columns: 1fr; }
  .ks-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 60px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0.4rem 0.5rem;
    border-right: 0;
    border-top: 1px solid var(--border);
    z-index: 30;
  }
  .ks-sidebar-logo { display: none; }
  .ks-sidebar-spacer { display: none; }
  .ks-sidebar-item { margin: 0; flex: 1; font-size: 0; gap: 0; }
  .ks-sidebar-item--active::before { display: none; }
  /* The bottom bar is a horizontal row — an inline dropdown can't fit, so
     the group collapses to a single tab (tapping it opens the hub page). */
  .ks-sidebar-group { flex: 1; }
  .ks-sidebar-sub, .ks-sidebar-caret { display: none; }
  .ks-main { padding-bottom: 60px; }
  .ks-header { gap: 1rem; padding: 0.75rem 1rem; }
  .ks-nav { display: none; }
  .ks-search-wrap { width: 0; flex: 1; }
  .ks-search-wrap:focus-within { width: auto; }
  .ks-hero { height: 60vh; min-height: 380px; }
  .ks-hero-content { padding: 0 1rem 3rem; max-width: 100%; }
  .ks-hero-title { font-size: 1.85rem; }
  .ks-hero-logo { max-width: 64%; max-height: 108px; }
  .ks-hero.is-trailer .ks-hero-logo { max-width: 48%; max-height: 80px; }
  .ks-card { width: 130px; }
  .ks-card--still { width: 240px; }
  .ks-wcard { width: 220px; }
  /* Touch screens have no real hover — drop the zoom so a tap just opens
     the detail view, and reclaim the desktop scroller's zoom padding. */
  .ks-wcard:hover,
  .ks-wcard:focus-within { transform: none; z-index: auto; }
  .ks-row { padding-left: 1rem; margin-top: 1.75rem; }
  .ks-row-scroller { padding: 14px 1rem 14px 0; margin: 0; gap: 0.4rem; }
  .ks-row-header { padding-right: 1rem; }
  .ks-row-title { font-size: 1.05rem; }
}
@media (min-width: 1700px) {
  .ks-card:focus-visible {
    outline: 3px solid var(--ks-red);
    outline-offset: 4px;
    border-radius: var(--ks-radius-md);
  }
  .ks-nav-link:focus-visible,
  .ks-sidebar-item:focus-visible,
  .ks-hero-btn-primary:focus-visible,
  .ks-hero-btn-secondary:focus-visible {
    outline: 3px solid var(--ks-red);
    outline-offset: 3px;
    border-radius: 6px;
  }
}

/* ============================================================
   Transcoding stats panel (admin · Fase 1A)
   ============================================================ */

.tx-root { display: flex; flex-direction: column; gap: 1.25rem; }

.tx-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.tx-h2 { font-size: 1.3rem; font-weight: 700; }
.tx-sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.2rem; }

/* Empty state */
.tx-empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
  text-align: center; color: var(--text-dim);
  padding: 3.5rem 1.5rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tx-empty-icon {
  font-size: 1.6rem; width: 58px; height: 58px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border-radius: 50%;
}
.tx-empty-sm { color: var(--text-dim); font-size: 0.88rem; padding: 0.4rem 0; }

/* Honesty / caveat notes */
.tx-note {
  font-size: 0.84rem; color: var(--text-dim);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

/* Hero metric cards — Direct Play / Direct Stream / Transcode */
.tx-metrics {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.tx-metric {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 0.35rem;
}
.tx-metric--ok   { border-top: 3px solid var(--success); }
.tx-metric--warn { border-top: 3px solid var(--warning); }
.tx-metric--err  { border-top: 3px solid var(--danger); }
.tx-metric-pct { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.tx-metric-label { font-size: 0.98rem; font-weight: 600; }
.tx-metric-count { font-size: 0.82rem; color: var(--text-dim); }
.tx-metric-desc { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.15rem; }

/* Progress bar */
.tx-bar {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--bg); margin: 0.35rem 0 0.1rem;
}
.tx-bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.tx-bar-fill--ok   { background: var(--success); }
.tx-bar-fill--warn { background: var(--warning); }
.tx-bar-fill--err  { background: var(--danger); }

/* Breakdown grid */
.tx-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.tx-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.tx-card-title { font-size: 0.98rem; font-weight: 700; margin-bottom: 0.85rem; }
.tx-card-hint { font-size: 0.78rem; color: var(--text-dim); margin: -0.5rem 0 0.85rem; }

.tx-rank { display: flex; flex-direction: column; gap: 0.7rem; }
.tx-rank-row { display: flex; flex-direction: column; gap: 0.1rem; }
.tx-rank-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 0.75rem; font-size: 0.86rem;
}
.tx-rank-label { font-weight: 500; }
.tx-rank-count { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }

/* Per-browser rows */
.tx-clients { display: flex; flex-direction: column; gap: 0.8rem; }
.tx-client-row { display: flex; flex-direction: column; gap: 0.15rem; }
.tx-client-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 0.75rem; font-size: 0.86rem; flex-wrap: wrap;
}
.tx-client-name { font-weight: 600; }
.tx-client-stat { color: var(--text-dim); font-size: 0.79rem; }

/* Device profile registry (Fase 3) */
.tx-dp-grid {
  display: grid; gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.tx-dp {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.8rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.tx-dp--planned { opacity: 0.7; }
.tx-dp-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; margin-bottom: 0.1rem;
}
.tx-dp-name { font-weight: 600; font-size: 0.9rem; }
.tx-dp-badge {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.12rem 0.45rem; border-radius: 999px;
  white-space: nowrap;
}
.tx-dp-badge--active {
  background: rgba(16, 185, 129, 0.16); color: var(--success);
}
.tx-dp-badge--planned {
  background: rgba(245, 158, 11, 0.16); color: var(--warning);
}
.tx-dp-meta { font-size: 0.76rem; color: var(--text-dim); }
.tx-dp-codecs {
  font-size: 0.74rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   Playback Engine tab (admin · Fase 5)
   ============================================================ */

/* Vivo / Histórico sub-nav */
.pe-subnav { display: flex; gap: 0.45rem; margin: 0.3rem 0 1.15rem; flex-wrap: wrap; }
.pe-subnav-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); padding: 0.5rem 1.15rem; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pe-subnav-btn:hover { color: var(--text); background: var(--card-hover); }
.pe-subnav-btn--active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.pe-subnav-btn--active:hover { background: var(--primary-hover); color: #fff; }

/* Per-component pipeline breakdown inside a now-playing card */
.np-pipeline { margin-top: 0.7rem; }
.np-pipe-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.35rem;
}
.np-pipe {
  display: flex; flex-direction: column; gap: 0.05rem;
  padding: 0.4rem 0.7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  border-left-width: 3px;
}
.np-pipe--copy      { border-left-color: var(--success); }
.np-pipe--transcode { border-left-color: var(--danger); }
.np-pipe--remux     { border-left-color: var(--warning); }
.np-pipe-key {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); font-weight: 700;
}
.np-pipe-val { font-size: 0.82rem; font-weight: 600; }
