:root {
  --bg: #0b0b0f;
  --bg-soft: #14141b;
  --card: #17171f;
  --line: #262632;
  --text: #f4f4f8;
  --muted: #9a9aab;
  --accent: #ff2d55;
  --accent-soft: rgba(255, 45, 85, .16);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-top: calc(52px + var(--safe-top)); padding-bottom: calc(8px + var(--safe-bottom)); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(52px + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, rgba(11,11,15,.98), rgba(11,11,15,.86));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.top-actions { display: flex; gap: 6px; }

.icon-btn {
  border: 0; background: transparent; color: var(--text);
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.08); }
.icon-btn.light { color: #fff; }

/* ---------- 分类 tab ---------- */
.tabs {
  position: fixed; top: calc(52px + var(--safe-top)); left: 0; right: 0; z-index: 39;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 6px 12px 10px;
  background: linear-gradient(180deg, rgba(11,11,15,.96), rgba(11,11,15,.82) 70%, rgba(11,11,15,0));
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; border: 0; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600;
}
.tab.active { color: #fff; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(255,45,85,.35); }

body { padding-top: calc(100px + var(--safe-top)); }

/* ---------- 列表 ---------- */
main { padding: 0 12px; }
.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1080px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.card { position: relative; cursor: pointer; }
.card .thumb {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: var(--radius); overflow: hidden; background: var(--bg-soft);
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.card:active .thumb img { transform: scale(1.04); }
.card .badge {
  position: absolute; left: 8px; top: 8px;
  padding: 3px 7px; border-radius: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  background: rgba(0,0,0,.62); backdrop-filter: blur(6px); color: #fff;
}
.card .badge.rank { background: linear-gradient(135deg, #ff2d55, #ff6b3d); }
.card .ep-tag {
  position: absolute; right: 8px; bottom: 8px;
  padding: 3px 7px; border-radius: 8px; font-size: 11px;
  background: rgba(0,0,0,.62); backdrop-filter: blur(6px); color: #fff;
}
.card .name {
  margin-top: 8px; font-size: 13.5px; line-height: 1.35; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .sub { margin-top: 3px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list-status { text-align: center; color: var(--muted); font-size: 13px; padding: 22px 0 30px; }
.sentinel { height: 1px; }

.skeleton { border-radius: var(--radius); background: linear-gradient(100deg, #16161e 30%, #1e1e28 50%, #16161e 70%); background-size: 200% 100%; animation: shine 1.2s infinite; aspect-ratio: 3/4; }
@keyframes shine { to { background-position: -200% 0; } }

/* ---------- 页面容器 ---------- */
.page { position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 40px; }

/* ---------- 搜索 ---------- */
.search-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: rgba(11,11,15,.96); backdrop-filter: blur(12px);
}
.search-bar input {
  flex: 1; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); padding: 0 12px; font-size: 14px; outline: none;
}
.search-bar input:focus { border-color: rgba(255,45,85,.55); }
.text-btn { border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 700; padding: 8px 10px; cursor: pointer; }
.text-btn.light { color: rgba(255,255,255,.86); font-weight: 600; font-size: 13px; }
.hot-words { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 12px; }
.hot-words .word { padding: 7px 12px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font-size: 13px; cursor: pointer; }
#searchPage .grid { padding: 0 12px; }

/* ---------- 详情 ---------- */
.detail { padding-bottom: 60px; }
.back-fab {
  position: fixed; left: 12px; top: calc(12px + var(--safe-top)); z-index: 70;
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px);
}
.detail-hero { position: relative; padding: calc(56px + var(--safe-top)) 16px 16px; overflow: hidden; }
.hero-bg {
  position: absolute; inset: -30px; background-size: cover; background-position: center;
  filter: blur(28px) saturate(1.3) brightness(.42); transform: scale(1.15);
}
.hero-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,11,15,.25), var(--bg) 88%); }
.hero-inner { position: relative; display: flex; gap: 14px; }
.hero-inner img { width: 108px; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.hero-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.hero-meta h1 { margin: 2px 0 0; font-size: 19px; line-height: 1.3; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; color: var(--muted); background: rgba(255,255,255,.06); padding: 4px 8px; border-radius: 7px; }
.chip.accent { color: #ffb3c1; background: var(--accent-soft); }
.hero-actions { display: flex; gap: 8px; margin-top: auto; }
.btn { border: 0; cursor: pointer; padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 700; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: rgba(255,255,255,.1); color: var(--text); }
.btn.ghost.on { background: rgba(255,45,85,.2); color: #ff9db0; }
.intro { margin: 4px 16px 0; color: var(--muted); font-size: 13px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.intro.open { -webkit-line-clamp: unset; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 20px 16px 10px; }
.section-head h2 { margin: 0; font-size: 15px; }
.muted { color: var(--muted); font-size: 12.5px; }
.ep-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 0 16px; }
@media (min-width: 640px) { .ep-grid { grid-template-columns: repeat(10, 1fr); } }
.ep {
  aspect-ratio: 1; border: 0; cursor: pointer; border-radius: 10px;
  background: var(--bg-soft); color: var(--text); font-size: 13.5px; font-weight: 600;
  display: grid; place-items: center; position: relative;
}
.ep.playing { background: var(--accent); color: #fff; }
.ep.watched::after { content: ''; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* ---------- 我的 ---------- */
.mine { padding: 8px 16px; }
.mine h2 { font-size: 15px; margin: 18px 0 10px; }
.mine .empty { color: var(--muted); font-size: 13px; padding: 14px 0; }

/* ---------- 播放器 ---------- */
.player { position: fixed; inset: 0; z-index: 90; background: #000; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.player-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(8px + var(--safe-top)) 10px 10px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,0));
  transition: opacity .25s;
}
.player-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#qualityBtn { font-size: 12.5px; font-weight: 700; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.14); color: #fff; width: auto; }
.player-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 12px;
  background: rgba(0,0,0,.62); color: #fff; font-size: 13px;
  backdrop-filter: blur(8px); z-index: 92; max-width: 80vw; text-align: left;
}
.player-hint[hidden] { display: none; }
.spin {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.big-play {
  pointer-events: auto; width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.45); color: #fff; display: grid; place-items: center;
  backdrop-filter: blur(6px); transition: opacity .2s, transform .2s;
}
.big-play.hide { opacity: 0; transform: scale(.86); pointer-events: none; }
.player-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px 14px calc(10px + var(--safe-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,.8), rgba(0,0,0,0));
  transition: opacity .25s;
}
.seek { padding: 12px 0 6px; cursor: pointer; }
.seek-track { position: relative; height: 4px; border-radius: 4px; background: rgba(255,255,255,.22); }
.seek-buffer { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255,255,255,.3); border-radius: 4px; }
.seek-played { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 4px; }
.seek-knob { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); box-shadow: 0 0 8px rgba(0,0,0,.6); }
.controls { display: flex; align-items: center; justify-content: space-between; }
.time { font-size: 12px; color: rgba(255,255,255,.8); font-variant-numeric: tabular-nums; }
.ctrl-right { display: flex; align-items: center; gap: 2px; }
.quality-menu {
  position: absolute; right: 12px; top: calc(52px + var(--safe-top)); z-index: 95;
  min-width: 132px; padding: 6px; border-radius: 12px;
  background: rgba(24,24,32,.96); border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 16px 40px rgba(0,0,0,.55); backdrop-filter: blur(14px);
}
.quality-menu button {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  border: 0; background: transparent; color: #fff; cursor: pointer;
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px;
}
.quality-menu button:hover { background: rgba(255,255,255,.07); }
.quality-menu button.on { color: var(--accent); font-weight: 700; }
.quality-menu .tag { font-size: 10.5px; color: var(--muted); }
.toast {
  position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: 13px;
  padding: 9px 14px; border-radius: 10px; max-width: 78vw; text-align: center;
}
.player.idle .player-top, .player.idle .player-bottom { opacity: 0; }
.player.idle { cursor: none; }

.loading-dot { display: inline-block; width: 6px; height: 6px; margin: 0 3px; border-radius: 50%; background: var(--muted); animation: bounce 1s infinite; }
.loading-dot:nth-child(2) { animation-delay: .15s; }
.loading-dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
