:root {
  --bg: #0a0c12;
  --bg-soft: #10131b;
  --panel: #141823;
  --panel-2: #1b2130;
  --line: #252c3b;
  --text: #e9edf6;
  --muted: #8a93a8;
  --accent: #5b8cff;
  --accent-2: #8b5cf6;
  --ok: #2fd27a;
  --warn: #f2b33d;
  --err: #ff5f7e;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2440 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  min-height: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

button, input, select, textarea { font-family: inherit; }

/* ------------------------------------------------------------------ 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  background: rgba(10, 12, 18, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(91, 140, 255, 0.35);
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }

.searchbox {
  flex: 1;
  display: flex;
  gap: 10px;
  max-width: 720px;
}
.searchbox input {
  flex: 1;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.searchbox input:focus {
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.16);
}

.top-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.source-badge {
  font-size: 12px;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
}
.source-badge:hover { color: var(--text); border-color: rgba(91, 140, 255, 0.45); }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  transition: transform 0.12s, opacity 0.12s, background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(91, 140, 255, 0.28);
}
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { border-color: rgba(91, 140, 255, 0.55); background: rgba(91, 140, 255, 0.08); }
.btn.lg { height: 46px; padding: 0 28px; font-size: 15px; border-radius: 12px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

.link {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ 布局 */
.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 22px;
  padding: 20px 24px 60px;
  max-width: 1560px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 82px;
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 104px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.side-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bulk { display: flex; gap: 10px; }

.site-list { overflow-y: auto; padding: 6px; }
.repo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: #7c87a1;
  letter-spacing: 0.4px;
}
.repo-head:first-child { padding-top: 6px; }
.site-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.site-row:hover { background: var(--panel-2); }
.site-row.disabled { opacity: 0.42; cursor: not-allowed; }
.site-row input { accent-color: var(--accent); flex: none; }
.site-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag {
  flex: none;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(91, 140, 255, 0.14);
  color: #9db6ff;
  font-weight: 600;
}
.tag.spider { background: rgba(255, 95, 126, 0.12); color: #ff93a8; }
.tag.csp { background: rgba(86, 207, 163, 0.12); color: #75dcb5; }
.tag.empty { background: rgba(138, 147, 168, 0.14); color: var(--muted); }

/* ------------------------------------------------------------------ 主内容 */
.content { min-width: 0; }

.cat-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav button {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.cat-nav button:hover { color: var(--text); border-color: rgba(91, 140, 255, 0.45); }
.cat-nav button.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #5b8cff, #7a5bff);
}

.home-meta {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}
.settings-title {
  margin: 4px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.search-meta { margin-bottom: 18px; }
.search-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.progress { height: 4px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
#progressBar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.results { display: flex; flex-direction: column; gap: 30px; }

.site-section { animation: rise 0.3s ease both; }
.site-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.site-section-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.site-section-head .count { font-size: 12px; color: var(--muted); }
.site-section-head .error { font-size: 12px; color: var(--err); margin-left: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 18px 16px;
}

.card {
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid transparent;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(91, 140, 255, 0.5);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
}
.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(160deg, #1d2331, #12151d);
  overflow: hidden;
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.remarks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 8px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-body { padding: 8px 9px 10px; }
.card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ 弹层 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(6px);
}

.modal {
  width: min(620px, 100%);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: pop 0.18s ease both;
}
.detail-modal { width: min(880px, 100%); }
@keyframes pop {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.field input:focus, textarea:focus { border-color: rgba(91, 140, 255, 0.65); }
textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px; }
.file-btn { display: inline-grid; place-items: center; }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.source-info {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.7;
  margin-bottom: 16px;
  word-break: break-all;
}
.source-info b { color: var(--text); }
.parse-info { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.8; }

/* ------------------------------------------------------------------ 详情 */
.detail-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 22px; }
.detail-poster {
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.detail-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-title { margin: 0 0 10px; font-size: 20px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: #b9c2d6;
  border: 1px solid var(--line);
}
.detail-desc {
  font-size: 13px;
  line-height: 1.8;
  color: #b3bccf;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.source-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 22px 0 12px; }
.source-tab {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.source-tab.active {
  color: #fff;
  border-color: rgba(91, 140, 255, 0.65);
  background: rgba(91, 140, 255, 0.16);
}
.episodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 240px; overflow-y: auto; }
.episode {
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: #c6cee0;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.episode:hover { border-color: rgba(91, 140, 255, 0.6); color: #fff; }
.episode.active {
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.9), rgba(139, 92, 246, 0.9));
  border-color: transparent;
  color: #fff;
}
.detail-tip { margin-top: 16px; font-size: 12px; color: var(--warn); line-height: 1.7; }

/* ------------------------------------------------------------------ 播放器 */
.player-modal {
  width: min(1080px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #090b10;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.player-title-wrap { min-width: 0; }
.player-head h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.player-tools select {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  max-width: 180px;
}
.player-stage {
  position: relative;
  background: #000;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 220px);
}
.player-stage video { width: 100%; height: 100%; display: block; background: #000; }
.player-notice {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: #d7deed;
  background: rgba(8, 10, 15, 0.88);
}
.notice-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.history-modal { width: min(720px, 100%); }
.history-head-actions { display: flex; align-items: center; gap: 8px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.history-item img {
  width: 56px;
  height: 78px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: #161b26;
}
.history-info { flex: 1; min-width: 0; }
.history-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-progress {
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.history-progress > div { height: 100%; background: var(--accent); }
.history-actions { display: flex; flex: none; gap: 6px; }
.mark-btn { white-space: nowrap; }
.mark-btn.set { border-color: rgba(91, 140, 255, 0.55); color: #9db6ff; }
.episode-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  min-height: 56px;
}
.episode-bar:empty { display: none; }
.episode-bar .episode { flex: none; }

/* ------------------------------------------------------------------ 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 11px 20px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: min(560px, 90vw);
}
.toast.error { border-color: rgba(255, 95, 126, 0.5); color: #ffb3c2; }
.toast.ok { border-color: rgba(47, 210, 122, 0.5); color: #a6f0c6; }

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .searchbox { order: 3; flex-basis: 100%; max-width: none; }
  .top-actions { margin-left: auto; }
  .source-badge { display: none; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: static; max-height: 260px; }
  .site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .detail-grid { grid-template-columns: 120px minmax(0, 1fr); gap: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px 12px; }
  .player-tools select { display: none; }
}
