/* ============ 基础 ============ */
:root {
  --bg: #0b0b0f;
  --bg2: #15151c;
  --card: #1c1c25;
  --card2: #24242f;
  --line: rgba(255, 255, 255, .08);
  --text: #f5f5f7;
  --sub: #9a9aa5;
  --brand: #ff4d6d;
  --brand2: #ff7a4d;
  --gold: #ffc857;
  --green: #34c759;
  --blue: #4d8bff;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #050507;
  color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 0; height: 0; }

/* 手机壳：桌面预览时居中，移动端全屏 */
#phone {
  position: relative;
  width: 100%; max-width: 460px; height: 100vh; height: 100dvh;
  margin: 0 auto; background: var(--bg); overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, .8);
}
@media (min-width: 520px) { #phone { height: min(96vh, 900px); margin-top: 2vh; border-radius: 28px; } }

.view { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.view::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }

/* ============ 顶部栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px; background: rgba(11, 11, 15, .92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--card2); font-size: 16px; }
.icon-btn:active { transform: scale(.92); }

/* ============ 底部导航 ============ */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(58px + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(12, 12, 16, .96); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--sub); font-size: 10px; }
.tabbar .tab .ic { font-size: 21px; line-height: 1; }
.tabbar .tab.active { color: var(--brand); }

