:root {
  --bg: #0c1015;
  --bg2: #10161f;
  --card: #161d29;
  --card2: #1b2432;
  --border: #232c3b;
  --text: #e8edf4;
  --muted: #8fa0b5;
  --accent: #2f8fff;
  --accent2: #6bb3ff;
  --danger: #f85149;
  --ok: #3fb950;
  --warn: #f0883e;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: #fff; }

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(12, 16, 21, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  margin-right: 8px;
}

.nav {
  display: flex;
  gap: 6px;
  flex: 1;
}
.nav a {
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.nav a:hover { color: #fff; background: var(--card2); }
.nav a.active { color: #fff; background: var(--card2); }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #3d7dff);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, #439bff, #4b87ff); color: #fff; }

.btn-danger { border-color: rgba(248, 81, 73, 0.5); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: #fff; background: rgba(248, 81, 73, 0.12); }

.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-plain {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.btn-plain:hover { color: #fff; }

.text-input, select.text-input, textarea.text-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
}
.text-input:focus { outline: none; border-color: var(--accent); }
textarea.text-input { resize: vertical; min-height: 80px; }

.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 视图容器 ---------- */
.view-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: calc(100vh - 140px);
}

.site-footer {
  text-align: center;
  color: #5b6b80;
  font-size: 12px;
  padding: 24px 16px 32px;
}

.loading, .empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 14px;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 62vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-title { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.login-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 18px; }

/* ---------- 首页 ---------- */
.hero {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  height: 300px;
  margin-bottom: 22px;
  background: var(--card);
  border: 1px solid var(--border);
}
.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  background-size: cover;
  background-position: center 30%;
}
.hero-slide.active { opacity: 1; }
.hero-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 11, 16, 0.92) 0%, rgba(8, 11, 16, 0.35) 55%, transparent 100%);
}
.hero-info {
  position: absolute;
  left: 32px;
  bottom: 28px;
  z-index: 2;
  max-width: 60%;
}
.hero-info h2 { margin: 0 0 8px; font-size: 26px; }
.hero-info p {
  margin: 0 0 14px;
  color: #c6d2e0;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-dots {
  position: absolute;
  right: 20px;
  bottom: 18px;
  z-index: 2;
  display: flex;
  gap: 6px;
}
.hero-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
}
.hero-dots i.active { background: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  background: transparent;
}
.chip:hover { color: #fff; border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin: 4px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
}

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

.series-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  transition: transform 0.15s ease, border-color 0.15s ease;
  color: var(--text);
}
.series-card:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--text); }
.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--card2);
  overflow: hidden;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-cover .play-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
}
.series-card:hover .play-mask { opacity: 1; }
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: rgba(47, 143, 255, 0.15);
  color: var(--accent2);
  border: 1px solid rgba(47, 143, 255, 0.35);
}
.badge-warn { background: rgba(240, 136, 62, 0.15); color: var(--warn); border-color: rgba(240, 136, 62, 0.4); }
.badge-hidden { background: rgba(143, 160, 181, 0.12); color: var(--muted); border-color: var(--border); }

.load-more { text-align: center; margin-top: 24px; }

/* ---------- 搜索页 ---------- */
.search-box { display: flex; gap: 10px; margin-bottom: 22px; }
.search-box .text-input { flex: 1; }

/* ---------- 详情页 ---------- */
.detail-top { display: grid; grid-template-columns: 320px 1fr; gap: 24px; margin-bottom: 24px; }
.detail-poster { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.detail-poster img { width: 100%; display: block; aspect-ratio: 16 / 9; object-fit: cover; }
.detail-info h1 { font-size: 24px; margin: 0 0 10px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.detail-desc { color: #b9c6d6; font-size: 14px; margin: 0 0 18px; max-width: 720px; }

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--warn);
  font-size: 14px;
  background: #0a0d12;
}
.p2p-status {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #8fd0ff;
  font-size: 12px;
  pointer-events: none;
}
.player-tip {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}
.seek-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
  z-index: 3;
}
.seek-hint.hide { opacity: 0; }

/* ---------- 自定义控制条 ---------- */
.ctrl-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.25) 70%, transparent 100%);
  padding: 26px 12px 8px;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.ctrl-bar.hide {
  opacity: 0;
  pointer-events: none;
}
.ctrl-progress {
  position: absolute;
  top: 8px;
  left: 12px;
  right: 12px;
  height: 18px;
  cursor: pointer;
}
.ctrl-progress::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.28);
  border-radius: 2px;
}
.ctrl-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, var(--accent), #7c5cff);
  border-radius: 2px;
}
.ctrl-thumb {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctrl-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}
.ctrl-btn:hover { color: var(--accent2); }
.ctrl-time {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ctrl-row .spacer { flex: 1; }
.ctrl-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}
.ctrl-spinner::after {
  content: "";
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  aspect-ratio: auto;
}

.speed-box {
  position: relative;
}
.speed-btn {
  background: rgba(15, 20, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.speed-btn:hover { border-color: var(--accent); }
.speed-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  background: rgba(20, 27, 38, 0.96);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 96px;
  box-shadow: var(--shadow);
}
.speed-item {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}
.speed-item:hover { background: rgba(47, 143, 255, 0.12); color: #fff; }
.speed-item.active { color: var(--accent2); font-weight: 600; }

.episode-section { margin-top: 26px; }
.episode-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.episode-item {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.episode-item:hover { border-color: var(--accent); }
.episode-item.active { border-color: var(--accent); background: rgba(47, 143, 255, 0.1); color: var(--accent2); }
.episode-item .dur { color: var(--muted); font-size: 11px; flex-shrink: 0; }

/* ---------- 管理端 ---------- */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.admin-tab {
  padding: 7px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.panel h3 { margin: 0 0 14px; font-size: 15px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar .text-input { width: auto; min-width: 200px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; }
.table td.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.file-field { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.file-field .text-input { flex: 1; min-width: 220px; }
.upload-progress { flex-basis: 100%; display: flex; align-items: center; gap: 10px; }
.upload-progress .bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg2);
  overflow: hidden;
}
.upload-progress .bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #7c5cff);
  transition: width 0.2s ease;
}
.upload-progress .pct { color: var(--muted); font-size: 12px; min-width: 46px; text-align: right; }
.batch-progress {
  width: 200px;
  flex-basis: auto;
  min-width: 200px;
}
.table tr.row-error td { color: var(--danger); }
.cover-preview {
  margin-top: 10px;
  width: 260px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cleanup-result {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

/* ---------- 作品行内剧集面板 ---------- */
.ep-toggle { font-size: 12px; padding: 2px 8px; }
.ep-row > td { padding: 0 !important; background: var(--bg2); border-bottom: none; }
.ep-inline { padding: 14px 18px; }
.ep-inline-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.ep-inline-title { font-weight: 600; font-size: 13px; color: var(--accent2); }
.ep-table-wrap { margin-top: 8px; }
.ep-table th { background: var(--bg2); }
.ep-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}
.multi-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.inline-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline-form .full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.check-row input { accent-color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: #1d2635;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: 86vw;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .hero { height: 210px; }
  .hero-info { left: 18px; bottom: 18px; max-width: 82%; }
  .hero-info h2 { font-size: 19px; }
  .hero-info p { display: none; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .detail-top { grid-template-columns: 1fr; }
  .form-grid, .inline-form { grid-template-columns: 1fr; }
  .nav a { padding: 6px 8px; }
}
