:root {
  --bg: #0f1117;
  --surface: #171a24;
  --surface-2: #202534;
  --line: rgba(243, 241, 236, 0.08);
  --line-strong: rgba(243, 241, 236, 0.16);
  --ink: #f3f1ec;
  --muted: #98a0b3;
  --accent: #e13b5c;
  --accent-hover: #f04b6c;
  --gold: #d9a441;
  --ok: #38b87c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

[hidden] { display: none !important; }

.app-shell {
  min-height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: calc(36px + env(safe-area-inset-bottom));
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  flex-shrink: 0;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(145deg, var(--accent) 0%, #9b2242 100%);
  position: relative;
  display: inline-block;
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  border-style: solid;
  border-width: 6px 0 6px 9px;
  border-color: transparent transparent transparent var(--ink);
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.search-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s;
}

.search-wrap:focus-within {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.search-ico {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.search-wrap input::placeholder { color: var(--muted); }

.search-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.account-btn {
  flex-shrink: 0;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-btn.signed-in {
  border-color: rgba(217, 164, 65, 0.35);
  color: var(--ink);
}

/* ── Filter strips ───────────────────────────────────────────────────────── */
.catalog-view {
  padding: 12px 14px 0;
}

.chip-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.chip-strip::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.chip .cnt {
  font-size: 11px;
  opacity: 0.65;
  font-weight: 500;
}

.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.chip.genre-chip {
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  background: transparent;
}

.chip.genre-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.subbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.genres-strip { flex: 1; min-width: 0; }

.sort-wrap select {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  outline: 0;
}

/* ── Continue watching shelf ─────────────────────────────────────────────── */
.shelf {
  margin-top: 16px;
}

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.shelf-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.continue-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.continue-strip::-webkit-scrollbar { display: none; }

.continue-card {
  flex: 0 0 230px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
}

.continue-thumb {
  width: 44px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.continue-info {
  min-width: 0;
  flex: 1;
}

.continue-title {
  font-size: 13px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.continue-ep {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.prog-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  background: var(--accent);
}

/* ── Catalog grid ────────────────────────────────────────────────────────── */
.catalog-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.text-btn {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 11px;
}

@media (min-width: 560px) {
  .poster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 14px; }
}
@media (min-width: 840px) {
  .poster-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 16px; }
}
@media (min-width: 1080px) {
  .poster-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  min-width: 0;
}

.poster-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}

.poster-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-fallback {
  width: 100%;
  height: 100%;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(155deg, #21273a 0%, #2a1d2e 60%, #151822 100%);
}

.poster-fallback-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poster-scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 44%;
  background: linear-gradient(to top, rgba(15, 17, 23, 0.88) 0%, rgba(15, 17, 23, 0) 100%);
  pointer-events: none;
}

.poster-top {
  position: absolute;
  top: 7px;
  left: 7px;
  right: 7px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  pointer-events: none;
}

.tag-pill {
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(15, 17, 23, 0.78);
  backdrop-filter: blur(6px);
  color: var(--ink);
}

.tag-pill.gold {
  color: var(--gold);
}

.tag-pill.pending {
  color: var(--muted);
}

.poster-bottom {
  position: absolute;
  bottom: 7px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(243, 241, 236, 0.88);
  pointer-events: none;
}

.card-title {
  margin-top: 8px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.secondary-btn {
  height: 42px;
  padding: 0 24px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 600;
}

/* ── Detail & Player View ────────────────────────────────────────────────── */
.detail-view {
  padding: 12px 14px 24px;
}

.detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 600;
}

.back-btn svg { width: 18px; height: 18px; }

.icon-pill {
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.icon-pill.active {
  background: rgba(225, 59, 92, 0.16);
  border-color: var(--accent);
  color: #ff8aa0;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 880px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: start;
    gap: 24px;
  }
  .stage-col { position: sticky; top: 68px; }
}

.player-stage {
  position: relative;
  width: 100%;
  background: #06070a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}

.video-el {
  width: 100%;
  max-height: 72dvh;
  display: block;
  background: #06070a;
  object-fit: contain;
}

.player-placeholder {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.paywall-gate {
  position: relative;
  width: 100%;
  min-height: 310px;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  overflow: hidden;
}

.paywall-bg {
  position: absolute;
  inset: -16px;
  background-size: cover;
  background-position: center;
  filter: blur(22px) brightness(0.32);
  transform: scale(1.06);
}

.paywall-box {
  position: relative;
  z-index: 2;
  max-width: 340px;
  text-align: center;
  background: rgba(15, 17, 23, 0.78);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
}

.paywall-price {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(217, 164, 65, 0.16);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.paywall-title {
  margin: 12px 0 6px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.paywall-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}

.paywall-cta {
  width: 100%;
  height: 44px;
  margin-top: 16px;
  font-size: 14.5px;
}

.paywall-sub-btn {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.player-bar {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.now-playing { min-width: 0; flex: 1; }
.now-ep-title { font-size: 14px; font-weight: 700; }
.now-ep-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.player-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.primary-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
}

.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.ghost-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.series-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.detail-thumb-wrap {
  width: 78px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

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

.detail-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink);
}

.badge.gold { color: var(--gold); }

.detail-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.genre-link {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--muted);
}

.detail-desc {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(243, 241, 236, 0.84);
  white-space: pre-line;
  max-width: 68ch;
}

.episodes-section {
  margin-top: 18px;
}

.episodes-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.episodes-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.episodes-summary {
  font-size: 12.5px;
  color: var(--muted);
}

.episodes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ep-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
}

.ep-row.active {
  background: var(--surface-2);
  border-color: var(--accent);
}

.ep-row.not-ready {
  opacity: 0.55;
}

.ep-main {
  flex: 1;
  min-width: 0;
}

.ep-name {
  font-size: 14px;
  font-weight: 600;
}

.ep-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.ep-dl-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.ep-row.active .ep-dl-btn {
  background: rgba(225, 59, 92, 0.16);
  border-color: rgba(225, 59, 92, 0.5);
}

/* ── Modal & Toast ───────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { font-size: 22px; color: var(--muted); padding: 2px 6px; }
.modal-body { font-size: 14px; color: var(--muted); line-height: 1.5; }
.modal-body .primary-btn { width: 100%; margin-top: 14px; display: grid; place-items: center; text-decoration: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