/* ============ 首页 ============ */
.searchbar { display: flex; align-items: center; gap: 8px; margin: 12px 14px; padding: 10px 14px; background: var(--card); border-radius: 22px; color: var(--sub); font-size: 13px; }
.cats { display: flex; gap: 8px; padding: 4px 14px 12px; overflow-x: auto; }
.cat { flex: none; padding: 7px 16px; border-radius: 18px; background: var(--card); color: var(--sub); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cat.active { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.section-title { padding: 6px 16px 10px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; width: 4px; height: 15px; border-radius: 2px; background: var(--brand); }

/* 推荐横滑大卡 */
.hero-scroll { display: flex; gap: 12px; padding: 2px 16px 16px; overflow-x: auto; scroll-snap-type: x mandatory; }
.hero-card { position: relative; flex: 0 0 200px; height: 290px; border-radius: 14px; overflow: hidden; scroll-snap-align: start; }
.hero-card img { width: 100%; height: 100%; object-fit: cover; }
.hero-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.88) 0%, rgba(0,0,0,.1) 55%); }
.hero-card .meta { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 2; }
.hero-card .meta .t { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.hero-card .meta .d { font-size: 11px; color: #d5d5db; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-card .badge { position: absolute; top: 10px; left: 10px; z-index: 2; padding: 3px 8px; border-radius: 10px; background: var(--brand); font-size: 10px; font-weight: 700; }

/* 双列瀑布 */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 14px 20px; }
.gcard { border-radius: 12px; overflow: hidden; background: var(--card); }
.gcard .cover { position: relative; aspect-ratio: 3 / 4; overflow: hidden; }
.gcard .cover img { width: 100%; height: 100%; object-fit: cover; }
.gcard .cover .ep { position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 8px; background: rgba(0,0,0,.7); font-size: 10px; }
.gcard .info { padding: 9px 10px 11px; }
.gcard .info .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcard .info .c { margin-top: 4px; font-size: 11px; color: var(--sub); }

/* ============ 详情页 ============ */
.detail-hero { position: relative; height: 300px; }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 2%, transparent 60%); }
.detail-hero .back { position: absolute; top: 14px; left: 14px; z-index: 3; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.5); font-size: 18px; }
.detail-info { position: relative; z-index: 2; margin-top: -46px; padding: 0 16px; }
.detail-info h2 { font-size: 22px; }
.detail-info .stats { display: flex; gap: 14px; margin: 10px 0; font-size: 12px; color: var(--sub); }
.detail-info .desc { font-size: 13px; line-height: 1.7; color: #c9c9d1; }
.detail-actions { display: flex; gap: 10px; padding: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 700;
  background: var(--card2); color: var(--text); transition: transform .1s;
}
.btn:active { transform: scale(.96); }
.btn.primary { flex: 1; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.btn.ghost { background: var(--card); color: var(--sub); }
.btn.gold { background: linear-gradient(135deg, #ffc857, #ff9a3c); color: #3a2400; }
.btn.sm { padding: 8px 12px; font-size: 12px; border-radius: 9px; }
.ep-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 0 16px 24px; }
.ep-cell { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; background: var(--card2); font-size: 13px; font-weight: 600; position: relative; }
.ep-cell.cur { background: linear-gradient(135deg, var(--brand), var(--brand2)); }
.ep-cell .lock { position: absolute; top: 3px; right: 5px; font-size: 9px; }
.ep-cell.unlocked { background: #2a2a36; color: var(--gold); }

/* ============ 播放页（核心） ============ */
#player-view { background: #000; overflow: hidden; }
.feed { height: 100%; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.feed-item { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden; background: #000; }
.feed-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.feed-shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.78) 0%, transparent 38%, rgba(0,0,0,.35) 100%); pointer-events: none; }
.feed-top { position: absolute; top: 16px; left: 16px; right: 16px; z-index: 5; display: flex; align-items: center; gap: 10px; }
.feed-top .back { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.45); font-size: 18px; }
.feed-top .dtitle { font-size: 14px; font-weight: 700; text-shadow: 0 1px 4px #000; }
.feed-side { position: absolute; right: 12px; bottom: 108px; z-index: 5; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.side-item { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; text-shadow: 0 1px 4px #000; }
.side-item .ic { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.35); font-size: 24px; }
.side-item .ic.liked { color: var(--brand); }
.side-item .n { font-size: 11px; }
.feed-bottom { position: absolute; left: 14px; right: 74px; bottom: 26px; z-index: 5; }
.feed-bottom .drama-line { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feed-bottom .ep-desc { font-size: 13px; line-height: 1.5; color: #e8e8ee; text-shadow: 0 1px 4px #000; }
.feed-bottom .tags { margin-top: 8px; font-size: 12px; color: #ffd7de; }
.progress-wrap { position: absolute; left: 14px; right: 74px; bottom: 16px; z-index: 6; height: 3px; border-radius: 2px; background: rgba(255,255,255,.28); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 2px; transition: width .2s linear; }
.center-play { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none; }
.center-play span { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.4); font-size: 30px; opacity: 0; transition: opacity .2s; }
.center-play.show span { opacity: 1; }

/* 解锁遮罩 */
.lock-mask { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(0,0,0,.68); backdrop-filter: blur(6px); text-align: center; padding: 24px; }
.lock-mask .lk { font-size: 52px; }
.lock-mask .t { font-size: 17px; font-weight: 700; }
.lock-mask .d { font-size: 12px; color: #c9c9d1; }
.lock-mask .btn { min-width: 220px; }

/* 剧集抽屉 */
.drawer-mask { position: absolute; inset: 0; z-index: 40; background: rgba(0,0,0,.5); }
.drawer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 70%; background: var(--bg2); border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + var(--safe-b)); transform: translateY(100%); transition: transform .25s ease; }
.drawer.open { transform: translateY(0); }
.drawer .hd { display: flex; align-items: center; margin-bottom: 14px; }
.drawer .hd h3 { font-size: 16px; flex: 1; }
.drawer .dscroll { max-height: 50vh; overflow-y: auto; }
.drawer .ep-grid { padding: 0; }

/* ============ 我的 ============ */
.me-head { display: flex; align-items: center; gap: 14px; padding: 22px 18px; }
.avatar { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand2)); display: grid; place-items: center; font-size: 24px; }
.me-head .nm { font-size: 18px; font-weight: 700; }
.me-head .id { font-size: 11px; color: var(--sub); margin-top: 4px; }
.wallet-card { margin: 0 14px 16px; padding: 18px; border-radius: 16px; background: linear-gradient(135deg, #2a2140, #1a1a28); border: 1px solid rgba(255,200,87,.18); }
.wallet-card .lb { font-size: 12px; color: var(--gold); }
.wallet-card .bal { font-size: 34px; font-weight: 800; margin: 4px 0 14px; }
.wallet-card .bal small { font-size: 13px; font-weight: 500; color: var(--sub); }
.wallet-card .row { display: flex; gap: 8px; }
.task-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 14px 16px; }
.task-card { padding: 14px 8px; border-radius: 12px; background: var(--card); text-align: center; }
.task-card .ic { font-size: 24px; }
.task-card .t { font-size: 12px; margin: 6px 0 2px; }
.task-card .r { font-size: 11px; color: var(--gold); }
.list-block { padding: 0 14px 20px; }
.list-block h3 { font-size: 14px; margin: 6px 0 12px; }
.tx-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tx-item .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card2); font-size: 17px; }
.tx-item .mid { flex: 1; }
.tx-item .mid .t { font-size: 13px; }
.tx-item .mid .d { font-size: 11px; color: var(--sub); margin-top: 3px; }
.tx-item .amt { font-weight: 700; font-size: 14px; }
.tx-item .amt.plus { color: var(--gold); }
.tx-item .amt.minus { color: var(--text); }
.seg { display: flex; gap: 8px; padding: 0 14px 14px; }
.seg .s { flex: 1; text-align: center; padding: 8px; border-radius: 9px; background: var(--card); font-size: 12px; color: var(--sub); }
.seg .s.active { background: var(--card2); color: var(--text); font-weight: 700; }

/* ============ 弹窗 ============ */
.modal-mask { position: absolute; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.6); }
.modal { width: 100%; max-width: 460px; background: var(--bg2); border-radius: 20px 20px 0 0; padding: 22px 18px calc(24px + var(--safe-b)); animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal .mh { display: flex; align-items: center; margin-bottom: 14px; }
.modal .mh h3 { font-size: 17px; flex: 1; }
.modal .mh .x { font-size: 20px; color: var(--sub); }
.pkg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.pkg { padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); text-align: center; background: var(--card); }
.pkg.active { border-color: var(--gold); background: rgba(255,200,87,.1); }
.pkg .p { font-size: 18px; font-weight: 800; color: var(--gold); }
.pkg .r { font-size: 11px; color: var(--sub); margin-top: 4px; }
.pkg .d { font-size: 10px; color: var(--brand); margin-top: 2px; }
.pay-row { display: flex; gap: 10px; margin-bottom: 14px; }
.pay-opt { flex: 1; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line); text-align: center; font-size: 13px; }
.pay-opt.active { border-color: var(--brand); background: rgba(255,77,109,.1); }

