/* PSflix Web — Netflix-style theme: black #141414 + red #E50914. */

:root {
  --bg: #141414;
  --bg-2: #1f1f1f;
  --bg-3: #2a2a2a;
  --red: #e50914;
  --red-dark: #b00610;
  --text: #ffffff;
  --muted: #b3b3b3;
  --dim: #808080;
  --border: #333333;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

main { padding: 0 4vw 48px; }
.page { padding-top: 16px; }

/* ---------- top nav ---------- */

.topnav {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 4vw;
  background: linear-gradient(to bottom, rgba(0,0,0,.7), rgba(0,0,0,0));
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #141414;
  border-bottom: 1px solid var(--border);
}
.logo {
  color: var(--red);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  flex: 1;
}
.nav-link {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 700; }
.nav-profile {
  margin-left: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 56vh;
  display: flex;
  align-items: flex-end;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2) center / cover no-repeat;
  margin-top: 12px;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20,20,20,.95) 0%, rgba(20,20,20,.35) 55%, rgba(20,20,20,.15) 100%);
}
.hero-body {
  position: relative;
  z-index: 1;
  padding: 32px;
  max-width: 640px;
}
.hero-title { font-size: 36px; font-weight: 800; margin: 0 0 8px; line-height: 1.1; }
.hero-meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.hero-overview {
  color: #e5e5e5;
  font-size: 15px;
  margin: 0 0 18px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 4px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 700;
  background: var(--red);
  color: #fff;
}
.btn:hover { background: var(--red-dark); }
.btn.secondary { background: rgba(109,109,110,.7); color: #fff; }
.btn.secondary:hover { background: rgba(109,109,110,.9); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--muted); }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- rows & cards ---------- */

