:root {
  --bg: #0d1017;
  --bg2: #141926;
  --card: #171d2e;
  --line: #232b45;
  --txt: #e8ecf5;
  --mut: #9aa3c0;
  --acc: #8b7cff;
  --acc2: #5b4fe0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(13, 16, 23, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo {
  font-weight: 800; font-size: 1.25rem; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--acc), #4fd1e0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.search {
  flex: 1; max-width: 420px; margin-left: auto;
  background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 9px 14px; font-size: .95rem; outline: none;
}
.search:focus { border-color: var(--acc); }
.back { color: var(--mut); font-size: .9rem; margin-left: auto; white-space: nowrap; }
.back:hover { color: var(--txt); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.wrap h2 { font-size: 1.15rem; margin: 22px 0 12px; }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; position: relative; transition: transform .15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--acc); }
.card img, .poster-ph { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.poster-ph {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #232b45, #3a2d6e);
  font-size: 2rem; font-weight: 800; color: var(--acc);
}
.card-ep {
  position: absolute; top: 8px; left: 8px;
  background: var(--acc2); font-size: .72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}
.card-title { padding: 10px; font-size: .85rem; line-height: 1.35; }

.detail { display: flex; gap: 18px; flex-wrap: wrap; }
.detail .poster-wrap { width: 180px; flex-shrink: 0; }
.detail .poster-wrap img, .detail .poster-wrap .poster-ph { border-radius: 12px; }
.detail-info { flex: 1; min-width: 240px; }
.detail-info h1 { font-size: 1.5rem; margin-bottom: 8px; }
.meta { color: var(--mut); font-size: .88rem; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  font-size: .78rem; background: var(--bg2); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 20px; color: var(--mut);
}
.syn { color: #c6cde4; font-size: .92rem; line-height: 1.65; }

.ep-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ep-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 12px; text-align: left; cursor: pointer; font-size: .88rem;
}
.ep-btn:hover { border-color: var(--acc); }
.ep-btn.active { border-color: var(--acc); background: #1e2540; }
.ep-btn .t { color: var(--mut); font-size: .78rem; display: block; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.watch-title { font-size: 1.2rem; }
.player {
  position: relative; width: 100%; aspect-ratio: 16/9;
  background: #000; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); margin: 12px 0;
}
.player-frame { width: 100%; height: 100%; border: 0; }
.play-overlay {
  position: absolute; inset: 0; width: 100%; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #1a2140, #05070c);
  border: 0; color: var(--txt);
  display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center;
}
.play-btn {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--acc); display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; padding-left: 6px;
}
.play-txt { color: var(--mut); font-size: .9rem; }
.player-empty { color: var(--mut); font-size: .9rem; text-align: center; padding: 0 24px; line-height: 1.6; }

.ep-nav { display: flex; gap: 10px; margin-bottom: 6px; align-items: stretch; }
.btn {
  flex: 1; background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 11px; font-size: .9rem; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--acc); }
.btn:disabled { opacity: .35; cursor: default; }
.quality-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px;
}
.q-label { color: var(--mut); font-size: .78rem; white-space: nowrap; }
.q-btns { display: flex; gap: 6px; }
.q-btn {
  background: transparent; border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 6px 12px; font-size: .8rem; cursor: pointer;
}
.q-btn.active { border-color: var(--acc); background: #1e2540; }

.foot {
  text-align: center; color: var(--mut); font-size: .8rem;
  padding: 26px 16px; border-top: 1px solid var(--line);
}

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .detail .poster-wrap { width: 220px; }
}

/* ---------- v0.2 additions ---------- */
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  position: relative; padding: 8px 14px; border-radius: 10px;
  color: var(--mut); font-size: .9rem; font-weight: 600; white-space: nowrap;
}
.tab:hover { color: var(--txt); background: var(--bg2); }
.tab.active { color: var(--txt); background: var(--bg2); box-shadow: inset 0 0 0 1px var(--line); }
.tab-soon {
  font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: var(--acc2); color: #fff; border-radius: 6px;
  padding: 2px 6px; margin-left: 6px; vertical-align: 2px;
}

.sec-head { display: flex; align-items: center; justify-content: space-between; }
.sec-head h2 { margin: 22px 0 12px; }
.link-btn {
  background: none; border: none; color: var(--mut); font-size: .8rem;
  cursor: pointer; padding: 4px 0;
}
.link-btn:hover { color: var(--txt); }

/* Hero */
.hero {
  position: relative; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line); margin-top: 18px; min-height: 210px;
  display: flex; align-items: flex-end;
  background: linear-gradient(135deg, #232b45, #3a2d6e);
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .45; }
.hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(5,7,12,.94) 10%, rgba(5,7,12,.35) 60%, transparent);
}
.hero-body { position: relative; padding: 22px; width: 100%; }
.hero-kicker {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: #fff; background: var(--acc2);
  border-radius: 20px; padding: 4px 12px; margin-bottom: 10px;
}
.hero-title { font-size: 1.6rem; font-weight: 800; line-height: 1.2; margin-bottom: 6px; }
.hero-meta { color: #c6cde4; font-size: .88rem; margin-bottom: 14px; }
.btn-primary {
  display: inline-block; background: var(--acc); color: #fff; font-weight: 700;
  border-radius: 10px; padding: 10px 22px; font-size: .9rem; border: none; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }

/* Genre chips (clickable) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip-btn {
  font-size: .78rem; background: var(--bg2); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 20px; color: var(--mut); cursor: pointer;
}
.chip-btn:hover { color: var(--txt); border-color: var(--acc); }
.chip-btn.active { color: #fff; border-color: var(--acc); background: #1e2540; }

/* Skeleton loading */
.skel {
  border-radius: 12px; border: 1px solid var(--line); overflow: hidden;
  background: var(--card);
}
.skel .skel-poster { aspect-ratio: 3/4; }
.skel .skel-line { height: 12px; margin: 10px; border-radius: 6px; }
.shimmer {
  background: linear-gradient(100deg, var(--bg2) 40%, #1d2540 50%, var(--bg2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--mut);
  border: 1px dashed var(--line); border-radius: 16px; margin-top: 8px;
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h2 { margin: 0 0 8px !important; color: var(--txt); }
.empty-state p { font-size: .9rem; line-height: 1.6; margin-bottom: 18px; }

@media (min-width: 720px) {
  .hero { min-height: 260px; }
  .hero-title { font-size: 2.1rem; }
}

/* ---------- Manga reader ---------- */
.reader-wrap { max-width: 860px; }
.reader {
  display: flex; flex-direction: column;
  max-width: 760px; margin: 12px auto 20px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #000;
}
.reader img { width: 100%; display: block; }
.ch-select {
  flex: 2; background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 11px; font-size: .9rem; outline: none; cursor: pointer;
}
.ep-btn.disabled { opacity: .38; cursor: default; }
.ep-btn.disabled:hover { border-color: var(--line); }
.archive { margin-top: 18px; }
.archive summary {
  cursor: pointer; color: var(--mut); font-size: .9rem; padding: 10px 0;
  list-style: none;
}
.archive summary:hover { color: var(--txt); }
.archive summary::before { content: "▸ "; }
.archive[open] summary::before { content: "▾ "; }
