/* 搜影 - 深色紧凑主题 */
:root {
  color-scheme: dark;
  --bg: #101014;
  --bg2: #17171d;
  --card: #1c1c24;
  --card2: #232330;
  --line: #2c2c38;
  --text: #e8e8ee;
  --muted: #9a9aa8;
  --brand: #0fdc78;
  --brand-dim: #0a9c56;
  --brand-bg: rgba(15, 220, 120, .13);
  --blue: #5aa4ff;
  --blue-bg: rgba(90, 164, 255, .15);
  --orange: #ffab40;
  --orange-bg: rgba(255, 171, 64, .15);
  --danger: #ff5c5c;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(16, 16, 20, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 16px; flex: 0 0 auto; }
.searchbox { display: flex; flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.searchbox:focus-within { border-color: var(--brand-dim); }
.searchbox input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); padding: 7px 10px; }
.searchbox input::placeholder { color: var(--muted); }
.searchbox input::-webkit-search-cancel-button { -webkit-appearance: none; }
.btn-search { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 38px; background: var(--brand); color: #04240f; }
.btn-search:active { filter: brightness(.9); }
.icon-btn { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius); color: var(--muted); }
.icon-btn:hover { background: var(--card); color: var(--text); }

/* ---------- 布局 ---------- */
#main { max-width: 1080px; margin: 0 auto; padding: 12px 12px 48px; }
.view { animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 0 8px; }
.sec-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
#main > .view > .sec-head:first-child, #continue-wrap .sec-head:first-child { margin-top: 2px; }
.link-btn { color: var(--muted); font-size: 12px; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { color: var(--danger); background: var(--card); }
.empty-tip { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 13px; border: 1px dashed var(--line); border-radius: var(--radius-lg); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* ---------- 状态条 ---------- */
.list-status { color: var(--muted); font-size: 12.5px; padding: 6px 2px; min-height: 18px; }
.loading-bar { position: fixed; top: 0; left: 0; height: 2px; width: 40%; background: var(--brand); z-index: 99; animation: slide 1s linear infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

/* ---------- 海报卡片网格 ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px 8px; }
.vcard { position: relative; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.vcard .pic { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--card2); }
.vcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard .pic-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; font-weight: 700; background: linear-gradient(145deg, #232336, #1a1a28); }
.vcard .remarks { position: absolute; right: 4px; bottom: 4px; background: rgba(0, 0, 0, .72); color: var(--brand); font-size: 10.5px; line-height: 1; padding: 3px 5px; border-radius: 5px; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard .name { font-size: 12.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vcard .meta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard:active .pic { outline: 2px solid var(--brand); }

/* ---------- 继续观看 ---------- */
.continue-list { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.continue-list::-webkit-scrollbar { height: 6px; }
.continue-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.ccard { flex: 0 0 118px; display: flex; flex-direction: column; gap: 4px; }
.ccard .pic { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--card2); cursor: pointer; }
.ccard .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ccard .pic::after { content: "▶"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; background: rgba(0, 0, 0, .28); opacity: 0; transition: opacity .12s; }
.ccard .pic:hover::after, .ccard .pic:active::after { opacity: 1; }
.ccard .name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard .ep { font-size: 11px; color: var(--blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard .ep.done { color: var(--brand); }
.ccard .prog { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.ccard .prog i { display: block; height: 100%; background: var(--brand); }
.ccard .prog i.done { background: var(--brand); }
.ccard .ops { display: flex; gap: 4px; }
.ccard .ops button { flex: 1; font-size: 10.5px; color: var(--muted); background: var(--card); border-radius: 5px; padding: 3px 0; }
.ccard .ops button:hover { color: var(--text); background: var(--card2); }

/* ---------- 分类浏览 ---------- */
.browse-controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.select { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; outline: none; max-width: 180px; }
.type-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.pill.on { color: #04240f; background: var(--brand); border-color: var(--brand); font-weight: 600; }
.pager { display: flex; align-items: center; gap: 6px; }
.page-btn { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 12.5px; color: var(--text); }
.page-btn:disabled { opacity: .35; cursor: default; }
.page-btn:not(:disabled):hover { border-color: var(--brand-dim); color: var(--brand); }
.page-num { font-size: 12.5px; color: var(--muted); min-width: 20px; text-align: center; }

/* ---------- 详情 ---------- */
.detail-top { display: flex; gap: 14px; margin-bottom: 14px; }
.detail-top .poster { flex: 0 0 132px; aspect-ratio: 2 / 3; border-radius: var(--radius-lg); overflow: hidden; background: var(--card2); }
.detail-top .poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; min-width: 0; }
.detail-info h2 { margin: 0 0 6px; font-size: 18px; line-height: 1.3; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag { font-size: 11px; color: var(--muted); background: var(--card); border-radius: 5px; padding: 3px 7px; }
.tag.b { color: var(--brand); background: var(--brand-bg); }
.detail-info .desc { color: var(--muted); font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.detail-info .desc.open { -webkit-line-clamp: unset; }
.line-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.ep-sec-title { font-size: 13px; color: var(--muted); margin: 14px 0 8px; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.ep-btn { position: relative; text-align: center; font-size: 12.5px; padding: 7px 2px; border-radius: 7px; background: var(--card); border: 1px solid var(--line); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-btn:hover { border-color: var(--brand-dim); }
/* 集数状态配色：看过=绿，在看=蓝，未看=灰 */
.ep-btn.watched { color: var(--brand); background: var(--brand-bg); border-color: rgba(15, 220, 120, .35); }
.ep-btn.watching { color: var(--blue); background: var(--blue-bg); border-color: rgba(90, 164, 255, .45); }
.ep-btn.current { color: #04240f; background: var(--brand); border-color: var(--brand); font-weight: 700; }
.ep-btn .mini-prog { position: absolute; left: 0; bottom: 0; height: 2.5px; background: var(--blue); }
.back-row { margin-bottom: 10px; }
.back-row .icon-btn { background: var(--card); }

/* ---------- 播放器 ---------- */
#view-player { max-width: 900px; }
.player-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.player-title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-badge { flex: 0 0 auto; font-size: 11px; color: var(--orange); background: var(--orange-bg); border-radius: 5px; padding: 3px 7px; }
.player-stage { position: relative; background: #000; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 16 / 9; max-height: 62vh; }
.player-stage video { width: 100%; height: 100%; display: block; background: #000; }
.player-stage.center video { margin: 0 auto; max-width: calc(62vh * 16 / 9); }
.player-stage:fullscreen { border-radius: 0; }
.player-shell:fullscreen { display: flex; flex-direction: column; justify-content: center; background: #000; }
.player-shell:fullscreen .player-stage { aspect-ratio: auto; max-height: none; height: 0; flex: 1; border-radius: 0; }
.player-shell:fullscreen .player-bar { padding: 10px 14px; }
.pic img { position: relative; }
.pic img.img-err { display: none; }
.player-bar { display: flex; align-items: center; gap: 8px; padding: 8px 2px; }
.ctl-play { width: 36px; height: 36px; background: var(--card); color: var(--brand); }
.ctl-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
#ctl-seek { flex: 1; min-width: 0; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--brand) var(--fill, 0%), var(--line) var(--fill, 0%)); outline: none; }
#ctl-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--brand); border: 2px solid #04240f; }
.select-rate { max-width: 74px; padding: 5px 4px; }
.player-sub { margin-top: 6px; }
.player-eps-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.player-ep-label { font-size: 13px; color: var(--muted); }
.player-eps-nav { display: flex; gap: 6px; }

/* ---------- 片源管理 ---------- */
.sources-list { display: flex; flex-direction: column; gap: 8px; }
.src-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; }
.src-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.src-dot.ok { background: var(--brand); }
.src-dot.bad { background: var(--danger); }
.src-info { flex: 1; min-width: 0; }
.src-name { font-size: 13.5px; font-weight: 600; }
.src-name small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.src-url { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-ops { display: flex; gap: 6px; flex: 0 0 auto; }
.src-ops .page-btn { padding: 4px 8px; }
.src-ops .del:hover { color: var(--danger); border-color: var(--danger); }
.add-source { display: flex; gap: 8px; flex-wrap: wrap; }
.input { flex: 1 1 160px; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); padding: 8px 10px; outline: none; }
.input:focus { border-color: var(--brand-dim); }
.add-btn { width: auto; padding: 0 18px; border-radius: var(--radius); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.switch-row small { display: block; color: var(--muted); font-size: 11.5px; }
.switch { -webkit-appearance: none; appearance: none; width: 40px; height: 22px; border-radius: 999px; background: var(--line); position: relative; outline: none; transition: background .15s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--brand-dim); }
.switch:checked::after { transform: translateX(18px); }
.danger-btn { width: 100%; margin-top: 12px; padding: 9px; border-radius: var(--radius); border: 1px solid rgba(255, 92, 92, .4); color: var(--danger); background: rgba(255, 92, 92, .07); }
.danger-btn:hover { background: rgba(255, 92, 92, .14); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: #2a2a36; color: var(--text); font-size: 13px; padding: 9px 16px; border-radius: 999px; box-shadow: var(--shadow); z-index: 50; max-width: 86vw; text-align: center; border: 1px solid var(--line); }
.toast.err { border-color: rgba(255, 92, 92, .5); color: #ffb3b3; }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .topbar-inner { padding: 6px 8px; gap: 8px; }
  .brand span { display: none; }
  #main { padding: 8px 8px 40px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px 6px; }
  .detail-top .poster { flex-basis: 108px; }
  .detail-info h2 { font-size: 16px; }
  .player-stage { max-height: 40vh; border-radius: var(--radius); }
  .player-stage.center video { max-width: calc(40vh * 16 / 9); }
  .select { max-width: 150px; }
}
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
