:root {
  --brand: #B84A4A;
  --brand-light: #D47878;
  --brand-dark: #C24A4A;
  --tab-selected: #FD8729;
  --page-bg: #F0F0F0;
  --card-bg: #FFFFFF;
  --text: #2d2d2d;
  --text-gray: #9e9e9e;
  --footer-bg: #F0F0F0;
  --footer-default: #666666;
  --footer-selected: #B84A4A;
  --header-grad-start: #C24A4A;
  --header-grad-mid: #D47878;
  --header-grad-end: #F0F0F0;
  --search-bg: rgba(255,255,255,0.7);
  --search-stroke: rgba(255,255,255,0.4);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --dock-content-h: 50px;
  --dock-h: calc(var(--dock-content-h) + env(safe-area-inset-bottom, 0px));
}

[data-theme="dark"] {
  --page-bg: #2C2C2E;
  --card-bg: #3A3A3C;
  --text: #F0F0F0;
  --text-gray: #B0B0B0;
  --footer-bg: #2C2C2E;
  --footer-default: #C8C8C8;
  --footer-selected: #D47878;
  --header-grad-start: #A33A3A;
  --header-grad-mid: #6E3333;
  --header-grad-end: #2C2C2E;
  --search-bg: rgba(255,255,255,0.25);
}

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

/*
 * Dock 贴底：
 * - html/body 不要 position:fixed
 * - #app 用 fixed + top/height（bottom:auto），高度由 JS 跟 visualViewport，避免 iOS 布局视口比可视区矮/高导致底缝
 * - #bottom-nav 为 #page-main flex 最后一项
 */
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  background: var(--browser-surface, #000);
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--page-bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
body:has(#app.tiktok-active) { background: #000; }

#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  /* Safari 浏览器：默认 svh；standalone 由 JS 写死 innerHeight */
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
  background: var(--page-bg);
}
#app.tiktok-active { background: #000; }

/*
 * 主屏幕 Web App：#app 子节点全是 absolute，height:auto 会塌缩 → dock 悬空、底下黑缝。
 * 必须用明确高度 / fixed dock，不能靠 height:auto + bottom:0。
 */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html, body {
    height: 100%;
    min-height: 100%;
    min-height: -webkit-fill-available;
    background: var(--browser-surface, #000);
  }
  #app {
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    /* 与 html.standalone #app 保持同一回退链：fill-available → dvh（含安全区） */
    height: 100%;
    height: -webkit-fill-available;
    height: 100dvh;
    min-height: 100%;
    min-height: -webkit-fill-available;
  }
  .bottom-nav {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
  }
  #page-main.active {
    padding-bottom: calc(var(--dock-content-h) + env(safe-area-inset-bottom, 0px));
  }
}
html.standalone, html.standalone body {
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  background: var(--browser-surface, #000);
}
html.standalone #app {
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  width: 100% !important;
  /* status-bar-style=black 下视口 = 物理屏高；dvh 为主，fill-available 兜底老 iOS */
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  min-height: 100%;
  min-height: -webkit-fill-available;
}
html.standalone .bottom-nav {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}
html.standalone #page-main.active {
  padding-bottom: calc(var(--dock-content-h) + env(safe-area-inset-bottom, 0px));
}

/* 封面加载占位（Worker 解密期间避免空白闪烁） */
.img-loading {
  background: linear-gradient(90deg, #2a2a2c 25%, #3a3a3c 37%, #2a2a2c 63%);
  background-size: 400% 100%;
  animation: img-shimmer 1.2s ease-in-out infinite;
}
@keyframes img-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.page {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  flex-direction: column;
  background: var(--page-bg);
  overflow: hidden;
}
.page.active { display: flex; }
.page-overlay { z-index: 100; background: var(--page-bg); }

@keyframes page-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes page-sheet-in {
  from { opacity: 0; transform: translateX(28%); }
  to { opacity: 1; transform: translateX(0); }
}
.page-enter { animation: page-fade-in 0.22s ease; }
.page-enter-sheet { animation: page-sheet-in 0.28s ease; }

/* 勿写 #page-main { display:flex }，会盖过 .page { display:none } */
#page-main.active {
  flex-direction: column;
  min-height: 0;
  /* 由 .page 的 absolute inset 撑满，勿再设 height/--app-h */
  overflow: hidden;
  background: var(--page-bg);
  box-sizing: border-box;
}
#app.tiktok-active #page-main.active { background: #000; }

