:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #1f2328;
  --fg-dim: #6b7280;
  --line: #e5e7eb;
  --accent: #ea580c;
  --accent-soft: #fff7ed;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
/* header：只有「筛选 + 搜索」这一行吸顶（position:sticky 的约束框是 body，
   所以整行会一直钉在顶部）；容量统计行已移出 header，随页面一起滚走。 */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.header-row {
  display: flex; align-items: center; gap: 14px;
  padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap;
}

/* 左侧筛选 */
.header-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 首页按钮：红底白字，回到未筛选的首页 */
.header-filters .home-btn {
  border: 1px solid #dc2626; background: #dc2626; color: #fff;
  padding: 7px 15px; border-radius: 8px; font-size: 13px; text-decoration: none;
  white-space: nowrap; flex-shrink: 0; transition: background .15s, border-color .15s;
}
.header-filters .home-btn:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.header-filters select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; background: #fff; outline: none; max-width: 190px;
  color: var(--fg);
}
.header-filters select:focus { border-color: var(--accent); }
.header-filters button {
  border: 0; background: var(--fg); color: #fff; padding: 7px 18px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.header-filters button:hover { background: #000; }

/* 右侧搜索 */
.search { display: flex; margin-left: auto; flex: 1 1 260px; max-width: 560px; min-width: 220px; }
.search input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-right: 0;
  border-radius: 8px 0 0 8px; padding: 9px 14px; font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  border: 0; background: var(--accent); color: #fff; padding: 9px 20px;
  border-radius: 0 8px 8px 0; cursor: pointer; font-size: 14px; white-space: nowrap;
}
.search button:hover { background: #c2410c; }

.result-info { color: var(--fg-dim); font-size: 14px; margin: 16px 2px; }
.result-info strong { color: var(--accent); }
.result-info .reset-link { margin-left: 10px; font-size: 13px; color: var(--fg-dim); text-decoration: none; }
.result-info .reset-link:hover { color: var(--accent); }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: box-shadow .18s, transform .18s, border-color .18s;
  display: flex; flex-direction: column;
}
.card:hover { box-shadow: 0 8px 22px rgba(0,0,0,.09); transform: translateY(-2px); border-color: #fdba74; }

.poster { display: block; position: relative; background: #e5e7eb; aspect-ratio: 2/3; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-cover { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--fg-dim); font-size: 13px; }
.badge {
  position: absolute; top: 8px; right: 8px; background: rgba(234,88,12,.95); color: #fff;
  font-size: 11px; padding: 2px 7px; border-radius: 999px; font-weight: 600;
}

.info { padding: 10px 12px 12px; }
.title { margin: 0 0 2px; font-size: 15px; line-height: 1.35; }
.title a { color: var(--fg); text-decoration: none; }
.title a:hover { color: var(--accent); }
.title-en {
  margin: 0 0 6px; font-size: 12px; color: var(--fg-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.meta { margin: 0 0 4px; font-size: 12px; color: var(--fg-dim); display: flex; flex-wrap: wrap; gap: 8px; }
.meta .genres { color: var(--accent); }
.sub { margin: 0; font-size: 12px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pager ---------- */
/* 页码窗口：首页 | 1 2 3 4 5 6 … | 下一页 | 尾页 */
.pager {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 6px; margin: 30px 0 40px; font-size: 13px;
}
.pager a, .pager span {
  min-width: 34px; padding: 5px 10px; text-align: center; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--fg-dim); text-decoration: none;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager .gap { border: 0; background: none; min-width: 0; padding: 5px 2px; color: var(--fg-dim); }
.pager .dis { opacity: .4; cursor: default; }

/* ---------- detail ---------- */
.crumb { margin: 18px 0 12px; font-size: 14px; }
.crumb a { color: var(--fg-dim); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

.detail { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 40px; }
.detail-head { display: flex; gap: 24px; flex-wrap: wrap; }
.detail-cover { width: 200px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.14); }
.detail-title { flex: 1; min-width: 260px; }
.detail-title h1 { margin: 0 0 4px; font-size: 26px; }
.title-en.big { font-size: 15px; margin: 0 0 10px; }
.tag {
  display: inline-block; background: #f3f4f6; color: #4b5563; font-size: 12px;
  padding: 2px 9px; border-radius: 999px;
}
.tag.genre { background: var(--accent-soft); color: var(--accent); }
/* 类型标签可点击 -> 跳到该类型的影片列表 */
a.tag.genre { text-decoration: none; cursor: pointer; transition: background .15s, color .15s; }
a.tag.genre:hover { background: var(--accent); color: #fff; }
/* 年份 / 国家标签可点击 -> 跳到对应筛选 */
a.tag.tag-link { text-decoration: none; cursor: pointer; transition: background .15s, color .15s; }
a.tag.tag-link:hover { background: var(--fg); color: #fff; }

/* 详情页：导演 / 编剧 / 主演 可点击 -> 列出该人物的所有影片 */
.line .plink { color: var(--accent); text-decoration: none; border-bottom: 1px dashed #fdba74; }
.line .plink:hover { color: #c2410c; border-bottom-style: solid; }
.line .sep, .meta .sep { color: var(--fg-dim); margin: 0 1px; }

/* 列表卡片：年份 / 国家 可点击 */
.meta a.mlink { color: var(--fg-dim); text-decoration: none; }
.meta a.mlink:hover { color: var(--accent); text-decoration: underline; }

/* 封面放大入口 */
.cover-zoom { position: relative; display: inline-block; width: 200px; cursor: zoom-in; }
.cover-zoom .detail-cover { display: block; }
.zoom-hint {
  position: absolute; inset: auto 0 0 0; text-align: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px;
  padding: 5px 0; border-radius: 0 0 10px 10px;
  opacity: 0; transition: opacity .18s;
}
.cover-zoom:hover .zoom-hint { opacity: 1; }

/* 灯箱：本页覆盖层，高度 100%，点任意处关闭 */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.9);
  display: none; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 16px;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.lightbox-cap {
  position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
  color: #fff; font-size: 13px; opacity: .85;
}
.lightbox-close {
  position: absolute; top: 14px; right: 18px;
  color: #fff; font-size: 22px; line-height: 1; opacity: .7;
}
.lightbox-close:hover { opacity: 1; }
.line { margin: 6px 0; font-size: 14px; color: #374151; }
.line b { color: var(--fg-dim); font-weight: 400; margin-right: 4px; }
.line a { color: var(--accent); word-break: break-all; }

.block { margin-top: 26px; }
.block h2 { font-size: 17px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.block h2 .count { font-size: 13px; color: var(--fg-dim); font-weight: 400; }
.plot { white-space: pre-wrap; color: #374151; font-size: 14px; margin: 0; }

/* ---------- links ---------- */
.links { list-style: none; margin: 0; padding: 0; }
.links li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fafafa; }
.link-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.link-row + .link-row { margin-top: 6px; }
.q { background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.lname { font-size: 13px; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; flex: 1; min-width: 180px; }
.size { font-size: 12px; color: var(--fg-dim); }
.lurl {
  flex: 1; min-width: 240px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: #4b5563; word-break: break-all;
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}
.copy {
  border: 0; background: var(--fg); color: #fff; border-radius: 6px; padding: 6px 14px;
  cursor: pointer; font-size: 12px; flex-shrink: 0;
}
.copy:hover { background: var(--accent); }

/* ---------- 手动添加的磁链 ---------- */
.user-link { background: #f0fdff !important; border-color: #a5f3fc !important; }
.link-row .manual {
  font-size: 11px; color: #0e7490; background: #ecfeff; border: 1px solid #a5f3fc;
  border-radius: 999px; padding: 1px 8px; flex-shrink: 0;
}
.link-row .added-at { font-size: 11px; color: var(--fg-dim); }

.add-magnet {
  margin-top: 18px; padding: 14px 16px; border: 1px dashed var(--line);
  border-radius: 10px; background: #fcfcfd;
}
.add-magnet h3 { margin: 0 0 4px; font-size: 14px; }
.add-magnet p.muted { margin: 0 0 12px; font-size: 12px; }
.add-magnet form {
  display: grid; grid-template-columns: 1fr 130px 120px; gap: 10px 12px; align-items: end;
}
.add-magnet label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-dim);
}
.add-magnet label.f-magnet { grid-column: 1 / -1; }
.add-magnet input, .add-magnet select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px;
  background: #fff; outline: none; color: var(--fg); width: 100%;
}
.add-magnet input:focus, .add-magnet select:focus { border-color: var(--accent); }
.add-magnet button.add-btn {
  grid-column: 1 / -1; justify-self: start; border: 0; background: var(--accent);
  color: #fff; padding: 8px 24px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.add-magnet button.add-btn:hover { background: #c2410c; }
@media (max-width: 720px) {
  .add-magnet form { grid-template-columns: 1fr; }
}

/* ---------- 页面提示条 ---------- */
.msg-box {
  padding: 9px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
  border: 1px solid transparent;
}
.msg-box.ok { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.msg-box.err { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* 容量统计：在 header 之外，随页面滚动（手机端与 PC 端行为一致） */
.cap-wrap { padding: 12px 20px 2px; }
.cap-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start;
  gap: 10px;
}
.cap-item {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: #f9fafb; border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 12px; font-size: 12px; color: var(--fg-dim); white-space: nowrap;
}
.cap-item b { font-size: 12px; color: var(--fg); font-weight: 600; }
.cap-item em { font-style: normal; font-weight: 600; color: var(--accent); }
.cap-item i { font-style: normal; color: var(--fg-dim); }
.cap-4k em { color: #7c3aed; }
.cap-2k em { color: #0891b2; }
.cap-1080p em { color: var(--accent); }
.cap-720p em { color: #16a34a; }
.cap-sd em { color: #64748b; }
.cap-other em { color: #94a3b8; }
/* 当日新增（定时同步任务写入） */
.cap-daily { background: #fdf4ff; border-color: #e9d5ff; }
.cap-daily em { color: #a21caf; }
/* 最近更新（最近一次同步/抓取时间） */
.cap-updated { background: #f0f9ff; border-color: #bae6fd; }
.cap-updated em { color: #0369a1; }
.cap-total { background: var(--accent-soft); border-color: #fed7aa; }
.cap-total em { color: var(--accent); }

/* ---------- login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 28px; box-shadow: 0 10px 30px rgba(0,0,0,.07);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 22px; color: var(--fg-dim); font-size: 13px; }
.login-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
}
.login-busy {
  background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
  border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
}
.login-field { display: block; margin-bottom: 14px; }
.login-field span { display: block; font-size: 13px; color: var(--fg-dim); margin-bottom: 5px; }
.login-field input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; outline: none; background: #fff;
}
.login-field input:focus { border-color: var(--accent); }
.login-card button[type=submit] {
  width: 100%; border: 0; background: var(--accent); color: #fff;
  padding: 11px; border-radius: 8px; font-size: 15px; cursor: pointer; margin-top: 6px;
}
.login-card button[type=submit]:hover { background: #c2410c; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--fg-dim); }
.empty .big { font-size: 52px; margin: 0 0 6px; font-weight: 700; color: var(--line); }
.empty a { color: var(--accent); }
.muted { color: var(--fg-dim); font-size: 14px; }

.site-footer {
  border-top: 1px solid var(--line); background: #fff; margin-top: 40px;
  padding: 18px 0; color: var(--fg-dim); font-size: 13px;
}
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logout-btn {
  border: 1px solid var(--line); background: #fff; color: var(--fg-dim);
  border-radius: 8px; padding: 5px 14px; font-size: 13px; cursor: pointer;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 860px) {
  .header-row { gap: 10px; }
  .header-filters { width: 100%; }
  /* 窄屏排版：三个下拉框独占一行（最小 90px，文字不被截断），
     首页 / 筛选 按钮自动换到第二行 */
  .header-filters select { order: 1; flex: 1 1 90px; min-width: 90px; max-width: none; }
  .header-filters .home-btn { order: 2; }
  .header-filters button { order: 3; }
  .search { margin-left: 0; flex: 1 1 100%; max-width: none; }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .detail { padding: 16px; }
  .detail-cover { width: 140px; }
  .detail-title h1 { font-size: 20px; }
}
