:root {
  --bg: #060B14;
  --surface: #0a1020;
  --surface2: #0e1730;
  --surface3: #121e3d;
  --border: rgba(96, 165, 250, 0.18);
  --border-strong: rgba(96, 165, 250, 0.4);
  --accent: #38BDF8;
  --accent-2: #2563EB;
  --accent-glow: rgba(37, 99, 235, 0.35);
  --text: #ffffff;
  --text-2: #b6c4d9;
  --muted: #5a6a85;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}
body {
  background-image:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(37, 99, 235, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 70% 40% at 100% 100%, rgba(56, 189, 248, 0.10) 0%, transparent 55%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 11, 20, 0.65);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #7dd3fc 0%, var(--accent) 40%, var(--accent-2) 100%);
  box-shadow: 0 0 14px var(--accent-glow);
  position: relative;
}
.brand-logo::before {
  content: '';
  position: absolute; inset: 8px;
  border: 2px solid rgba(255,255,255,0.9);
  transform: rotate(45deg);
  border-radius: 2px;
}
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: 0.4px; }
.brand-sub { font-size: 11px; color: var(--text-2); }
.topnav { display: flex; gap: 22px; }
.link { color: var(--text-2); font-size: 14px; font-weight: 500; transition: color .18s; }
.link:hover { color: var(--accent); }

/* ---------- Layout ---------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ---------- Hero + Search ---------- */
.hero {
  text-align: center;
  padding: 40px 0 30px;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 18px;
}
.grad {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .lead {
  color: var(--text-2);
  font-size: 17px;
  max-width: 640px;
  margin: 0 auto 32px;
  line-height: 1.5;
}

.search {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px -20px rgba(37, 99, 235, 0.35);
}
.search input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  transition: border-color .18s;
}
.search input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.search input[type="text"]::placeholder { color: var(--muted); }

.category-row {
  display: flex;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  align-self: stretch;
}
.cat-chip {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: all .16s;
}
.cat-chip input { display: none; }
.cat-chip:has(input:checked) {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  box-shadow: 0 4px 12px -4px var(--accent-glow);
}
.cat-chip:not(:has(input:checked)):hover {
  color: var(--text);
  background: rgba(56, 189, 248, 0.06);
}

.sources-toggle {
  position: relative;
}
.sources-toggle summary {
  list-style: none;
  cursor: pointer;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: border-color .16s;
  user-select: none;
}
.sources-toggle summary::-webkit-details-marker { display: none; }
.sources-toggle summary::after {
  content: ' ▾';
  color: var(--muted);
  font-size: 11px;
}
.sources-toggle[open] summary { border-color: var(--accent); }
.sources-toggle[open] summary::after { content: ' ▴'; }
.sources-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  min-width: 200px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.5);
}
.sources-list .chip {
  background: transparent;
  border: 1px solid var(--border);
  justify-content: flex-start;
  width: 100%;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all .16s;
}
.chip input { accent-color: var(--accent); }
.chip:has(input:checked) {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}
.select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .16s;
}
.select:focus { outline: none; border-color: var(--accent); }
.select option { background: var(--surface2); }

.cta {
  align-self: stretch;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 8px 20px -6px var(--accent-glow);
  transition: transform .12s, box-shadow .16s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -6px var(--accent-glow); }
.cta:active { transform: translateY(0); }
.cta:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  transition: all .16s;
}
.ghost:hover { border-color: var(--accent); background: var(--surface3); }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 18px;
}

.key-warn {
  max-width: 820px;
  margin: 14px auto 0;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
}
.key-warn strong { color: var(--warn); font-weight: 700; }
.key-warn a { color: var(--accent); text-decoration: underline; margin-left: 4px; }

