:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #141820;
  --panel-2: #1b212b;
  --ink: #f7f7f2;
  --muted: #a7afbc;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #32d583;
  --accent-strong: #12b76a;
  --warm: #fdb022;
  --danger: #f97066;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(50, 213, 131, 0.16), transparent 30vw),
    radial-gradient(circle at top right, rgba(253, 176, 34, 0.10), transparent 26vw),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { border: 0; border-radius: 14px; cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 56px);
  background: rgba(11, 13, 16, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--ink);
  font-size: 25px;
  font-weight: 850;
  text-decoration: none;
  letter-spacing: -0.03em;
}

nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.primary, .search button {
  background: var(--accent);
  color: #062414;
  padding: 11px 17px;
  font-weight: 800;
}
.primary:hover, .search button:hover { background: var(--accent-strong); }

.ghost, .link {
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
}
.ghost:hover, .link:hover { color: var(--ink); background: rgba(255,255,255,0.06); }

main {
  width: min(1240px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 28px;
  align-items: end;
  padding: 38px 0 20px;
}
.hero.compact { padding-top: 28px; }

.eyebrow {
  color: var(--warm);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(38px, 6vw, 74px);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.subcopy {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.search {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 12px 13px;
  background: transparent;
  color: var(--ink);
}
.search input::placeholder { color: #717b8a; }

.quickbar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 0 2px;
}
.quickbar button {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: rgba(255,255,255,0.07);
  color: var(--ink);
  border: 1px solid var(--line);
}
.quickbar button:hover { border-color: rgba(50,213,131,0.5); }

.providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.provider-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  background: rgba(255,255,255,0.055);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.provider-tile div { display: grid; gap: 4px; }
.provider-tile span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.provider-tile em {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(50, 213, 131, 0.14);
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}
.provider-tile em[data-status="needs_config"], .provider-tile em[data-status="error"] {
  background: rgba(253, 176, 34, 0.14);
  color: var(--warm);
}

.toolbar { display: flex; justify-content: space-between; align-items: end; margin: 32px 0 18px; }
h2 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.toolbar p { margin: 6px 0 0; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.movie-card {
  overflow: hidden;
  min-height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.045));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.20);
}
.movie-card:hover { border-color: rgba(50,213,131,0.32); transform: translateY(-1px); transition: 160ms ease; }

.poster {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  background: linear-gradient(145deg, #182a26, #31424f);
  color: #fff;
  font-weight: 850;
  text-align: center;
  padding: 18px;
}
.compact-poster { aspect-ratio: 16 / 10; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.movie-card article { padding: 15px; }
.movie-card h3 { margin: 0; min-height: 48px; font-size: 18px; line-height: 1.35; }
.meta { margin: 8px 0; color: var(--muted); font-size: 13px; }
.overview {
  display: -webkit-box;
  min-height: 64px;
  margin: 0 0 14px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions.single { grid-template-columns: 1.2fr 0.8fr; }
.actions a, .actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 13px;
  text-decoration: none;
  text-align: center;
}
.actions a { background: rgba(255,255,255,0.08); color: var(--ink); }
.actions button { background: rgba(255,255,255,0.10); color: #fff; }
.actions .play { background: var(--accent); color: #062414; font-weight: 850; }

.empty {
  grid-column: 1 / -1;
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(430px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,0.72); backdrop-filter: blur(6px); }
.dialog-card { position: relative; display: grid; gap: 14px; padding: 26px; }
.dialog-card h2, .dialog-card p { margin: 0; }
.dialog-card p { color: var(--muted); line-height: 1.55; }
.dialog-card label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
.dialog-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: rgba(255,255,255,0.06);
  color: var(--ink);
}
.close { width: 38px; height: 38px; background: rgba(255,255,255,0.08); color: var(--ink); font-size: 24px; }
.dialog-card .close { position: absolute; top: 12px; right: 12px; }
.full { width: 100%; }
.error { color: var(--danger) !important; min-height: 20px; }

.player-dialog { width: min(1080px, calc(100vw - 24px)); background: #050607; }
.player-shell { padding: 14px; }
.player-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; padding: 4px 4px 12px; }
.player-head h2 { font-size: 22px; }
.player-head p { margin: 5px 0 0; color: var(--muted); }
#videoPlayer {
  width: 100%;
  max-height: min(70vh, 680px);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 16px;
  outline: 1px solid var(--line);
}
.source-list { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; }
.source-list button { background: rgba(255,255,255,0.10); color: var(--ink); padding: 8px 12px; }
.source-list button.active { background: var(--accent); color: #062414; font-weight: 850; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  nav { width: 100%; justify-content: space-between; }
  .hero { grid-template-columns: 1fr; padding-top: 22px; }
  .search { flex-direction: column; }
  .providers { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .movie-card h3 { min-height: auto; }
  .actions, .actions.single { grid-template-columns: 1fr; }
}

.hero-forms {
  display: grid;
  gap: 12px;
}

.url-resolver {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(253, 176, 34, 0.08);
  border: 1px solid rgba(253, 176, 34, 0.24);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.url-resolver input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 12px 13px;
  background: transparent;
  color: var(--ink);
}

.url-resolver input::placeholder { color: #8e7a59; }
.url-resolver button {
  flex: 0 0 auto;
  background: var(--warm);
  color: #261504;
  padding: 11px 17px;
  font-weight: 850;
}
.url-resolver button:hover { filter: brightness(0.95); }

@media (max-width: 760px) {
  .url-resolver { flex-direction: column; }
}

.result-divider {
  grid-column: 1 / -1;
  margin: 10px 0 2px;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-weight: 850;
}

.official-card .poster {
  background: linear-gradient(145deg, #3b2b0b, #664912);
}

.actions a.play {
  background: var(--accent);
  color: #062414;
  font-weight: 850;
}

button[disabled], a[aria-disabled="true"] {
  cursor: wait;
  opacity: 0.62;
  filter: grayscale(0.15);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 24px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 24, 34, 0.96);
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-type="success"] { border-color: rgba(47, 209, 139, 0.55); }
.toast[data-type="error"] { border-color: rgba(255, 93, 93, 0.7); color: #ffd6d6; }

#embedPlayer {
  width: 100%;
  max-height: min(70vh, 680px);
  aspect-ratio: 16 / 9;
  display: block;
  background: #000;
  border: 0;
  border-radius: 16px;
  outline: 1px solid var(--line);
}

#embedPlayer[hidden], #videoPlayer[hidden] { display: none; }

.official-watch-card {
  outline: 1px solid rgba(47, 209, 139, 0.28);
  background: linear-gradient(180deg, rgba(47, 209, 139, 0.10), rgba(255, 255, 255, 0.04));
}

.official-watch-poster,
.official-divider {
  background: linear-gradient(145deg, rgba(47, 209, 139, 0.24), rgba(253, 176, 34, 0.18));
}

.actions .secondary-play {
  background: rgba(255,255,255,0.10);
  color: var(--ink);
}

.episode-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(47, 209, 139, 0.16);
  color: var(--accent);
  font-weight: 850;
}
