:root {
  --bg: #0d1117;
  --bg2: #151b23;
  --card: #1b2330;
  --line: #2b3548;
  --text: #e6e9ef;
  --muted: #8b94a3;
  --accent: #2ea6ff;
  --accent2: #7c5cff;
  --danger: #ff5c5c;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(12px, 4vw, 40px);
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: 1px; white-space: nowrap; }
.brand span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.searchbar { flex: 1; display: flex; min-width: 200px; max-width: 560px; }
.searchbar input {
  flex: 1; padding: 9px 14px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius) 0 0 var(--radius); outline: none;
}
.searchbar input:focus { border-color: var(--accent); }
.searchbar button {
  padding: 9px 18px; border: none; border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  font-weight: 600; white-space: nowrap;
}
.topnav { display: flex; align-items: center; gap: 14px; font-size: 15px; }
.topnav a { color: var(--muted); padding: 4px 2px; }
.topnav a.active, .topnav a:hover { color: var(--text); }
.btn-ghost {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 12px; color: var(--muted);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

main { padding: 18px clamp(12px, 4vw, 40px) 60px; max-width: 1400px; margin: 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 0 30px; }

/* ===== 源/分类 chips ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.chip {
  padding: 6px 14px; border-radius: 999px; font-size: 14px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
}
.chip:hover { color: var(--text); }
.chip.active {
  background: linear-gradient(90deg, rgba(46,166,255,.2), rgba(124,92,255,.2));
  border-color: var(--accent); color: var(--text);
}

/* ===== 封面网格 ===== */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  position: relative; display: block; border-radius: var(--radius);
  overflow: hidden; background: var(--card); border: 1px solid var(--line);
  transition: transform .15s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card .pic {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block;
  background: #232c3b;
}
.card .badge {
  position: absolute; top: 6px; right: 6px; font-size: 12px;
  background: rgba(0,0,0,.68); border-radius: 6px; padding: 2px 7px;
}
.card .meta { padding: 8px 10px 10px; }
.card .name {
  font-size: 14px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.card .sub { font-size: 12px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .progress-line { height: 3px; background: var(--line); }
.card .progress-line i { display: block; height: 100%; background: var(--accent); }

/* ===== 分页 / 通用 ===== */
.pager { display: flex; justify-content: center; gap: 10px; margin: 26px 0 8px; align-items: center; }
.pager button {
  padding: 7px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text);
}
.pager button:disabled { opacity: .4; cursor: default; }
.state-box { text-align: center; color: var(--muted); padding: 60px 0; }
.state-box .retry {
  margin-top: 12px; padding: 7px 18px; border-radius: 8px;
  border: 1px solid var(--accent); background: none; color: var(--accent);
}
h2.section { font-size: 18px; margin: 4px 0 14px; }

/* ===== 详情页 ===== */
.detail-top { display: flex; gap: 22px; flex-wrap: wrap; }
.detail-pic { width: 210px; border-radius: var(--radius); border: 1px solid var(--line); }
.detail-info { flex: 1; min-width: 260px; }
.detail-info h1 { font-size: 26px; margin-bottom: 8px; }
.detail-info .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.detail-info .tags span {
  font-size: 12px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; color: var(--muted);
}
.detail-info p.desc { color: var(--muted); line-height: 1.7; font-size: 14px; margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.detail-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  padding: 10px 22px; border-radius: 10px; border: none; font-weight: 600;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff;
}
.btn.secondary { background: var(--bg2); border: 1px solid var(--line); color: var(--text); }
.btn.secondary.faved { color: #ffb020; border-color: #ffb020; }

.episodes { margin-top: 26px; }
.ep-lines { margin-bottom: 10px; }
.ep-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ep-btn {
  min-width: 64px; padding: 8px 12px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  font-size: 14px; text-align: center;
}
.ep-btn:hover { border-color: var(--accent); }
.ep-btn.watched { color: var(--muted); }
.ep-btn.current { border-color: var(--accent); color: var(--accent); }

/* ===== 播放页 ===== */
.player-wrap { max-width: 1100px; margin: 0 auto; }
.player-title { font-size: 18px; margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.player-title small { color: var(--muted); font-size: 13px; }
video.player {
  width: 100%; aspect-ratio: 16/9; background: #000;
  border-radius: var(--radius); border: 1px solid var(--line);
}
.player-bar { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.player-bar select {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
.player-msg { color: var(--muted); font-size: 13px; min-height: 18px; }
.player-msg.error { color: var(--danger); }

/* ===== 登录遮罩 ===== */
.auth-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 10, 14, 0.9); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-mask[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 360px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 16px; padding: 30px 28px;
}
.auth-card h1 { font-size: 28px; text-align: center; }
.auth-card h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 18px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; background: none; border: none; padding: 8px 0; color: var(--muted); font-size: 15px;
  border-bottom: 2px solid transparent;
}
.auth-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
#auth-form input {
  padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
#auth-form input:focus { border-color: var(--accent); }
#auth-submit {
  padding: 11px; border: none; border-radius: 10px; font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.auth-err { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }

/* ===== 手机适配 ===== */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
  .topnav { width: 100%; order: 3; }
  .detail-pic { width: 140px; }
  .searchbar { order: 2; width: 100%; max-width: none; }
}
