/* ============ 影库 · 样式 ============ */
:root {
  --bg: #0a0b0f;
  --bg-2: #101219;
  --bg-3: #171a24;
  --bg-4: #1f2431;
  --line: #262b39;
  --fg: #eef1f7;
  --fg-2: #9aa3b8;
  --fg-3: #626b80;
  --gold: #f5c45c;
  --gold-dim: #c89430;
  --danger: #ef6b6b;
  --ok: #6fce8e;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tab-h: 56px;
  --top-h: 52px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text", "PingFang SC",
               "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
  -webkit-user-select: none;
  user-select: none;
}

input, textarea { -webkit-user-select: text; user-select: text; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; }

/* ---------- 启动屏 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: radial-gradient(120% 80% at 50% 0%, #161a26 0%, #0a0b0f 70%);
  transition: opacity .35s ease, visibility .35s;
}
.boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-logo { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .95 } 50% { transform: scale(1.06); opacity: 1 } }
.boot-text { font-size: 22px; font-weight: 700; letter-spacing: .22em; color: var(--gold); }
.boot-sub { font-size: 12.5px; color: var(--fg-3); letter-spacing: .04em; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 6px;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) max(14px, var(--safe-l)) 0 max(14px, var(--safe-l));
  background: rgba(10,11,15,.82);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(38,43,57,.7);
}
.tb-title {
  flex: 1; font-size: 17px; font-weight: 650; letter-spacing: .01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-back, .tb-act {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; color: var(--fg); margin-left: -6px;
  transition: background .15s;
}
.tb-act { margin-left: 0; margin-right: -6px; color: var(--fg-2); }
.tb-back:active, .tb-act:active { background: var(--bg-4); }
.tb-back[hidden] { display: none; }

/* ---------- 主视图 ---------- */
.view {
  padding: 0 max(0px, var(--safe-l)) 0 max(0px, var(--safe-l));
  min-height: 60dvh;
}
.pad { padding: 14px 14px 24px; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: flex;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(13,15,21,.9);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(38,43,57,.8);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--fg-3); font-size: 10.5px; letter-spacing: .02em;
  transition: color .15s;
}
.tab.active { color: var(--gold); }
.tab:active { opacity: .7; }
body.no-tab .tabbar { transform: translateY(120%); transition: transform .25s; }

/* ---------- 通用块 ---------- */
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 14px 10px;
}
.sec-title { font-size: 16.5px; font-weight: 680; letter-spacing: .01em; }
.sec-title small { font-weight: 400; color: var(--fg-3); font-size: 12px; margin-left: 8px; letter-spacing: 0; }
.sec-more { font-size: 12.5px; color: var(--gold-dim); }

/* ---------- 海报网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 12px;
}
@media (min-width: 430px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(5, 1fr); gap: 14px; } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(7, 1fr); } }

.card { position: relative; }
.card-poster {
  position: relative; width: 100%; aspect-ratio: 2/3;
  border-radius: var(--r-s); overflow: hidden; background: var(--bg-3);
}
.card-poster img { width: 100%; height: 100%; object-fit: cover; }
.card-poster .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--fg-3); font-size: 11px; text-align: center; padding: 6px;
  background: linear-gradient(160deg, #1a1e29, #12151d);
}
.card-rem {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 5px 4px; font-size: 10.5px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-name {
  margin-top: 5px; font-size: 12.5px; line-height: 1.3; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin-top: 2px; font-size: 10.5px; color: var(--fg-3); display: flex; gap: 5px; }
.src-tag {
  display: inline-block; padding: 0 4px; border-radius: 4px; font-size: 9.5px;
  line-height: 14px; background: rgba(245,196,92,.14); color: var(--gold);
}
.card:active .card-poster { transform: scale(.97); }
.card-poster { transition: transform .12s; }

/* ---------- 横向轨道 ---------- */
.rail {
  display: flex; gap: 10px; overflow-x: auto; padding: 0 12px 4px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .card { flex: 0 0 31%; scroll-snap-align: start; }
@media (min-width: 700px) { .rail .card { flex: 0 0 15%; } }

/* ---------- 搜索 ---------- */
.searchbox {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 14px; padding: 0 12px;
  height: 42px; background: var(--bg-3); border-radius: var(--r-m);
  border: 1px solid var(--line);
}
.searchbox:focus-within { border-color: var(--gold-dim); }
.searchbox input {
  flex: 1; background: none; border: 0; outline: none; color: var(--fg);
  font-size: 15px; min-width: 0;
}
.searchbox input::placeholder { color: var(--fg-3); }
.sb-clear { color: var(--fg-3); font-size: 13px; padding: 4px 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 4px 14px 12px; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px;
  background: var(--bg-3); color: var(--fg-2); border: 1px solid var(--line);
}
.chip.on { background: rgba(245,196,92,.14); color: var(--gold); border-color: rgba(245,196,92,.4); }
.chip:active { opacity: .7; }

/* 搜索状态条 */
.src-state {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; font-size: 11.5px; color: var(--fg-3);
  border-bottom: 1px solid rgba(38,43,57,.5);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-3); flex: 0 0 auto; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--danger); }
