:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #58a6ff;
  --gold: #e3b341;
  --danger: #f85149;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent); }
.hidden { display: none !important; }
.app-layer.hidden { display: none !important; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { margin: 0 0 0.5rem; font-size: 1.4rem; }
.login-card p { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.login-card label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.login-card input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.login-card button {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.error { color: var(--danger); font-size: 0.85rem; margin-top: 0.5rem; }

/* Layout */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.app-header h1 { margin: 0; font-size: 1.15rem; flex: 1; }
.search-form { display: flex; gap: 0.5rem; flex: 2; min-width: 200px; max-width: 480px; }
.search-form input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.search-form button, .btn {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-primary { background: var(--accent); color: #000; border-color: transparent; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.55rem;
  line-height: 1;
}
.btn-icon .btn-icon-svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}
.btn-icon.is-busy .btn-icon-svg {
  animation: btn-icon-spin 0.8s linear infinite;
}
@keyframes btn-icon-spin {
  to { transform: rotate(360deg); }
}
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.app-header-user .search-form { flex: 1; max-width: none; }
.stats-bar {
  padding: 0.5rem 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.detail-breadcrumb-bar {
  padding: 0.5rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.detail-breadcrumb-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.detail-breadcrumb-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.detail-file-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.download-subtitles-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.detail-breadcrumb-bar .breadcrumb {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}
.cast-more-btn {
  margin-top: 0.5rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.breadcrumb-home {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-weight: 500;
  white-space: nowrap;
}
.breadcrumb-home:hover {
  border-color: var(--accent);
  background: var(--bg);
}
.breadcrumb-sep {
  color: var(--muted);
  user-select: none;
}
.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.breadcrumb-link {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb-link:hover { text-decoration: underline; }

.drill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.drill-grid-episodes {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.drill-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.drill-card:hover { border-color: var(--accent); }
.drill-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  line-height: 1.25;
}
.drill-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 0.35rem;
}
.drill-card-tags .badge.tag {
  font-size: 0.6rem;
  padding: 0.08rem 0.35rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gold);
  background: rgba(227, 179, 65, 0.12);
}
.drill-card-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.drill-card-file {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  word-break: break-all;
}
.drill-card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--surface2);
}
.drill-card-play {
  margin-top: 0.5rem;
  width: 100%;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width, 240px) 1fr;
  min-height: calc(100vh - 100px);
  align-items: start;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-bottom: 1px solid var(--border); }
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: sticky;
  top: 0;
  max-height: 100vh;
  width: var(--sidebar-width, 240px);
}
.sidebar-filters {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: calc(var(--sidebar-user-height, 6.75rem) + 1rem);
}
.sidebar-user {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: var(--sidebar-width, 240px);
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25);
}
.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
  min-width: 0;
}
.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.sidebar-user-profile-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.sidebar-user-profile-link:hover {
  color: var(--accent);
  background: rgba(88, 166, 255, 0.12);
}
.sidebar-user-profile-link .fa-user {
  font-size: 0.8rem;
}
.sidebar-user-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-logout {
  width: 100%;
}
.sidebar-app-version {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.02em;
}
@media (max-width: 800px) {
  .sidebar {
    position: static;
    max-height: none;
    width: auto;
  }
  .sidebar-user {
    position: fixed;
    left: 0;
    right: 0;
    width: auto;
  }
}
.sidebar h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.sidebar h3:first-child { margin-top: 0; }
.filter-group { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  color: var(--muted);
}
.chip.active { background: var(--accent); color: #000; border-color: transparent; }
.chip.library-movies.active { background: #3d5a80; color: #fff; }
.chip.library-tv.active { background: #5c4d7d; color: #fff; }
.chip.library-appletv.active { background: #4a6670; color: #fff; }
.chip.library-disney.active { background: #6b4a3a; color: #fff; }

.main { padding: 1rem 1.25rem; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.toolbar .result-count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--muted);
}
.sidebar .clear-filters {
  width: 100%;
  margin-top: 1rem;
}
.toolbar select {
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
}
.toolbar .per-page-select {
  min-width: 7.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card-media {
  position: relative;
}
.card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.card-episode-badge {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  border-bottom-left-radius: 4px;
}
.card .no-poster {
  aspect-ratio: 2/3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.5rem;
}
.card-body { padding: 0.5rem 0.65rem 0.75rem; }
.card-body h4 {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.card-size {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.2;
}
.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--surface2);
  margin-right: 0.25rem;
}
.rating { color: var(--gold); }

.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Item detail (catalog-sample layout) */
.detail-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
}
.detail-main {
  flex: 1;
  max-width: 52rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
.detail-view .media-card {
  position: relative;
  margin-bottom: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.detail-view .card-backdrop {
  height: 140px;
  background: var(--surface2) center/cover no-repeat;
}
.detail-view .card-body {
  display: flex;
  gap: 1.25rem;
  padding: 0 1.25rem 1.25rem;
  margin-top: -4rem;
}
.poster-play-wrap {
  position: relative;
  flex-shrink: 0;
  align-self: flex-start;
}
.detail-view .poster-play-wrap .poster {
  width: 140px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: block;
}
.detail-view .poster {
  width: 140px;
  flex-shrink: 0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  align-self: flex-start;
}
.poster-play-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(15, 20, 25, 0.72);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.poster-play-btn svg {
  width: 1.5rem;
  height: 1.5rem;
  margin-left: 0.12rem;
}
.poster-play-btn:hover,
.poster-play-btn:focus-visible {
  transform: translate(-50%, -50%) scale(1.06);
  background: rgba(88, 166, 255, 0.92);
  border-color: #fff;
  outline: none;
}
body.player-open { overflow: hidden; }
html.player-popout-window,
body.player-popout-window {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}
body.player-popout-window .player-popout-stage {
  position: fixed;
  inset: 0;
  background: #000;
}
.player-popout-hover-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem 1.1rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.35), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.player-popout-stage.popout-controls-visible .player-popout-hover-bar,
.player-popout-stage.popout-paused .player-popout-hover-bar {
  opacity: 1;
  pointer-events: auto;
}
.player-popout-stage.popout-paused .player-popout-hover-bar {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.55), transparent);
}
.player-popout-toggle-btn {
  min-width: 6.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: rgba(15, 20, 25, 0.78);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.player-popout-toggle-btn:hover {
  background: rgba(88, 166, 255, 0.88);
  border-color: #fff;
}
.player-popout-hover-status {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.8rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
body.player-popout-window .player-popout-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
  border: none;
  cursor: pointer;
}
.player-popout-tap-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  min-width: 7rem;
  height: 3.25rem;
  padding: 0 1.25rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}
.player-popout-tap-play:hover {
  background: rgba(0, 0, 0, 0.72);
  border-color: #fff;
}
.player-popout-tap-play.hidden {
  display: none;
}
.player-popout-boot #app-root:empty {
  display: none;
}
.player-popout-error {
  margin: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  max-width: 32rem;
}
.player-popped-out .player-stage {
  display: none;
}
.player-popout-note {
  display: none;
  margin: 0;
  padding: 1rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.player-detached-video-holder {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.player-popped-out .player-popout-note {
  display: block;
}
.player-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.player-modal {
  width: min(960px, 100%);
  max-height: calc(100vh - 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.player-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  overflow: visible;
  position: relative;
  z-index: 30;
  flex-shrink: 0;
}
.player-modal-close-btn {
  flex-shrink: 0;
}
.player-modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}
.player-header-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.player-mode-badge,
.player-header-convert-btn {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1.25;
  box-sizing: border-box;
}
.player-mode-badge {
  text-transform: uppercase;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.player-header-meta .convert-mp4-control,
.player-header-convert-wrap.convert-mp4-control {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.player-header-convert-wrap .convert-progress {
  min-width: 0;
}
.player-header-convert-wrap .convert-progress.hidden {
  display: none;
}
.player-header-convert-btn {
  background: transparent;
  border: 1px solid rgba(200, 170, 60, 0.55);
  color: rgba(210, 185, 90, 0.9);
  text-transform: none;
  cursor: pointer;
  font-family: inherit;
}
.player-header-convert-btn:hover:not(:disabled) {
  background: rgba(200, 170, 60, 0.12);
  border-color: rgba(210, 185, 90, 0.75);
  color: rgba(230, 205, 110, 0.95);
}
.player-header-convert-btn:disabled {
  opacity: 0.55;
}
.player-error-hint {
  margin: 0.5rem 20px 0;
  padding-bottom: 20px;
  font-size: 0.85rem;
  color: #f0a0a0;
}
.player-error-hint.hidden { display: none; }
.player-modal-actions {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.player-quality-wrap {
  display: flex;
  align-items: center;
}
.player-quality-select,
.live-quality-select {
  font-size: 0.8rem;
  padding: 0.35rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  max-width: 9rem;
}
.live-preview-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.35rem 0 0.5rem;
}
.live-quality-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.player-quality-toast {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 5;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.82rem;
  pointer-events: none;
}
.player-mobile-hint {
  margin: 0 20px 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

/* Mobile player — full-screen layout, wrapped controls, visible CC menu */
@media (max-width: 640px) {
  .player-modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .player-modal {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .player-modal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.55rem 0.65rem;
    flex-shrink: 0;
  }
  .player-modal-title-row {
    width: 100%;
  }
  .player-modal-title {
    font-size: 0.88rem;
  }
  .player-modal-close-btn {
    min-width: 2.85rem;
    min-height: 2.85rem;
    padding: 0.5rem 0.85rem;
    font-weight: 600;
  }
  .player-modal-actions {
    width: 100%;
    gap: 0.4rem;
  }
  .player-modal-actions .player-btn {
    min-height: 2.85rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  .player-quality-wrap {
    flex: 1 1 100%;
    min-width: 0;
  }
  .player-quality-select {
    width: 100%;
    max-width: none;
    min-height: 2.85rem;
    font-size: 0.85rem;
  }
  .player-cc-wrap {
    flex: 0 0 auto;
  }
  .player-cc-wrap.player-cc-open .player-cc-menu {
    position: fixed;
    left: 0.65rem;
    right: 0.65rem;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(40vh, 16rem);
  }
  .player-cc-option {
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
  }
  .player-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    background: #000;
  }
  .player-video {
    max-height: none;
    height: auto;
    max-width: 100%;
    flex: 0 1 auto;
    align-self: center;
  }
  .player-transport {
    flex-shrink: 0;
    padding: 0 0.65rem 0.75rem;
    margin-top: 0.35rem;
  }
  .player-transport-controls {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .player-transport-controls .player-btn {
    min-height: 2.75rem;
    padding: 0.45rem 0.6rem;
  }
  .player-transport-controls .player-clock {
    margin-left: 0;
    flex: 1 1 100%;
    text-align: center;
    font-size: 0.82rem;
    order: 10;
  }
  .player-error-hint {
    margin: 0.35rem 0.65rem 0;
    padding-bottom: 0.65rem;
    font-size: 0.8rem;
  }
  .player-mobile-hint {
    margin: 0 0.65rem 0.65rem;
    flex-shrink: 0;
  }
  .player-subtitle-delay {
    margin: 0 0.65rem 0.75rem;
    flex-shrink: 0;
    flex-direction: column;
    align-items: stretch;
  }
  .player-subtitle-offset-label {
    min-width: 0;
  }
  .player-subtitle-delay-btns {
    width: 100%;
    justify-content: space-between;
  }
  .player-subtitle-delay-btns .player-btn {
    flex: 1 1 auto;
    min-height: 2.75rem;
  }
  .player-subtitle-save {
    margin-left: 0;
    width: 100%;
    min-height: 2.85rem;
  }
}
.player-btn { font-size: 0.8rem; padding: 0.35rem 0.65rem; }
.player-cc-wrap { position: relative; }
.player-cc-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.player-cc-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: auto;
  margin-top: 0.25rem;
  min-width: 10rem;
  max-width: min(18rem, calc(100vw - 1.5rem));
  max-height: 12rem;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
}
.player-cc-wrap.player-cc-open .player-cc-menu {
  z-index: 2101;
}
.player-cc-option {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 0.8rem;
  cursor: pointer;
}
.player-cc-option:hover {
  background: var(--surface);
}
.player-video {
  width: 100%;
  max-height: min(70vh, calc(100vh - 8rem));
  background: #000;
  display: block;
  outline: none;
  border: none;
  position: relative;
  z-index: 1;
}
.player-video:focus,
.player-video:focus-visible {
  outline: none;
}
.player-transport {
  margin-top: 0.55rem;
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.player-transport-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
}
.player-transport-controls .player-clock {
  margin-left: auto;
}
.player-scrubber-row {
  width: 100%;
  min-width: 0;
}
.player-seek-hint {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}
.player-seek-hint.hidden {
  display: none;
}
.player-play-btn {
  min-width: 3.25rem;
}
.player-subtitle-delay {
  margin: 0.5rem 20px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.player-subtitle-offset-label {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 6.5rem;
}
.player-subtitle-delay-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.player-subtitle-save {
  margin-left: auto;
}
.detail-landing-actions {
  margin-top: 0.75rem;
}
.detail-landing-actions .media-file-actions {
  margin-left: 0;
}
.detail-file-actions .subtitle-sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.btn-danger {
  border-color: #9a4545;
  color: #f0a8a8;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(160, 50, 50, 0.28);
  border-color: #b85555;
  color: #ffd4d4;
}
.media-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}
.convert-mp4-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 10rem;
}
.convert-mp4-btn {
  border-color: #4a6a9a;
  color: #a8c8f0;
}
.convert-mp4-btn:hover:not(:disabled) {
  background: rgba(70, 110, 160, 0.28);
}
.convert-progress {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 11rem;
}
.convert-progress-track {
  height: 0.55rem;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.convert-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3a6a9a, #5a9ad4);
  transition: width 0.35s ease;
}
.convert-progress-fill.convert-progress-indeterminate {
  width: 40% !important;
  animation: convert-progress-pulse 1.2s ease-in-out infinite alternate;
}
@keyframes convert-progress-pulse {
  from { margin-left: 0; }
  to { margin-left: 60%; }
}
.convert-progress-label {
  font-size: 0.78rem;
  color: var(--muted);
}
.remove-convert-backup-btn {
  border-color: #6a5a3a;
  color: #e8d4a8;
}
.remove-convert-backup-btn:hover:not(:disabled) {
  background: rgba(120, 100, 50, 0.25);
}
.player-stage {
  position: relative;
  display: block;
}
.player-stage--plyr {
  --plyr-color-main: #6366f1;
  --plyr-video-control-color: #fff;
  --plyr-video-control-color-hover: #fff;
  --plyr-video-controls-background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75));
  --plyr-font-family: inherit;
  background: #000;
}
.player-stage--plyr .plyr {
  width: 100%;
  max-height: min(70vh, calc(100vh - 8rem));
}
.player-stage--plyr .plyr__video-wrapper {
  background: #000;
}
.player-stage--plyr .player-video {
  max-height: min(70vh, calc(100vh - 8rem));
}
.player-stage--plyr .player-video::cue {
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 1.05rem;
  line-height: 1.35;
}
.player-captions-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10%;
  z-index: 20;
  padding: 0 1.25rem;
  text-align: center;
  pointer-events: none;
  color: #fff;
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.85);
  white-space: pre-wrap;
}
.player-captions-overlay.hidden {
  display: none;
}
.plyr__video-wrapper .player-captions-overlay {
  bottom: 8%;
}
.player-stage--plyr .player-spinner {
  z-index: 4;
}
.player-popped-out .player-stage--plyr .plyr {
  display: none;
}
.player-spinner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.25);
}
.player-spinner.hidden {
  display: none;
}
.player-spinner-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: player-spin 0.8s linear infinite;
}
@keyframes player-spin {
  to {
    transform: rotate(360deg);
  }
}
.player-resume-toast {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 3;
}
.player-resume-startover {
  padding: 0.2rem 0.6rem;
}
.player-scrubber-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  min-width: 0;
}
.player-buffered {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  width: 0%;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}
.player-scrubber {
  position: relative;
  width: 100%;
}
.player-clock {
  color: var(--muted);
  font-size: 0.82rem;
  min-width: 7.5rem;
  text-align: right;
}
.player-modal:fullscreen .player-video,
.player-video:fullscreen,
.player-stage--plyr .plyr--fullscreen-active video {
  max-height: 100vh;
  width: 100vw;
}
.detail-view .poster-placeholder {
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.85rem;
}
.detail-view .card-main { flex: 1; min-width: 0; padding-top: 4.25rem; }
.detail-view .badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.35rem; }
.detail-view .badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--muted);
}
.detail-view .badge.library { color: var(--accent); }
.detail-view .badge.genre {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.detail-view a.badge.badge-link {
  text-decoration: none;
  cursor: pointer;
}
.detail-view a.badge.badge-link:hover {
  color: var(--accent);
}
.detail-view .badge.tag {
  text-transform: none;
  letter-spacing: 0;
  color: var(--gold);
  background: rgba(227, 179, 65, 0.12);
}
.detail-view .card-main h2 { margin: 0 0 0.35rem; font-size: 1.45rem; }
.detail-view .meta { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.9rem; }
.detail-view .rating { color: var(--gold); }
.detail-view .folder { font-style: italic; }
.detail-view .overview { margin: 0 0 0.75rem; }
.dvr-program-description { line-height: 1.55; margin-bottom: 0.75rem; }
.dvr-section-heading {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.75rem 0 0.35rem;
}
.dvr-recording-details { white-space: pre-line; line-height: 1.55; }
.detail-view .fs-path { font-size: 0.85rem; color: var(--muted); }
.detail-view .fs-note { color: var(--muted); }
.detail-view .card-main h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.detail-view .cast {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}
.detail-view .cast-member {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  background: var(--surface2);
  border-radius: 6px;
  padding: 0.35rem;
}
.detail-view .cast-member img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.detail-view .no-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.detail-view .cast-member span { display: block; color: var(--muted); font-size: 0.75rem; }
.detail-extra {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.detail-extra h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.detail-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.detail-table th, .detail-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.detail-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.detail-table-drill tbody tr.drill-row { cursor: pointer; }
.detail-table-drill tbody tr.drill-row:hover { background: var(--surface2); }
.detail-table-drill td:last-child {
  word-break: break-all;
  font-size: 0.8rem;
  color: var(--muted);
}
.detail-table-drill td:nth-child(1) { white-space: nowrap; }
.detail-extra .file-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.detail-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
@media (max-width: 600px) {
  .detail-view .card-body {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .detail-view .card-main { padding-top: 0; }
  .detail-view .badges { justify-content: center; }
}
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.section h3 { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--muted); }
.tag-editor { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tag-select { min-width: 160px; }

/* Tags admin */
.tags-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tags-table th, .tags-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.empty { color: var(--muted); text-align: center; padding: 2rem; }

/* Profile */
.profile-page {
  max-width: 520px;
  margin: 0 auto;
  padding-top: 1rem;
}
.profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.profile-field-label {
  font-size: 0.8rem;
  color: var(--muted);
}
.profile-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.profile-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.profile-status {
  margin: 0 0 1rem;
  font-size: 0.85rem;
}
.profile-status.success { color: #3fb950; }
.profile-status.error { color: var(--danger); }
.users-page { max-width: 720px; }
.users-table td:last-child { white-space: nowrap; }
.users-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.users-edit-btn {
  padding: 0.25rem 0.45rem;
  line-height: 1;
}
.users-edit-btn .fa-pencil {
  font-size: 0.8rem;
}
.users-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.users-self-label { font-size: 0.8rem; color: var(--muted); }

/* Add-tag modal */
.tag-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.tag-modal {
  width: min(460px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  padding: 1.25rem;
}
.tag-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.tag-modal-title {
  margin: 0;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-modal-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 0.25rem;
}
.tag-modal-empty { color: var(--muted); font-size: 0.85rem; }
.tag-modal-current,
.tag-modal-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.tag-modal-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.tag-modal-input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.tag-modal-status {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.8rem;
  color: var(--muted);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}
.tag-chip-add { cursor: pointer; }
.tag-chip-add:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip-active {
  background: rgba(227, 179, 65, 0.14);
  border-color: rgba(227, 179, 65, 0.4);
  color: var(--gold);
}
.tag-chip-remove {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.tag-chip-remove:hover { color: var(--danger); }

/* Live TV */
.live-main { max-width: 1100px; margin: 0 auto; }
.live-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.live-preview-popped-out .live-preview-video,
.live-preview-popped-out .live-play-overlay {
  display: none;
}
.live-preview-popped-out .live-popout-note {
  display: block;
}
.live-popout-note {
  display: none;
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.live-popout-btn {
  margin-left: 0.75rem;
}
.live-preview-meta { margin: 0 0 0.75rem; font-size: 0.9rem; }
.live-preview-video {
  width: 100%;
  max-height: 420px;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.live-play-overlay {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #3b82f6);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.live-play-overlay.hidden { display: none; }
.live-channels-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}
.live-channels-header h3 { margin: 0; }
.live-listed-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}
.live-list-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}
.live-duration-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.live-list-col {
  width: 2.25rem;
  text-align: center;
}
.live-list-star {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.15rem;
  cursor: pointer;
}
.live-list-star:hover,
.live-list-star.active {
  color: var(--gold);
}
.live-duration-input {
  width: 4rem;
  margin: 0 0.35rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.live-channels-wrap { overflow-x: auto; }
.live-channels-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.live-channels-table th,
.live-channels-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.live-channels-table th { color: var(--muted); font-weight: 600; }
.live-row-active { background: rgba(88, 166, 255, 0.06); }
.live-channel-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.live-record-btn { border-color: var(--gold); color: var(--gold); }
.live-rec-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.35);
}
.live-jobs-list { display: flex; flex-direction: column; gap: 0.5rem; }
.live-job-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.live-job-channel { font-weight: 600; flex: 1; min-width: 140px; }
.live-stop-btn { border-color: var(--danger); color: var(--danger); }
.muted { color: var(--muted); }

/* TV Guide */
.guide-header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.guide-forward-btns {
  display: inline-flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  padding-left: 0.35rem;
  border-left: 1px solid var(--border);
}
.guide-forward-btn { min-width: 2.75rem; }
.guide-main { max-width: none; padding: 0 1rem 1.5rem; }
.guide-status-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 1.75rem;
  margin-bottom: 0.75rem;
}
.guide-live-clock {
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text);
}
.guide-status-msg { font-size: 0.9rem; }
.guide-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .guide-layout { grid-template-columns: 1fr; }
}
.guide-main-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.guide-search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.guide-search-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.guide-search-input:focus {
  outline: none;
  border-color: var(--accent);
}
.guide-search-results {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--surface);
}
.guide-search-results h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}
.guide-search-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.guide-search-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.guide-search-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.guide-search-info:hover .guide-search-title { color: var(--accent); }
.guide-search-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.guide-search-meta { font-size: 0.8rem; }
.guide-search-empty { margin: 0; font-size: 0.9rem; }
.guide-grid-wrap {
  position: relative;
}
.guide-time-header {
  display: grid;
  grid-template-columns: 140px 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.guide-time-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  border-right: 1px solid var(--border);
}
.guide-time-slots {
  display: flex;
  min-height: 2rem;
}
.guide-time-slot {
  flex: 1;
  padding: 0.45rem 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-right: 1px solid var(--border);
  text-align: center;
}
.guide-grid-body {
  position: relative;
  max-height: 70vh;
  overflow-y: auto;
}
.guide-channel-row.unmapped .guide-ch-name { opacity: 0.65; }
.guide-empty, .guide-empty-window {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}
.guide-fav-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.guide-channel-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  border-bottom: 1px solid var(--border);
  min-height: 3rem;
}
.guide-channel-label {
  padding: 0.5rem 0.75rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 0.85rem;
}
.guide-ch-num { font-weight: 600; }
.guide-ch-name { color: var(--muted); font-size: 0.78rem; }
.guide-program-track {
  position: relative;
  min-height: 3rem;
  background: repeating-linear-gradient(
    to right,
    transparent,
    transparent calc(12.5% - 1px),
    rgba(45, 58, 79, 0.35) calc(12.5% - 1px),
    rgba(45, 58, 79, 0.35) 12.5%
  );
}
.guide-program-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border: 1px solid rgba(88, 166, 255, 0.45);
  background: rgba(88, 166, 255, 0.18);
  color: var(--text);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-size: 0.72rem;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.guide-program-block:hover { background: rgba(88, 166, 255, 0.3); }
