/* ============================================================
 * 全站基础框架 (dark theme)
 * 所有页面在自身 CSS 之后引入本文件，或本文件先于自身 CSS 加载
 * 提供: :root token · reset · topbar · chip-bar · ccard 通用卡片
 *       kind-badge · search · loader · fab · footer · user-menu
 * ============================================================ */

/* ── Token ───────────────────────────────────────────────── */
:root {
  --brand: #1a73e8; --brand-dark: #1557b0; --brand-light: rgba(26,115,232,.15);
  --bg: #0d0f14; --bg2: #13161e; --card: #1a1d27; --card2: #1f2235;
  --text: #f0f2f7; --text-2: #9ba3b8; --text-3: #60677d;
  --border: rgba(255,255,255,.07); --border-2: rgba(255,255,255,.04);
  --shadow: 0 2px 8px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  --radius: 14px; --radius-sm: 8px;
  --danger: #e5413e;
  --atype-1: #1a73e8; --atype-2: #2ba471; --atype-3: #f5a623;
  --glow-watched: rgba(255,75,43,.35);
  --glow-sub: rgba(26,115,232,.35);
  --glow-popular: rgba(255,196,0,.25);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; scrollbar-gutter: stable; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  background: rgba(13,15,20,.88); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  height: 56px; display: flex; align-items: center; padding: 0 clamp(24px, 4vw, 64px);
  position: sticky; top: 0; z-index: 100;
}
.topbar .brand {
  font-size: 20px; font-weight: 700; color: var(--text);
  margin-right: 28px; letter-spacing: -.2px;
  display: inline-flex; align-items: baseline; flex-shrink: 0;
}
.topbar .brand .brand-emph { font-size: 24px; font-weight: 800; color: var(--brand); margin-right: 1px; }
.topbar .nav-links { display: flex; gap: 20px; }
.topbar .nav-links a {
  font-size: 14px; color: var(--text-2); position: relative; padding: 4px 0;
  transition: color .15s; white-space: nowrap;
}
.topbar .nav-links a:hover { color: var(--text); }
.topbar .nav-links a.active { color: #fff; font-weight: 600; }
.topbar .nav-links a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -18px;
  height: 2px; background: var(--brand); border-radius: 2px;
}
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ── 搜索框 ──────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-box {
  width: 220px; padding: 7px 14px 7px 36px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; color: var(--text);
  background: rgba(255,255,255,.06); transition: .2s;
}
.search-box::placeholder { color: var(--text-3); }
.search-box:focus {
  outline: none; border-color: var(--brand);
  background: rgba(26,115,232,.08); width: 280px;
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}
.search-wrap::before {
  content: ""; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); width: 14px; height: 14px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2360677d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center / contain;
}
.search-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 320px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden;
}
.search-dropdown[hidden] { display: none; }
.search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; transition: background .12s; text-decoration: none; color: inherit;
}
.search-item:hover { background: rgba(255,255,255,.05); }
.search-item img { width: 36px; height: 48px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.no-poster {
  width: 36px; height: 48px; border-radius: 6px; flex-shrink: 0;
  background: var(--bg2); display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-3);
}
.si-info { min-width: 0; flex: 1; }
.si-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-meta  { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.search-loading, .search-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--text-3); }

/* 搜索状态条 */
.search-status {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px 0;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-2);
}
.search-status[hidden] { display: none; }
.search-status b { color: var(--text); }
.ss-clear {
  padding: 3px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-3); border: 1px solid var(--border); border-radius: 12px;
  transition: .15s; cursor: pointer;
}
.ss-clear:hover { color: var(--text); border-color: rgba(255,255,255,.2); }

/* ── Chip 筛选栏 ─────────────────────────────────────────── */
.chip-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 24px; overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 56px; z-index: 90;
}
.chip-bar::-webkit-scrollbar { display: none; }
.chip-track {
  display: flex; align-items: center; gap: 8px; height: 48px;
  max-width: 1200px; margin: 0 auto;
}
.chip-label { font-size: 12px; color: var(--text-3); margin-right: 4px; white-space: nowrap; flex-shrink: 0; }
.chip-divider { width: 1px; height: 16px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.chip-group { display: flex; gap: 8px; flex-shrink: 0; }
.chip {
  white-space: nowrap; font-size: 13px; font-weight: 500;
  color: var(--text-2); background: rgba(255,255,255,.05);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 16px; transition: all .15s; cursor: pointer; flex-shrink: 0;
}
.chip:hover { color: var(--text); background: rgba(255,255,255,.10); }
.chip.active {
  color: #fff; background: var(--brand); border-color: var(--brand);
  box-shadow: 0 0 12px rgba(26,115,232,.4);
}
/* atype 彩点 */
.chip .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: middle; background: currentColor; opacity: .6; }
.chip.atype-1 .dot { background: var(--atype-1); opacity: 1; }
.chip.atype-2 .dot { background: var(--atype-2); opacity: 1; }
.chip.atype-3 .dot { background: var(--atype-3); opacity: 1; }

