:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf1;
  --text-dim: #9aa4b2;
  --accent: #ff5a5f;
  --accent-2: #6c8cff;
  --gold: #ffce54;
  --green: #4fd18b;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(108, 140, 255, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(255, 90, 95, 0.15), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 26px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 30px;
  color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(255, 90, 95, 0.5));
}
.site-header h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.tagline { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }

.header-meta { display: flex; align-items: center; gap: 12px; }
.date-pill {
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
}
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}
.btn-ghost:hover { border-color: var(--accent-2); color: #fff; transform: translateY(-1px); }

.container { max-width: 1100px; margin: 0 auto; padding: 32px clamp(16px, 5vw, 56px) 60px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}

.film-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.poster {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .poster-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
}
.poster .fallback-letter {
  font-size: 64px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}
.poster .fallback-title {
  margin-top: 6px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.85);
  max-width: 80%;
}
.badge-kind {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 1px;
  backdrop-filter: blur(4px);
}

.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-title { font-size: 20px; margin: 0; font-weight: 700; }
.card-title .en { display: block; font-size: 13px; color: var(--text-dim); font-weight: 400; margin-top: 2px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.rating {
  font-weight: 800;
  font-size: 15px;
  padding: 2px 10px;
  border-radius: 999px;
}
.genres { display: flex; flex-wrap: wrap; gap: 6px; }
.genre {
  background: rgba(108, 140, 255, 0.14);
  border: 1px solid rgba(108, 140, 255, 0.3);
  color: #cdd8ff;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
}
.summary { font-size: 14px; color: #c9d1dc; margin: 2px 0; }
.credits { font-size: 13px; color: var(--text-dim); }
.credits b { color: #d7dde6; font-weight: 600; }

.card-actions { margin-top: auto; display: flex; gap: 10px; padding-top: 6px; }
.btn-play {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), #ff8a5f);
  border: none;
  color: #fff;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.btn-play:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-chat {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.2s;
}
.btn-chat:hover { border-color: var(--accent-2); }

/* 留言墙 */
.board { margin-top: 44px; }
.board-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.board-head h2 { margin: 0; font-size: 20px; }
.hint { color: var(--text-dim); font-size: 13px; }

.comment-form {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 160px; }
.comment-form input,
.comment-form textarea {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.comment-form input:focus,
.comment-form textarea:focus { outline: none; border-color: var(--accent-2); }
.form-actions { display: flex; align-items: center; justify-content: space-between; }
.counter { color: var(--text-dim); font-size: 12px; }
.btn-primary {
  background: var(--accent-2);
  border: none;
  color: #fff;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.comment-list { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.comment-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 16px;
}
.comment-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.comment-name { font-weight: 600; font-size: 14px; }
.comment-topic {
  font-size: 12px;
  color: var(--gold);
  background: rgba(255, 206, 84, 0.12);
  border: 1px solid rgba(255, 206, 84, 0.3);
  padding: 1px 8px;
  border-radius: 999px;
}
.comment-time { margin-left: auto; color: var(--text-dim); font-size: 12px; }
.comment-text { font-size: 14px; color: #d7dde6; white-space: pre-wrap; word-break: break-word; }
.empty { color: var(--text-dim); font-size: 14px; text-align: center; padding: 24px 0; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  width: min(900px, 100%);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
}
.modal-body { aspect-ratio: 16 / 9; background: #000; position: relative; }
.play-fallback {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: #ccc;
  white-space: nowrap;
}
.play-fallback a { color: #6c8cff; text-decoration: none; }
.modal-body iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---- 原生视频播放器 ---- */
.modal-box { max-height: 92vh; overflow-y: auto; }
.modal-body video { width: 100%; height: 100%; display: block; background: #000; }

.player-loading,
.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 20px;
  color: #cfd6e0;
  font-size: 15px;
  background: #000;
}
.player-error p { margin: 0; color: var(--text-dim); font-size: 14px; max-width: 80%; }
.player-error p.sub { font-size: 13px; color: #7d8797; }
.player-error .btn-open { margin-top: 4px; }
.btn-open {
  background: var(--accent-2);
  color: #fff;
  padding: 9px 20px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.player-bar {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--card-border);
}
.player-row { display: flex; align-items: flex-start; gap: 10px; }
.player-row[hidden] { display: none; }
.player-label { color: var(--text-dim); font-size: 13px; padding-top: 5px; white-space: nowrap; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; max-height: 92px; overflow-y: auto; }
.chip {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent-2); }
.chip.active {
  background: linear-gradient(135deg, var(--accent), #ff8a5f);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.player-tip { font-size: 12px; color: var(--text-dim); min-height: 16px; }
.chip-note { color: var(--text-dim); font-size: 12px; padding-top: 6px; line-height: 1.4; }
/* 选集标签更紧凑，80 集也能快速滚动定位 */
.ep-chip { font-size: 12px; padding: 4px 9px; border-radius: 8px; }
#ep-picker { max-height: 124px; }

/* ==================== 搜索 / 分类 ==================== */
.search-panel { margin-bottom: 28px; }

.search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 9px 10px 9px 16px;
  transition: 0.2s;
}
.search-form:focus-within {
  border-color: rgba(108, 140, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.13);
}
.search-ico { font-size: 15px; opacity: 0.7; flex: 0 0 auto; }
#search-q {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 6px 0;
}
#search-q::placeholder { color: #6b7484; }
#search-btn {
  flex: 0 0 auto;
  padding: 9px 20px;
  border-radius: 11px;
  font-size: 14px;
}

.cat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.18s;
}
.cat-tab:hover { color: #fff; border-color: rgba(255, 255, 255, 0.26); transform: translateY(-1px); }
.cat-tab.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 90, 95, 0.24), rgba(108, 140, 255, 0.24));
  border-color: rgba(255, 90, 95, 0.55);
  box-shadow: 0 6px 18px rgba(255, 90, 95, 0.14);
}
.cat-tab .cat-ico { font-size: 13px; }

/* ---- 结果区 ---- */
.search-results {
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
}
.search-results[hidden] { display: none; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.results-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.results-head h2 span { color: var(--text-dim); font-weight: 400; font-size: 13px; margin-left: 8px; }
.results-close {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: 0.15s;
}
.results-close:hover { color: #fff; border-color: var(--accent); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
}
.results-loading,
.results-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 26px 10px;
}

.r-card {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: 0.18s;
}
.r-card:hover { transform: translateY(-3px); }
.r-poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, hsl(var(--h, 220), 52%, 38%), hsl(calc(var(--h, 220) + 40), 50%, 22%));
  border: 1px solid var(--card-border);
}
.r-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.r-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
.r-letter-num { font-size: 46px; letter-spacing: -1px; }
.r-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  background: rgba(0, 0, 0, 0.66);
  color: #f0f4ff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.r-title {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.r-sub { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.results-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.results-status { font-size: 12.5px; color: var(--text-dim); }
