:root {
  --bg: #000;
  --panel: #121212;
  --panel2: #1b1b1b;
  --line: rgba(255,255,255,.08);
  --text: #fff;
  --muted: #a3a3a3;
  --accent: #ff2d55;
  --accent-soft: #ff4d6d;
  --header-h: 64px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.page.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ========== HEADER (StoryArchive style) ========== */
.sa-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(0,0,0,.92);
  border-bottom: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(12px);
}
.sa-header-inner {
  max-width: 1400px; margin: 0 auto; height: 100%;
  padding: 0 24px;
  display: flex; align-items: center; gap: 28px;
}
.sa-brand {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  font-weight: 800; font-size: 20px; letter-spacing: .01em;
}
.sa-brand img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.sa-brand span { color: #ff4d6d; }

.sa-nav {
  display: flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.sa-nav::-webkit-scrollbar { display: none; }
.sa-nav a {
  flex: 0 0 auto; padding: 8px 12px; border-radius: 6px;
  color: #cfcfcf; font-size: 14px; white-space: nowrap;
}
.sa-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sa-nav a.active { color: #fff; font-weight: 700; }

.sa-header-right { margin-left: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

.lang-switch {
  display: flex; gap: 2px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; padding: 2px;
}
.lang-switch button {
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #999;
}
.lang-switch button.active { background: var(--accent); color: #fff; }
.sa-search {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; padding: 4px 4px 4px 12px;
  width: 200px;
}
.sa-search input {
  flex: 1; min-width: 0; border: 0; outline: 0;
  background: transparent; color: #fff; font-size: 13px; padding: 6px 0;
}
.sa-search input::placeholder { color: #888; }
.sa-search button {
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; color: #bbb; font-size: 16px;
}

/* ========== HERO (cinematic) ========== */
.sa-main { width: 100%; }
.sa-hero {
  position: relative;
  width: 100%;
  height: clamp(360px, 52vw, 520px);
  overflow: hidden;
  background: #0a0a0a;
}
.sa-hero-track {
  display: flex; height: 100%; width: 100%;
  transition: transform .55s cubic-bezier(.22,.61,.36,1);
}
.sa-hero-slide {
  position: relative; min-width: 100%; height: 100%;
  color: #fff;
}
.sa-hero-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  filter: brightness(.55) saturate(1.05);
  transform: scale(1.02);
}
.sa-hero-mask {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,.88) 0%, rgba(0,0,0,.55) 42%, rgba(0,0,0,.15) 70%, rgba(0,0,0,.35) 100%),
    linear-gradient(180deg, rgba(0,0,0,.25) 0%, transparent 30%, rgba(0,0,0,.75) 100%);
}
.sa-hero-content {
  position: relative; z-index: 2;
  max-width: 1400px; margin: 0 auto; height: 100%;
  padding: 0 48px;
  display: flex; align-items: center; gap: 28px;
}
.sa-hero-poster {
  flex: 0 0 auto;
  width: clamp(140px, 16vw, 200px);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.12);
}
.sa-hero-poster img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.sa-hero-copy { max-width: 560px; }
.sa-hero-copy h1 {
  margin: 0 0 12px; font-size: clamp(28px, 4vw, 42px);
  font-weight: 800; line-height: 1.15;
  text-shadow: 0 6px 30px rgba(0,0,0,.5);
}
.sa-hero-copy p {
  margin: 0 0 22px; color: rgba(255,255,255,.86);
  font-size: 15px; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sa-play-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: #fff;
  padding: 12px 28px; border-radius: 10px;
  font-size: 16px; font-weight: 800;
  box-shadow: 0 12px 30px rgba(255,45,85,.35);
  transition: transform .15s ease, filter .15s ease;
}
.sa-play-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.sa-play-btn .tri {
  width: 0; height: 0;
  border-left: 10px solid #fff;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

.sa-hero-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.15);
  color: #fff; font-size: 28px; display: grid; place-items: center;
}
.sa-hero-arrow:hover { background: rgba(255,45,85,.85); }
.sa-hero-arrow.left { left: 16px; }
.sa-hero-arrow.right { right: 16px; }

.sa-hero-dots {
  position: absolute; left: 0; right: 0; bottom: 18px; z-index: 5;
  display: flex; justify-content: center; gap: 8px;
}
.sa-hero-dots span {
  width: 28px; height: 3px; border-radius: 99px;
  background: rgba(255,255,255,.28);
}
.sa-hero-dots span.on { background: #fff; }

/* ========== CENTER TABS ========== */
.sa-tabs-wrap {
  display: none !important;
}
.sa-tabs {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 22px; max-width: 100%;
}
.sa-tabs a, .cat-chip {
  position: relative;
  color: #9a9a9a; font-size: 15px; padding: 8px 4px 10px;
  white-space: nowrap; background: none; border: 0; border-radius: 0;
}
.sa-tabs a:hover, .cat-chip:hover { color: #fff; }
.sa-tabs a.active, .cat-chip.active {
  color: var(--accent); font-weight: 700;
}
.sa-tabs a.active::after, .cat-chip.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: var(--accent); border-radius: 2px;
}

/* All Dramas page — clickable filter tags */
.sa-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 8px;
}
.sa-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: #cfcfcf;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  white-space: nowrap;
  transition: .15s ease;
}
.sa-filter-chip:hover {
  color: #fff;
  border-color: rgba(255,255,255,.22);
}
.sa-filter-chip.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #ff6a3d);
  box-shadow: 0 8px 18px rgba(255, 45, 85, .3);
}