/* Toast */
#toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 100; padding: 12px 20px; border-radius: 12px; background: rgba(0,0,0,.85); color: #fff; font-size: 13px; white-space: nowrap; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

/* ============ 管理后台 ============ */
#view-admin { background: #f5f6f8; color: #1a1a22; }
#view-admin .adm-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; background: #fff; border-bottom: 1px solid #e8e8ee; }
#view-admin .adm-top h1 { font-size: 16px; flex: 1; }
#view-admin .adm-body { padding: 14px; padding-bottom: 40px; }
.adm-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 14px; background: #fff; border-bottom: 1px solid #e8e8ee; }
.adm-tab { flex: none; padding: 7px 14px; border-radius: 18px; background: #f0f1f4; color: #555; font-size: 12px; font-weight: 600; }
.adm-tab.active { background: #1a1a22; color: #fff; }
.adm-card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.adm-card .row { display: flex; align-items: center; gap: 10px; }
.adm-card .row + .row { margin-top: 10px; }
.adm-card img.thumb { width: 52px; height: 68px; border-radius: 6px; object-fit: cover; background: #eee; }
.adm-card .ttl { font-size: 14px; font-weight: 700; }
.adm-card .sub { font-size: 11px; color: #888; margin-top: 4px; }
.adm-card .ops { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.adm-card .ops button { padding: 6px 10px; border-radius: 7px; background: #f0f1f4; font-size: 11px; color: #333; }
.adm-card .ops button.danger { background: #ffe9ec; color: #d0021b; }
.adm-card .ops button.ok { background: #e6f9ed; color: #0a7a35; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card { background: #fff; border-radius: 12px; padding: 14px; }
.stat-card .n { font-size: 24px; font-weight: 800; color: #1a1a22; }
.stat-card .l { font-size: 11px; color: #888; margin-top: 4px; }
.stat-card.hl .n { color: #ff4d6d; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-row label { font-size: 12px; color: #666; font-weight: 600; }
.form-row input, .form-row textarea, .form-row select { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 13px; background: #fff; color: #1a1a22; }
.form-row textarea { min-height: 72px; resize: vertical; }
.adm-primary { width: 100%; padding: 13px; border-radius: 10px; background: #1a1a22; color: #fff; font-weight: 700; font-size: 14px; }
.adm-primary:active { opacity: .85; }
.badge-status { padding: 2px 8px; border-radius: 8px; font-size: 10px; font-weight: 700; }
.badge-status.online { background: #e6f9ed; color: #0a7a35; }
.badge-status.pending { background: #fff4e0; color: #a86a00; }
.badge-status.offline, .badge-status.draft { background: #eee; color: #777; }
#view-admin input, #view-admin textarea, #view-admin select { color: #1a1a22; }

/* 桌面端后台稍宽 */
@media (min-width: 520px) { .pkg-grid { grid-template-columns: repeat(4, 1fr); } }
