:root {
  --bg: #07070a;
  --surface: #14141a;
  --ink: #f4f2ef;
  --muted: #9a9790;
  --accent: #e85d04;
  --accent-2: #ff9f1c;
  --accent-deep: #9b2226;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --header-h: 64px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Syne", "Manrope", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: linear-gradient(#111, rgba(5,5,5,.92));
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -.03em;
}

.brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 30% 20%, #ffb703 0%, transparent 55%),
    linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 0 0 1px rgba(255,159,28,.25), 0 6px 18px rgba(232,93,4,.35);
}

.brand__name {
  font-size: 1.25rem;
  background: linear-gradient(90deg, #fff 40%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand--auth {
  justify-content: center;
  margin-bottom: .35rem;
}

.brand--auth .brand__mark {
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
  border-radius: 12px;
}

.brand--auth .brand__name { font-size: 1.85rem; }

.nav {
  display: flex;
  align-items: center;
  gap: .85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav__link {
  font-size: .9rem;
  color: var(--muted);
}

.nav__link.is-active,
.nav__link:hover { color: #fff; }

.nav__link--muted { opacity: .75; }

.nav__user {
  font-size: .8rem;
  color: #fff;
  background: rgba(255,255,255,.08);
  padding: .35rem .65rem;
  border-radius: 999px;
}

/* Home hero */
.hero {
  position: relative;
  min-height: min(72vh, 640px);
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(90deg, rgba(5,5,5,.92) 0%, rgba(5,5,5,.55) 48%, rgba(5,5,5,.25) 100%),
    var(--hero-img, none) center / cover no-repeat,
    #111;
}

.hero__shade {
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 640px;
  padding: 2.5rem 1.25rem 2.75rem;
}

.hero__eyebrow {
  margin: 0 0 .5rem;
  color: var(--accent-2);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.hero__title {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -.03em;
}

.hero__plot {
  margin: .9rem 0 0;
  color: #e5e5e5;
  font-size: .95rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.tags {
  list-style: none;
  margin: .75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.tags li {
  font-size: .72rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: #fff;
}

.tags--hero li:first-child {
  background: var(--accent-2);
  color: #1a1208;
  font-weight: 600;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: .7rem 1.2rem;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  background: rgba(255,255,255,.12);
  color: var(--ink);
  cursor: pointer;
}

.btn--primary { background: var(--accent); color: #fff; }
.btn--play {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-top: 1.15rem;
  background: #fff;
  color: #111;
  padding: .85rem 1.4rem;
}
.btn--play:hover { filter: brightness(0.95); }
.btn__icon { font-size: .85rem; }
.btn--block { width: 100%; }
.btn--sm { padding: .35rem .7rem; font-size: .8rem; }
.btn--danger { background: #7f1d1d; color: #fecaca; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.shelf {
  padding: 1.25rem 1.25rem 3rem;
}

.shelf__head {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1rem;
}

.shelf__head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.shelf__meta { color: var(--muted); font-size: .85rem; }

.posters {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .85rem;
}

.poster {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.poster img,
.poster__ph {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #1a1a1a;
  display: block;
}

.poster__ph {
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.poster__title {
  font-size: .78rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.poster__eps { color: var(--muted); font-size: .7rem; }

.poster:hover img { outline: 2px solid rgba(229,9,20,.7); outline-offset: 2px; }

/* Auth / account */
.is-auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at top, rgba(229,9,20,.25), transparent 55%),
    var(--bg);
}

.auth__card {
  width: min(100%, 380px);
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid rgba(255,255,255,.06);
}

.auth__sub {
  margin: 0 0 1.1rem;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

.auth__error {
  margin: 0 0 .85rem;
  color: #fecaca;
  background: rgba(127,29,29,.35);
  padding: .6rem .75rem;
  border-radius: 8px;
  font-size: .85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .85rem;
  font-size: .85rem;
  color: var(--muted);
}

.field input {
  border: 1px solid rgba(255,255,255,.12);
  background: #0a0a0a;
  color: #fff;
  border-radius: 10px;
  padding: .7rem .8rem;
  font: inherit;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.page__title {
  margin: 0 0 .35rem;
  font-size: 1.6rem;
  letter-spacing: -.02em;
}

.muted { color: var(--muted); font-size: .9rem; }
.text-link { color: var(--accent-2); }

.panel {
  margin-top: 1.25rem;
  padding: 1.1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.06);
}

.panel h2 {
  margin: 0 0 .85rem;
  font-size: 1.05rem;
}

.banner {
  margin: .75rem 0;
  padding: .7rem .85rem;
  border-radius: 8px;
  font-size: .9rem;
}
.banner--ok { background: rgba(16,185,129,.15); color: #a7f3d0; }
.banner--error, .banner--warn { background: rgba(229,9,20,.18); color: #fecaca; }

.form--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem 1rem;
}
.form--grid .field--actions { grid-column: 1 / -1; }

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th, .table td {
  text-align: left;
  padding: .55rem .4rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.inline { display: inline; }

.empty { padding: 2rem 1.25rem; color: var(--muted); }
.empty code { color: var(--accent-2); }

/* Player + episódios */
body.is-player { height: 100dvh; overflow: hidden; background: #050505; }

.player-layout {
  display: grid;
  grid-template-columns: 1fr;
  height: 100dvh;
  background: #050505;
  position: relative;
}

.player-col {
  position: relative;
  min-width: 0;
  height: 100dvh;
  background: #000;
}

.back,
.cast-btn,
.eps-fab {
  position: absolute;
  z-index: 8;
  top: .75rem;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  padding: 0;
  box-sizing: border-box;
}

.back {
  left: .75rem;
  font-size: 1.1rem;
  line-height: 1;
  text-decoration: none;
}

.cast-btn {
  --connected-color: var(--accent-2);
  --disconnected-color: #fff;
  right: .75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .4rem;
}

.cast-btn:hover { background: rgba(0,0,0,.7); }

.eps-fab {
  right: .75rem;
  top: 3.5rem;
  width: auto;
  min-width: 2.4rem;
  height: auto;
  padding: .35rem .55rem;
  border-radius: 12px;
  gap: .05rem;
  font: inherit;
}

.eps-fab__n {
  font-family: var(--display);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1;
}

.eps-fab__lbl {
  font-size: .62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stage {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#vid {
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  object-fit: contain;
  background: #000;
}

.edge-stack {
  position: absolute;
  right: .55rem;
  top: 50%;
  z-index: 6;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.edge-btn {
  appearance: none;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  opacity: .55;
  transition: opacity .15s ease, background .15s ease;
}

.edge-btn:hover:not(:disabled) { opacity: 1; background: rgba(0,0,0,.7); }
.edge-btn:disabled { opacity: .15; cursor: default; }

.hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  padding: .85rem 3.2rem calc(3.4rem + var(--safe-b));
  background: linear-gradient(transparent, rgba(0,0,0,.72));
  pointer-events: none;
}

.hud__meta { min-width: 0; pointer-events: none; }

.hud__series {
  margin: 0;
  color: var(--accent-2);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hud__title {
  margin: .15rem 0 0;
  font-size: .92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud__syn {
  margin: .35rem 0 0;
  color: #cfcfcf;
  font-size: .72rem;
  line-height: 1.35;
  max-height: 2.7em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Painel de episódios */
.eps-panel {
  background: #0c0c10;
  border-left: 1px solid rgba(255,255,255,.06);
  padding: 1.1rem 1.15rem 1.5rem;
  overflow: auto;
  display: none;
  flex-direction: column;
  gap: .75rem;
}

.eps-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}

.eps-panel__kicker {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.eps-panel__title {
  margin: .2rem 0 0;
  font-family: var(--display);
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.eps-panel__close {
  display: none;
  appearance: none;
  border: 0;
  background: rgba(255,255,255,.08);
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.eps-panel__plot {
  margin: 0;
  color: #c9c6c0;
  font-size: .85rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.tags--eps { margin: 0; }
.tags--eps li { background: rgba(255,255,255,.08); }

.eps-panel__meta {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}

.eps-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.eps-range {
  appearance: none;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: #ddd;
  border-radius: 999px;
  padding: .35rem .7rem;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
}

.eps-range.is-active {
  background: rgba(232,93,4,.2);
  border-color: rgba(255,159,28,.45);
  color: #fff;
}

.eps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: .45rem;
}

.eps-cell {
  appearance: none;
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: #17171d;
  color: #eee;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.eps-cell:hover {
  background: #22222b;
  border-color: rgba(255,255,255,.18);
}

.eps-cell.is-active {
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(232,93,4,.35);
}

.eps-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,.55);
}

@media (max-width: 640px) {
  .form--grid { grid-template-columns: 1fr; }
  .nav__user { display: none; }
  .hero { min-height: 70vh; }
  .hud { padding-left: .9rem; padding-right: .9rem; }
}

@media (max-width: 899px) {
  .player-layout.eps-open .eps-panel {
    display: flex;
    position: fixed;
    z-index: 30;
    left: 0; right: 0; bottom: 0;
    top: auto;
    max-height: min(72dvh, 560px);
    border-left: 0;
    border-top: 1px solid rgba(255,255,255,.08);
    border-radius: 18px 18px 0 0;
    animation: eps-up .2s ease;
  }
  .player-layout.eps-open .eps-scrim { display: block; }
  .eps-panel__close { display: grid; place-items: center; }
}

@keyframes eps-up {
  from { transform: translateY(12%); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 900px) {
  .player-layout {
    grid-template-columns: minmax(320px, 42vw) minmax(360px, 1fr);
  }
  .player-col { border-right: 1px solid rgba(255,255,255,.05); }
  .stage { max-width: min(480px, 100%); margin: 0 auto; }
  .eps-panel { display: flex; }
  .eps-fab { display: none; }
  .eps-scrim { display: none !important; }
  .posters { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