#results-more { padding: 7px 18px; font-size: 13px; }
#results-more[hidden] { display: none; }

.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--card-border);
}

@media (max-width: 480px) {
  .form-row { flex-direction: column; }
  .card-title { font-size: 18px; }
}

/* ---------------- 视图切换（今日推荐 / 豆瓣榜单） ---------------- */
.view-tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 18px;
}
.view-tab {
  appearance: none;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-dim);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.view-tab:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.18); }
.view-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, rgba(255, 90, 95, 0.92), rgba(255, 128, 96, 0.8));
  box-shadow: 0 8px 22px rgba(255, 90, 95, 0.26);
}

/* ---------------- 豆瓣榜单 ---------------- */
.rank-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.rank-head h2 { margin: 0; font-size: 20px; }
.rank-head .hint { font-size: 12.5px; color: var(--text-dim); }

.rank-groups {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
}
.rank-group { display: flex; align-items: flex-start; gap: 10px; }
.rank-group-name {
  flex: 0 0 auto;
  width: 76px;
  padding-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.rank-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.rank-chip { font-size: 12.5px; padding: 5px 11px; }
.rank-chip i {
  font-style: normal;
  margin-left: 5px;
  font-size: 10.5px;
  opacity: 0.6;
}

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

.rk-card {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.rk-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: linear-gradient(
    135deg,
    hsl(var(--h, 220), 45%, 32%),
    hsl(calc(var(--h, 220) + 40), 45%, 18%)
  );
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.rk-card:hover .rk-poster {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}
.rk-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rk-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.24);
}
.rk-rank {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  min-width: 26px;
  padding: 1px 7px 2px;
  font-size: 14px;
  font-weight: 800;
  font-style: italic;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-bottom-right-radius: 10px;
  backdrop-filter: blur(4px);
}
.rk-rank.is-top-1 { background: linear-gradient(135deg, #ffd45e, #ee9f1c); color: #3a2600; }
.rk-rank.is-top-2 { background: linear-gradient(135deg, #e6ecf3, #a3afc0); color: #232a33; }
.rk-rank.is-top-3 { background: linear-gradient(135deg, #f0b27a, #c47a3d); color: #351c07; }
.rk-rate {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  padding: 1px 7px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
}
.rk-rate.is-none { color: var(--text-dim); font-weight: 500; }
.rk-title {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rk-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#rank-more[hidden] { display: none; }

@media (max-width: 560px) {
  .rank-grid { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 14px 10px; }
  .rank-group { flex-direction: column; gap: 6px; }
  .rank-group-name { width: auto; padding-top: 0; }
  .view-tab { padding: 8px 15px; font-size: 13px; }
}