/* Splash */
#page-splash {
  align-items: center; justify-content: center;
  background: #fff; color: #666;
}
.splash-logo {
  display: block; width: 100px; height: 100px;
  object-fit: contain; flex-shrink: 0; margin-bottom: 28px;
}
.splash-spinner {
  width: 36px; height: 36px; flex-shrink: 0;
  border: 3px solid #e8e8e8; border-top-color: #b84a4a;
  border-radius: 50%; animation: splash-spin .85s linear infinite;
}
.splash-loading { color: #777; font-size: 14px; }
#splash-retry {
  margin-top: 16px; min-height: 44px; padding: 10px 24px;
  border: 1px solid #b84a4a; border-radius: 22px;
  background: #fff; color: #b84a4a; font-size: 14px; cursor: pointer;
}
#splash-status[hidden], #splash-retry[hidden] { display: none; }
.splash-failed .splash-spinner { display: none; }
@keyframes splash-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .splash-spinner { animation-duration: 2s; }
}

/* Main layout */
#main-main { flex: 1; }
.main-header {
  background: linear-gradient(180deg, var(--header-grad-start) 0%, var(--header-grad-mid) 55%, var(--header-grad-end) 100%);
  padding: max(8px, env(safe-area-inset-top)) 0 8px;
}
.main-header.hidden { display: none; }

.search-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 10px; height: 35px;
  background: var(--search-bg);
  border: 1px solid var(--search-stroke);
  border-radius: 18px; padding: 0 12px;
  color: var(--text-gray); font-size: 14px;
}
.search-bar svg { flex-shrink: 0; }

.category-tabs {
  display: flex; overflow-x: auto; gap: 4px;
  padding: 4px 8px 8px; scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0; border: none; background: transparent;
  padding: 8px 12px; font-size: 14px; color: var(--text);
  border-bottom: 2px solid transparent;
}
.cat-tab.active { color: var(--tab-selected); border-bottom-color: var(--tab-selected); font-weight: 600; }

/*
 * 二级分类横栏（ui6）：挂在一级栏下方，层级更轻——小号、药丸底、无下划线。
 * 默认 max-height:0 + opacity:0，只有当前一级真有子类时加 .open，
 * 约 200ms 展开且真实撑开高度，下方列表随之下移（不是覆盖在列表上）。
 * 没有子类时既不显示也不占位。
 */
.sub-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  max-height: 0;
  opacity: 0;
  padding: 0 8px;
  transition:
    max-height 0.2s ease-out,
    opacity 0.18s ease-out,
    padding-bottom 0.2s ease-out;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tabs.open {
  max-height: 44px;
  opacity: 1;
  padding-bottom: 8px;
}
.sub-tab {
  flex-shrink: 0;
  border: none;
  border-radius: 14px;
  background: var(--sub-tab-bg, rgba(127, 127, 127, 0.12));
  padding: 5px 12px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  opacity: 0.85;
}
.sub-tab.active {
  background: var(--tab-selected);
  color: #fff;
  opacity: 1;
  font-weight: 600;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 8px;
  min-height: 0;
}

/*
 * Bottom nav — #page-main 的 flex 最后一项，随 #app 贴屏幕底。
 * 背景含 home indicator；图标在安全区上方。
 */
.bottom-nav {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  width: 100%;
  margin: 0;
  padding: 0;
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
  background: var(--footer-bg);
  border-top: 1px solid rgba(0,0,0,0.06);
  z-index: 50;
}
.bottom-nav.dock-dark {
  background: #000;
  border-top-color: #222;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  border: none; background: transparent;
  color: var(--footer-default); font-size: 11px;
  height: var(--dock-content-h);
  padding: 0;
}
.nav-item svg { width: 22px; height: 22px; fill: currentColor; }
.nav-item .nav-icon-img {
  width: 22px; height: 22px; object-fit: contain;
  display: block;
}
.nav-item.active { color: var(--footer-selected); }
/*
 * dock 按下反馈：安卓是波纹，H5 上做波纹容易掉帧，改用缩放+轻微变淡，
 * 手感接近原生且不会残留高亮。iOS 上光靠 :active 不一定触发，
 * app.js 另外用 touchstart/touchend 加 .nav-tapping 兜底。
 */