.guide-program-block.scheduled {
  font-weight: 600;
}
.guide-program-block.scheduled-pending,
.guide-program-block.scheduled:not(.scheduled-recording):not(.scheduled-completed) {
  border-color: rgba(227, 179, 65, 0.85);
  background: rgba(227, 179, 65, 0.28);
  box-shadow: inset 4px 0 0 var(--gold);
}
.guide-program-block.scheduled-pending:hover,
.guide-program-block.scheduled:not(.scheduled-recording):not(.scheduled-completed):hover {
  background: rgba(227, 179, 65, 0.38);
}
.guide-program-block.scheduled-recording {
  border-color: rgba(248, 81, 73, 0.85);
  background: rgba(248, 81, 73, 0.24);
  box-shadow: inset 4px 0 0 var(--danger);
  animation: guide-rec-pulse 2s ease-in-out infinite;
}
.guide-program-block.scheduled-recording:hover {
  background: rgba(248, 81, 73, 0.34);
}
.guide-program-block.scheduled-completed {
  border-color: rgba(63, 185, 80, 0.65);
  background: rgba(63, 185, 80, 0.16);
  box-shadow: inset 4px 0 0 #3fb950;
}
.guide-program-block.scheduled-completed:hover {
  background: rgba(63, 185, 80, 0.24);
}
.guide-prog-block-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
}
.guide-sched-badge {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.28rem;
  border-radius: 3px;
  line-height: 1.2;
}
.scheduled-pending .guide-sched-badge {
  color: var(--gold);
  background: rgba(227, 179, 65, 0.2);
  border: 1px solid rgba(227, 179, 65, 0.45);
}
.scheduled-recording .guide-sched-badge {
  color: #fff;
  background: var(--danger);
}
.scheduled-completed .guide-sched-badge {
  color: #3fb950;
  background: rgba(63, 185, 80, 0.15);
  border: 1px solid rgba(63, 185, 80, 0.4);
}
@keyframes guide-rec-pulse {
  0%, 100% { background: rgba(248, 81, 73, 0.24); }
  50% { background: rgba(248, 81, 73, 0.36); }
}
.guide-program-block.has-episode {
  font-weight: 600;
}
.guide-ep-badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(88, 166, 255, 0.2);
  border: 1px solid rgba(88, 166, 255, 0.45);
  color: var(--accent);
}
.guide-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--danger);
  box-shadow: 0 0 6px rgba(248, 81, 73, 0.65);
  pointer-events: none;
  z-index: 5;
}
.guide-now-line::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 6px rgba(248, 81, 73, 0.65);
}
.guide-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
.guide-sidebar h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.guide-sched-list { display: flex; flex-direction: column; gap: 0.5rem; }
.guide-sched-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 0.85rem;
}
.guide-sched-status { font-size: 0.75rem; text-transform: uppercase; }
.guide-sched-pending { color: var(--gold); }
.guide-sched-recording { color: var(--danger); }
.guide-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.guide-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 480px;
  width: 100%;
}
.guide-modal h3 { margin: 0 0 0.75rem; }
.guide-modal-body { font-size: 0.9rem; margin-bottom: 1rem; }
.guide-prog-desc { color: var(--muted); font-size: 0.85rem; max-height: 8rem; overflow-y: auto; }
.guide-modal-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