/* ========== SECTIONS ========== */
.sa-sections {
  max-width: 1400px; margin: 0 auto;
  padding: 8px 24px 40px;
}
.shelf-block { margin: 18px 0 28px; }
.shelf-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.shelf-head h2 {
  margin: 0; font-size: 20px; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
}
.shelf-head a {
  color: #9a9a9a; font-size: 13px;
}
.shelf-head a:hover { color: #fff; }

.row-scroll {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 14px;
  overflow: hidden;
  padding-bottom: 4px;
}
@media (max-width: 1200px) {
  .row-scroll { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .row-scroll { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .row-scroll { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

.poster-card {
  scroll-snap-align: start;
  position: relative; display: block;
  border-radius: 10px; overflow: hidden;
  background: #111;
  transition: transform .18s ease;
}
.poster-card:hover { transform: translateY(-4px) scale(1.03); z-index: 2; }
.poster-thumb { position: relative; overflow: hidden; border-radius: 10px; }
.poster-card img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #000;
  transition: transform .25s ease;
}
.poster-card:hover .poster-thumb img { transform: scale(1.06); }
.ep-badge {
  position: absolute; left: 6px; bottom: 6px; z-index: 2;
  padding: 2px 7px; border-radius: 6px;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .3px;
}
.poster-thumb::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,.55) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23fff" d="M8 5v14l11-7z"/></svg>') center/22px no-repeat;
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.poster-card:hover .poster-thumb::after { opacity: 1; }
.poster-body {
  padding: 8px 2px 0;
  background: none; position: static;
}
.poster-body h3 {
  margin: 0; font-size: 13px; line-height: 1.35; font-weight: 600; color: #eee;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.5em;
}

.apk-more-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 200px; padding: 16px; text-align: center;
  border-radius: 10px; border: 1px dashed rgba(255,45,85,.5);
  background: linear-gradient(160deg, rgba(255,45,85,.15), #141414);
}
.apk-more-logo { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; }
.apk-more-body strong { display: block; margin-bottom: 4px; }
.apk-more-body p { margin: 0; color: #ffb3c1; font-size: 12px; }
.dense-grid .apk-more-card, .category-grid .apk-more-card { aspect-ratio: 3/4; min-height: 0; }
.search-empty { padding: 48px 12px; text-align: center; color: var(--muted); }

/* watch page */
.watch-layout {
  max-width: 1400px; margin: 20px auto; padding: 0 24px 40px;
  display: grid; grid-template-columns: minmax(0,1.4fr) minmax(280px,.85fr); gap: 16px;
}
.player-pane, .side {
  background: #121212; border: 1px solid var(--line); border-radius: 14px;
}
#page-watch.is-loading .player-pane,
#page-watch.is-loading .side {
  opacity: 0.72;
  transition: opacity .2s ease;
}
.stage {
  position: relative; aspect-ratio: 9/16; max-height: 72vh;
  margin: 14px auto 0; width: min(420px, 100%);
  background: #000; border-radius: 12px; overflow: hidden;
}
#video { width: 100%; height: 100%; object-fit: contain; background: #000; }
/* tap-to-play overlay (iOS/FB autoplay block) */
.stage-play {
  position: absolute; inset: 0; margin: auto; z-index: 6;
  width: 74px; height: 74px; border: 0; border-radius: 50%;
  background: rgba(255, 45, 106, .94); cursor: pointer;
  box-shadow: 0 10px 34px rgba(0,0,0,.55);
}
.stage-play[hidden] { display: none; }
.stage-play::after {
  content: ""; display: block; margin: 0 auto;
  border-left: 26px solid #fff; border-top: 16px solid transparent;
  border-bottom: 16px solid transparent; transform: translateX(4px);
}
.sound-hint {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  background: rgba(0,0,0,.75); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 7px 12px; font-size: 12px; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sound-hint[hidden] { display: none; }
.ep, .now-actions button, .stage-play, .sound-hint, .stream-btn {
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
/* free-banner overlaps the episode grid on mobile watch page — hide it there */
body.watch-open .apk-banner { display: none; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: end start;
  padding: 18px; pointer-events: none;
  background: linear-gradient(transparent 45%, rgba(0,0,0,.8));
}
.overlay.hide { opacity: 0; }
.overlay-card h1 { margin: 0 0 6px; font-size: 18px; }
.overlay-card p { margin: 0; color: #ddd; font-size: 13px; }
.now-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 16px 8px;
}
.now-ep { font-weight: 700; }
.now-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.now-actions { display: flex; gap: 8px; }
.primary {
  background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 700;
}
.ghost {
  background: #1f1f1f; color: #fff; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line);
}
.stream-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 10px; }
.stream-btn {
  background: #1f1f1f; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 10px; font-size: 12px;
}
.stream-btn.active { border-color: var(--accent); color: #fff; }
.episode-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px; padding: 12px 16px 18px; max-height: 220px; overflow: auto;
}
.ep {
  background: #1f1f1f; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 8px; text-align: center;
}
.ep.active { border-color: var(--accent); }
.ep.locked { opacity: .55; }
.ep.locked small { color: #ff8fab; }
.ep.paid small { color: #ffd166; font-weight: 700; }
.ep small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.watch-side { padding: 16px; }
.back-link { display: inline-block; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.lang-notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border: 1px solid rgba(255,196,0,.35); background: rgba(255,196,0,.08); border-radius: 10px; font-size: 13px; color: #f3d78a; }
.lang-notice[hidden] { display: none; }
.lang-notice-btn { flex: 0 0 auto; padding: 6px 12px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.lang-notice-btn:hover { background: var(--accent-soft); }
.watch-cover-wrap { border-radius: 12px; overflow: hidden; margin-bottom: 12px; border: 1px solid var(--line); }
.watch-cover { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.watch-title { margin: 0 0 8px; font-size: 22px; }
.watch-desc { margin: 0 0 10px; color: #cfcfcf; font-size: 14px; line-height: 1.5; }
.watch-meta { font-size: 12px; }

.apk-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(90deg, #2a0614 0%, #8b123f 40%, #ff2d6a 78%, #8b123f 100%);
  border-top: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 -10px 32px rgba(0,0,0,.55);
  animation: apkBannerPulse 2.8s ease-in-out infinite;
}
@keyframes apkBannerPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}
.apk-banner-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.apk-banner-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  background: #111;
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.apk-banner-copy {
  min-width: 0; flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.apk-banner-text {
  font-size: 15px; font-weight: 900; color: #fff;
  letter-spacing: .01em;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.apk-banner-sub {
  font-size: 12px; color: #ffe4ec; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lock-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #ff2d6a;
  color: #fff !important;
  font-weight: 700;
  text-decoration: none !important;
  border: 0;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 45, 106, 0.35);
}
.lock-download-btn:hover { filter: brightness(1.08); }
.side-download {
  display: block;
  width: 100%;
  margin-top: 14px;
  text-align: center;
  box-sizing: border-box;
}
.apk-banner-btn {
  background: #fff; color: #c01048 !important; padding: 12px 18px;
  border-radius: 999px; font-size: 13px; font-weight: 900; white-space: nowrap;
  text-decoration: none !important;
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
  flex-shrink: 0;
  border: 0;
}
.apk-banner-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.apk-banner-btn.free-badge { cursor: default; }
.apk-banner-btn.free-badge:hover { filter: none; transform: none; }
@media (max-width: 560px) {
  .apk-banner-icon { width: 38px; height: 38px; }
  .apk-banner-text { font-size: 13px; }
  .apk-banner-sub { font-size: 11px; }
  .apk-banner-btn { padding: 10px 12px; font-size: 12px; }
}

body { padding-bottom: 72px; }

@media (max-width: 960px) {
  .sa-header-inner { padding: 0 12px; gap: 12px; }
  .sa-nav { display: none; }
  .sa-hero { height: 420px; }
  .sa-hero-content { padding: 0 16px; gap: 16px; }
  .sa-hero-poster { width: 120px; }
  .sa-hero-copy h1 { font-size: 24px; }
  .sa-hero-arrow { display: none; }
  .sa-sections, .sa-tabs-wrap { padding-left: 12px; padding-right: 12px; }
  .watch-layout { grid-template-columns: 1fr; padding: 0 12px 40px; }
  .row-scroll { grid-auto-columns: minmax(120px, 132px); }
}
