/* ========================= iOS 复刻 — 短剧播放器 ========================= */
:root {
  color-scheme: light;
  --ios-bg: #f2f2f7;
  --ios-card: #ffffff;
  --ios-separator: rgba(60,60,67,0.10);
  --ios-separator-strong: rgba(60,60,67,0.16);
  --ios-text: #000000;
  --ios-text-secondary: rgba(60,60,67,0.60);
  --ios-text-tertiary: rgba(60,60,67,0.30);
  --ios-pink: #f0465c;
  --ios-pink-bg: rgba(240,70,92,0.10);
  --ios-pink-text: #d63d52;
  --ios-green: #34c759;
  --ios-blue: #8e8e93;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --r: 10px;
  --r-lg: 12px;
}

/* ========================= RESET ========================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  margin: 0; min-height: 100%;
  background: var(--ios-bg); color: var(--ios-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}

button, input { font: inherit; color: inherit; border: none; background: none; outline: none; -webkit-appearance: none; appearance: none; }
button { cursor: pointer; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.empty { color: var(--ios-text-tertiary); font-size: 15px; text-align: center; padding: 60px 16px; }

/* ========================= SCREEN SWITCH ========================= */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; }
.discover-screen { min-height: 100vh; min-height: 100dvh; background: var(--ios-bg); }

/* ========================= SEARCH PAGE ========================= */
.search-screen { min-height: 100vh; min-height: 100dvh; background: var(--ios-bg); }

/* ---- Header ---- */
.hero-billboard {
  padding: calc(48px + var(--safe-top)) 20px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--ios-bg);
}

.search-head { text-align: center; }
.logo {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.01em; color: var(--ios-text);
}

/* search bar — iOS Mail/Spotlight style */
.search-bar { display: flex; gap: 10px; width: 100%; max-width: 480px; }
.search-input-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: rgba(118,118,128,0.12); border-radius: 10px; padding: 0 12px;
  transition: background 0.2s;
}
.search-input-box svg { flex-shrink: 0; color: var(--ios-text-tertiary); }
.search-input-box input { flex: 1; padding: 10px 0; font-size: 16px; background: transparent; color: var(--ios-text); }
.search-input-box input::placeholder { color: var(--ios-text-tertiary); }
.search-input-box:focus-within {
  background: rgba(118,118,128,0.20);
}

.search-submit {
  padding: 0 20px; border-radius: 10px;
  background: var(--ios-pink); color: #fff;
  font-size: 15px; font-weight: 600; flex-shrink: 0;
  transition: opacity 0.15s;
}
.search-submit:active { opacity: 0.7; }

.search-suggest-panel {
  display: none; width: 100%; max-width: 480px;
  background: var(--ios-card); border-radius: 10px; overflow: hidden;
}
.search-suggest-panel.show { display: block; }
.search-suggest-list { display: flex; flex-direction: column; }

.search-suggest-item {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; text-align: left; background: transparent;
  border-bottom: 0.5px solid var(--ios-separator);
}
.search-suggest-item:last-child { border-bottom: none; }
.search-suggest-item:active { background: rgba(60,60,67,0.06); }