.nav-item {
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, opacity .12s ease;
}
.nav-item:active,
.nav-item.nav-tapping {
  transform: scale(.92);
  opacity: .78;
}
@media (prefers-reduced-motion: reduce) {
  .nav-item { transition: none; }
  .nav-item:active, .nav-item.nav-tapping { transform: none; }
}
.nav-item.has-free-badge span::after {
  content: '全免'; font-size: 9px; color: #fff; background: #f24024;
  padding: 1px 4px; border-radius: 6px; margin-left: 2px; vertical-align: top;
}

/* Carousel */
.carousel {
  position: relative; height: 200px; margin: 8px 10px;
  border-radius: 8px; overflow: hidden; background: #333;
}
.carousel-track {
  display: flex; height: 100%;
  transition: transform 0.35s ease;
}
.carousel-slide {
  min-width: 100%; height: 100%; position: relative;
}
.carousel-slide img {
  width: 100%; height: 100%; object-fit: cover;
}
.carousel-title {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 24px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff; font-size: 15px;
}
.carousel-dots {
  position: absolute; bottom: 6px; right: 10px;
  display: flex; gap: 4px;
}
.carousel-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.4);
}
.carousel-dots span.on { background: #fff; }

/* Column section */
.column-section { padding: 12px 0 4px; width: 100%; overflow: hidden; }
.column-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; padding: 0 10px;
}
.column-title { font-size: 18px; font-weight: 600; flex: 1; }
.btn-more {
  font-size: 12px; padding: 4px 12px;
  border: 1px solid var(--brand);
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
}
.btn-more:active { opacity: 0.85; }

/* Film grid — 对齐 Android FilmItemView：宽/1.77 ≈ 16:9（padding 兜底旧 WebKit） */
.film-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 8px;
  padding: 8px 10px 16px;
  width: 100%;
  box-sizing: border-box;
}
/* 首页/一级/二级专用；共享 film-grid 与其他入口保持原样。 */
.home-film-list {
  grid-template-columns: minmax(0, 640px);
  justify-content: center;
  gap: 12px;
  padding: 8px 10px 16px;
}
.home-film-list .film-cover-wrap { border-radius: 10px; }
.home-film-list .film-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.4;
  max-height: 2.8em;
}

