/* ===== Reset & Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background: #0a0a0f;
  color: #c8cad0;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a {
  color: #6ea8fe;
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: #93c5fd;
}
::selection {
  background: #2563eb40;
  color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* ===== Layout ===== */
.container {
  margin: 0 auto;
  padding: 32px 32px;
}
h1 {
  text-align: center;
  margin-bottom: 16px;
  font-size: 1.75rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.search-bar {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Navbar ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: rgba(14, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar-left {
  font-weight: 600;
  color: #fff;
  font-size: 0.95rem;
}
.top-bar-brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  transition: opacity 0.2s;
}
.top-bar-brand:hover {
  opacity: 0.8;
  color: #fff;
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.top-bar-user {
  color: #6b7280;
  font-size: 0.85rem;
}
.top-bar-link {
  color: #9ca3af;
  font-size: 0.85rem;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}
.top-bar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Site Toggle Switch ===== */
.site-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}
.site-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  transition: color 0.3s;
  user-select: none;
}
.site-label.active {
  color: #fff;
}
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 28px;
  transition: background 0.4s;
}
.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .slider {
  background: linear-gradient(135deg, #9333ea, #7c3aed);
}
.switch input:checked + .slider::before {
  transform: translateX(24px);
}

/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
}
.search-bar input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #e0e0e0;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
}
.search-bar input:focus {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.search-bar input::placeholder {
  color: #555;
}
.search-bar button {
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.search-bar button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}
.search-bar button:active {
  transform: translateY(0);
}
.search-bar button:disabled {
  background: #1e1e2a;
  color: #555;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ===== Spinner ===== */
.spinner {
  display: none;
  text-align: center;
  padding: 24px;
  color: #6b7280;
  font-size: 0.9rem;
}

/* ===== Results Grid ===== */
.results {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
}
.card {
  width: 170px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  border-color: rgba(37, 99, 235, 0.3);
}
.card img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  background: #12121a;
}
.card .info {
  padding: 12px 14px;
}
.card .title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e4e9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Downloaded Badge ===== */
.downloaded-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.9);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
  pointer-events: none;
  z-index: 2;
}
.downloaded-badge::after {
  content: "";
  display: block;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  margin: 5px auto 0;
}

/* ===== Modal Overlay ===== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: #111118;
  max-width: 720px;
  margin: 48px auto;
  border-radius: 16px;
  padding: 28px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.modal .close {
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 1.4rem;
  cursor: pointer;
  color: #555;
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.modal .close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* Modal Header */
.modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}
.modal-header img {
  width: 140px;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
  background: #12121a;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.modal-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.modal-meta h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-meta .genres {
  font-size: 0.8rem;
  color: #6ea8fe;
  margin-bottom: 6px;
}
.modal-meta .year {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 10px;
}
.modal-meta .desc {
  font-size: 0.85rem;
  color: #9ca3af;
  line-height: 1.55;
  max-height: 110px;
  overflow-y: auto;
}

