:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #11151d;
  --panel-2: #171d27;
  --text: #f5f7fb;
  --muted: #a4adbb;
  --faint: #687384;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #3dd5a7;
  --accent-2: #64a7ff;
  --danger: #ff6b6b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input {
  font: inherit;
}

button {
  color: inherit;
  border: 0;
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(76px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(9, 11, 16, 0.96), rgba(9, 11, 16, 0.72));
  backdrop-filter: blur(14px);
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.profile-chip img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-chip span {
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-view {
  overflow: hidden;
}

.hero {
  min-height: 54vh;
  display: flex;
  align-items: flex-end;
  padding: 84px 18px 26px;
  background:
    linear-gradient(180deg, rgba(9, 11, 16, 0.12), rgba(9, 11, 16, 0.72) 58%, var(--bg)),
    linear-gradient(125deg, #1c2740, #122016);
  background-size: cover;
  background-position: center;
}

.hero-copy {
  width: min(680px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: 14ch;
  font-size: clamp(36px, 12vw, 76px);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero p {
  max-width: 720px;
}

#heroDescription {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: rgba(245, 247, 251, 0.86);
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.danger-button,
.token-row button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  background: var(--text);
  color: #07090d;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.1);
}

.danger-button {
  background: rgba(255, 107, 107, 0.14);
  color: #ffb4b4;
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.content-rows {
  padding: 0 0 28px;
}

.row {
  margin-top: 24px;
}

.row-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 10px;
}

.row-title {
  margin: 0;
  font-size: 19px;
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
}

.scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(132px, 38vw, 190px);
  gap: 12px;
  overflow-x: auto;
  padding: 2px 16px 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.scroller::-webkit-scrollbar {
  display: none;
}

.poster-card {
  min-width: 0;
  padding: 0;
  text-align: left;
  background: transparent;
  scroll-snap-align: start;
}

.poster-art {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel-2);
}

.poster-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.progress-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.poster-title {
  margin-top: 8px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.25;
  font-size: 14px;
  font-weight: 750;
}

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

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(11, 14, 20, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.nav-item {
  height: 48px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.nav-item.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.62);
}

.hidden {
  display: none !important;
}

.sheet {
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  border-radius: 18px 18px 0 0;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 -24px 80px rgba(0, 0, 0, 0.45);
}

.sheet-header,
.search-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  background: rgba(17, 21, 29, 0.94);
  backdrop-filter: blur(12px);
}

.sheet-header h2 {
  margin: 0;
  font-size: 22px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.profile-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.profile-card img {
  width: 78px;
  height: 78px;
  border-radius: 50%;
}

.token-form {
  padding: 0 16px 18px;
}

.token-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.token-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.token-row button {
  background: var(--accent);
  color: #06100d;
}

.search-bar input {
  flex: 1;
}

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

.details-sheet {
  background: var(--bg);
}

.details-hero {
  min-height: 42vh;
  display: flex;
  align-items: flex-end;
  padding: 18px;
  background-size: cover;
  background-position: center;
}

.details-body {
  padding: 16px 16px calc(24px + var(--safe-bottom));
}

.details-body h2 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.05;
}

.metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.description {
  color: rgba(245, 247, 251, 0.82);
  line-height: 1.48;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.action-row.single {
  grid-template-columns: 1fr;
}

.season-select {
  margin: 18px 0 12px;
}

.episode-list {
  display: grid;
  gap: 10px;
}

.episode-card {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 12px;
  width: 100%;
  min-height: 82px;
  padding: 8px;
  text-align: left;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.episode-card img {
  width: 116px;
  height: 66px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-2);
}

.episode-card strong {
  display: block;
  margin-bottom: 4px;
}

.episode-card span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
}

.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #000;
}

.player-topbar {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent);
}

.player-topbar strong,
.player-topbar span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.player-topbar span {
  color: var(--muted);
  font-size: 13px;
}

.player-stage {
  position: relative;
  min-height: 0;
  display: grid;
}

video {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #000;
}

.player-resume {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 142px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  background: rgba(245, 247, 251, 0.94);
  color: #07090d;
  font-weight: 900;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
}

.player-status {
  min-height: 34px;
  padding: 8px 14px calc(8px + var(--safe-bottom));
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(86px + var(--safe-bottom));
  z-index: 100;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(245, 247, 251, 0.94);
  color: #090b10;
  font-weight: 750;
}

.empty-state,
.loading-state {
  padding: 24px 16px;
  color: var(--muted);
}

@media (min-width: 720px) {
  .app-shell {
    padding-bottom: 0;
  }

  .topbar {
    padding-inline: 28px;
  }

  .hero {
    min-height: 66vh;
    padding-inline: 36px;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(440px, calc(100vw - 36px));
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px;
  }

  .scroller {
    grid-auto-columns: 190px;
    padding-inline: 36px;
  }

  .row-header {
    padding-inline: 36px;
  }

  .overlay {
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  .sheet {
    width: min(900px, 100%);
    border-radius: 12px;
  }

  .profile-sheet,
  .search-sheet {
    width: min(620px, 100%);
  }

  .poster-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .profile-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
