/* ── AllDL · токены (спецификация 6.6) ─────────────────────────── */
:root {
  --bg-0: #09090b;
  --bg-1: #13151a;
  --bg-2: #1a1830;
  --bg-3: #10131f;
  --panel: rgba(20, 20, 25, 0.65);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text-hi: #f4f4f5;
  --text-mid: #a1a1aa;
  --text-low: #71717a;
  --accent-1: #8b5cf6;
  --accent-2: #ec4899;
  --accent-3: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --aurora-1: rgba(139, 92, 246, 0.5);
  --aurora-2: rgba(236, 72, 153, 0.42);
  --aurora-3: rgba(34, 211, 238, 0.36);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, serif;
  --font-mono: "Space Mono", ui-monospace, "Cascadia Mono", monospace;
  --radius: 16px;
  --blur: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

/* ── База ─────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--bg-2), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--bg-3), transparent 60%),
    var(--bg-0);
  color: var(--text-hi);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-1); color: #fff; }

button { font-family: inherit; }

/* ── Фоновые слои ─────────────────────────────────────────────── */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(520px 420px at 12% 18%, var(--aurora-1), transparent 65%),
    radial-gradient(560px 460px at 88% 12%, var(--aurora-2), transparent 65%),
    radial-gradient(640px 520px at 70% 92%, var(--aurora-3), transparent 68%),
    radial-gradient(420px 380px at 35% 75%, rgba(139, 92, 246, 0.25), transparent 70%);
  animation: drift 26s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d(1.5%, 1%, 0) scale(1.06); }
}

.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, #000 30%, transparent 100%);
  pointer-events: none;
}

/* ── Стеклянные панели ────────────────────────────────────────── */
.glass {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
}

/* ── Шапка ────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px auto 0;
  padding: 12px 20px;
  max-width: 980px;
  border-radius: 14px;
}

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }

.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  font-size: 17px;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.45);
}

.logo-word {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.02em;
}

.header-status { display: flex; align-items: center; gap: 8px; color: var(--text-mid); font-size: 13px; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px currentColor;
}

.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.err { background: var(--err); box-shadow: 0 0 10px var(--err); }

/* ── Раскладка ────────────────────────────────────────────────── */
.layout {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px 90px;
}

/* ── Hero + ввод ──────────────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 34px; }

.hero-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(30px, 5.4vw, 48px);
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  background: linear-gradient(100deg, #f4f4f5 30%, #c4b5fd 60%, #f0abfc 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub { color: var(--text-mid); margin: 0 auto 26px; max-width: 560px; }

.input-panel { position: relative; padding: 14px; text-align: left; }

#url-input {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(9, 9, 11, 0.55);
  color: var(--text-hi);
  font: 400 14px/1.55 var(--font-mono);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

#url-input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22); }
#url-input::placeholder { color: var(--text-low); }

.input-panel-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.hint { color: var(--text-low); font-size: 12px; }

/* ── Кнопки ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-hi);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
  user-select: none;
}

.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover { box-shadow: 0 8px 26px rgba(139, 92, 246, 0.55); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.07); }

.btn-icon { padding: 8px 14px; font-size: 13px; }

.danger:hover { border-color: rgba(248, 113, 113, 0.5); color: var(--err); }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

/* ── Панель действий ──────────────────────────────────────────── */
.queue-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
  border-radius: 14px;
}

.toolbar-spacer { flex: 1; }

/* ── Карточки ─────────────────────────────────────────────────── */
.cards { display: grid; gap: 16px; }

.card {
  position: relative;
  display: grid;
  grid-template-columns: 46px 128px 1fr;
  gap: 14px;
  padding: 16px;
  animation: card-in 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card.deleting { opacity: 0; transform: translateX(24px); transition: opacity 0.28s, transform 0.28s; }

.card-select { display: grid; place-items: start; padding-top: 4px; }

.card-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-1);
  cursor: pointer;
}

.card-thumb {
  position: relative;
  width: 128px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb-fallback {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(236, 72, 153, 0.25));
}

.thumb-img:not([src]), .thumb-img[src=""], .thumb-img.load-fail { opacity: 0; }
.thumb-img:not([src]) + .thumb-fallback, .thumb-img[src=""] + .thumb-fallback, .thumb-img.load-fail + .thumb-fallback { opacity: 1; }

.card-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.card-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.card-source {
  font: 700 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-mid);
}

.card-status[data-status="ready"] { background: rgba(34, 211, 238, 0.14); color: var(--accent-3); }
.card-status[data-status="queued"] { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.card-status[data-status="fetching"] { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.card-status[data-status="downloading"] { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.card-status[data-status="processing"] { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.card-status[data-status="done"] { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.card-status[data-status="error"] { background: rgba(248, 113, 113, 0.14); color: var(--err); }
.card-status[data-status="expired"] { background: rgba(113, 113, 122, 0.2); color: var(--text-low); }

.card-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-low); font-size: 12.5px; }

/* Скелетон */
.card.skeleton .card-title { color: transparent; background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.14), rgba(255,255,255,0.06)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; height: 22px; width: 70%; margin-top: 2px; }
.card.skeleton .card-meta span { display: inline-block; height: 12px; width: 90px; border-radius: 6px; background: rgba(255,255,255,0.07); }
.card.skeleton .thumb-fallback { opacity: 1; animation: pulse 1.4s infinite; }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse { 50% { opacity: 0.5; } }

/* Прогресс */
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  transition: width 0.45s ease;
}

.progress-info { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-low); margin-top: 4px; }
.progress-detail { font-family: var(--font-mono); font-size: 11px; }

/* Ошибка */
.card-error {
  color: var(--err);
  font-size: 12.5px;
  background: rgba(248, 113, 113, 0.09);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 10px;
  padding: 8px 12px;
}

/* Действия */
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.mode-group {
  display: inline-flex;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-low);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-btn:hover { color: var(--text-hi); }

.mode-btn.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(236, 72, 153, 0.28));
  color: #fff;
}

.card-files { display: flex; gap: 8px; }

.file-link { text-decoration: none; }
.file-link[hidden] { display: none; }

/* ── Пустое состояние ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 70px 20px; color: var(--text-low); }

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 26px;
  color: var(--text-mid);
  border: 1px dashed rgba(255, 255, 255, 0.2);
}

.empty-title { font-family: var(--font-serif); font-size: 20px; color: var(--text-mid); margin: 0 0 6px; }
.empty-sub { margin: 0; font-size: 13.5px; }

/* ── Тост ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, 90vw);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(20, 20, 25, 0.92);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }
.toast.err { border-color: rgba(248, 113, 113, 0.55); }

/* ── Футер ────────────────────────────────────────────────────── */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  text-align: center;
  color: var(--text-low);
  font-size: 12px;
  background: linear-gradient(transparent, rgba(9, 9, 11, 0.85));
  pointer-events: none;
}

/* ── Адаптивность ─────────────────────────────────────────────── */
@media (max-width: 720px) {
  .card { grid-template-columns: 40px 1fr; }
  .card-thumb { grid-column: 1 / -1; width: 100%; height: 150px; }
  .card-select { grid-row: 1; }
  .card-body { grid-column: 1 / -1; }
  .hero-sub { font-size: 14px; }
}

/* ── Уважение к снижению анимаций ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