.row { margin-top: 28px; }
.row-title { font-size: 19px; font-weight: 700; margin: 0 0 12px; }
.row-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.row-scroll::-webkit-scrollbar { height: 6px; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.card {
  flex: 0 0 auto;
  width: 150px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-2);
  transition: transform .15s ease;
}
.card:hover { transform: scale(1.04); }
.card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-3);
}
.card-poster-fallback {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--muted);
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  padding: 8px;
}
.card-body { padding: 8px 10px 10px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.card-progress > div { height: 100%; background: var(--red); }

/* grid (search results / browse / more trending) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.grid .card { width: auto; }

/* ---------- search & chips ---------- */

.search-box { margin-top: 20px; position: relative; }
.search-box input {
  width: 100%;
  max-width: 560px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 16px;
  padding: 11px 14px 11px 40px;
  outline: none;
}
.search-box input:focus { border-color: var(--muted); }
.search-box::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  border-right-color: transparent;
  transform: rotate(-45deg);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { background: var(--text); color: #000; border-color: var(--text); font-weight: 700; }

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

.detail-hero {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: flex-end;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2) center / cover no-repeat;
  margin-top: 12px;
}
.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20,20,20,.97) 0%, rgba(20,20,20,.45) 60%, rgba(20,20,20,.2) 100%);
}
.detail-body { position: relative; z-index: 1; padding: 32px; max-width: 720px; }
.detail-title { font-size: 34px; font-weight: 800; margin: 0 0 8px; line-height: 1.1; }
.detail-meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.detail-meta .rating { color: #46d369; font-weight: 700; }
.detail-overview { color: #e5e5e5; font-size: 15px; margin: 0 0 18px; }
.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.resume-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
}
.resume-pill:hover { border-color: var(--muted); }

.season-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.episode-list { display: flex; flex-direction: column; gap: 10px; }
.episode {
  display: flex;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  align-items: flex-start;
}
.episode:hover { border-color: var(--muted); }
.episode-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
  min-width: 32px;
  text-align: center;
  padding-top: 2px;
}
.episode-still {
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-3);
  flex-shrink: 0;
}
.episode-info { min-width: 0; }
.episode-title { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.episode-overview {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.episode-meta { color: var(--dim); font-size: 12px; margin-top: 4px; }

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

.player-page { padding: 0; }
.player-wrap {
  position: relative;
  background: #000;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 57px);
}
.player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  background: rgba(0,0,0,.6);
  z-index: 5;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  color: var(--text);
  background: rgba(0,0,0,.85);
  z-index: 6;
}
.player-error p { color: var(--muted); margin: 0; max-width: 480px; }

/* double-tap seek zones */
.seek-zone {
  position: absolute;
  top: 0;
  bottom: 64px;
  width: 30%;
  z-index: 3;
}
.seek-zone.left { left: 0; }
.seek-zone.right { right: 0; }
.seek-flash {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.7);
  color: #fff;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.seek-flash.show { opacity: 1; }
.seek-flash.left { left: 12%; }
.seek-flash.right { right: 12%; }

/* custom controls */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 8px 12px 10px;
  background: linear-gradient(to top, rgba(0,0,0,.85), transparent);
  opacity: 1;
  transition: opacity .25s;
}
.player-wrap.idle .controls { opacity: 0; pointer-events: none; }
.player-wrap.idle { cursor: none; }
.seek-row { display: flex; align-items: center; gap: 10px; }
.seek-row input[type="range"] {
  flex: 1;
  accent-color: var(--red);
  cursor: pointer;
}
.time-label { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.controls-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.ctl-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  padding: 6px 9px;
  border-radius: 4px;
}
.ctl-btn:hover { background: rgba(255,255,255,.15); }
.ctl-btn:disabled { opacity: .35; cursor: default; }
.ctl-spacer { flex: 1; }
.ctl-select {
  background: rgba(0,0,0,.6);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  max-width: 150px;
}
.volume-row { display: flex; align-items: center; gap: 4px; }
.volume-row input[type="range"] { width: 80px; accent-color: var(--red); }
.player-title-bar { padding: 14px 4vw 0; }
.player-title { font-size: 19px; font-weight: 700; margin: 0; }
.player-sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.player-note {
  margin: 12px 4vw 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- live tv / sports tiles ---------- */

.channel-row { margin-top: 28px; }
.channel-grid { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.channel-tile {
  flex: 0 0 auto;
  width: 104px;
  cursor: pointer;
  text-align: center;
}
.channel-logo-box {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  background: var(--bg-2);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.channel-logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.channel-letter {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}
.channel-name {
  font-size: 13px;
  margin: 6px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.channel-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.channel-tile.offline .channel-logo-box,
.channel-tile.offline .channel-name,
.channel-tile.offline .channel-sub { opacity: .4; }
.live-pill {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.offline-pill {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: #555;
  color: #ccc;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.inline-player {
  margin-top: 16px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: none;
}
.inline-player.open { display: block; }
.inline-player video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }
.inline-player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
}
.inline-player-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-player-status { font-size: 13px; color: var(--muted); }

/* ---------- modal (server picker) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal-list { display: flex; flex-direction: column; gap: 8px; }
.modal-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  font-size: 15px;
}
.modal-item:hover { border-color: var(--muted); }
.modal-actions { margin-top: 16px; text-align: right; }

/* ---------- misc ---------- */

.empty-state { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 15px; }
.error-state { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 15px; }
.loading-row { color: var(--muted); padding: 24px 0; text-align: center; }
.section-head { font-size: 22px; font-weight: 800; margin: 20px 0 4px; }
.section-sub { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* app_state gate overlay */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-box { text-align: center; max-width: 480px; }
.gate-logo { color: var(--red); font-size: 34px; font-weight: 800; letter-spacing: 1px; margin-bottom: 16px; }
.gate-title { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.gate-msg { color: var(--muted); font-size: 15px; }

@media (max-width: 640px) {
  .hero-title, .detail-title { font-size: 26px; }
  .hero-body, .detail-body { padding: 20px; }
  .card { width: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .episode-still { width: 110px; }
  .nav-links { gap: 14px; }
  .topnav { gap: 16px; }
  .volume-row input[type="range"] { width: 56px; }
}
