/* ============================================================
   nekocaree — style responsif (mobile-first)
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #131722;
  --card: #181d2a;
  --card2: #1e2434;
  --line: #232a3b;
  --text: #f2f4f8;
  --muted: #98a1b3;
  --accent: #ff5a78;
  --accent2: #8b6cff;
  --ok: #2dd4a7;
  --radius: 14px;
  --header-h: 52px;
  --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --content-max: 1180px;
}

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

html { height: 100%; background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:where(button, a, input):focus-visible {
  outline: 3px solid rgba(255, 90, 120, 0.85);
  outline-offset: 3px;
}

/* ---------- layout ---------- */
#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--header-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 14px; padding-right: 10px;
  background: rgba(11, 13, 18, 0.86);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  z-index: 50;
}
#app-header.hidden { display: none; }
.header-inner {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}

.logo-btn { display: flex; align-items: center; gap: 9px; padding: 6px 8px 6px 2px; }
.logo-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  filter: drop-shadow(0 5px 10px rgba(255, 90, 120, 0.24));
}
.logo-mark img { width: 100%; height: 100%; object-fit: contain; }
.logo-text { font-size: 19px; font-weight: 800; letter-spacing: 0.2px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text);
  background: var(--card); border: 1px solid var(--line);
}

#main {
  position: fixed; top: 0; bottom: 0; left: 0; right: 0;
  padding-top: calc(var(--header-h) + var(--safe-t));
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(13, 15, 21, 0.92);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 50;
}
#tabbar.hidden { display: none; }
.tabbar-inner {
  height: 100%; width: 100%; max-width: 640px; margin: 0 auto; display: flex;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; min-height: 44px;
}
.tab.active { color: var(--accent); }

.view { display: none; width: 100%; max-width: var(--content-max); min-height: 100%; margin: 0 auto; padding: 10px 12px 26px; }
.view.active { display: block; animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- chips platform ---------- */
.chips-wrap {
  position: sticky; top: 0; z-index: 20;
  margin: -10px -12px 12px;
  padding: 8px 12px 8px;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: none;
}
.chips::-webkit-scrollbar, .hrow::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 999px; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all 0.15s;
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.chip.active {
  background: linear-gradient(135deg, rgba(255,77,109,0.16), rgba(124,92,255,0.16));
  border-color: rgba(255,77,109,0.55); color: var(--text);
}
.chip.active .chip-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ---------- grid kartu ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 11px; }
.card { display: block; }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius);
  overflow: hidden; background: var(--card2); box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.poster img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.card:active .poster img { transform: scale(1.04); }
