:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #ff5a5f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 700; color: var(--text); text-decoration: none; }
.fav-btn {
  padding: 7px 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font-size: 13px; text-decoration: none;
}
.fav-btn:hover, .fav-btn.active { border-color: var(--accent); color: #fff; background: var(--accent); }
.source, .search input, .search button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.search { display: flex; gap: 6px; margin-left: auto; }
.search input { width: 200px; }
.search button { cursor: pointer; }
.search button:hover { border-color: var(--accent); }
.view { padding: 18px; max-width: 1280px; margin: 0 auto; }
.loading, .empty { padding: 40px; text-align: center; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.card a { color: inherit; text-decoration: none; display: block; }
.cover { position: relative; aspect-ratio: 3 / 4; background: var(--panel-2); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #555c6b; font-size: 12px; text-align: center; padding: 8px;
}
.card .title { padding: 8px 10px; font-size: 13px; line-height: 1.35; height: 42px; overflow: hidden; }
.card .meta { padding: 0 10px 10px; color: var(--muted); font-size: 12px; }
.pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 22px 0; }
.pager a, .pager span {
  padding: 7px 14px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 13px;
}
.pager .disabled { opacity: 0.4; }
.detail { display: flex; gap: 20px; flex-wrap: wrap; }
.detail .poster { width: 200px; flex: none; }
.detail .poster img { width: 100%; border-radius: 10px; display: block; }
.detail .info { flex: 1; min-width: 260px; }
.detail h1 { margin: 0 0 10px; font-size: 21px; }
.detail .desc { color: var(--muted); white-space: pre-wrap; margin-bottom: 14px; }
.episodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 16px; }
.episodes a {
  display: block; text-align: center; padding: 9px 6px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  text-decoration: none; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.episodes a:hover { border-color: var(--accent); }
.player-wrap { max-width: 900px; margin: 0 auto; }
.player-wrap video { width: 100%; background: #000; border-radius: 10px; display: block; }
/* 竖屏短剧：按真实比例收窄并居中，画面最大化又不会被上下裁切。
   --ratio 由 JS 按 videoWidth/videoHeight 填 */
.player-wrap video.portrait {
  width: min(100%, calc((100vh - 190px) * var(--ratio, 0.5625)));
  margin-left: auto; margin-right: auto;
}
@media (max-height: 560px) {
  .player-wrap video.portrait { height: calc(100vh - 150px); width: auto; }
}
.player-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.player-bar .btn {
  padding: 6px 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 13px;
}
.player-bar .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.player-bar .spacer { margin-left: auto; }
.player-bar label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.player-bar select {
  padding: 6px 10px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font-size: 13px; cursor: pointer;
}
.player-bar a.btn {
  padding: 6px 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 13px;
}
.player-title { font-size: 16px; margin-bottom: 10px; }
.notice {
  display: none; margin: 10px 0 0; padding: 10px 12px; border-radius: 8px;
  background: rgba(240, 160, 32, 0.14); border: 1px solid #f0a020;
  color: var(--text); font-size: 13px; line-height: 1.6;
}
.notice.next-up {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(58, 140, 255, 0.12); border-color: #3a8cff;
}
.notice.next-up b { color: var(--accent); font-size: 15px; }
.notice.next-up .btn { padding: 4px 10px; }
.player-bar .toggle { cursor: pointer; user-select: none; }
.player-bar .toggle input {
  width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0;
}
.link-btn {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font-size: 13px; padding: 0 2px; text-decoration: underline;
}
.btn {
  padding: 6px 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { border-color: #7a2b2f; color: #ff8b90; }
.btn.danger:hover { background: #7a2b2f; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }
.detail-actions { margin-top: 12px; }
/* 收藏夹 */
.lib-tabs {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.lib-tabs .spacer { margin-left: auto; }
.lib-tab {
  padding: 7px 14px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 13px;
}
.lib-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lib-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.lib-all { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.lib-card { position: relative; }
.lib-card .lib-link { position: relative; }
.lib-remove {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 24px; height: 24px; line-height: 1; border-radius: 999px; cursor: pointer;
  background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff; font-size: 15px; padding: 0;
}
.lib-remove:hover { background: var(--accent); }
.lib-check { position: absolute; top: 6px; left: 6px; z-index: 2; }
.lib-check input, .lib-all input { width: 16px; height: 16px; accent-color: var(--accent); }
.progress {
  height: 4px; margin: 0 10px 10px; border-radius: 999px;
  background: var(--panel-2); overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--accent); }
