:root {
  --bg: #080a10;
  --bg-soft: #0e121b;
  --card: #141a26;
  --card-hover: #1b2230;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e9edf5;
  --muted: #8b93a7;
  --accent: #ff5fa2;
  --accent-2: #7c5cff;
  --gold: #ffcc57;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif,
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 60px;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(900px 500px at 15% -5%, rgba(255, 95, 162, 0.16), transparent 60%),
    radial-gradient(800px 500px at 90% 0%, rgba(124, 92, 255, 0.16), transparent 60%);
  z-index: 0;
}

.hero,
main,
.footer {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  padding: 0 20px;
}

.hero,
.footer {
  max-width: 1180px;
}

/* 表格需要比正文更宽，才能一屏放下 12 个区间列 */
main {
  max-width: 1640px;
}

.hero {
  padding-top: 44px;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 2px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.lang-select,
#yearRange,
#promptType {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}

.counter {
  margin-top: 22px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
}

.counter .percent {
  color: var(--accent);
  font-weight: 700;
}

.progress {
  margin-top: 8px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.toolbar {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

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

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(92deg, rgba(255, 95, 162, 0.22), rgba(124, 92, 255, 0.22));
  border-color: rgba(255, 95, 162, 0.35);
}

.btn-accent {
  background: linear-gradient(92deg, rgba(255, 95, 162, 0.22), rgba(124, 92, 255, 0.22));
  border-color: rgba(124, 92, 255, 0.4);
}

.year-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.year-count {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* ---------- 关闭图片时的纯文字表格（与导出图片同款：白底 / 已看绿底） ---------- */

.table-wrap.text-mode {
  background: #ffffff;
  border-color: #cfcfcf;
}

.sedai-table.text-mode thead th {
  background: #f2f3f5;
  color: #333333;
  border-bottom-color: #cfcfcf;
  border-right-color: #cfcfcf;
}

.sedai-table.text-mode thead th.corner {
  border-left-color: #cfcfcf;
}

.sedai-table.text-mode tbody th.year-cell {
  background: #f2f3f5;
  color: #333333;
  border-color: #cfcfcf;
}

/* 文字模式年份列更窄：默认 104px 的 min-width 会把表格撑出横向滚动条 */
.sedai-table.text-mode tbody th.year-cell {
  min-width: 0;
  padding: 8px 8px;
}

.sedai-table.text-mode thead th {
  padding: 8px 4px;
  font-size: 11px;
}

.sedai-table.text-mode tbody th.year-cell .year-title {
  font-size: 14px;
}

.sedai-table.text-mode tbody th.year-cell .year-count {
  background: #ffffff;
  color: #666666;
  border-color: #cfcfcf;
  font-size: 10px;
  padding: 1px 5px;
}

.sedai-table.text-mode tbody tr:hover th.year-cell {
  background: #e8eaed;
}

.sedai-table.text-mode tbody tr:hover td {
  background: #fafafa;
}

.sedai-table.text-mode td {
  border-bottom-color: #cfcfcf;
  border-right-color: #cfcfcf;
}

.sedai-table.text-mode td.empty {
  color: #999999;
}

.card.text-mode {
  background: #ffffff;
  border: none;
  border-radius: 0;
  min-height: 54px;
  display: flex;
  align-items: center;
}

.card.text-mode:hover {
  box-shadow: none;
  transform: none;
}

.card.text-mode .poster {
  display: none;
}

.card.text-mode .meta {
  padding: 5px 6px;
  font-size: 12px;
  width: 100%;
}

.card.text-mode .meta .name {
  -webkit-line-clamp: 3;
  height: auto;
  line-height: 1.4;
  color: #1f1f1f;
}

.card.text-mode.watched {
  background: #c6efce;
}

.card.text-mode.watched .meta .name {
  color: #0b6b2a;
  font-weight: 700;
}

.card.text-mode .badge-check {
  background: #1f9c46;
}

/* 文字模式下不显示右上角详情图标（点击格子本身即可查看详情） */
.card.text-mode .info-btn {
  display: none;
}

/* ---------- 表格布局 ---------- */

.table-wrap {
  margin-top: 22px;
  /* 不限制高度：所有年份行直接铺开，随页面正常滚动，表头 sticky 到视口顶部 */
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.012);
}

.sedai-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed; /* 列宽固定，否则长标题会把列撑开 */
}

.sedai-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  width: 118px;
  background: #0f141f;
  padding: 9px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.sedai-table thead th.corner {
  left: 0;
  z-index: 4;
  width: 104px;
  border-left: 1px solid var(--line);
}

.sedai-table tbody th.year-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #0f141f;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  padding: 10px 12px 10px 14px;
  text-align: left;
  vertical-align: middle;
  min-width: 104px;
}