.poster.noimg::after {
  content: "🎬"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 34px; opacity: 0.45;
}
.poster.noimg img { display: none; }
.badge {
  position: absolute; font-size: 10.5px; font-weight: 700; padding: 3px 7px;
  border-radius: 999px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.badge.rating { top: 7px; left: 7px; background: rgba(255, 190, 40, 0.92); color: #241a00; }
.badge.eps { bottom: 7px; right: 7px; background: rgba(0,0,0,0.6); color: #fff; }
.play-ic {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,0); color: #fff; opacity: 0;
  transition: opacity 0.2s;
}
.play-ic svg { filter: drop-shadow(0 3px 8px rgba(0,0,0,0.6)); }
.card:active .play-ic { opacity: 1; background: rgba(0,0,0,0.28); }
.card-title {
  margin-top: 7px; font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.7em; color: var(--text);
}
.card-desc { margin-top: 3px; font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- section ---------- */
.section { margin-bottom: 22px; }
.section-title { font-size: 16.5px; font-weight: 800; margin-bottom: 11px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 16px; border-radius: 4px; background: linear-gradient(var(--accent), var(--accent2)); }

/* ---------- baris lanjutkan nonton ---------- */
.hrow { display: flex; gap: 11px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.hcard { width: 118px; flex: none; }
.poster.small { aspect-ratio: 2 / 3; }
.hcard-title { margin-top: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcard-ep { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,0.25); }
.progress-fill { height: 100%; background: var(--accent); }

/* ---------- pencarian ---------- */
.search-bar {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 0 13px; margin-bottom: 10px;
}
.search-ic { color: var(--muted); display: grid; }
#search-input {
  flex: 1; background: none; border: 0; outline: none;
  color: var(--text); font-size: 16px; padding: 12px 0;
}
#search-input::placeholder { color: var(--muted); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 700;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  min-height: 44px;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; color: #fff; box-shadow: 0 6px 18px rgba(255,77,109,0.3); }
.btn.ghost { border-style: dashed; color: var(--muted); }
.btn:active { transform: scale(0.97); }
.loadmore { display: flex; justify-content: center; padding: 18px 0 6px; }
.loadmore .btn { width: 100%; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 52px 22px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty h3 { color: var(--text); font-size: 16.5px; margin-bottom: 6px; }
.empty p { font-size: 13.5px; }
.empty .btn { margin-top: 16px; }

/* ---------- skeleton ---------- */
.skeleton .skeleton-poster { aspect-ratio: 2/3; border-radius: var(--radius); background: linear-gradient(100deg, var(--card) 40%, var(--card2) 50%, var(--card) 60%); background-size: 200% 100%; animation: sk 1.2s infinite; }
.skeleton .skeleton-line { height: 12px; margin-top: 8px; border-radius: 6px; background: var(--card); animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- detail ---------- */
.detail-hero { position: relative; margin: -10px -12px 0; padding: 10px 12px 16px; }
.blur-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center 25%;
  filter: blur(46px) saturate(1.3); opacity: 0.5; transform: scale(1.15);
  mask-image: linear-gradient(#000 55%, transparent); -webkit-mask-image: linear-gradient(#000 55%, transparent);
}
.detail-top { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 4px 0 14px; }
.spacer { flex: 1; }
.favbtn.on { color: var(--accent); border-color: rgba(255,77,109,0.5); background: rgba(255,77,109,0.12); }
.detail-body { position: relative; display: flex; gap: 14px; }
.detail-poster-wrap { flex: none; }
.detail-poster { width: 118px; aspect-ratio: 2/3; object-fit: cover; border-radius: 13px; box-shadow: 0 10px 28px rgba(0,0,0,0.5); }
.detail-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.detail-title { font-size: 18.5px; font-weight: 800; line-height: 1.3; }
.detail-meta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.detail-stats { display: flex; gap: 10px; margin-top: 7px; flex-wrap: wrap; }
.stat { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 4px 9px; border-radius: 999px; }
.detail-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; }
.detail-actions .btn { flex: 1; padding: 11px 10px; font-size: 13.5px; }

.detail-content { padding: 4px 2px 26px; }
.continue-card {
  width: 100%; display: flex; align-items: center; gap: 13px;
  background: linear-gradient(135deg, rgba(255,77,109,0.14), rgba(124,92,255,0.14));
  border: 1px solid rgba(255,77,109,0.35); border-radius: 14px; padding: 12px 14px; margin: 14px 0;
  text-align: left;
}
.cc-play { color: var(--accent); display: grid; }
.cc-title { font-weight: 700; font-size: 14px; }
.cc-sub { font-size: 12px; color: var(--muted); }

.subtitle { font-size: 16px; font-weight: 800; margin: 18px 0 9px; }
.synopsis-text { font-size: 13.5px; color: #c7cdd9; line-height: 1.6; }
.eps-head { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 0 10px; }
.eps-head .subtitle { margin: 0; }
.eps-count { font-size: 12px; color: var(--muted); }
.eps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 9px; }
.ep-btn {
  aspect-ratio: 1; border-radius: 12px; font-size: 14.5px; font-weight: 700;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center; min-height: 44px;
}
.ep-btn:active { background: var(--card2); }
.ep-btn.locked { opacity: 0.45; }
.ep-btn.locked::after { content: "🔒"; font-size: 11px; position: absolute; margin-top: 26px; }

.detail-skeleton { padding: 12px 0; }
.detail-skeleton .sk { height: 14px; border-radius: 8px; background: var(--card); margin-bottom: 12px; animation: sk 1.2s infinite; }
.detail-skeleton .sk:nth-child(1) { height: 190px; border-radius: 14px; }
.detail-skeleton .sk:nth-child(2) { width: 70%; }
.detail-skeleton .sk:nth-child(3) { width: 90%; }
.detail-skeleton .sk:nth-child(4) { width: 55%; }

/* ---------- player ---------- */
#player-view { display: none; position: fixed; inset: 0; z-index: 100; background: #05060a; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#player-view.active { display: block; }

.player-video-wrap { position: relative; background: #000; aspect-ratio: 16/10; max-height: 46vh; width: 100%; }
#player-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-back {
  position: absolute; top: calc(8px + var(--safe-t)); left: 10px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff; display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.player-buffering {
  position: absolute; inset: 0; display: none; place-items: center; gap: 10px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 13px; flex-direction: column; z-index: 4;
}
.player-buffering.show { display: flex; }
.spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2); border-top-color: var(--accent);
  animation: rot 0.8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

.player-error {
  position: absolute; inset: 0; z-index: 6; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(0,0,0,0.78); text-align: center; padding: 20px; color: #fff;
}
.player-error.show { display: flex; }
.player-error h3 { font-size: 15.5px; }
.player-error p { font-size: 12.5px; color: #c9ccd4; max-width: 300px; }
.player-error .btn { margin-top: 8px; }

.player-body { padding: 14px 14px calc(30px + var(--safe-b)); }
.player-title { font-size: 17px; font-weight: 800; margin-bottom: 12px; line-height: 1.35; }
.player-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 11px 12px; font-size: 13px; font-weight: 600; min-height: 44px;
}
.pbtn svg { flex: none; }
.pbtn:active { background: var(--card2); }
.pbtn.disabled { opacity: 0.4; }
.player-actions > .pbtn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.pbtn.small { padding: 8px 13px; min-height: 36px; font-size: 12.5px; }
.pbtn.small.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.pbtn-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pbtn-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-right: 2px; }

#player-ep-sheet {
  position: fixed; left: 50%; right: auto; bottom: 0; z-index: 110;
  width: min(100%, 680px);
  background: var(--surface); border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  max-height: 62vh; display: flex; flex-direction: column;
  transform: translate(-50%, 105%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
  padding-bottom: var(--safe-b);
}
#player-ep-sheet.open { transform: translate(-50%, 0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { font-size: 15.5px; }
.sheet-list { overflow-y: auto; padding: 6px 10px 16px; }
.sheet-ep {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 10px; border-radius: 11px; text-align: left; min-height: 46px;
}
.sheet-ep:active { background: var(--card2); }
.sheet-ep.on { background: rgba(255,77,109,0.13); }
.sheet-ep.locked { opacity: 0.45; }
.sheet-num {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--card2); color: var(--muted);
}
.sheet-ep.on .sheet-num { background: var(--accent); color: #fff; }
.sheet-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.player-error-page { padding: 90px 30px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; color: #fff; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 200;
  transform: translateX(-50%) translateY(16px);
  background: rgba(20, 24, 34, 0.95); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 18px; font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all 0.25s;
  max-width: 86vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- persetujuan privasi ---------- */
#privacy-consent {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); z-index: 230;
  width: min(calc(100% - 24px), 620px); transform: translateX(-50%);
  padding: 16px; border: 1px solid rgba(255,255,255,0.1); border-radius: 18px;
  background: rgba(19, 23, 34, 0.97); box-shadow: 0 18px 54px rgba(0,0,0,0.55);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.privacy-copy { display: flex; align-items: flex-start; gap: 12px; }
.privacy-icon {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: 10px; color: var(--ok); background: rgba(45,212,167,0.12);
}
.privacy-copy h2 { font-size: 15.5px; margin-bottom: 4px; }
.privacy-copy p { color: #c4cad6; font-size: 12.5px; line-height: 1.55; }
.privacy-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.privacy-actions .btn { min-width: 94px; }

/* ---------- responsif ---------- */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

@media (max-width: 359px) {
  .view { padding-left: 10px; padding-right: 10px; }
  .detail-poster { width: 96px; }
  .detail-body { gap: 10px; }
  .detail-actions { flex-direction: column; }
  .detail-title { font-size: 17px; }
  .logo-text { font-size: 17px; }
  .header-actions { gap: 5px; }
  .header-actions .iconbtn { width: 38px; }
  .privacy-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .privacy-actions .ghost { grid-column: 1 / -1; }
}

@media (min-width: 480px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 18px 13px; }
  .view { padding-left: 16px; padding-right: 16px; }
  .chips-wrap { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}

@media (min-width: 768px) {
  :root { --header-h: 60px; --tab-h: 62px; }
  #app-header { padding-left: 22px; padding-right: 22px; }
  .view { padding: 18px 22px 34px; }
  .chips-wrap { margin: -18px -22px 18px; padding: 12px 22px; }
  .grid { grid-template-columns: repeat(4, 1fr); gap: 22px 16px; }
  .card-title { font-size: 14px; }
  .detail-hero { margin: -18px -22px 0; padding: 18px 22px 24px; }
  .detail-body { gap: 22px; }
  .detail-poster { width: 168px; }
  .detail-title { font-size: clamp(24px, 3vw, 34px); }
  .detail-content { max-width: 940px; margin: 0 auto; }
  .player-shell { max-width: 1180px; min-height: 100%; margin: 0 auto; background: #080a10; }
  .player-video-wrap { aspect-ratio: 16/9; max-height: 70vh; }
  .player-body { padding: 22px 24px calc(38px + var(--safe-b)); }
  .player-title { font-size: 22px; }
  .player-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .player-actions > .pbtn:last-child:nth-child(odd) { grid-column: auto; }
}

@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
  .play-ic { opacity: 0; }
}

@media (min-width: 1240px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
}

@media (hover: hover) and (pointer: fine) {
  .card:hover .poster img { transform: scale(1.045); }
  .card:hover .play-ic { opacity: 1; background: rgba(0,0,0,0.28); }
  :where(.btn, .pbtn, .iconbtn, .chip, .tab):not(:disabled):hover { border-color: rgba(255, 90, 120, 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
