:root {
  --bg: #0e1013;
  --bg2: #16191f;
  --card: #1a1e26;
  --card-hover: #20252f;
  --border: #262b35;
  --text: #e8eaee;
  --muted: #9aa3b2;
  --accent: #e5484d;
  --accent2: #ff8a8e;
  --gold: #f5c451;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Noto Sans CJK SC",
        sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* topbar */
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--accent2);
  white-space: nowrap;
}
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 14px; }
.nav a:hover { color: var(--text); }

.search { display: flex; flex: 1 1 260px; min-width: 220px; }
.search input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0 8px 8px 0;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.langs { display: flex; gap: 8px; }
.langs a {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.langs a.active { color: var(--accent2); border-color: var(--border); background: var(--bg); }

.container { flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; padding: 20px 16px 40px; }

/* hero */
.hero { margin: 4px 0 20px; }
.hero h1 { font-size: 24px; font-weight: 700; }
.hero-sub { color: var(--muted); margin-top: 4px; font-size: 14px; }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.card:hover { transform: translateY(-3px); border-color: #39404d; background: var(--card-hover); }

.thumb { position: relative; aspect-ratio: 3 / 2; background: #0b0d10; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nothumb {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--gold);
  border: 1px solid rgba(245, 196, 81, 0.35);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 700;
}
.badge.big { position: static; display: inline-block; font-size: 14px; padding: 2px 9px; }

.card-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 4px; }
.card-code { font-size: 11.5px; color: var(--accent2); font-weight: 700; letter-spacing: 0.4px; }
.card-title {
  font-size: 13.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}
.card-meta { display: flex; gap: 10px; color: var(--muted); font-size: 12px; }
.card-sub { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; color: var(--muted); }
.card-sub .maker { color: #7fb3ff; }
.card-sub .cast { color: #b59cf0; }

/* video page */
.video-page { margin-top: 6px; }
.video-head { display: flex; gap: 26px; flex-wrap: wrap; }
.video-cover {
  flex: 0 0 320px;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  align-self: flex-start;
}
.video-cover img { width: 100%; display: block; }
.video-info { flex: 1; min-width: 300px; }
.video-title { font-size: 21px; line-height: 1.4; font-weight: 700; margin-bottom: 6px; }
.alt-title { color: var(--muted); font-size: 14px; margin: 2px 0; }

.infotable { border-collapse: collapse; width: 100%; margin-top: 14px; }
.infotable th, .infotable td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.infotable th { color: var(--muted); font-weight: 600; width: 110px; white-space: nowrap; }
.infotable td a { color: #7fb3ff; }
.infotable td a:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 13px;
  color: var(--text);
}
.chip:hover { border-color: var(--accent); color: var(--accent2); }
.chip.actor:hover { border-color: #8a6fd8; color: #b59cf0; }

.previews, .related { margin-top: 30px; }
.previews h2, .related h2 { font-size: 17px; margin-bottom: 12px; }
.preview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.preview-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  background: #0b0d10;
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-item:hover { border-color: var(--accent); }

/* filters */
.filters { margin-top: 12px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-form select, .filter-form input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
.filter-form input { width: 130px; }
.filter-form button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.clear { color: var(--muted); font-size: 13px; }
.clear:hover { color: var(--accent2); }

.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* entity list */
.entity-list { list-style: none; columns: 3 320px; column-gap: 24px; }
.entity-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
  break-inside: avoid;
}
.entity-name { font-size: 14.5px; }
.entity-list li a:hover .entity-name { color: var(--accent2); }
.entity-alt { color: var(--muted); font-size: 12px; margin-left: 8px; }
.entity-count { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
}

/* pager */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 26px;
  color: var(--muted);
  font-size: 14px;
}
.pager a {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 7px 16px;
  border-radius: 8px;
}
.pager a:hover { border-color: var(--accent); color: var(--accent2); }

/* footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 14px 16px;
}
.stats {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.stats b { color: var(--text); }
.stats .note { margin-left: auto; opacity: 0.7; }

@media (max-width: 720px) {
  .video-cover { flex-basis: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .entity-list { columns: 1; }
}
