:root {
  --bg: #0d0f13;
  --bg-soft: #14171e;
  --panel: #181c24;
  --panel-hi: #1f242e;
  --line: #262c38;
  --text: #e6e9ef;
  --text-dim: #8b93a3;
  --accent: #4ea1ff;
  --accent-soft: rgba(78, 161, 255, .12);
  --gold: #f0b429;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--text-dim); font-size: 13px; }
.small { font-size: 12px; }

.wrap {
  width: min(1200px, 100% - 32px);
  margin: 0 auto;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(13, 15, 19, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7a5cff);
  font-weight: 700; font-size: 15px; color: #fff;
}

.brand-text { font-weight: 650; font-size: 16px; letter-spacing: .3px; }

.searchbox {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px 0 16px;
  transition: border-color .18s, box-shadow .18s;
}

.searchbox:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.searchbox input {
  flex: 1;
  height: 40px;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 14px;
}

.searchbox input::placeholder { color: #5c6474; }

.searchbox button {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: filter .15s;
}

.searchbox button:hover { filter: brightness(1.12); }

.ghost-btn {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}

.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.ghost-btn:disabled { opacity: .5; cursor: default; }

/* ---------- 状态条 ---------- */

.statsbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 2px 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.statsbar .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #34d399;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.statsbar .dot.warn { background: var(--gold); }
.statsbar .dot.bad { background: #ef4444; }

/* ---------- 面板 ---------- */

.panel { margin: 20px 0 30px; }

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  letter-spacing: .2px;
}

.panel-head h2::before {
  content: '';
  display: inline-block;
  width: 3px; height: 14px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: -2px;
}

/* ---------- 卡片网格 ---------- */

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

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .16s, border-color .16s, background .16s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #38404f;
  background: var(--panel-hi);
}

.card-poster {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(160deg, #1b2130, #12161d);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-poster span {
  font-size: 34px;
  font-weight: 700;
  color: #2f3a4d;
  letter-spacing: 1px;
  padding: 0 10px;
  text-align: center;
  line-height: 1.25;
  word-break: break-all;
}

.card-badge {
  position: absolute;
  top: 8px; left: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
}

.card-body { padding: 10px 11px 12px; }

.card-title {
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.42;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}

.card-sub {
  margin-top: 7px;
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 11.5px;
}

/* ---------- 分页 ---------- */

.pager {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.pager button {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}

.pager button:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.pager button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager button:disabled { opacity: .35; cursor: default; }

/* ---------- 抽屉（剧集详情） ---------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(3px);
}

.drawer-body {
  position: absolute;
  top: 0; right: 0;
  width: min(520px, 92vw);
  height: 100%;
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  overflow-y: auto;
  animation: slideIn .22s ease;
}

@keyframes slideIn {
  from { transform: translateX(24px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-close, .modal-close {
  position: absolute;
  top: 14px; right: 16px;
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.drawer-close:hover, .modal-close:hover { background: var(--panel); color: var(--text); }

.drawer-body h3 {
  margin: 0 40px 6px 0;
  font-size: 18px;
  line-height: 1.4;
}

.episodes {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.ep-btn {
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  text-align: center;
  transition: border-color .14s, background .14s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- 播放器 ---------- */

.modal { position: fixed; inset: 0; z-index: 70; }
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .78); backdrop-filter: blur(4px); }

.modal-body {
  position: relative;
  width: min(1080px, 94vw);
  margin: 4vh auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 560;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close { position: static; }

.video-shell { background: #000; }
.video-shell video { display: block; width: 100%; max-height: 76vh; background: #000; }

#playHint { margin: 10px 18px 14px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(30, 36, 46, .96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 82vw;
  text-align: center;
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

@media (max-width: 640px) {
  .topbar .wrap { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 10px; }
  .searchbox { order: 3; width: 100%; flex-basis: 100%; }
  .ghost-btn { margin-left: auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 11px; }
  .drawer-body { width: 100vw; }
}
