/* 交付版本 immutable-v1：缓存策略迁移时更新资源摘要，淘汰旧地址的响应头缓存。 */
/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f13;
  --bg-card: #1a1a24;
  --bg-card-hover: #22223a;
  --text: #e8e8f0;
  --text-dim: #9090a8;
  --text-muted: #aaaabd;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --green: #00b894;
  --orange: #fdcb6e;
  --red: #ff6b6b;
  --pink: #fd79a8;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

html, body {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

html {
  scroll-padding-top: calc(var(--tabs-scroll-offset, 5rem) + 8px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--accent-light); text-decoration: none; }
/* LVHA 顺序：:visited 须在 :hover 之前，否则已访问链接悬停时不变色。 */
a:visited { color: #8e86d1; }
a:hover { color: var(--pink); }

:where(a, button, input, select):focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--orange);
  color: #1a1a24;
  font-weight: 700;
}

.skip-link:focus { transform: translateY(0); color: #1a1a24; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 20px 0 16px;
  text-align: center;
  border-bottom: 1px solid rgba(108,92,231,0.3);
}

.logo {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

/* 渐变文字会把子元素的填充色设为透明；表情图标恢复默认填充才能正常显示。 */
.logo-icon {
  -webkit-text-fill-color: initial;
}

.subtitle {
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto;
  font-size: 0.95rem;
}

.update-info {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--green);
}

/* 窄屏的完整更新说明通常占两行；预留高度，避免数据到达后整页下移。 */
@media (max-width: 640px) {
  .update-info { min-height: 3.2em; }
}

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
  background: var(--bg-card);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* 年份在数据到达后才写入；预留“2026 新剧”的宽度，避免标签横向跳动。 */
.tab-year-label {
  display: inline-block;
  min-width: 4.9em;
}

.tab-year-label-variety {
  min-width: 5.9em;
}