.dot.wait { background: var(--gold); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25 } }

/* ---------- 详情 ---------- */
.hero { position: relative; padding: 0; }
.hero-bg {
  position: absolute; inset: 0; height: 260px; overflow: hidden;
}
.hero-bg img { width: 100%; height: 100%; object-fit: cover; filter: blur(26px) saturate(1.3); opacity: .38; transform: scale(1.25); }
.hero-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,11,15,.25) 0%, rgba(10,11,15,.75) 55%, var(--bg) 100%);
}
.hero-body {
  position: relative; display: flex; gap: 14px; padding: 18px 14px 0;
}
.hero-poster {
  flex: 0 0 104px; width: 104px; aspect-ratio: 2/3; border-radius: var(--r-m);
  overflow: hidden; background: var(--bg-3); box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.hero-poster img { width: 100%; height: 100%; object-fit: cover; }
.hero-info { flex: 1; min-width: 0; padding-top: 4px; }
.hero-name { font-size: 20px; font-weight: 700; line-height: 1.25; }
.hero-sub { margin-top: 5px; font-size: 12px; color: var(--fg-2); line-height: 1.5; }
.hero-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 2px 7px; border-radius: 5px; font-size: 10.5px;
  background: var(--bg-4); color: var(--fg-2);
}
.tag.gold { background: rgba(245,196,92,.14); color: var(--gold); }

.hero-acts { display: flex; gap: 10px; padding: 16px 14px 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 44px; padding: 0 18px; border-radius: var(--r-m);
  font-size: 15px; font-weight: 620; transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gold); color: #17130a; flex: 1; }
.btn-ghost { background: var(--bg-3); color: var(--fg); border: 1px solid var(--line); }
.btn-ghost.on { color: var(--gold); border-color: rgba(245,196,92,.45); background: rgba(245,196,92,.1); }
.btn-icon { width: 44px; padding: 0; }

.synopsis { padding: 12px 14px 0; font-size: 13px; line-height: 1.75; color: var(--fg-2); white-space: pre-wrap; }
.synopsis.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.syn-more { padding: 6px 14px 0; font-size: 12.5px; color: var(--gold-dim); }

/* 线路 + 选集 */
.line-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 6px; scrollbar-width: none; }
.line-tabs::-webkit-scrollbar { display: none; }
.line-tab {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 9px; font-size: 12.5px;
  background: var(--bg-3); color: var(--fg-2); border: 1px solid var(--line); white-space: nowrap;
}
.line-tab.on { background: rgba(245,196,92,.15); color: var(--gold); border-color: rgba(245,196,92,.45); }
.line-tab small { opacity: .65; margin-left: 4px; font-size: 10.5px; }

.eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; padding: 8px 14px 28px; }
.ep {
  height: 38px; border-radius: 9px; background: var(--bg-3); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--fg-2); display: grid; place-items: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px;
}
.ep.on { background: rgba(245,196,92,.16); color: var(--gold); border-color: rgba(245,196,92,.5); }
.ep:active { opacity: .65; }

/* ---------- 播放页 ---------- */
body.playing { background: #000; padding-bottom: 0; overflow: hidden; }
body.playing .topbar, body.playing .tabbar { display: none; }

.player-wrap {
  position: fixed; inset: 0; background: #000;
  display: flex; flex-direction: column;
}
.player-stage {
  position: relative; flex: 1; background: #000; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.player-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 10px;
  background: linear-gradient(rgba(0,0,0,.75), transparent);
  transition: opacity .22s;
}
.player-top .pt-title { flex: 1; font-size: 13.5px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: rgba(255,255,255,.1); }
.pt-btn:active { background: rgba(255,255,255,.22); }
.player-wrap.hide-ui .player-top, .player-wrap.hide-ui .player-bottom { opacity: 0; pointer-events: none; }

.player-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 20px 14px calc(var(--safe-b) + 12px);
  background: linear-gradient(transparent, rgba(0,0,0,.85) 40%);
  transition: opacity .22s;
}
.seek-row { display: flex; align-items: center; gap: 10px; }
.time { font-size: 11px; color: #cfd4e0; font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; }
.seek {
  flex: 1; -webkit-appearance: none; appearance: none; height: 22px; background: none;
}
.seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.24); }
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold); margin-top: -5px; box-shadow: 0 0 0 4px rgba(245,196,92,.18);
}
.pb-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.pb-left, .pb-right { display: flex; align-items: center; gap: 6px; }
.pb-btn { padding: 7px 11px; border-radius: 9px; font-size: 12px; color: #e8ebf3; background: rgba(255,255,255,.1); }
.pb-btn:active { background: rgba(255,255,255,.24); }
.pb-btn.gold { color: var(--gold); background: rgba(245,196,92,.18); }

.big-play {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 4;
}
.big-play button {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,.35);
}
.big-play button svg { margin-left: 3px; }

