:root {
  --bg: #090d16;
  --bg-elev: #111827;
  --bg-card: rgba(17, 24, 39, 0.78);
  --bg-card-hover: rgba(24, 34, 54, 0.94);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --online: #10b981;
  --online-bg: rgba(16, 185, 129, 0.12);
  --online-border: rgba(16, 185, 129, 0.35);
  --offline: #ef4444;
  --offline-bg: rgba(239, 68, 68, 0.12);
  --offline-border: rgba(239, 68, 68, 0.35);
  --warn: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.28;
}

.bg-glow-1 {
  width: 520px;
  height: 520px;
  top: -180px;
  left: -120px;
  background: radial-gradient(circle, #38bdf8, transparent 70%);
}

.bg-glow-2 {
  width: 540px;
  height: 540px;
  top: -120px;
  right: -140px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(9, 13, 22, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.25);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.brand-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: all 0.25s ease;
}

.status-pill.status-online {
  background: var(--online-bg);
  border-color: var(--online-border);
}

.status-pill.status-offline {
  background: var(--offline-bg);
  border-color: var(--offline-border);
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--warn);
  flex-shrink: 0;
  position: relative;
}

.status-online .status-dot {
  background: var(--online);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

.status-offline .status-dot {
  background: var(--offline);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65); }
  70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.status-text strong {
  font-size: 0.88rem;
  font-weight: 700;
}

.status-online .status-text strong { color: #6ee7b7; }
.status-offline .status-text strong { color: #fca5a5; }

.status-text span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Main content */
.main-content {
  flex: 1;
  padding-top: 24px;
  padding-bottom: 56px;
}

.hidden {
  display: none !important;
}

/* Offline banner */
.offline-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 22px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(153, 27, 27, 0.1));
  border: 1px solid var(--offline-border);
}

.offline-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.offline-banner-icon svg {
  width: 20px;
  height: 20px;
}

.offline-banner strong {
  display: block;
  color: #fecaca;
  font-size: 0.94rem;
  margin-bottom: 2px;
}

.offline-banner p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.84rem;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(8px);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.stat-value-sm {
  font-size: 1.05rem;
  margin-top: 4px;
}

.stat-hint {
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* Toolbar */
.toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 26px;
  backdrop-filter: blur(10px);
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.tabs {
  display: inline-flex;
  background: rgba(9, 13, 22, 0.7);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  gap: 4px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.18s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.22));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.tab-count {
  font-size: 0.74rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

.tab.active .tab-count {
  background: rgba(56, 189, 248, 0.25);
  color: #e0f2fe;
}

.search-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  min-width: 260px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 34px 9px 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.72);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.sort-select {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.72);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.sort-select:focus {
  border-color: var(--accent);
}

.view-toggle {
  display: inline-flex;
  background: rgba(9, 13, 22, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.icon-btn {
  width: 32px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 7px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  color: #fff;
}

.icon-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
}

/* Genre pills */
.genre-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.genre-pill {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.genre-pill:hover {
  border-color: var(--border-strong);
  color: #fff;
}

.genre-pill.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
}

.genre-pill-count {
  font-size: 0.72rem;
  opacity: 0.75;
}

/* Sections */
.media-section {
  margin-bottom: 36px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

/* Films grid */
.films-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.film-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.film-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
}

.film-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.genre-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75%;
}

.ext-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  flex-shrink: 0;
}

.ext-badge.ext-mkv {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
}

.ext-badge.ext-mp4 {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.ext-badge.ext-avi {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

.film-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  word-break: break-word;
}

.film-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.film-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

/* Films list mode */
.films-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.films-list .film-card {
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  gap: 16px;
}

.films-list .film-card:hover {
  transform: none;
}

.films-list .film-body {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.films-list .film-card-top {
  flex-shrink: 0;
}

.films-list .film-title-wrap {
  flex: 1;
  min-width: 180px;
}

.films-list .film-actions {
  margin-top: 0;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-download {
  flex: 1;
  background: linear-gradient(135deg, #0ea5e9, #4f46e5);
  color: #fff;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.24);
}

.btn-download:hover {
  filter: brightness(1.1);
  box-shadow: 0 8px 22px rgba(14, 165, 233, 0.36);
}

.btn-download.disabled,
.btn-download:disabled {
  background: rgba(51, 65, 85, 0.55);
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-copy {
  padding: 9px 10px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-copy:hover {
  background: rgba(148, 163, 184, 0.22);
  color: #fff;
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.14);
  color: #fff;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.24);
}

/* Series accordion */
.series-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.series-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.series-card.open {
  border-color: rgba(99, 102, 241, 0.4);
}

.series-header {
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease;
}

.series-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.series-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.series-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(56, 189, 248, 0.25));
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #e0e7ff;
  font-weight: 800;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.series-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: #fff;
}

.series-meta {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.series-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.22s ease;
  flex-shrink: 0;
}

.series-card.open .series-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.series-body {
  display: none;
  padding: 0 20px 18px;
  border-top: 1px solid var(--border);
}

.series-card.open .series-body {
  display: block;
}

.season-block {
  margin-top: 16px;
}

.season-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.season-title {
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a5b4fc;
}

.season-size {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.episode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.episode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(9, 13, 22, 0.58);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.episode-row:hover {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(15, 23, 42, 0.85);
}

.episode-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.episode-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.episode-name-wrap {
  min-width: 0;
}

.episode-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.episode-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.episode-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.episode-actions .btn-download {
  flex: initial;
  padding: 7px 12px;
  font-size: 0.8rem;
}

.episode-actions .btn-copy {
  padding: 7px 9px;
}

/* Empty & Loading */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent);
  border-radius: 999px;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.22s ease;
  max-width: 340px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .status-pill {
    justify-content: center;
  }

  .films-list .film-card {
    flex-direction: column;
    align-items: stretch;
  }

  .episode-row {
    flex-direction: column;
    align-items: stretch;
  }

  .episode-actions {
    justify-content: flex-end;
  }

  .search-controls {
    width: 100%;
    justify-content: stretch;
  }

  .search-box {
    max-width: none;
  }
}