/* ---------- Results ---------- */
.results { margin-top: 48px; }
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.results-head h2 { font-size: 22px; font-weight: 700; }
.results-meta { color: var(--text-2); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .16s, transform .16s;
  display: flex; flex-direction: column;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.card-media video, .card-media img {
  width: 100%; height: 100%; object-fit: cover;
}
.card-badges {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: flex; gap: 6px; flex-wrap: wrap;
  pointer-events: none;
}
.badge {
  background: rgba(6, 11, 20, 0.85);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  color: var(--text);
}
.badge.res { color: var(--accent); }
.badge.fps { color: var(--accent); }
.badge.src {
  background: rgba(37, 99, 235, 0.22);
  border-color: transparent;
  color: #fff;
}
.badge.warn { color: var(--warn); }

.badge.type {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}
.badge.type-twixtor {
  background: rgba(217, 70, 239, 0.18);
  border-color: rgba(217, 70, 239, 0.4);
  color: #f0abfc;
}
.badge.type-episode {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}
.badge.type-scenepack, .badge.type-4k {
  background: rgba(56, 189, 248, 0.20);
  border-color: rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
}
.badge.type-trailer, .badge.type-teaser {
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(148, 163, 184, 0.3);
  color: #cbd5e1;
}

.card-body {
  padding: 12px 14px 14px;
  display: flex; flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub {
  font-size: 11.5px;
  color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.card-actions {
  display: flex; gap: 6px; margin-top: auto; padding-top: 8px;
}
.card-actions .btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 12.5px;
  border-radius: 8px;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all .14s;
}
.card-actions .btn:hover { border-color: var(--accent); background: var(--surface3); }
.card-actions .btn.primary {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
}
.card-actions .btn.primary:hover { transform: translateY(-1px); }

.loadmore {
  display: flex; justify-content: center;
  margin-top: 28px;
}

/* ---------- Empty ---------- */
.empty { margin-top: 60px; text-align: center; }
.empty-inner {
  max-width: 400px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
}
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty h3 { font-size: 18px; margin-bottom: 8px; }
.empty p { color: var(--text-2); font-size: 14px; line-height: 1.5; }

/* ---------- Section ---------- */
.section { margin-top: 80px; }
.section h2 { font-size: 24px; font-weight: 700; margin-bottom: 22px; }

.how {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.how-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
}
.how-num {
  position: absolute; top: 16px; right: 16px;
  font-size: 34px; font-weight: 800;
  color: var(--accent);
  opacity: 0.35;
  line-height: 1;
}
.how-card h3 { font-size: 15.5px; margin-bottom: 8px; }
.how-card p { color: var(--text-2); font-size: 13.5px; line-height: 1.55; }

.sources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.source-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.source-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.source-head h3 { font-size: 16px; }
.tag {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.tag.ok {
  color: var(--ok);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}
.tag.warn {
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}
.source-card p { color: var(--text-2); font-size: 13.5px; line-height: 1.55; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 80px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}
.footer a { color: var(--accent); }
.footer-sub { margin-top: 6px; color: var(--muted); font-size: 12px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 11, 20, 0.78);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-2);
  transition: all .14s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}
#cutterVideo {
  width: 100%;
  max-height: 46vh;
  background: #000;
  border-radius: var(--radius-sm);
}
.timeline {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.time-row { display: flex; flex-direction: column; gap: 6px; }
.time-row label {
  font-size: 12.5px; color: var(--text-2);
  display: flex; justify-content: space-between;
}
.time-row label span { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.time-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.duration { font-size: 13px; color: var(--text-2); }
.duration strong { color: var(--accent); font-variant-numeric: tabular-nums; }

.status {
  font-size: 12.5px;
  color: var(--text-2);
  min-height: 18px;
  text-align: center;
}
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---------- Loading skeletons ---------- */
.skel {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 14px 18px; }
  .topnav { gap: 14px; }
  .link { font-size: 13px; }
  .wrap { padding: 24px 14px 60px; }
  .search { padding: 14px; }
  .modal { padding: 8px; }
  .modal-body { padding: 14px; }
}