.spinner {
  position: absolute; z-index: 3; width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.18); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.play-err {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center;
  background: rgba(0,0,0,.86);
}
.play-err h4 { margin: 0; font-size: 15px; color: #fff; }
.play-err p { margin: 0; font-size: 12.5px; color: #9aa3b8; line-height: 1.7; max-width: 300px; }

/* 选集抽屉 */
.ep-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 62dvh; background: #12151d;
  border-radius: var(--r-l) var(--r-l) 0 0;
  transform: translateY(101%); transition: transform .28s cubic-bezier(.3,.9,.3,1);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.ep-drawer.open { transform: translateY(0); }
.ep-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.ep-drawer-head h4 { margin: 0; font-size: 15px; }
.ep-drawer-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }

/* ---------- 列表行 ---------- */
.rows { padding: 0 0 20px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid rgba(38,43,57,.55);
}
.row:active { background: var(--bg-2); }
.row-pic { flex: 0 0 52px; width: 52px; aspect-ratio: 2/3; border-radius: 8px; overflow: hidden; background: var(--bg-3); }
.row-pic img { width: 100%; height: 100%; object-fit: cover; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { margin-top: 3px; font-size: 11.5px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-act { flex: 0 0 auto; color: var(--fg-3); font-size: 12px; }
.row-switch {
  width: 46px; height: 27px; border-radius: 999px; background: var(--bg-4);
  position: relative; transition: background .2s;
}
.row-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #7a8296; transition: transform .2s, background .2s;
}
.row-switch.on { background: rgba(245,196,92,.3); }
.row-switch.on::after { transform: translateX(19px); background: var(--gold); }

/* ---------- 设置页 ---------- */
.me-hero { padding: 22px 16px 8px; }
.me-hero h2 { margin: 0; font-size: 22px; font-weight: 700; }
.me-hero p { margin: 6px 0 0; font-size: 12.5px; color: var(--fg-3); line-height: 1.6; }
.group { margin: 16px 14px 0; }
.group-label { padding: 0 4px 8px; font-size: 12px; color: var(--fg-3); letter-spacing: .04em; }
.group-body { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.grow { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid rgba(38,43,57,.55); }
.grow:last-child { border-bottom: 0; }
.grow-label { flex: 1; font-size: 14px; }
.grow-value { font-size: 12.5px; color: var(--fg-3); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow-input {
  flex: 1; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  height: 34px; padding: 0 10px; color: var(--fg); font-size: 13px; outline: none; min-width: 0;
}
.grow-input:focus { border-color: var(--gold-dim); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 22px);
  transform: translateX(-50%); z-index: 800;
  max-width: 82vw; padding: 10px 16px; border-radius: 11px;
  background: rgba(30,34,46,.96); color: var(--fg); font-size: 13px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  animation: toastIn .22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px) } }

.sheet {
  position: fixed; inset: 0; z-index: 750; display: flex; align-items: flex-end;
  background: rgba(0,0,0,.55);
  animation: fadeIn .18s;
}
/* 关键：hidden 属性的 UA 样式是 display:none，会被上面的 display:flex 覆盖。
   不写这条，整个遮罩会永远盖在页面上，导致「能滑动但点不动」。 */
.sheet[hidden] { display: none; }
.big-play[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0 } }
.sheet-inner {
  width: 100%; max-height: 76dvh; overflow-y: auto;
  background: var(--bg-2); border-radius: var(--r-l) var(--r-l) 0 0;
  padding: 8px 0 calc(var(--safe-b) + 10px);
  animation: slideUp .24s cubic-bezier(.3,.9,.3,1);
}
@keyframes slideUp { from { transform: translateY(30%) } }

/* ---------- 空态 ---------- */
.empty { padding: 60px 30px; text-align: center; }
.empty-ico { font-size: 34px; opacity: .35; margin-bottom: 12px; }
.empty-title { font-size: 14.5px; color: var(--fg-2); margin-bottom: 6px; }
.empty-desc { font-size: 12.5px; color: var(--fg-3); line-height: 1.7; }
.empty .btn { margin-top: 16px; height: 38px; font-size: 13.5px; }

/* ---------- 骨架屏 ---------- */
.sk { background: linear-gradient(90deg, #14171f 25%, #1c2029 50%, #14171f 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0 } }
.sk-card { aspect-ratio: 2/3; border-radius: var(--r-s); }

/* ---------- 横屏/大屏 ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .hero-bg { height: 200px; }
}