.search-suggest-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--ios-text-tertiary); }
.search-suggest-cover {
  width: 44px; height: 58px; object-fit: cover; border-radius: 6px;
  background: var(--ios-bg); flex-shrink: 0;
}
.search-suggest-content { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.search-suggest-title {
  font-size: 17px; line-height: 1.3; color: var(--ios-text); font-weight: 400;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all;
}
.search-suggest-title mark { background: transparent; color: var(--ios-pink-text); font-weight: 600; }
.search-suggest-meta { font-size: 13px; color: var(--ios-text-secondary); display: flex; gap: 6px; flex-wrap: wrap; }

.hint { font-size: 15px; color: var(--ios-text-tertiary); text-align: center; padding: 40px 0; }

/* ---- Browse Rows ---- */
.browse-rows {
  padding: 8px 20px calc(36px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 18px;
  max-width: 900px; margin: 0 auto; width: 100%;
}

/* ---- Tabs (iOS segmented control style) ---- */
.tabs {
  display: flex; gap: 0; overflow-x: auto; scrollbar-width: none;
  background: rgba(118,118,128,0.12); border-radius: 8px; padding: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
#categoryTabs { display: none; }

.tab {
  padding: 7px 14px; border-radius: 6px;
  background: transparent; border: none;
  font-size: 13px; font-weight: 500; color: var(--ios-text);
  white-space: nowrap; flex-shrink: 0; flex: 1; text-align: center;
  min-width: 0;
}
.tab.active {
  background: var(--ios-card); color: var(--ios-text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

/* discover panel shortcuts */
.discover-panel { margin-top: 0; display: flex; flex-direction: column; gap: 12px; }

.home-rank-shortcuts {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
.home-rank-shortcuts::-webkit-scrollbar { display: none; }

.home-rank-chip {
  min-height: 33px; padding: 0 16px; border-radius: 8px; white-space: nowrap; flex-shrink: 0;
  background: var(--ios-card);
  display: inline-flex; align-items: center; justify-content: center;
}
.home-rank-chip:active { opacity: 0.7; }
.home-rank-chip.active {
  background: var(--ios-pink);
}
.home-rank-chip-label {
  font-size: 13px; font-weight: 500; color: var(--ios-text);
}
.home-rank-chip.active .home-rank-chip-label { color: #fff; }

/* ---- Discover Page ---- */
.discover-page {
  padding: calc(8px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 16px;
  max-width: 600px; margin: 0 auto; width: 100%;
}
.discover-page-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 2px; }
.discover-back-btn { flex-shrink: 0; }
.discover-page-title-wrap { display: flex; flex-direction: column; gap: 2px; }
#discoverTitle { font-size: 22px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; color: var(--ios-text); }
#discoverStatus { font-size: 13px; color: var(--ios-text-secondary); }

.discover-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.discover-card {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  border-radius: var(--r-lg); text-align: left;
  background: var(--ios-card);
}
.discover-card:active { opacity: 0.7; }

.discover-icon {
  width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.discover-card.rank .discover-icon { background: var(--ios-pink); }
.discover-card.fresh .discover-icon { background: var(--ios-green); }
.discover-card.actor .discover-icon { background: var(--ios-blue); }
.discover-card.cate .discover-icon { background: var(--ios-blue); }

.discover-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.discover-copy strong { font-size: 15px; font-weight: 600; color: var(--ios-text); }
.discover-copy span { font-size: 12px; color: var(--ios-text-secondary); line-height: 1.35; }

.discover-content {
  background: var(--ios-card); border-radius: var(--r-lg); padding: 16px;
}
.discover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.discover-head h3 { font-size: 17px; font-weight: 600; }

.discover-subtabs {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 0 6px;
}
.discover-subtabs::-webkit-scrollbar { display: none; }

.discover-subtab {
  flex-shrink: 0; padding: 7px 16px; border-radius: 8px;
  background: var(--ios-card); border: none;
  color: var(--ios-text); font-size: 13px; font-weight: 500;
}
.discover-subtab:active { opacity: 0.7; }
.discover-subtab.active {
  background: var(--ios-pink); color: #fff;
}
.discover-results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.discover-results-rank { display: block; }
.discover-results-rank > .rank-section-root { width: 100%; }
.discover-results.empty {
  display: flex; align-items: center; justify-content: center; min-height: 120px;
}

.discover-load-more {
  margin: 14px 0 4px; padding: 14px; border-radius: var(--r);
  text-align: center; font-size: 15px; font-weight: 500;
  color: var(--ios-text-secondary); background: var(--ios-card);
}
.discover-load-more[data-discover-load-more="1"] { color: var(--ios-pink-text); }
.discover-load-more.loading { opacity: 0.6; }

.discover-mini { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.discover-mini-cover {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; background: var(--ios-bg);
}
.discover-mini-title {
  font-size: 13px; font-weight: 500; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.discover-mini-sub { font-size: 12px; color: var(--ios-text-secondary); }
.discover-clickable { cursor: pointer; }

/* ---- Cards ---- */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.card-grid.empty {
  display: flex; align-items: center; justify-content: center; min-height: 200px; grid-template-columns: none;
}

.card {
  background: var(--ios-card); border-radius: var(--r-lg); overflow: hidden;
  text-align: left; display: block; width: 100%;
}
.card:active { opacity: 0.7; }

.card-visual { position: relative; overflow: hidden; aspect-ratio: 2 / 3; }
.card-cover {
  width: 100%; height: 100%; object-fit: cover; display: block; background: var(--ios-bg);
}

.card-playcnt {
  position: absolute; right: 8px; bottom: 8px; padding: 3px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 500; color: #fff;
  background: rgba(0,0,0,0.45);
}

.card-corner {
  position: absolute; left: 8px; top: 8px; padding: 3px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--ios-pink);
}

.card-body { padding: 12px 12px 14px; }
.card-title {
  font-size: 15px; font-weight: 500; line-height: 1.35; color: var(--ios-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  margin-top: 5px; font-size: 13px; color: var(--ios-text-secondary);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.card-tag {
  padding: 0; border-radius: 0; background: transparent; color: var(--ios-green); font-size: 12px; font-weight: 500;
}

/* ========================= PLAYER ========================= */
.player-screen { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; }
.player-stage {
  position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; background: #000;
}

.video-layer, .layer-video { position: absolute; inset: 0; width: 100%; height: 100%; }
.layer-video {
  object-fit: contain; background: #000;
  transition: opacity 180ms ease; will-change: opacity;
}
.vid-prev { opacity: 0; z-index: 1; pointer-events: none; }
.vid-curr { opacity: 1; z-index: 2; }
.vid-next { opacity: 0; z-index: 1; pointer-events: none; }

.loading-toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 2;
  padding: 14px 28px; border-radius: 20px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(20px);
  color: rgba(255,255,255,0.85); font-size: 14px; font-weight: 500;
  pointer-events: none; opacity: 0; transition: opacity 0.3s;
}
.loading-toast.show { opacity: 1; }
.touch-skin { position: absolute; inset: 0; z-index: 3; }

.center-play-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.5);
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255,255,255,0.2);
  z-index: 7; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
}
.center-play-btn.manual-play {
  pointer-events: auto; cursor: pointer;
  background: rgba(0,0,0,0.58);
}
.center-play-btn.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.center-play-btn.flash {
  opacity: 0; transform: translate(-50%, -50%) scale(1.12);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.center-play-btn.playing .center-play-icon { display: none; }
.center-play-btn.playing .center-pause-icon { display: none; }
.center-play-btn:not(.playing) .center-play-icon { display: block; }
.center-play-btn:not(.playing) .center-pause-icon { display: none; }
.center-play-btn.paused-shown .center-pause-icon { display: block; }
.center-play-btn.paused-shown .center-play-icon { display: none; }
.center-play-icon, .center-pause-icon {
  width: 30px; height: 30px; color: #fff; filter: drop-shadow(0 1px 4px rgba(0,0,0,0.4));
}

.grad { position: absolute; left: 0; right: 0; z-index: 4; pointer-events: none; }
.grad-top {
  top: 0; height: 140px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.3) 50%, transparent 100%);
}
.grad-bot {
  bottom: 0; height: 280px;
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.4) 40%, transparent 100%);
}

.overlay { position: absolute; z-index: 5; }
.top-row, .bot-row, .grad { transition: opacity 220ms ease, transform 220ms ease; }

.player-screen.chrome-hidden .top-row { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.player-screen.chrome-hidden .bot-row { opacity: 0; transform: translateY(10px); pointer-events: none; }
.player-screen.chrome-hidden .grad { opacity: 0; }

/* ===== TOP BAR ===== */
.top-row {
  top: calc(16px + var(--safe-top)); left: 20px; right: 20px;
  display: flex; align-items: flex-start; gap: 12px; z-index: 6;
}
.back-btn {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.back-btn:active { background: rgba(255,255,255,0.12); }
.top-center {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 4px;
}
.drama-name {
  font-size: 18px; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.ep-tag {
  font-size: 13px; color: rgba(255,255,255,0.65); text-shadow: 0 1px 3px rgba(0,0,0,0.6); flex-shrink: 0;
}
.top-right-btns { display: flex; gap: 8px; flex-shrink: 0; }
#moreButton { display: none; }

.pill-btn {
  min-width: 44px; height: 34px; border-radius: 17px;
  background: rgba(255,255,255,0.12); backdrop-filter: blur(20px);
  font-size: 13px; font-weight: 500; color: #fff;
  display: flex; align-items: center; justify-content: center; padding: 0 14px;
  border: 0.5px solid rgba(255,255,255,0.15);
}
.pill-btn:active { background: rgba(255,255,255,0.22); }
.icon-pill { gap: 4px; }
.fs-label { font-size: 12px; }
.fs-exit-icon { display: none; }
.player-screen.is-fullscreen .fs-enter-icon { display: none; }
.player-screen.is-fullscreen .fs-exit-icon { display: block; }

/* ===== BOTTOM BAR ===== */
.bot-row {
  left: 20px; right: 20px; bottom: calc(20px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px; z-index: 6;
}
.bot-ep-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.bot-ep-title {
  font-size: 16px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.bot-ep-btn {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  padding: 10px 18px; border-radius: 18px;
  background: rgba(255,255,255,0.14); backdrop-filter: blur(20px);
  color: #fff; font-size: 13px; font-weight: 500;
  border: 0.5px solid rgba(255,255,255,0.15);
}
.bot-ep-btn:active { background: rgba(255,255,255,0.26); }

.bot-pr-row { display: flex; flex-direction: column; gap: 8px; }
.pr-time {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  font-size: 12px; color: rgba(255,255,255,0.65); font-variant-numeric: tabular-nums;
}
.pr-sep { color: rgba(255,255,255,0.3); }

.pr-track {
  position: relative; height: 4px; width: 100%;
  background: rgba(255,255,255,0.12); border-radius: 2px; overflow: visible;
}
.pr-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--ios-pink); border-radius: 2px;
  width: 0%; pointer-events: none; z-index: 1;
}
.pr-thumb {
  display: none;
  position: absolute; top: 50%; transform: translate(-50%, -50%); left: 0%;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,0.2);
  z-index: 2; pointer-events: none; transition: left 0.08s linear;
}
.pr-thumb.active { display: block; }
.pr-input {
  position: absolute; top: -14px; left: 0; width: 100%; height: 34px;
  opacity: 0; cursor: pointer; z-index: 3; margin: 0; touch-action: none;
}

.speed-popup { display: none; gap: 8px; justify-content: flex-start; padding: 6px 0; }
.speed-popup.show { display: flex; }
.quality-popup {
  display: none; gap: 8px; justify-content: flex-start; padding: 6px 0; flex-wrap: wrap;
}
.quality-popup.show { display: flex; }

.sp-opt, .ql-opt {
  padding: 10px 18px; border-radius: 18px;
  background: rgba(255,255,255,0.10); border: 0.5px solid rgba(255,255,255,0.12);
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.70);
  backdrop-filter: blur(16px);
}
.sp-opt.active, .ql-opt.active {
  background: #fff; color: #000; border-color: transparent; font-weight: 600;
}

.meta-popup {
  display: none; padding: 12px 16px; border-radius: 10px;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(20px);
  font-size: 13px; line-height: 1.7; color: rgba(255,255,255,0.75);
}
.meta-popup.show { display: block; }

/* ===== DRAWER (iOS action sheet style) ===== */
.drawer-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.20); opacity: 0; pointer-events: none;
  transition: opacity 300ms ease; z-index: 8;
}
.drawer-bg.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; bottom: 0; left: 0; right: 0; max-height: 55vh;
  background: var(--ios-card);
  border-radius: 12px 12px 0 0;
  z-index: 9;
  transform: translateY(100%); transition: transform 350ms cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column; padding-bottom: var(--safe-bottom);
}
.drawer.open { transform: translateY(0); }

.drawer-knob {
  width: 36px; height: 5px; border-radius: 3px;
  background: rgba(60,60,67,0.25); margin: 12px auto 0; flex-shrink: 0;
}
.drawer-title-row {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; flex-shrink: 0;
}
.drawer-title-row h3 { font-size: 17px; font-weight: 600; color: var(--ios-text); }
.drawer-x {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--ios-text-secondary);
}
.drawer-x:active { background: rgba(60,60,67,0.06); }

.drawer-grid {
  flex: 1; overflow-y: auto; padding: 4px 20px 20px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-content: start;
}
.drawer-grid.empty { display: flex; align-items: center; justify-content: center; min-height: 120px; }

.chip {
  padding: 14px 6px; border-radius: 10px;
  background: rgba(118,118,128,0.10); font-size: 13px; font-weight: 500; text-align: center; color: var(--ios-text);
}
.chip:active { opacity: 0.7; }
.chip.active {
  background: var(--ios-pink); color: #fff;
}
.chip-no { font-size: 12px; font-weight: 600; }
.chip-name {
  display: block; margin-top: 3px; font-size: 12px; color: var(--ios-text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip.active .chip-name { color: rgba(255,255,255,0.7); }

.player-screen.is-fullscreen .player-stage {
  max-width: none; width: 100vw; height: 100vh; height: 100dvh;
  aspect-ratio: auto; border-radius: 0; top: 0; transform: none;
}