.film-card { cursor: pointer; min-width: 0; width: 100%; }
.film-cover-wrap {
  position: relative; border-radius: 5px; overflow: hidden;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9，兼容旧 WebKit（勿再叠 aspect-ratio，会双倍高度） */
  background: #444;
}
.film-cover-wrap img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.film-badge {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.55); color: #ffd700;
  font-size: 10px; padding: 2px 5px; border-radius: 3px;
}
.film-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 6px 4px;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  color: #fff; font-size: 10px;
  display: flex; justify-content: space-between;
}
.film-title {
  margin-top: 6px; font-size: 13px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Mine — 对齐 Android MineFragment */
.mine-page { min-height: 100%; background: var(--page-bg); }
.mine-header {
  min-height: 160px;
  background: linear-gradient(180deg, var(--header-grad-start), var(--header-grad-mid) 70%, var(--header-grad-end));
  padding: max(20px, calc(env(safe-area-inset-top) + 12px)) 16px 40px;
}
.mine-user { display: flex; align-items: center; gap: 14px; }
.mine-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  object-fit: cover; background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.45);
  flex-shrink: 0;
}
.mine-user-meta { min-width: 0; }
.mine-name { color: #fff; font-size: 16px; font-weight: 700; }
.mine-id { color: rgba(255,255,255,0.8); font-size: 12px; margin-top: 6px; }
.mine-body { padding: 0 12px 24px; margin-top: -28px; }
.mine-stat-card {
  display: flex; align-items: stretch;
  background: var(--card-bg); border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  overflow: hidden; margin-bottom: 12px;
}
.mine-stat-card .mine-stat-click {
  flex: 1; text-align: center; padding: 16px 8px; cursor: pointer;
}
.mine-stat-divider { width: 1px; background: rgba(0,0,0,0.08); margin: 12px 0; }
[data-theme="dark"] .mine-stat-divider { background: rgba(255,255,255,0.08); }
.mine-stat-val {
  font-size: 18px; font-weight: 700; color: var(--brand);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mine-stat-label { font-size: 12px; color: var(--text-gray); margin-top: 6px; }
.mine-quick {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: var(--card-bg); border-radius: 10px; padding: 8px;
  margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.mine-quick-item {
  border: none; background: transparent; color: var(--text);
  padding: 12px 4px; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
/* 三个快捷入口统一：同尺寸圆角底 + 同粗细线性图标，不再用 emoji */
.mine-quick-icon {
  width: 34px; height: 34px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--mine-quick-icon-bg, rgba(184, 74, 74, .10));
  color: var(--tab-selected);
}
.mine-quick-icon svg { width: 19px; height: 19px; }
.mine-quick-item { -webkit-tap-highlight-color: transparent; transition: transform .12s ease; }
.mine-quick-item:active { transform: scale(.94); }
@media (prefers-reduced-motion: reduce) {
  .mine-quick-item { transition: none; }
  .mine-quick-item:active { transform: none; }
}
.mine-menu { list-style: none; border-radius: 10px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.mine-menu li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 16px; border-bottom: 1px solid rgba(0,0,0,0.06);
  background: var(--card-bg); font-size: 15px;
}
.mine-menu li:last-child { border-bottom: none; }
.mine-menu-hint { color: var(--text-gray); font-size: 13px; }
.main-content.mine-mode { padding-bottom: 0; }

.placeholder-page {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 50vh; color: var(--text-gray); gap: 8px;
}

/* Player */
#page-player { background: var(--page-bg); z-index: 100; }
/* 只作手势进度反馈，不建立拦截播放控件的透明触摸层。 */
.identity-card { padding: 20px 16px 30px; text-align: center; }
.identity-qr {
  width: min(70vw, 290px); height: auto; padding: 10px;
  background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.identity-id { margin-top: 14px; font-size: 15px; font-weight: 600; letter-spacing: .5px; color: var(--text); }
.identity-save {
  margin-top: 16px; min-height: 42px; padding: 0 26px; border: 0; border-radius: 21px;
  background: var(--brand); color: #fff; font-size: 15px;
}
.identity-save:active { transform: scale(.97); }
.identity-hint {
  margin: 16px auto 0; max-width: 300px; text-align: left;
  font-size: 12.5px; line-height: 1.75; color: var(--text-gray);
}
.identity-warn {
  margin: 12px auto 0; max-width: 300px; text-align: left;
  font-size: 12.5px; line-height: 1.75; color: #c0392b;
}

#page-player::after,
#page-search::after {
  content: '‹'; position: absolute; z-index: 8;
  left: max(8px, env(safe-area-inset-left, 0px)); top: 50%;
  width: 40px; height: 48px; border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; line-height: 1; color: #fff;
  background: rgba(0,0,0,.55); pointer-events: none;
  opacity: 0; transform: translate(-20px, -50%);
  transition: opacity .15s ease, transform .15s ease;
}
#page-player.edge-back-tracking::after,
#page-search.edge-back-tracking::after {
  opacity: var(--edge-back-progress, 0);
  transform: translate(0, -50%);
}
#page-player.edge-back-ready::after,
#page-search.edge-back-ready::after { background: #b84a4a; }
@media (prefers-reduced-motion: reduce) {
  #page-player::after,
  #page-search::after { transition: none; }
}
#page-player .btn-back { color: #fff; }
.btn-back {
  border: none; background: transparent; color: var(--text);
  font-size: 28px; line-height: 1; padding: 0 8px;
}
.player-wrap { position: relative; flex-shrink: 0; background: #000; width: 100%; }
/* 视频内仅保留透明返回按钮；完整片名在下方详情展示。 */
#player-back.player-back-overlay {
  position: absolute; z-index: 3;
  top: max(8px, env(safe-area-inset-top, 0px));
  /* 样式接管失败时保留原生控件避让；自定义控制栏就绪后恢复左上角。 */
  left: calc(64px + env(safe-area-inset-left, 0px));
  width: 44px; height: 44px; padding: 8px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: #fff;
  cursor: pointer;
}
.player-back-overlay svg {
  width: 28px; height: 28px; fill: none; stroke: currentColor;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.65));
}
.player-back-overlay:focus-visible { outline: 2px solid #fff; outline-offset: -4px; border-radius: 8px; }
#video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 42vh;
  background: #000;
  display: block;
  object-fit: contain;
}
.player-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  background: var(--page-bg);
}
.player-info {
  padding: 12px 10px 16px;
  background: var(--page-bg);
  color: var(--text);
}
.player-section-title {
  font-size: 18px; font-weight: 600;
  margin: 16px 0 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.08);
}
[data-theme="dark"] .player-section-title { border-top-color: rgba(255,255,255,0.08); }
.player-linked-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.player-comments-head {
  display: flex; align-items: baseline; gap: 6px;
  margin: 8px 0 12px;
}
.player-comments-head h4 { font-size: 18px; font-weight: 600; }
.player-comments-head span { font-size: 14px; color: var(--text-gray); }
.comment-list { list-style: none; }
.comment-item {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
[data-theme="dark"] .comment-item { border-bottom-color: rgba(255,255,255,0.06); }
.comment-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-light); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
}
.comment-body { flex: 1; min-width: 0; }
.comment-meta {
  font-size: 13px; color: var(--text-gray); margin-bottom: 6px;
}
.comment-text { font-size: 15px; line-height: 1.5; word-break: break-word; }
.player-comment-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--card-bg);
  border-top: 1px solid rgba(0,0,0,0.08);
}
.player-comment-bar input {
  flex: 1; height: 38px; border-radius: 19px;
  border: 1px solid rgba(0,0,0,0.1);
  padding: 0 14px; font-size: 14px;
  background: var(--page-bg); color: var(--text);
}
.player-comment-bar button {
  border: none; background: var(--brand); color: #fff;
  padding: 0 16px; height: 38px; border-radius: 19px;
  font-size: 14px; flex-shrink: 0;
}
.player-stat-row {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin: 12px 0; font-size: 13px; color: var(--text-gray);
}
.player-stat-row span { display: inline-flex; align-items: center; gap: 4px; }