/* ── 通用内容网格 ────────────────────────────────────────── */
.topics-grid {
  width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 24px 40px;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px;
}
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--text-3);
  padding: 80px 20px; font-size: 14px;
}

/* ── ccard 通用卡片 ─────────────────────────────────────── */
.ccard {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
  transition: transform .2s cubic-bezier(.34,1.4,.64,1), box-shadow .2s;
  display: flex; flex-direction: column; position: relative;
  min-width: 0; width: 100%;
}
.ccard:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-lg); border-color: rgba(255,255,255,.14);
}
/* 封面固定 3:4 */
.cc-cover {
  position: relative; display: block;
  width: 100%; padding-top: 133.33%;
  background: #0a0c12; overflow: hidden; flex-shrink: 0;
}
.cc-cover img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease;
}
.ccard:hover .cc-cover img { transform: scale(1.06); }
.cc-cover .mask {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.5) 75%, rgba(0,0,0,.88) 100%);
}
/* 播放按钮 */
.cc-cover .play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.cc-cover .play::after {
  content: ""; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.2); backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,.4);
  box-shadow: 0 0 24px rgba(255,255,255,.15);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-size: 20px; background-repeat: no-repeat; background-position: 52% 50%;
}
.ccard:hover .cc-cover .play { opacity: 1; }
/* kind badge */
.cc-cover .kind-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .4px;
  padding: 3px 8px; border-radius: 6px;
  backdrop-filter: blur(6px); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.kind-watched  { background: linear-gradient(135deg,#ff4b2b,#ff7043); color:#fff; box-shadow: 0 2px 10px var(--glow-watched); }
.kind-popular  { background: linear-gradient(135deg,#b8860b,#ffc400); color:#1a1400; box-shadow: 0 2px 10px var(--glow-popular); }
.kind-hotest   { background: linear-gradient(135deg,#b8860b,#ffc400); color:#1a1400; box-shadow: 0 2px 10px var(--glow-popular); }
.kind-sub      { background: linear-gradient(135deg,#1a73e8,#4dabf7); color:#fff; box-shadow: 0 2px 10px var(--glow-sub); }
/* 集数标签 */
.cc-cover .ep-tag {
  position: absolute; bottom: 10px; left: 10px;
  font-size: 11px; color: #fff; font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,.6); letter-spacing: .2px;
}
/* 卡片底部 */
.cc-body { padding: 10px 12px 12px; flex: 1; display: flex; align-items: center; width: 100%; min-width: 0; }
.cc-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  line-height: 1.35; overflow: hidden; width: 100%; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2;
}
/* glow 边框变体 */
.ccard.kind-watched-card:hover  { box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,75,43,.4); }
.ccard.kind-popular-card:hover  { box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,196,0,.3); }
.ccard.kind-hotest-card:hover   { box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,196,0,.3); }
.ccard.kind-sub-card:hover      { box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(26,115,232,.4); }

/* ── 重试条 ──────────────────────────────────────────────── */
.retry-bar {
  display: none; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; color: var(--text-3); font-size: 13px;
}
.retry-bar:not([hidden]) { display: flex; }
.retry-bar button {
  padding: 6px 18px; font-size: 13px; font-weight: 600;
  color: var(--brand); background: rgba(26,115,232,.12);
  border: 1px solid rgba(26,115,232,.3); border-radius: 20px; transition: .15s;
}
.retry-bar button:hover { background: var(--brand); color: #fff; }

/* ── Loader / Spinner ────────────────────────────────────── */
.loader {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 24px; color: var(--text-3); font-size: 13px;
}
.loader[hidden] { display: none; }
.loader.in-grid { grid-column: 1 / -1; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.1);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FAB ─────────────────────────────────────────────────── */
.fab {
  position: fixed; right: 24px; bottom: 28px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 20px rgba(26,115,232,.5); z-index: 80;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.fab.show { opacity: 1; pointer-events: auto; }
.fab:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(26,115,232,.6); }

/* ── 通用 btn ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text-2); transition: .15s; cursor: pointer;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text-2); font-size: 16px; transition: .15s; cursor: pointer;
}
.btn-icon:hover { border-color: var(--brand); color: var(--brand); }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 26px 20px 20px; margin-top: auto;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px;
}
.footer-brand-block { display: flex; flex-direction: column; gap: 2px; }
.footer-brand {
  font-size: 16px; font-weight: 700; color: var(--text);
  display: inline-flex; align-items: baseline; letter-spacing: -.2px;
}
.footer-brand .brand-emph { font-size: 19px; font-weight: 800; color: var(--brand); margin-right: 1px; }
.footer-slogan { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.footer-links a { font-size: 12px; color: var(--text-3); transition: color .15s; }
.footer-links a:hover { color: var(--brand); }
.footer-copy {
  font-size: 12px; color: var(--text-3); width: 100%; text-align: center;
  margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border-2); line-height: 1.7;
}
.footer-copy .footer-icp a { color: var(--text-3); transition: color .15s; }
.footer-copy .footer-icp a:hover { color: var(--brand); }

/* ── 用户菜单 ────────────────────────────────────────────── */
.ui-ico { width: 18px; height: 18px; display: block; flex-shrink: 0; }
.login-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  color: var(--text-2); transition: all .18s;
}
.login-btn .ui-ico { width: 17px; height: 17px; }
.login-btn:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.user-menu { position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #4fc3f7);
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; padding: 0; border: none; list-style: none;
  border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--border);
  transition: box-shadow .18s, transform .18s;
}
.user-avatar::-webkit-details-marker { display: none; }
.user-avatar:hover { transform: translateY(-1px); }
.user-menu[open] .user-avatar { box-shadow: 0 0 0 2px var(--brand); }
.user-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 220px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 500;
  animation: userPop .16s ease;
}
@keyframes userPop { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.user-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border-2);
}
.user-head-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #4fc3f7);
  color: #fff; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.user-head-avatar .user-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.user-head-info { min-width: 0; }
.user-head-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.user-head-sub  { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.user-actions { padding-top: 2px; }
.user-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text-2); text-decoration: none; transition: background .12s, color .12s;
}
.user-item .ui-ico { width: 17px; height: 17px; color: var(--text-3); transition: color .12s; }
.user-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.user-item:hover .ui-ico { color: var(--brand); }
.user-item.danger:hover { color: var(--danger); background: rgba(229,65,62,.08); }
.user-item.danger:hover .ui-ico { color: var(--danger); }

