* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #f5f3ef;
  --ink-dim: rgba(245, 243, 239, 0.72);
  --accent: #16d9b8;
  --accent-ink: #06231d;
  --vip: #e0ab5c;
  --danger: #e2685f;
  --surface: rgba(20, 19, 22, 0.82);
  --surface-solid: #131217;
}

html, body {
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app { position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ── Loading / error ─────────────────────────────────────────────────── */
.loading, .error-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-screen p { color: var(--ink-dim); font-size: 15px; padding: 0 24px; text-align: center; }

/* ── Feed: scroll-snap vertikal, ala TikTok/Reels ────────────────────── */
.feed {
  position: absolute; inset: 0;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  width: 100%;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  overflow: hidden;
}

/* Saat .slide di-fullscreen-kan (Fullscreen API), browser default-nya
   center + letterbox berdasar ukuran natural elemen — paksa full inset
   supaya tetap konsisten dengan layout normal (video object-fit:contain
   yang sudah menangani letterboxing sendiri). */
.slide:fullscreen, .slide:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

.slide-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}

/* Subtitle default browser nempel di bagian bawah video, bentrok dengan
   .slide-controls yang juga absolute di bottom (seek bar dsb menutupi teks).
   Geser track container ke atas via transform — satu-satunya properti yang
   didukung konsisten di Chrome & Safari untuk reposisi cue secara paksa
   (::cue sendiri tidak bisa diberi position/transform langsung). */
.slide-video::-webkit-media-text-track-container {
  transform: translateY(-72px);
}
.slide-video::cue {
  font-size: 15px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
}

/* ── Kunci episode ────────────────────────────────────────────────────── */
.slide-lock {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.85));
  backdrop-filter: blur(2px);
  z-index: 5;
}
.lock-card {
  text-align: center;
  padding: 32px 28px;
  max-width: 320px;
}
.lock-icon { font-size: 36px; margin-bottom: 12px; }
.lock-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.lock-sub { color: var(--ink-dim); font-size: 14px; margin-bottom: 20px; }

.btn-unlock {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 13px 28px;
  border-radius: 100px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-unlock:active { transform: scale(0.97); }

/* ── Prompt unmute (episode aktif pertama kali, masih muted) ─────────── */
.unmute-prompt {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.55);
  border: 1.5px solid rgba(255,255,255,0.35);
  color: var(--ink);
  padding: 18px 26px;
  border-radius: 20px;
  cursor: pointer;
  animation: unmutePulse 1.4s ease-in-out infinite;
}
.unmute-prompt svg { width: 30px; height: 30px; fill: var(--ink); }
.unmute-prompt span { font-size: 13px; font-weight: 700; }
@keyframes unmutePulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.06); opacity: 0.85; }
}

/* ── Kontrol player custom ───────────────────────────────────────────── */
.slide-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,0.75), transparent);
  z-index: 4;
}

.btn-playpause, .btn-mute, .btn-fullscreen {
  background: none; border: none; color: var(--ink);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.btn-playpause svg, .btn-mute svg, .btn-fullscreen svg { width: 24px; height: 24px; fill: currentColor; }
.btn-fullscreen svg { width: 21px; height: 21px; }

.seek-row {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.time-current, .time-total {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  flex-shrink: 0;
  width: 32px;
}
.time-total { text-align: right; }

.seek-bar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(255,255,255,0.28);
  border-radius: 2px;
  outline: none;
}
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.seek-bar::-moz-range-thumb {
  width: 12px; height: 12px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

/* ── Meta atas (VIP badge, nomor episode, subtitle toggle) ───────────── */
.slide-meta {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px; right: 14px;
  display: flex; align-items: center; gap: 10px;
  z-index: 4;
}
.badge-vip {
  background: linear-gradient(135deg, var(--vip), #f4cf8e);
  color: #3a2405;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 100px;
}
.btn-episode-list {
  display: flex; align-items: center; gap: 3px;
  background: rgba(0,0,0,0.4);
  border: none;
  padding: 4px 8px 4px 10px;
  border-radius: 100px;
  cursor: pointer;
}
.episode-label {
  font-size: 13px; font-weight: 600;
  color: var(--ink-dim);
}
.episode-list-caret {
  width: 14px; height: 14px;
  fill: var(--ink-dim);
}
.btn-subtitle {
  margin-left: auto;
  background: rgba(0,0,0,0.4);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,0.3);
  font-size: 11px; font-weight: 700;
  width: 28px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
}

/* ── Hint swipe (episode pertama saja, dihilangkan setelah interaksi) ── */
.swipe-hint {
  position: absolute;
  bottom: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  opacity: 0.5;
  animation: bob 1.6s ease-in-out infinite;
  pointer-events: none;
}
.hint-arrow { font-size: 20px; color: var(--ink); }
@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -6px); }
}

/* ── Paywall overlay ──────────────────────────────────────────────────── */
.paywall-overlay {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,0.6);
}
.paywall-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface-solid);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
}
.paywall-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--ink-dim);
  font-size: 18px; cursor: pointer;
  width: 28px; height: 28px;
}

.paywall-step h2 { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.paywall-price, .paywall-amount { color: var(--accent); font-weight: 700; font-size: 15px; margin-bottom: 18px; }

.paywall-label { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.paywall-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ink);
  font-size: 16px;
  padding: 13px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.paywall-input:focus { outline: none; border-color: var(--accent); }
.paywall-hint { font-size: 12px; color: var(--ink-dim); margin-bottom: 20px; }
.paywall-error { font-size: 13px; color: var(--danger); margin-top: 10px; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; }
.btn-primary:active { transform: scale(0.99); }

.btn-link {
  display: block;
  width: 100%;
  background: none; border: none;
  color: var(--ink-dim);
  font-size: 13px;
  text-decoration: underline;
  margin-top: 16px;
  cursor: pointer;
}

.qris-box {
  display: flex; justify-content: center;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.qris-box img { width: 100%; max-width: 240px; }

.paywall-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-dim);
  justify-content: center;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--vip);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Panel daftar episode (lompat jauh) ──────────────────────────────── */
.episode-list-overlay {
  position: fixed; inset: 0;
  z-index: 45;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,0.6);
}
.episode-list-sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--surface-solid);
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
}
.episode-list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 14px;
  flex-shrink: 0;
}
.episode-list-header h2 { font-size: 17px; font-weight: 700; }
.episode-list-close {
  background: none; border: none; color: var(--ink-dim);
  font-size: 18px; cursor: pointer;
  width: 28px; height: 28px;
}
.episode-list-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 0 20px 20px;
  overflow-y: auto;
}
.episode-item {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 44px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ink);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.episode-item.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.episode-item.is-locked {
  color: var(--ink-dim);
}
.episode-item.is-locked::after {
  content: '🔒';
  position: absolute;
  top: -4px; right: -4px;
  font-size: 9px;
}

@media (prefers-reduced-motion: reduce) {
  .swipe-hint, .status-dot, .spinner { animation: none; }
}
