:root {
  --bg: #0f1115;
  --panel: #181b22;
  --line: #262a33;
  --text: #e8e9ec;
  --muted: #9aa0ab;
  --accent: #e5484d;
  --accent-text: #fff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; text-decoration: none; }

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 17, 21, 0.96);
  border-bottom: 1px solid var(--line);
}

.bar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 16px 8px;
  max-width: 1280px;
  margin: 0 auto;
}

.brand { font-weight: 700; font-size: 18px; color: var(--accent); white-space: nowrap; }

.search { flex: 1; display: flex; gap: 6px; min-width: 0; }
.search input, .search select {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.search input { flex: 1; min-width: 0; width: 100%; }
.search select { flex: none; cursor: pointer; }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 16px 8px;
  max-width: 1280px;
  margin: 0 auto;
  scrollbar-width: none;
}
.tabs a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--text); color: var(--bg); }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }

h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.chips span { color: var(--muted); }
.chips a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.chips a:hover { border-color: var(--muted); }

.row { margin-bottom: 24px; }
.rowhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.rowhead a { color: var(--muted); font-size: 14px; }
.rowhead a:hover { color: var(--text); }

.scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 140px;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px 12px;
}

.card { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card img, .card .noposter {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel);
}
.card .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card small { color: var(--muted); }
.card:hover img { outline: 2px solid var(--muted); }

.title { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.title .poster { width: 220px; border-radius: 10px; flex-shrink: 0; }
.title .meta { display: flex; gap: 14px; color: var(--muted); margin: 0 0 8px; }
.title .genres { color: var(--muted); margin: 0 0 12px; }
.title .desc { max-width: 70ch; }

.episodes h2 { margin: 16px 0 8px; }
.eps { display: flex; flex-wrap: wrap; gap: 6px; }
.eps a {
  min-width: 40px;
  padding: 6px 10px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.eps a:hover { border-color: var(--muted); }
.eps a.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.downloads { margin-top: 24px; }
.downloads h2 { margin-bottom: 10px; }

.streams { width: 100%; border-collapse: collapse; }
.streams th { text-align: left; color: var(--muted); font-weight: 500; }
.streams th, .streams td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.streams td:first-child { word-break: break-word; }

.download {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  white-space: nowrap;
}
.download:hover { filter: brightness(1.1); }

.pager { display: flex; justify-content: space-between; margin: 24px 0; }
.pager a { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; }

.empty { color: var(--muted); }

.error { text-align: center; padding: 64px 0; }
.error h1 { font-size: 48px; margin: 0; }
.error a { color: var(--accent); }

@media (max-width: 640px) {
  .title { flex-direction: column; }
  .title .poster { width: 160px; }
  .streams th:first-child, .streams td:first-child { display: none; }
  .scroller { grid-auto-columns: 118px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