/* ── 响应式 ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .topics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
}
@media (max-width: 760px) {
  .topics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 16px 14px 32px; }
  .cc-body { padding: 8px 10px 10px; }
  .cc-title { font-size: 12px; }
  .chip-bar { padding: 0 14px; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 14px; height: 50px; }
  .topbar .brand { font-size: 18px; margin-right: 14px; }
  .topbar .nav-links { gap: 14px; }
  .topbar .nav-links a { font-size: 13px; }
  .topbar .nav-links a.active::after { bottom: -14px; }
  .chip-bar { padding: 0 14px; top: 50px; }
  .user-dropdown { right: -4px; min-width: 200px; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .search-box { width: 0; padding: 7px 0; border: none; background: transparent; }
  .search-box:focus { width: 120px; padding: 7px 14px; border: 1px solid var(--border); }
  .topics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 12px 28px; }
  .fab { right: 14px; bottom: 18px; }
  .footer-inner { flex-direction: column; gap: 12px; }
  .footer-brand-block { align-items: center; }
  .footer-links { margin-left: 0; justify-content: center; gap: 14px; }
}

/* ── 管理员导航下拉菜单 ────────────────────────────────────── */
.admin-menu { position: relative; list-style: none; }
.admin-menu-btn {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--text-2);
  padding: 0; line-height: inherit;
  display: flex; align-items: center; gap: 3px;
}
.admin-menu-btn::after { content: "▾"; font-size: 10px; }
.admin-menu[open] .admin-menu-btn { color: #fff; }
.admin-dropdown {
  position: absolute; top: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--surface, #1e1e1e); border: 1px solid var(--border, #333);
  border-radius: 8px; padding: 6px 0; min-width: 120px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 200;
  display: flex; flex-direction: column;
}
.admin-dropdown a {
  padding: 9px 16px; font-size: 13px; color: var(--text-2);
  text-decoration: none; white-space: nowrap;
}
.admin-dropdown a:hover { color: #fff; background: rgba(255,255,255,.06); }

/* ── 登录引导脉冲动画 ─────────────────────────────────────── */
@keyframes nudge-ring {
  0%   { box-shadow: 0 0 0 0 rgba(232,93,38,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(232,93,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,93,38,0); }
}
.login-btn.nudge-pulse {
  animation: nudge-ring 1.2s ease-out infinite;
  border-color: var(--brand) !important;
  color: var(--brand) !important;
}