/* Controls row */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}
.controls select {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #c8cad0;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.controls select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}
.controls select:focus {
  border-color: #2563eb;
  outline: none;
}

/* Episodes header */
.episodes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.episodes-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e4e9;
}
.select-all-label {
  font-size: 0.8rem;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.select-all-label:hover {
  color: #9ca3af;
}
.select-all-label input {
  margin-right: 5px;
  accent-color: #2563eb;
}

/* Queue sync source badge */
.queue-sync-badge {
  color: #4ade80;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Sync selects (settings & autosync pages) */
.sync-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #e0e0e0;
  font-size: 0.9rem;
  cursor: pointer;
}
.sync-select option {
  color: #000;
  background: #fff;
}

/* Episode list (legacy, kept for compatibility) */
.episode-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.episode-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
  transition: background 0.15s;
}
.episode-item:last-child {
  border-bottom: none;
}
.episode-item:hover {
  background: rgba(255, 255, 255, 0.03);
}
.episode-item input {
  margin-right: 12px;
  flex-shrink: 0;
  accent-color: #2563eb;
}
.episode-item .ep-num {
  color: #6ea8fe;
  width: 50px;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.8rem;
}
.episode-item .ep-downloaded {
  color: #22c55e;
  font-size: 0.85rem;
  margin: 0 6px;
}
.season-label .season-downloaded {
  color: #22c55e;
  font-size: 0.8rem;
  margin-left: 8px;
}
.episode-item .ep-title {
  color: #9ca3af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status bar */
.status-bar {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 10px;
  font-size: 0.85rem;
  color: #6ea8fe;
  display: none;
}
.status-bar.active {
  display: block;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 20px;
  color: #e0e0e0;
  font-size: 0.85rem;
  z-index: 200;
  display: none;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

/* ===== Navbar ===== */
/* (already defined above in Top bar section) */

/* ===== Auth Pages (login / setup) ===== */
.auth-container {
  max-width: 400px;
  margin: 80px auto;
  padding: 36px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.auth-container h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.5rem;
  color: #fff;
}
.auth-container h2 {
  text-align: center;
  margin-bottom: 20px;
  font-size: 1rem;
  color: #6b7280;
  font-weight: 400;
}
.auth-container .auth-info {
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 16px;
  line-height: 1.5;
}
.auth-container .auth-error {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  text-align: center;
}
.auth-container form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-container input {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #e0e0e0;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.auth-container input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.auth-container button {
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.auth-container button:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

/* ===== Settings Page ===== */
.settings-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px;
}
.settings-container h1 {
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: left;
}
.settings-notice {
  font-size: 0.84rem;
  color: #fbbf24;
  line-height: 1.5;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 24px;
}
.settings-notice code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: "SF Mono", "Fira Code", monospace;
}
.settings-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
}
.settings-section h2 {
  font-size: 1.05rem;
  color: #e2e4e9;
  margin-bottom: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-subtitle {
  font-size: 0.9rem;
  color: #9ca3af;
  font-weight: 500;
  margin-bottom: 10px;
}
.settings-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.settings-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #e0e0e0;
  font-size: 0.9rem;
  outline: none;
  min-width: 200px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  font-family: "SF Mono", "Fira Code", monospace;
}
.settings-row input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.settings-row button {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}
.settings-row button:hover {
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.settings-hint {
  font-size: 0.8rem;
  color: #4b5563;
  margin-top: 10px;
}

/* ===== User Management ===== */
.add-user-form {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}
.add-user-form h3 {
  font-size: 0.9rem;
  color: #e2e4e9;
  margin-bottom: 12px;
  font-weight: 600;
}
.add-user-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.add-user-row input,
.add-user-row select {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #e0e0e0;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}
.add-user-row input:focus {
  border-color: #2563eb;
}
.add-user-row button {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.add-user-row button:hover {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.user-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  overflow: hidden;
}
.user-table th,
.user-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.user-table th {
  background: rgba(255, 255, 255, 0.03);
  color: #6b7280;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.user-table td {
  color: #c8cad0;
}
.user-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.user-table select {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #c8cad0;
  font-size: 0.8rem;
}
.btn-del {
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.btn-del:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ===== SSO ===== */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}
.auth-divider span {
  color: #6b7280;
  font-size: 0.85rem;
}
.sso-button {
  display: block;
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #c8cad0;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.sso-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Auth badges */
.auth-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.auth-local {
  background: rgba(37, 99, 235, 0.15);
  color: #6ea8fe;
}
.auth-sso {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

/* ===== Season Accordion ===== */
.season-accordion {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.season-section {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.season-section:last-child {
  border-bottom: none;
}
.season-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.2s;
}
.season-header:hover {
  background: rgba(255, 255, 255, 0.06);
}
.season-header .season-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: #e2e4e9;
  font-weight: 500;
}
.season-header .season-arrow {
  font-size: 0.65rem;
  color: #6b7280;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
}
.season-header.expanded .season-arrow {
  transform: rotate(90deg);
}
.season-header .season-all-label {
  font-size: 0.8rem;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}
.season-header .season-all-label:hover {
  color: #9ca3af;
}
.season-header .season-all-label input {
  cursor: pointer;
  accent-color: #2563eb;
}
.season-body {
  display: none;
  background: rgba(0, 0, 0, 0.15);
}
.season-body.expanded {
  display: block;
}

/* ===== Modal Download Actions ===== */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}
.modal-actions button {
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-download-all {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-download-all:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}
.btn-download-all:active {
  transform: translateY(0);
}
.btn-download-all:disabled {
  background: #1e1e2a;
  color: #555;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn-download-selected {
  background: rgba(255, 255, 255, 0.04);
  color: #6ea8fe;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-download-selected:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #93c5fd;
  border-color: rgba(255, 255, 255, 0.15);
}
.btn-download-selected:disabled {
  background: #1e1e2a;
  color: #444;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.04);
}
.btn-download-all-langs {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}
.btn-download-all-langs:hover {
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
  transform: translateY(-1px);
}
.btn-download-all-langs:active {
  transform: translateY(0);
}
.btn-download-all-langs:disabled {
  background: #1e1e2a;
  color: #555;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ===== Browse Sections ===== */
.browse-section {
  margin-bottom: 48px;
}
.browse-heading {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 18px;
  letter-spacing: -0.02em;
  text-align: center;
}
.browse-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.browse-card {
  width: 170px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.browse-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  border-color: rgba(37, 99, 235, 0.3);
}
.browse-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: #12121a;
  display: block;
}
.browse-card .browse-info {
  padding: 10px 12px;
}
.browse-card .browse-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e4e9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.browse-card .browse-genre {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Random Button ===== */
/* Inherits .search-bar button styles */

/* ===== Queue Badge ===== */
.queue-badge {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* ===== Queue Modal ===== */
.queue-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 150;
  overflow-y: auto;
}
.queue-modal {
  background: #111118;
  max-width: 640px;
  margin: 48px auto;
  border-radius: 16px;
  padding: 28px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.queue-modal .close {
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 1.4rem;
  cursor: pointer;
  color: #555;
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.queue-modal .close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.queue-modal-title {
  font-size: 1.15rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

/* Queue list */
.queue-list {
  max-height: 500px;
  overflow-y: auto;
}
.queue-empty {
  text-align: center;
  color: #6b7280;
  padding: 40px 20px;
  font-size: 0.9rem;
}

/* Queue item */
.queue-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: all 0.2s;
}
.queue-item:last-child {
  margin-bottom: 0;
}
.queue-item-active {
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(37, 99, 235, 0.06);
}
.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 10px;
}
.queue-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e4e9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.queue-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.queue-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: #6b7280;
}
.queue-item-meta span {
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: 5px;
}
.queue-user {
  color: #a78bfa !important;
  background: rgba(167, 139, 250, 0.1) !important;
}

/* Status badges */
.queue-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.queue-status-running {
  background: rgba(37, 99, 235, 0.15);
  color: #6ea8fe;
}
.queue-status-queued {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}
.queue-status-completed {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
.queue-status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.queue-status-cancelling {
  background: rgba(251, 146, 36, 0.15);
  color: #fb923c;
}
.queue-status-cancelled {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

/* Progress bar */
.queue-progress {
  margin-top: 10px;
}
.queue-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 5px;
}
.queue-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.queue-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Errors */
.queue-errors {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #f87171;
}
.queue-errors-expandable {
  cursor: pointer;
  user-select: none;
}
.queue-errors-expandable:hover {
  color: #fca5a5;
}
.queue-errors-toggle {
  font-size: 0.6rem;
  display: inline-block;
  transition: transform 0.2s;
  margin-left: 4px;
}
.queue-error-details {
  display: none;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.12);
}
.queue-error-details.expanded {
  display: block;
}
.queue-errors-expandable.expanded .queue-errors-toggle {
  transform: rotate(90deg);
}
.queue-error-detail {
  font-size: 0.75rem;
  color: #fca5a5;
  padding: 4px 0;
  border-bottom: 1px solid rgba(239, 68, 68, 0.08);
  word-break: break-word;
}
.queue-error-detail:last-child {
  border-bottom: none;
}

/* Remove button */
.queue-remove {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.2s;
  line-height: 1;
}
.queue-remove:hover {
  color: #f87171;
}
.queue-move {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 3px;
  transition: color 0.2s;
  line-height: 1;
}
.queue-move:hover {
  color: #6ea8fe;
}
.queue-cancel {
  background: none;
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.queue-cancel:hover {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.5);
}

/* ===== Library Page ===== */
.library-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px;
}
.library-container h1 {
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: left;
}
.library-list {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
.library-empty {
  text-align: center;
  color: #6b7280;
  padding: 40px 20px;
  font-size: 0.9rem;
}

/* Location header */
.library-location-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  background: rgba(37, 99, 235, 0.06);
  border-bottom: 1px solid rgba(37, 99, 235, 0.1);
  transition: background 0.2s;
}
.library-location-header:hover {
  background: rgba(37, 99, 235, 0.1);
}

/* Title accordion */
.library-title-section {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.library-title-section:last-child {
  border-bottom: none;
}
.library-title-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.2s;
}
.library-title-header:hover {
  background: rgba(255, 255, 255, 0.06);
}
.library-title-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.library-title-name {
  font-size: 0.88rem;
  color: #e2e4e9;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-title-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.library-arrow {
  font-size: 0.65rem;
  color: #6b7280;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  flex-shrink: 0;
}
.library-arrow.expanded {
  transform: rotate(90deg);
}
.library-title-body {
  display: none;
  background: rgba(0, 0, 0, 0.15);
}
.library-title-body.expanded {
  display: block;
}

/* Season rows */
.library-season-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 10px 32px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  font-size: 0.85rem;
  color: #c8cad0;
}
.library-season-header:hover {
  background: rgba(255, 255, 255, 0.03);
}
.library-season-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.library-season-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.library-season-body {
  display: none;
  background: rgba(0, 0, 0, 0.1);
}
.library-season-body.expanded {
  display: block;
}

/* Episode rows */
.library-episode {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 48px;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s;
}
.library-episode:last-child {
  border-bottom: none;
}
.library-episode:hover {
  background: rgba(255, 255, 255, 0.02);
}
.library-ep-num {
  color: #6ea8fe;
  width: 44px;
  flex-shrink: 0;
  font-weight: 600;
}
.library-ep-file {
  color: #9ca3af;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-ep-size {
  color: #6b7280;
  flex-shrink: 0;
  font-size: 0.78rem;
}

/* Meta badges */
.library-meta {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  text-align: center;
}
.library-meta-size {
  width: 76px;
  flex-shrink: 0;
}

/* Delete button */
.library-delete {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.2s;
  line-height: 1;
  flex-shrink: 0;
}
.library-delete:hover {
  color: #f87171;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container {
    padding: 20px 14px;
  }
  .modal {
    margin: 20px 12px;
    padding: 20px;
  }
  .modal-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .modal-header img {
    width: 120px;
    height: 170px;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions button {
    width: 100%;
  }
  .search-bar {
    flex-wrap: wrap;
  }
  .search-bar input {
    min-width: 100%;
  }
  .settings-row {
    flex-direction: column;
  }
  .settings-row input {
    width: 100%;
    min-width: 0;
  }
  .settings-row button {
    width: 100%;
  }
  .queue-modal {
    margin: 20px 12px;
    padding: 20px;
  }
  .library-container {
    padding: 20px 14px;
  }
}