/* Search */
.search-header {
  display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  background: var(--card-bg);
}
.search-header input {
  flex: 1; height: 36px; border: 1px solid #ddd;
  border-radius: 18px; padding: 0 14px; font-size: 14px;
  background: var(--page-bg); color: var(--text);
}
#search-go {
  border: none; background: var(--brand); color: #fff;
  padding: 8px 14px; border-radius: 16px; font-size: 14px;
}
#page-search .film-grid { padding-bottom: 20px; }

/* A2HS */
.a2hs-tip {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
.a2hs-tip.hidden { display: none; }
.a2hs-card {
  background: var(--card-bg); border-radius: 12px;
  padding: 20px; width: 100%; max-width: 360px;
}
.a2hs-card ol { margin: 12px 0 16px 20px; font-size: 14px; line-height: 1.8; }
#a2hs-close {
  width: 100%; padding: 12px; border: none;
  background: var(--brand); color: #fff; border-radius: 8px;
  font-size: 15px;
}

.loading-center {
  text-align: center; padding: 40px; color: var(--text-gray);
}

.empty-tip { text-align: center; padding: 40px 20px; color: var(--text-gray); }

/* Sheet overlays */
.page-sheet { background: var(--page-bg); z-index: 110; }
.sheet-header {
  display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: var(--card-bg); border-bottom: 1px solid rgba(0,0,0,0.06);
}
.sheet-body { flex: 1; overflow-y: auto; padding-bottom: var(--safe-bottom); }