/* 右侧还有分类没露出时显示渐隐和箭头（脚本按滚动位置切换 .has-more），滑到头后消失。 */
.tabs::after {
  content: '›';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: var(--accent-light);
  font-size: 1.4rem;
  font-weight: 700;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(26,26,36,0), var(--bg-card) 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.tabs.has-more::after { opacity: 1; }

.tabs .container {
  display: flex;
  gap: 4px;
  padding-top: 12px;
  padding-bottom: 12px;
  padding-right: 44px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* 宽屏九个分类一行放得下，不再为溢出箭头预留右侧空白。 */
@media (min-width: 1200px) {
  .tabs .container { padding-right: 20px; }
}

.tabs .container::-webkit-scrollbar {
  display: none;
}

/* 桌面左右内边距收紧到 14px，1200px 以上九个分类一行放得下。 */
.tab {
  min-height: 44px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.tab:hover {
  color: var(--text);
  background: rgba(108,92,231,0.15);
}

.tab.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 2px 10px rgba(108,92,231,0.4);
}

/* ── Filters ────────────────────────────────────────────── */
.filters {
  background: rgba(26,26,36,0.8);
  padding: 14px 0 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.filter-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.filter-group select {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.filter-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-check label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--text);
  cursor: pointer;
}

.filter-group[hidden] {
  display: none;
}

.search-box {
  flex: 1;
  min-width: 200px;
}

.filter-toggle {
  display: none;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid rgba(162,155,254,0.45);
  border-radius: 8px;
  background: transparent;
  color: var(--accent-light);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-toggle:hover {
  background: rgba(108,92,231,0.16);
  color: #fff;
}

.search-box input {
  width: 100%;
  padding: 8px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s;
  font-family: inherit;
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box input:focus-visible {
  border-color: var(--orange);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

/* 快捷筛选标签：一排可横向滑动的开关，点一下即生效。空容器不占高度。 */
.quick-filters {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  /* 给焦点环留出空间，避免被横向滚动容器裁掉。 */
  padding: 4px;
  margin-inline: -4px;
}

.quick-filters:empty { display: none; }
.quick-filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 4px 14px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent-light); color: #fff; }

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.chip:focus-visible { outline-offset: 1px; }

/* 可单独移除的生效条件 */
.chip.chip-remove { background: rgba(108,92,231,0.22); border-color: var(--accent-light); color: #fff; font-weight: 600; }

.filter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-top: 8px;
}

.result-summary {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.filter-reset,
.empty-action {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(162,155,254,0.45);
  border-radius: 6px;
  background: transparent;
  color: var(--accent-light);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-reset:hover,
.empty-action:hover {
  background: rgba(108,92,231,0.16);
  color: #fff;
}

/* ── Stats Bar ──────────────────────────────────────────── */
.stats-bar {
  padding: 12px 0;
  background: var(--bg);
}

.stats-bar .container {
  display: flex;
  gap: 8px 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* 统计数字兼作快捷筛选 */
.stat-shortcut {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.stat-shortcut:hover { border-color: var(--border); }

.stat-shortcut[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.16);
}

.stat-shortcut:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.back-to-top[hidden] { display: none; }

.back-to-top:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* 整张海报可点，行为与主按钮一致；徽标不拦截点击。 */
.card-poster-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-badges { pointer-events: none; }

.badge-legend {
  flex: 1 1 100%;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-align: center;
}

.badge-legend .badge {
  display: inline-block;
  padding: 0 6px;
  font-size: 0.68rem;
  letter-spacing: 0;
}

/* ── Show Grid ──────────────────────────────────────────── */
.content {
  padding: 20px 0 60px;
}

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

.load-more {
  display: block;
  min-height: 44px;
  margin: 24px auto 0;
  padding: 10px 22px;
  border: 1px solid rgba(162,155,254,0.45);
  border-radius: 8px;
  background: rgba(108,92,231,0.12);
  color: var(--accent-light);
  font: inherit;
  font-weight: 700;
  text-align: center;
  user-select: none;
}

.load-more[hidden] {
  display: none;
}

#loadMoreButton {
  margin-left: 12px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--accent-light);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* ── Show Card ──────────────────────────────────────────── */
.show-card {
  display: block;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s, background 0.3s;
  position: relative;
  border: 1px solid rgba(255,255,255,0.04);
  color: inherit;
  text-decoration: none;
}

.show-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(108,92,231,0.3);
  background: var(--bg-card-hover);
}

.show-card:focus-within {
  border-color: rgba(162,155,254,0.65);
  box-shadow: 0 0 0 2px rgba(162,155,254,0.18), var(--shadow);
}

.show-card:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.card-poster {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a2e, #2d2d44);
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.show-card:hover .card-poster img {
  transform: scale(1.05);
}

.card-poster .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 4rem;
  line-height: 1.2;
}

.card-poster .placeholder > span:first-child { opacity: 0.3; }

/* 没有海报或加载失败时，占位里写出片名。 */
.card-poster .placeholder-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.card-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  z-index: 2;
}

.badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-score {
  background: rgba(253,203,110,0.9);
  color: #1a1a24;
}

/* 周榜名次：金底深字，明暗海报上都清楚。 */
.badge-rank {
  background: #f5c542;
  color: #1a1a24;
}

.badge-new {
  background: #a82f3c;
  color: #fff;
}

.badge-complete {
  background: #087b60;
  color: #fff;
}

.badge-ongoing {
  background: var(--accent);
  color: #fff;
}

.badge-classic {
  background: #a43263;
  color: #fff;
}

.badge-playable {
  background: #0b6b3a;
  color: #fff;
}

.badge-cover-pending {
  background: #a3540c;
  color: #fff;
}

.badge-ai {
  background: linear-gradient(135deg, #5865c9, #764ba2);
  color: #fff;
}

.card-ai-reason {
  font-size: 0.78rem;
  color: var(--accent-light);
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 6px 8px;
  background: rgba(108,92,231,0.08);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  /* 上下留白用透明边框而非 padding：overflow 在 padding 边界裁剪，padding 会露出被截断的第三行。 */
  padding-block: 0;
  border-block: 6px solid transparent;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-body {
  padding: 14px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.meta-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  background: rgba(108,92,231,0.15);
  color: var(--accent-light);
}

.meta-tag.region {
  background: rgba(0,184,148,0.15);
  color: var(--green);
}

.card-desc {
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  max-height: 4.8em;
  overflow: hidden;
}

/* 状态与播放量合并为一行，空间不足时自然换行。 */
.card-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
  gap: 2px 10px;
}

.card-status {
  font-size: 0.78rem;
  color: var(--green);
  font-weight: 600;
}

.card-status.ongoing {
  color: var(--accent-light);
}

.card-views {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.card-actors {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommend-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--pink));
  border-radius: 2px;
  margin-bottom: 8px;
  opacity: 0.55;
  transition: opacity 0.3s;
}

.show-card:hover .recommend-bar {
  opacity: 1;
}

.show-card:focus-within .recommend-bar { opacity: 1; }

.card-primary-action { margin: 10px 0 12px; }

.card-primary-action .card-action {
  width: 100%;
  min-height: 44px;
  background: var(--accent);
  color: #fff;
  font-size: 0.86rem;
}

.card-primary-action .card-action:hover {
  background: var(--accent-light);
  color: #161525;
}

/* 没有播放源时主操作降为次要样式，只用于查看资料。 */
.card-primary-action .card-action.is-info {
  min-height: 36px;
  border: 1px solid rgba(162,155,254,0.45);
  background: transparent;
  color: var(--accent-light);
  font-weight: 600;
}

.card-primary-action .card-action.is-info:hover {
  background: rgba(108,92,231,0.18);
  color: #fff;
}

/* “想看 / 看过”标记：只保存在本机浏览器。 */
.card-marks {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
}

.card-mark {
  flex: 1 1 0;
  min-height: 32px;
  padding: 2px 8px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.card-mark:hover { border-color: var(--accent-light); color: #fff; }

.card-mark[aria-pressed="true"] {
  border-color: var(--green);
  background: rgba(0,184,148,0.16);
  color: #7fe8d0;
  font-weight: 700;
}

.card-mark[aria-pressed="true"]::before { content: "✓ "; }

.card-mark[data-mark="want"][aria-pressed="true"] {
  border-color: var(--orange);
  background: rgba(253,203,110,0.14);
  color: var(--orange);
}

/* 看过的卡片压暗海报和标题，文字仍保持可读对比度。 */
.show-card.is-seen .card-poster img,
.show-card.is-seen .card-poster .placeholder { opacity: 0.4; }
.show-card.is-seen .card-title { color: var(--text-muted); }

.meta-tag.category {
  background: rgba(253,203,110,0.16);
  color: var(--orange);
  font-weight: 700;
}

/* 资料来源收为一行小号文字链接；每个链接至少 24px 高，保持可点击。 */
.card-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 2px;
  margin-top: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.card-links-label {
  margin-right: 4px;
  color: var(--text-dim);
}

.card-link {
  display: inline-flex;
  align-items: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 6px;
  border-radius: 4px;
  color: var(--accent-light);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(162,155,254,0.5);
  text-underline-offset: 3px;
}

.card-link:hover {
  background: rgba(108,92,231,0.18);
  color: #fff;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card-action {
  flex: 1 1 92px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.card-action:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.card-action.source-tmdb {
  background: linear-gradient(135deg, #01b4e4, #90cea1);
  color: #071820;
}

.card-action.source-tmdb:hover {
  background: linear-gradient(135deg, #20c6f2, #a7e5b7);
  color: #041016;
}

/* ── Loading & Empty ────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 60px 0;
}

/* 骨架已占位时只保留读屏可读的加载提示，不再在网格下方插入转圈区块。 */
.show-grid[aria-busy="true"] ~ .loading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skeleton-card {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.skeleton-poster {
  width: 100%;
  aspect-ratio: 3/4;
}

.skeleton-body {
  padding: 14px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 12px;
  border-radius: 6px;
}

.skeleton-line-title {
  width: 72%;
  height: 18px;
}

.skeleton-line-medium { width: 84%; }
.skeleton-line-short { width: 42%; }

.skeleton-shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.11) 37%, rgba(255,255,255,0.05) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(108,92,231,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-dim);
  font-size: 1.1rem;
}

.empty-action { margin-top: 16px; }

/* ── Footer ─────────────────────────────────────────────── */
.footer {
  padding: 30px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.footer-note {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* 窄屏卡片在正文里显示的标签行；宽屏海报足够大，标签仍叠在海报上。 */
.card-badges-inline {
  display: none;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 14px; }
  .header { padding: 24px 0 18px; }
  .logo { font-size: 1.5rem; }
  .subtitle { font-size: 0.88rem; }
  .show-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .card-body { padding: 12px; }
  .card-title { font-size: 0.95rem; }
  .card-desc { font-size: 1rem; -webkit-line-clamp: 3; max-height: 4.8em; }
  .card-actions { flex-direction: row; gap: 6px; margin-top: 8px; }
  .card-action { flex: 1 1 45%; min-height: 44px; padding: 8px 8px; font-size: 0.85rem; }
  .filter-row { gap: 8px; }
  .filter-controls { order: 2; flex: 1 1 100%; gap: 8px; }
  .filter-group { flex: 1 1 45%; min-width: 0; }
  .filter-group select { width: 100%; min-height: 44px; padding: 8px 10px; font-size: 0.9rem; }
  .search-box { order: 1; flex: 1 1 100%; min-width: 0; }
  .search-box input { padding: 10px 14px; font-size: 0.95rem; }
  .tab { padding: 8px 14px; font-size: 0.82rem; }
  /* 窄屏把统计压成一行，让第一张卡片更早出现。 */
  .stats-bar { padding: 6px 0; }
  .stats-bar .container { gap: 2px 6px; align-items: center; }
  .stat-item { display: flex; align-items: baseline; gap: 4px; padding: 6px 6px; }
  .stat-num { display: inline; font-size: 1rem; }
  .stat-label { font-size: 0.72rem; }
  .badge-legend { font-size: 0.7rem; }
}

@media (max-width: 480px) {
  .container { padding: 0 10px; }
  .header { padding: 20px 0 14px; }
  .logo { font-size: 1.3rem; }
  .show-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .show-card { grid-template-columns: 112px minmax(0, 1fr); display: grid; align-items: start; }
  .card-poster { height: auto; min-height: 172px; aspect-ratio: 3/4; align-self: start; }
  .card-poster .placeholder { font-size: 2.4rem; }
  .card-body { padding: 12px; min-width: 0; }
  .card-title { font-size: 1rem; }
  /* 112px 宽的海报叠 4–6 个标签会遮住近一半画面；窄屏改为标题下的紧凑标签行。 */
  .card-badges { display: none; }
  .card-badges-inline { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
  .card-badges-inline .badge { padding: 2px 6px; font-size: 0.68rem; letter-spacing: 0; line-height: 1.5; }
  .card-meta { gap: 4px; }
  .meta-tag { padding: 3px 7px; font-size: 0.72rem; }
  .card-actors { font-size: 0.8rem; }
  .card-desc { font-size: 1rem; -webkit-line-clamp: 2; max-height: 3.2em; line-height: 1.6; margin-bottom: 8px; }
  .card-ai-reason { -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
  .card-primary-action { margin: 8px 0 10px; }
  .card-primary-action .card-action { min-height: 44px; font-size: 0.82rem; }
  .card-marks { margin-bottom: 8px; }
  .card-mark { min-height: 40px; font-size: 0.82rem; }
  .chip { min-height: 40px; padding: 6px 14px; }
  .card-actions { flex-wrap: wrap; gap: 5px; }
  .card-action { flex: 1 1 45%; min-height: 44px; font-size: 0.85rem; }
  .filter-row { display: grid; grid-template-columns: minmax(0, 1fr); }
  .filter-toggle { display: block; order: 2; width: 100%; }
  .filter-controls { display: none; order: 3; flex-direction: column; align-items: stretch; width: 100%; }
  .filter-controls.is-open { display: flex; }
  .filter-group { flex: 1 1 100%; }
  .filter-group select { min-height: 44px; padding: 10px 12px; font-size: 1rem; }
  .skeleton-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: start; }
  .skeleton-poster { min-height: 172px; }
  .skeleton-body { min-width: 0; }
  .search-box input { padding: 12px 14px; font-size: 1rem; }
  .tab { padding: 10px 14px; font-size: 0.82rem; }
  .filter-meta { align-items: flex-start; flex-direction: column; }
  .filter-reset,
  .empty-action { width: 100%; min-height: 44px; }
}

/* Disable hover transform on touch devices to prevent sticky hover jitter */
@media (hover: none) {
  .show-card:hover {
    transform: none;
    box-shadow: none;
    border-color: rgba(255,255,255,0.04);
    background: var(--bg-card);
  }
  .show-card:hover .card-poster img {
    transform: none;
  }
  .show-card:hover .recommend-bar {
    opacity: 0.55;
  }
  .card-action:hover {
    transform: none;
  }
}

/* ── Animations ─────────────────────────────────────────── */
.not-found { padding-top: 15vh; text-align: center; }
.not-found p { margin: 24px 0; }
.not-found .card-action { display: inline-flex; }
.not-found .card-action.primary { padding: 10px 22px; background: var(--accent); color: #fff; }
.not-found .card-action.primary:hover { background: var(--accent-light); color: #161525; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.show-card {
  animation: fadeInUp 0.4s ease-out both;
}

/* 仅在切换标签/首次加载(.animate)时播放入场动画;筛选/搜索/排序的即时重渲不重放动画,避免抖动 */
.show-grid:not(.animate) .show-card {
  animation: none;
}

/* 尊重系统"减少动态效果"偏好:关闭入场/旋转/悬停位移等非必要动效 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .show-card { animation: none; }
  .show-card:hover { transform: none; }
  .show-card:hover .card-poster img { transform: none; }
}

/* ── 紧凑海报网格（推荐标签）─────────────────────────────── */
/* 卡片只留海报、片名、评分和状态，点开看详情；时间表标签仍用上面的完整卡片。 */
.show-grid.is-compact {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.show-grid.is-compact .show-card { display: block; }
.show-grid.is-compact .card-poster { height: auto; min-height: 0; aspect-ratio: 2/3; }
.show-grid.is-compact .card-poster .placeholder { font-size: 2.6rem; }
.show-grid.is-compact .card-body { padding: 10px 12px 12px; }
.show-grid.is-compact .card-title { font-size: 0.95rem; margin-bottom: 4px; }
.show-grid.is-compact .recommend-bar { margin-bottom: 6px; }
.show-grid.is-compact .card-badges { display: flex; top: 8px; left: 8px; gap: 4px; }
.show-grid.is-compact .card-badges .badge { padding: 2px 7px; font-size: 0.68rem; }

/* 片名链接铺满整张卡片，卡片任意位置都能点开详情；焦点环画在卡片上。 */
.card-open,
.card-open:visited { color: inherit; }
.card-open::after { content: ""; position: absolute; inset: 0; z-index: 3; }
.card-open:focus-visible { outline: none; }
.show-card:has(.card-open:focus-visible) { outline: 3px solid var(--orange); outline-offset: 3px; }

.card-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.card-sub .card-status { font-size: inherit; }
.card-sub .meta-tag { align-self: center; }
.card-score { color: var(--orange); font-weight: 700; white-space: nowrap; }

.card-play-tag,
.card-mark-pill {
  position: absolute;
  z-index: 2;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.6;
  pointer-events: none;
}

.card-play-tag { left: 8px; bottom: 8px; background: #0b6b3f; color: #fff; }
.card-mark-pill { top: 8px; right: 8px; background: rgba(15,15,19,0.88); color: var(--orange); border: 1px solid currentColor; }
.show-card.is-seen .card-mark-pill { color: #7fe8d0; }
.card-mark-pill[hidden] { display: none; }

.show-grid.is-compact .skeleton-card { display: block; }
.show-grid.is-compact .skeleton-poster { min-height: 0; aspect-ratio: 2/3; }
.show-grid.is-compact .skeleton-line:nth-child(n+3) { display: none; }

@media (max-width: 768px) {
  .show-grid.is-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}

@media (max-width: 480px) {
  .show-grid.is-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .show-grid.is-compact .card-body { padding: 8px; }
  .show-grid.is-compact .card-title { font-size: 0.84rem; line-height: 1.35; }
  .show-grid.is-compact .card-badges { top: 5px; left: 5px; }
  .show-grid.is-compact .card-badges .badge { padding: 1px 5px; font-size: 0.62rem; letter-spacing: 0; }
  .card-sub { font-size: 0.72rem; gap: 0 6px; }
  .card-play-tag { left: 5px; bottom: 5px; font-size: 0.62rem; padding: 0 5px; }
  .card-mark-pill { top: 5px; right: 5px; font-size: 0.62rem; padding: 0 5px; }
}

/* ── 详情层 ──────────────────────────────────────────────── */
html:has(.detail[open]) { overflow: hidden; }

.detail {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  max-height: 86vh;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}

.detail-notice { padding-block: 12px; color: var(--text-muted); }

.detail::backdrop { background: rgba(0,0,0,0.62); }

.detail-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(15,15,19,0.72);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.detail-close:hover { background: var(--accent); }

.detail-body {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px 20px;
  padding: 22px 22px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-poster { height: auto; min-height: 0; aspect-ratio: 2/3; border-radius: 10px; align-self: start; }
.detail-poster > img, .detail-poster > .placeholder { position: absolute; inset: 0; }
.detail-title { padding-right: 44px; font-size: 1.4rem; line-height: 1.3; overflow-wrap: anywhere; }
.detail-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; }
.detail-status,
.detail-actors { margin-top: 8px; font-size: 0.9rem; color: var(--text-muted); }
.detail-status .card-status { font-size: inherit; }
.detail-label { margin-right: 8px; color: var(--text-dim); font-size: 0.82rem; }
.detail-text { grid-column: 1 / -1; }
.detail-desc { font-size: 1rem; line-height: 1.7; overflow-wrap: anywhere; }
.detail-text .card-ai-reason { margin-top: 12px; }
.detail-text .card-links { margin-top: 12px; }

.detail-bar {
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-card);
}

.detail-bar .card-action.primary {
  flex: 2 1 0;
  min-height: 44px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
}

.detail-bar .card-action.primary:hover { background: var(--accent-light); color: #161525; }

.detail-bar .card-action.primary.is-info {
  border: 1px solid rgba(162,155,254,0.45);
  background: transparent;
  color: var(--accent-light);
}

.detail-bar .card-action.primary.is-info:hover { background: rgba(108,92,231,0.18); color: #fff; }
.detail-bar .card-marks { flex: 2 1 0; margin: 0; }
.detail-bar .card-mark { min-height: 44px; font-size: 0.88rem; }

.detail-share {
  flex: 0 0 auto;
  min-width: 56px;
  min-height: 44px;
  padding: 2px 12px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.detail-share:hover { border-color: var(--accent-light); color: #fff; }

@media (max-width: 600px) {
  .detail {
    width: 100%;
    max-height: 90vh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }
  .detail-sheet { max-height: 90vh; }
  .detail-body { grid-template-columns: 96px minmax(0, 1fr); gap: 12px 14px; padding: 16px 16px 12px; }
  .detail-title { font-size: 1.15rem; }
  /* 关闭按钮占右上角，标签行让开它。 */
  .detail-badges { margin-right: 40px; }
  .detail-bar { flex-wrap: wrap; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .detail-bar .card-action.primary { flex: 1 1 100%; }
  .detail-bar .card-marks { flex: 1 1 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .detail[open] { animation: fadeInUp 0.22s ease-out both; }
}

/* ── External Source Cards ──────────────────────────────────── */
.card-schedule {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.schedule-date {
  color: var(--text);
  font-weight: 600;
}

.schedule-ep {
  background: rgba(108,92,231,0.2);
  color: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.78rem;
}

.schedule-time {
  color: var(--text-dim);
}

.schedule-rating {
  color: var(--orange);
  font-weight: 600;
}

.card-source-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* External source action buttons */
.card-action.source-tvmaze-link {
  background: linear-gradient(135deg, #1868be, #3757c4);
  color: #fff;
}
.card-action.source-tvmaze-link:hover {
  background: linear-gradient(135deg, #2075c9, #4367d0);
  color: #fff;
}
