:root {
  --bg: #0b0d12;
  --surface: #141822;
  --surface-2: #1c2230;
  --line: #262d3d;
  --text: #eef1f7;
  --muted: #9aa4b8;
  --accent: #7cc4ff;
  --accent-2: #a98bff;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(64px + var(--safe-b)); }

a { color: var(--accent); text-decoration: none; }

header.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(11, 13, 18, 0.86);
  backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}

header.topbar h1 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
  display: grid;
  place-items: center;
}

.searchbar {
  display: flex;
  gap: 10px;
  padding: 12px 18px 4px;
}

.searchbar input {
  flex: 1;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.searchbar button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08101c;
  font-weight: 700;
  font-size: 15px;
}

nav.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}

nav.tabs button {
  flex: 1;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

nav.tabs button.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

main { padding: 8px 18px 24px; }

h2.section-title {
  font-size: 16px;
  margin: 22px 0 10px;
  color: var(--text);
}

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

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }
  main { padding: 8px 28px 32px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card .cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}

.card .meta { padding: 8px 10px 12px; }

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

.card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

.row-list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.row img.thumb {
  width: 62px;
  height: 84px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}

.row .info { flex: 1; min-width: 0; }
.row .info .title { font-weight: 600; font-size: 15px; }
.row .info .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.hero {
  display: flex;
  gap: 18px;
  padding: 8px 0 4px;
}

.hero img {
  width: 132px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
  flex: none;
}

.hero .hero-info { flex: 1; min-width: 0; }
.hero h1 { font-size: 20px; margin: 0 0 8px; line-height: 1.25; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.chip {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 5px 10px;
  border-radius: 999px;
}

.synopsis { color: var(--muted); font-size: 14px; line-height: 1.6; margin-top: 14px; }

.btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  min-height: 50px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08101c;
  font-weight: 700;
  font-size: 16px;
}

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}

.reader { display: flex; flex-direction: column; gap: 6px; padding: 0; }

.reader img {
  width: 100%;
  display: block;
  background: #0f1218;
  min-height: 60px;
}

.status {
  padding: 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.status.error { color: #ffb4b4; }

select.picker {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 15px;
  padding: 0 12px;
}

video.player {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  margin-top: 12px;
}

.spinner {
  width: 22px;
  height: 22px;
  margin: 24px auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden { display: none !important; }

/* ---------------------------------------------------------- pemutar video */

.stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage video.player {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  object-fit: contain;
  background: #000;
}

/* Safari iPad tidak mengizinkan kunci orientasi, jadi gambar diputar sendiri.

   PENTING: ukuran dan titik putar TIDAK boleh memakai 100vh/100vw. Di Safari,
   tinggi viewport berubah mengikuti bilah peramban yang muncul-hilang, sehingga
   elemen berukuran 100vh lebih besar daripada layar; karena diputar mengelilingi
   titik tengah, hasilnya bergeser — gambar menepi ke satu sisi dan menyisakan
   bidang hitam lebar di sisi lain. Ukuran pastinya dihitung di app.js dari
   ukuran panggung, lalu diputar dari sudut kiri atas. */
.stage video.player.berputar {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  transform-origin: top left;
}

.stage-bar {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(20, 24, 34, 0.86);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.stage-bar.pudar { opacity: 0; pointer-events: none; }

.stage-btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.stage-btn.aktif {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08101c;
}

.catatan-rotasi {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 24, 34, 0.9);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.catatan-rotasi.tampil { opacity: 1; }

/* --------------------------------------------------------------- unduhan */

.unduhan-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.unduhan-item .info { flex: 1; min-width: 0; }
.unduhan-item .judul { font-weight: 600; font-size: 14px; }
.unduhan-item .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

.unduhan-item button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.unduhan-item button.hapus { color: #ffb4b4; }

.kemajuan {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}

.kemajuan > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

.sumber { display: flex; gap: 10px; margin: 0 0 18px; flex-wrap: wrap; }
.sumber button {
  flex: 1; min-width: 130px; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  color: inherit; font-size: 15px;
}
.sumber button.aktif { border-color: #7cc4ff; background: rgba(124,196,255,.18); font-weight: 600; }
.sub { opacity: .65; font-size: 13px; font-weight: 400; }