/* Free mode */
.free-mode-banner {
  background: #2bdf7e22; color: #1a9d5c; padding: 10px 14px;
  border-radius: 8px; margin-bottom: 10px; font-size: 13px;
}
.mine-menu li.disabled { opacity: 0.45; pointer-events: none; }

/* Pay */
.pay-page { padding: 16px; }
.pay-title { font-size: 20px; margin-bottom: 16px; color: var(--brand); }
.pay-subtitle { font-size: 15px; margin: 20px 0 10px; }
.pay-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-item {
  border: 1px solid var(--brand-light); border-radius: 8px;
  padding: 10px 6px; text-align: center; background: var(--card-bg);
  cursor: pointer;
}
.pay-item.selected { border-color: var(--brand); background: #fff3e8; }
.pay-item input { display: none; }
.pay-item-name { font-size: 12px; font-weight: 600; }
.pay-item-price { color: var(--brand); font-size: 16px; margin: 4px 0; }
.pay-item-comment { font-size: 10px; color: var(--text-gray); }
.pay-methods { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-method {
  padding: 10px 16px; border: 1px solid #ddd; border-radius: 20px;
  background: var(--card-bg); font-size: 14px;
}
.pay-method.selected { border-color: var(--brand); color: var(--brand); }
.pay-method input { display: none; }
.pay-submit {
  width: 100%; margin-top: 24px; padding: 14px; border: none;
  background: var(--brand); color: #fff; border-radius: 8px; font-size: 16px;
}
.pay-status { text-align: center; color: var(--text-gray); margin-top: 12px; font-size: 13px; }

/* History */
.history-tabs { display: flex; gap: 8px; padding: 12px; }
.history-tab {
  flex: 1; padding: 8px; border: none; border-radius: 16px;
  background: var(--card-bg); color: var(--text);
}
.history-tab.active { background: var(--brand); color: #fff; }
.history-list { padding: 0 12px; }
.history-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06); cursor: pointer;
}
.history-item img { width: 100px; height: 60px; object-fit: cover; border-radius: 6px; }
.history-cover-wrap { position: relative; flex: 0 0 100px; width: 100px; height: 60px; border-radius: 6px; overflow: hidden; }
.history-cover-wrap img { display: block; }
/* 单一低调左上角标，贴封面边框；不改封面比例、价格与底部信息。 */
.film-cover-wrap, .carousel-slide { overflow: hidden; }
.film-ribbon {
  position: absolute; z-index: 2; top: 0; left: 0;
  height: 15px; line-height: 15px; padding: 0 4px;
  border-radius: 0 0 4px 0; text-align: center;
  font-size: 9px; font-weight: 500; white-space: nowrap;
  pointer-events: none;
}
.film-ribbon--uncensored { background: #315a7d; color: #fff; }
.film-ribbon--censored { background: #675632; color: #fff; }
.film-ribbon--hd { background: #356349; color: #fff; }
.history-title { font-size: 14px; margin-bottom: 4px; }
.history-meta { font-size: 12px; color: var(--text-gray); }

/* Player actions */
.player-meta { color: var(--text-gray); font-size: 13px; margin: 8px 0 12px; }
.player-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.btn-primary, .btn-secondary {
  padding: 8px 16px; border-radius: 16px; border: none; font-size: 13px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: var(--card-bg); border: 1px solid #ddd; color: var(--text); }

/* TikTok tab — 内容区铺满，底部让给 fixed dock */
.main-content.tiktok-mode {
  padding-bottom: 0;
  background: #000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.bottom-nav.dock-dark { background: #000; border-top-color: #222; }
.bottom-nav.dock-dark .nav-item { color: #c8c8c8; }
.bottom-nav.dock-dark .nav-item.active { color: #fff; }

.main-content.tiktok-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
}
.tiktok-subtabs {
  flex-shrink: 0;
  display: flex; justify-content: center; gap: 24px;
  padding: max(8px, env(safe-area-inset-top)) 0 8px; background: #000;
}
.tiktok-sub {
  border: none; background: transparent; color: #888; font-size: 15px; padding: 8px;
}
.tiktok-sub.active { color: #fff; font-weight: 600; border-bottom: 2px solid #fff; }
.tiktok-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  touch-action: pan-y;
}
.tiktok-slide {
  height: var(--slide-h, 100%);
  min-height: var(--slide-h, 100%);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  background: #111;
  box-sizing: border-box;
  overflow: hidden;
}
.tiktok-poster {
  position: absolute; inset: 0;
  background: #111 center/contain no-repeat;
  z-index: 1;
  pointer-events: none;
}
.tiktok-media {
  position: absolute; inset: 0;
  z-index: 0;
}
.tiktok-video {
  width: 100%; height: 100%; object-fit: contain; background: transparent;
  display: block;
}
.tiktok-slide.has-video .tiktok-poster { opacity: 0; }
.tiktok-overlay {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: flex-end;
  z-index: 2;
}
.tiktok-pause-icon {
  position: absolute; left: 50%; top: 50%;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 28px;
  line-height: 64px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.tiktok-slide.is-paused .tiktok-pause-icon {
  opacity: 1;
  transform: scale(1);
}
.tiktok-side {
  position: absolute; right: 12px; bottom: 80px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #fff; pointer-events: auto;
}
.tiktok-action {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 20px;
}
.tiktok-action.liked { color: #ff4d6d; background: rgba(255,77,109,0.25); }
.tiktok-bottom { padding: 16px 16px 36px; color: #fff; pointer-events: none; }
.tiktok-user { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.tiktok-desc { font-size: 13px; opacity: 0.9; }
.tiktok-progress {
  position: absolute; left: 5px; right: 5px; bottom: 0;
  height: 32px; z-index: 3; touch-action: none;
}
.tiktok-seek {
  --seek-progress: 0%; --seek-buffered: 0%;
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 32px; margin: 0; padding: 0;
  background: transparent; border: 0; border-radius: 0;
  cursor: pointer; touch-action: none;
}
.tiktok-seek::-webkit-slider-runnable-track {
  height: 1.5px;
  background: linear-gradient(to right, #f85959 0%, #f85959 var(--seek-progress), transparent var(--seek-progress)),
    linear-gradient(to right, #ffffffc8 0%, #ffffffc8 var(--seek-buffered), #ffffff80 var(--seek-buffered));
}
.tiktok-seek::-moz-range-track {
  height: 1.5px;
  background: linear-gradient(to right, #f85959 0%, #f85959 var(--seek-progress), transparent var(--seek-progress)),
    linear-gradient(to right, #ffffffc8 0%, #ffffffc8 var(--seek-buffered), #ffffff80 var(--seek-buffered));
}
.tiktok-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 4px; height: 4px; margin-top: -1.25px;
  border: 0; border-radius: 50%; background: #f85959;
}
.tiktok-seek::-moz-range-thumb {
  width: 4px; height: 4px; border: 0; border-radius: 50%; background: #f85959;
}
.tiktok-progress.is-seeking .tiktok-seek::-webkit-slider-thumb { width: 10px; height: 10px; margin-top: -4.25px; }
.tiktok-progress.is-seeking .tiktok-seek::-moz-range-thumb { width: 10px; height: 10px; }
.tiktok-seek:disabled { opacity: 0.35; cursor: default; }
.tiktok-seek:focus-visible { outline: 1px solid #fff; outline-offset: -2px; }

/* Book tab — 顶栏固定，正文滚动，对齐 Android 3 列封面 */
.main-content.book-mode {
  padding-bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.book-shell {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
}
.book-header {
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--header-grad-start), var(--header-grad-mid) 55%, var(--header-grad-end));
  padding: max(8px, env(safe-area-inset-top)) 0 8px;
}
.book-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
.book-shortcuts {
  display: flex; gap: 10px; padding: 12px 10px 4px;
}
.book-shortcut {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: var(--card-bg); color: var(--text); font-size: 13px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 8px;
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
}
.book-card { cursor: pointer; text-align: left; min-width: 0; }
.book-card img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 6px; background: #444; display: block;
}
.book-card-title {
  font-size: 13px; margin-top: 6px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  white-space: normal;
}
.book-card-author {
  font-size: 11px; color: var(--text-gray); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Pull refresh */
.pull-refresh-ind {
  height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-gray); font-size: 13px;
  transition: height 0.15s ease;
}
.pull-refresh-ind.show { opacity: 1; }
.pull-refresh-ind.loading { color: var(--brand); }

/* Standalone PWA */
html.standalone body {
  overscroll-behavior-y: none;
}
html.standalone .a2hs-tip { display: none !important; }

/* Reader */
.reader-shell { display: flex; flex-direction: column; height: 100%; }
.reader-toolbar {
  display: flex; justify-content: space-around; padding: 10px;
  background: var(--card-bg); border-bottom: 1px solid rgba(0,0,0,0.06);
}
.reader-toolbar button {
  border: none; background: transparent; color: var(--brand); font-size: 14px;
}
.reader-chapter-title {
  padding: 12px 16px; font-weight: 600; background: var(--card-bg);
}
.reader-body {
  flex: 1; overflow-y: auto; padding: 16px; line-height: 1.8; font-size: 16px;
}
.reader-body p { margin-bottom: 12px; }
.reader-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 60vh;
  background: var(--card-bg); border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15); z-index: 120;
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
}
.reader-drawer.hidden { display: none; }
.reader-drawer-head { padding: 14px 16px; font-weight: 600; border-bottom: 1px solid rgba(0,0,0,0.06); }
.reader-chapters { overflow-y: auto; padding: 8px; }
.reader-ch {
  display: block; width: 100%; text-align: left; padding: 12px;
  border: none; background: transparent; border-bottom: 1px solid rgba(0,0,0,0.04);
  color: var(--text); font-size: 14px;
}
.reader-ch.on { color: var(--brand); font-weight: 600; }

/* Ads */
.adv-splash {
  position: fixed; inset: 0; z-index: 300;
  background: #000; display: flex; align-items: center; justify-content: center;
}
.adv-splash-img { width: 100%; height: 100%; object-fit: cover; }
.adv-splash-skip {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px;
  border: none; border-radius: 14px; padding: 6px 12px;
  background: rgba(0,0,0,0.45); color: #fff; font-size: 13px;
}
.adv-popup-mask {
  position: fixed; inset: 0; z-index: 280;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.adv-popup {
  position: relative; width: min(86vw, 360px);
  border-radius: 10px; overflow: hidden; background: #111;
}
.adv-popup img { width: 100%; display: block; }
.adv-popup-close {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.5); color: #fff; font-size: 20px; line-height: 1;
}

/* Feedback */
.feedback-page { padding: 12px 12px 80px; }
.feedback-list { display: flex; flex-direction: column; gap: 10px; }
.feedback-item {
  background: var(--card-bg); border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.feedback-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 12px; color: var(--text-gray);
}
.feedback-status { color: var(--brand); font-weight: 600; }
.feedback-status.pending { color: #e6a23c; }
.feedback-text { font-size: 14px; line-height: 1.5; }
.feedback-reply {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.06); font-size: 13px; color: var(--text);
}
.feedback-reply-label { color: var(--brand); font-size: 12px; margin-bottom: 4px; }
.feedback-add {
  position: sticky; bottom: 12px; width: 100%; margin-top: 16px;
  padding: 12px; border: none; border-radius: 22px;
  background: var(--brand); color: #fff; font-size: 15px;
}
.feedback-submit-mask {
  position: fixed; inset: 0; z-index: 260;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.feedback-submit-sheet {
  width: 100%; background: var(--card-bg);
  border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.feedback-submit-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.feedback-submit-sheet textarea {
  width: 100%; min-height: 120px; border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px; padding: 10px; font-size: 14px; resize: vertical;
  background: var(--page-bg); color: var(--text);
}
.feedback-submit-actions {
  display: flex; gap: 10px; margin-top: 12px;
}
.feedback-submit-actions button {
  flex: 1; padding: 12px; border-radius: 8px; border: none; font-size: 15px;
}
#feedback-cancel { background: var(--page-bg); color: var(--text); }
.feedback-submit-status { margin-top: 8px; font-size: 13px; color: #e74c3c; text-align: center; }

