:root {
  --bg: #000000;
  --bg-elevated: #0d0d0f;
  --surface: #161618;
  --surface-2: #1f1f22;
  --surface-3: #2a2a2e;
  --text: #f4f4f6;
  --text-dim: #a1a1a8;
  --text-faint: #6e6e76;
  --accent: #2fd45f;
  --accent-dim: #1f9c45;
  --accent-soft: rgba(47, 212, 95, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --shadow-card: 0 18px 46px rgba(0, 0, 0, 0.66);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --sidebar-w: 248px;
  --rail-gap: 18px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

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

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

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
  background-clip: content-box;
}

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  background:
    radial-gradient(1100px 620px at 78% -12%, rgba(47, 212, 95, 0.09), transparent 62%),
    radial-gradient(900px 520px at 8% 0%, rgba(64, 120, 255, 0.07), transparent 58%),
    var(--bg);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 14px 18px;
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(26px) saturate(140%);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--accent), #1a8f43);
  display: grid;
  place-items: center;
  color: #04140a;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.4px;
  box-shadow: 0 6px 18px rgba(47, 212, 95, 0.3);
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 550;
  font-size: 14px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.nav-item[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.nav-icon {
  width: 19px;
  height: 19px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item[aria-current="page"] .nav-icon {
  color: var(--accent);
}

.sidebar-section {
  margin-top: 16px;
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.provider-nav {
  flex: 1;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
}

.provider-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.provider-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.provider-link[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
}

.provider-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--text-faint);
}

.provider-dot[data-state="ok"] {
  background: var(--accent);
}

.provider-dot[data-state="auth"] {
  background: #f5a623;
}

.provider-dot[data-state="offline"] {
  background: #55555c;
}

.provider-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- main ---------- */

.main {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.view {
  padding: 26px 34px 90px;
  max-width: 1680px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 34px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0));
  backdrop-filter: blur(8px);
}

.page-title {
  margin: 0;
  font-size: 34px;
  font-weight: 750;
  letter-spacing: -0.9px;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 550;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip[data-active="true"] {
  color: var(--text);
  border-color: rgba(47, 212, 95, 0.5);
  background: var(--accent-soft);
}

.input {
  width: 100%;
  padding: 11px 15px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.input::placeholder {
  color: var(--text-faint);
}

.input:focus {
  border-color: rgba(47, 212, 95, 0.55);
  background: var(--surface-2);
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, 44vw);
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.searchbar:focus-within {
  border-color: rgba(47, 212, 95, 0.55);
}

.searchbar input {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
}

/* ---------- rails ---------- */

.rail {
  margin: 30px 0 8px;
}

.rail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.rail-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.rail-meta {
  color: var(--text-faint);
  font-size: 13px;
}

.rail-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.rail-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-dim);
  transition: background 0.15s var(--ease), color 0.15s var(--ease), opacity 0.15s var(--ease);
}

.rail-arrow:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.rail-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.rail-track {
  display: flex;
  gap: var(--rail-gap);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding-bottom: 6px;
}

.rail-track::-webkit-scrollbar {
  display: none;
}

.rail-track > * {
  scroll-snap-align: start;
}

/* ---------- poster cards ---------- */

.poster {
  position: relative;
  flex: none;
  width: 172px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.poster:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
}

.poster-art {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(160deg, #232327, #141416);
  overflow: hidden;
}

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

.poster-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: linear-gradient(150deg, #26262b, #17171a);
}

.poster-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.poster-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 11px;
  font-weight: 600;
}

.poster-body {
  padding: 9px 11px 12px;
}

.poster-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poster-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-faint);
}

.poster-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
}

/* ---------- hover card ---------- */

.hovercard {
  position: fixed;
  z-index: 60;
  width: 320px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: rgba(18, 18, 21, 0.96);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}

.hovercard[data-open="true"] {
  opacity: 1;
  transform: translateY(0);
}

.hovercard-art {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-3);
}

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