.sedai-table tbody tr:hover th.year-cell {
  background: #131a27;
}

.sedai-table td {
  padding: 6px 6px 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.sedai-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.022);
}

.sedai-table td.empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding-top: 28px;
}

.card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
  z-index: 1;
}

.poster {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #10151f center / cover no-repeat;
  filter: grayscale(1) brightness(0.62);
  opacity: 0.72;
  transition: filter 0.25s ease, opacity 0.25s ease;
}

.card.watched .poster {
  filter: none;
  opacity: 1;
}

.card.watched {
  border-color: rgba(255, 95, 162, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 95, 162, 0.25), 0 10px 24px rgba(255, 95, 162, 0.12);
}

.badge-check {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s ease;
}

.card.watched .badge-check {
  opacity: 1;
  transform: scale(1);
}

.info-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: rgba(8, 10, 16, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.card:hover .info-btn {
  opacity: 1;
}

.info-btn:hover {
  background: var(--accent);
}

.meta {
  padding: 6px 7px 7px;
  font-size: 11px;
  min-width: 0;
}

.meta .name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.35;
  height: 2.7em;
  color: var(--muted);
}

.card.watched .meta .name {
  color: var(--text);
}

.meta .num {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.score {
  color: var(--gold);
  font-weight: 700;
}

.votes {
  color: var(--muted);
}

.footer {
  margin-top: 46px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

/* tooltip */
.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  background: rgba(12, 16, 24, 0.97);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.tooltip b {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.tooltip .row {
  color: var(--muted);
}

.tooltip .row span {
  color: var(--text);
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

/* 关键：display:grid 会覆盖 [hidden] 的默认 display:none，必须显式声明 */
.modal[hidden],
.tooltip[hidden],
.toast[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: pop 0.18s ease;
}

@keyframes pop {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(8, 10, 16, 0.7);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  padding: 18px;
}

.modal-body img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.modal-body h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.native-title {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
  word-break: break-all;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions a,
.modal-actions button {
  text-decoration: none;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(16, 20, 30, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: pop 0.18s ease;
}

/* prompt dialog */
.prompt-box {
  width: min(720px, 100%);
}

/* 导出后「试试随机模式」提示弹窗：无封面图，单列布局 */
.modal-card.hint .modal-body {
  display: block;
  padding: 22px 24px;
}

.modal-card.hint .modal-body h3 {
  margin: 0 0 10px;
}

.modal-card.hint .modal-body p {
  margin: 0 0 16px;
  line-height: 1.8;
  font-size: 13px;
  color: var(--muted);
}

.prompt-box .modal-body {
  display: block;
}

.prompt-text {
  width: 100%;
  min-height: 220px;
  margin-top: 10px;
  background: #0a0d14;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.7;
  resize: vertical;
  font-family: inherit;
}

@media (max-width: 640px) {
  h1 {
    font-size: 26px;
  }
  .hero,
  main,
  .footer {
    padding: 0 12px;
  }
  /* 手机：表格容器内横向滑动（年份列保持钉在左侧），纵向跟随页面滚动 */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sedai-table thead th {
    position: static;
  }
  .counter {
    font-size: 13px;
  }
  .modal-body {
    grid-template-columns: 1fr;
  }
  .modal-body img {
    max-width: 160px;
  }
}

/* 触屏设备：没有 hover，与 PC 一致默认隐藏信息角标（点击卡片直接弹详情，3 秒自动关），
   仅去掉 hover 位移效果 */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: none;
  }
}
