:root {
  --bg: #0a0e14;
  --surface: #141b26;
  --surface-hover: #1c2738;
  --border: #2a3648;
  --text: #eef2f7;
  --text-muted: #8fa3bc;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --purple: #a78bfa;
  --radius: 14px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(167, 139, 250, 0.08), transparent);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 1024px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.header {
  margin-bottom: 2rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}

.logo-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 14px;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.search-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.search-input-wrap {
  flex: 1;
  min-width: 220px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  inset-inline-end: 1rem;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1.1rem;
  line-height: 1;
}

.search-form input {
  width: 100%;
  padding-block: 0.85rem;
  padding-inline-start: 1rem;
  padding-inline-end: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

button {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-search {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  min-width: 100px;
}

.btn-search:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  width: 100%;
  margin-top: 1rem;
  padding: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.btn-watch {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.35);
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-watch:hover {
  background: rgba(34, 197, 94, 0.25);
}

.hidden {
  display: none !important;
}

.section-head h2 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge {
  background: var(--accent);
  color: white;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.queued {
  background: #6366f1;
}

.badge.awaiting {
  background: var(--warning);
  color: #1a1a1a;
}

.badge.done {
  background: var(--success);
}

.badge.cancelled,
.badge.failed {
  background: var(--danger);
}

.progress-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.progress-bar-track {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #818cf8, var(--purple));
  border-radius: 5px;
  transition: width 0.35s ease;
}

.progress-message {
  margin-top: 0.65rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.selection-actions {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.candidates-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  padding: 2px;
}

.candidate-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.candidate-item:hover {
  background: var(--surface-hover);
}

.candidate-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.candidate-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.candidate-thumb-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--border);
}

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

.candidate-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: var(--surface-hover);
}

.candidate-info h3 {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.results-title {
  font-size: 1.3rem;
}

.result-group {
  margin-bottom: 2rem;
}

.result-group > h3 {
  color: var(--accent);
  margin-bottom: 1rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-group > h3::before {
  content: '';
  width: 4px;
  height: 1.1em;
  background: linear-gradient(var(--accent), var(--purple));
  border-radius: 2px;
}

.results-grid .result-card {
  margin-bottom: 1.25rem;
}

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

.result-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.result-hero {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.06) 0%, transparent 100%);
}

.result-poster-wrap {
  flex-shrink: 0;
  width: 110px;
  height: 160px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--border);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.result-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-poster.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result-body h3 {
  font-size: 1.15rem;
  margin-bottom: 0.65rem;
  line-height: 1.35;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.meta-chip {
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

.meta-chip strong {
  color: var(--text);
  font-weight: 500;
}

.result-actions-top {
  margin-top: 0.85rem;
}

.result-content {
  padding: 0 1.25rem 1.25rem;
}

.qualities h4,
.episodes h4 {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.65rem;
}

.quality-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.quality-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}

.quality-row:hover {
  border-color: rgba(59, 130, 246, 0.45);
}

.quality-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.quality-size {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.quality-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.quality-download {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
}

.quality-download:hover {
  border-color: var(--accent);
}

.episode-block {
  border-right: 3px solid var(--accent);
  padding-right: 0.85rem;
  margin-bottom: 1rem;
}

.episode-block h5 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.swal2-popup {
  font-family: var(--font) !important;
}

.site-footer {
  max-width: 1024px;
  margin: 2.5rem auto 0;
  padding: 1.5rem 1.25rem 2rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-made {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.65rem;
}

.footer-made strong {
  color: var(--text);
  font-weight: 600;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem 1.25rem;
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.15s;
}

.footer-link:hover {
  color: var(--purple);
  text-decoration: underline;
}

@media (max-width: 480px) {
  .footer-links {
    flex-direction: column;
    gap: 0.45rem;
  }
}

@media (max-width: 600px) {
  .result-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .result-meta {
    justify-content: center;
  }

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

  .quality-actions {
    justify-content: stretch;
  }

  .quality-actions .btn-watch,
  .quality-actions .quality-download {
    flex: 1;
    justify-content: center;
  }
}