.hovercard-title {
  margin: 11px 0 2px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.hovercard-meta {
  color: var(--text-dim);
  font-size: 12.5px;
}

.hovercard-genre {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 2px;
}

.hovercard-desc {
  margin: 9px 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hovercard-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 650;
  transition: filter 0.15s var(--ease), background 0.15s var(--ease), transform 0.12s var(--ease);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #04150a;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: var(--surface-3);
  color: var(--text);
}

.btn-ghost:hover {
  background: #34343a;
}

.btn-round {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
}

.btn-round:hover {
  background: #3a3a40;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- grids & misc ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 20px var(--rail-gap);
}

.grid .poster {
  width: auto;
}

.panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.panel + .panel {
  margin-top: 16px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  animation: shimmer 1.25s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}

.error {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 99, 71, 0.12);
  border: 1px solid rgba(255, 99, 71, 0.35);
  color: #ffb4a4;
  font-size: 13.5px;
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- detail view ---------- */

.detail {
  position: relative;
  min-height: 78vh;
  padding-bottom: 40px;
}

.detail-backdrop {
  position: absolute;
  inset: 0 0 auto 0;
  height: 78vh;
  z-index: 0;
  overflow: hidden;
}

.detail-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  filter: saturate(1.05);
}

.detail-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.32) 0%, rgba(0, 0, 0, 0.72) 58%, #000 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.25) 58%, transparent 100%);
}

.detail-content {
  position: relative;
  z-index: 1;
  padding: 96px 34px 0;
  max-width: 1100px;
}

.detail-title {
  margin: 0;
  font-size: 58px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1.03;
  text-shadow: 0 6px 34px rgba(0, 0, 0, 0.6);
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 16px 0 10px;
  color: var(--text-dim);
  font-size: 14px;
  flex-wrap: wrap;
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 6px;
  background: #f5c518;
  color: #201800;
  font-weight: 750;
  font-size: 12.5px;
}

.detail-genre {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 14px;
}

.detail-desc {
  max-width: 640px;
  color: #d8d8dd;
  font-size: 14.5px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 22px 0 30px;
}

.detail-actions .btn-primary {
  flex: none;
  min-width: 148px;
  padding: 13px 26px;
  font-size: 15px;
}

.cast-row {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.cast-item {
  flex: none;
  width: 92px;
  text-align: center;
}

.cast-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  border: 2px solid var(--border);
}

.cast-name {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- player ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: none;
}

.player[data-open="true"] {
  display: block;
}

.player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.player[data-chrome="true"] .player-top {
  opacity: 1;
}

.player-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(38px) saturate(1.2) brightness(0.5);
  opacity: 0.35;
}

.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 24px 20px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.82), transparent);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.player[data-chrome="true"] .player-controls {
  opacity: 1;
}

.player-title {
  font-size: 16px;
  font-weight: 650;
}

.player-sub {
  color: var(--text-dim);
  font-size: 12.5px;
}

.player-seek {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin: 6px 0 4px;
}

.player-seek-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.player-seek-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 3px;
}

.player-seek-thumb {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.player-seek:hover .player-seek-thumb {
  opacity: 1;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-time {
  color: var(--text-dim);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.player-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: background 0.15s var(--ease);
}

.player-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.player-btn svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.player-select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12.5px;
}

.player-error {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  text-align: center;
  padding: 30px;
  background: rgba(0, 0, 0, 0.72);
}

.player[data-error="true"] .player-error {
  display: grid;
}

/* ---------- provider picker / settings ---------- */

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.picker-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.picker-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-3);
  flex: none;
}

.picker-name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-sub {
  font-size: 11.5px;
  color: var(--text-faint);
}

.switch {
  margin-left: auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  transition: background 0.18s var(--ease);
  flex: none;
}

.switch[data-on="true"] {
  background: var(--accent-dim);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s var(--ease);
}

.switch[data-on="true"]::after {
  transform: translateX(18px);
}

/* ---------- age gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(12px);
  text-align: center;
  padding: 30px;
}

.gate[hidden] {
  display: none;
}

.gate h1 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: -0.8px;
}

.gate p {
  color: var(--text-dim);
  max-width: 460px;
  margin: 0 auto 22px;
}

.gate-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 16px);
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(26, 26, 30, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  z-index: 300;
}

.toast[data-open="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1080px) {
  .app {
    grid-template-columns: 76px 1fr;
  }
  .brand-text,
  .nav-item span,
  .provider-name,
  .sidebar-section {
    display: none;
  }
  .nav-item,
  .provider-link {
    justify-content: center;
  }
}

.provider-logo {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--surface-3);
  flex: none;
}
