:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #dde5ee;
  --line-strong: #c8d3df;
  --text: #172334;
  --muted: #68778a;
  --accent: #0aa7bd;
  --accent-strong: #087d92;
  --green: #12865a;
  --red: #b33a3a;
  --amber: #a06b12;
  --shadow: 0 16px 45px rgba(23, 35, 52, .08);
}

* {
  box-sizing: border-box;
}

/* hidden 属性优先级要盖过下方 .filters/.cloud-hint 等 display 规则 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 max(28px, calc((100vw - 1240px) / 2));
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
}

.brand-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
}

.brand-tagline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
}

.shell {
  width: min(1240px, calc(100vw - 40px));
  margin: 46px auto 72px;
}

.search-zone {
  display: grid;
  gap: 20px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-box {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 0 24px;
}

.search-icon {
  width: 20px;
  height: 20px;
  border: 3px solid var(--accent);
  border-radius: 999px;
  position: relative;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 3px;
  right: -8px;
  bottom: -5px;
  background: var(--accent);
  transform: rotate(45deg);
  border-radius: 4px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 20px;
  background: transparent;
}

.search-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.search-button:hover {
  background: var(--accent-strong);
}

.filters {
  display: flex;
  gap: 10px;
}

.filter-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.filter-button:hover {
  color: var(--text);
  border-color: var(--muted);
}

.filter-button.active {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: rgba(10, 167, 189, .08);
}

.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7edf4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-button.active .filter-count {
  background: var(--accent);
  color: #fff;
}

.filter-count:empty {
  display: none;
}

/* 首屏引导区：热门词 + 空状态。出结果后整块隐藏。 */
.guide {
  margin-top: 26px;
}

.hot-zone {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.hot-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.hot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hot-chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.hot-chip:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: rgba(10, 167, 189, .08);
}

/* 首屏热门资源榜：5 列（短剧/电影/电视剧/动漫/综艺），每列榜首出海报卡 */
.rank-zone {
  margin-top: 28px;
}

.rank-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.rank-title {
  font-size: 17px;
  font-weight: 800;
}

.rank-sub {
  font-size: 13px;
  color: var(--muted);
}

.rank-boards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.rank-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.rank-col-title {
  font-size: 15px;
  font-weight: 800;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.rank-hero {
  display: block;
  position: relative;
  text-decoration: none;
  color: inherit;
}

.rank-hero-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  /* 竖版海报按 2:3 铺满列宽会把 4 名之后全推到首屏外，所以限高；
     标题本来就在图下面重复了一遍，裁掉海报底部的片名不影响识别 */
  max-height: 200px;
  object-fit: cover;
  object-position: center top;
  border-radius: 10px;
  background: rgba(10, 167, 189, .08);
}

.rank-hero-blank {
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  color: var(--accent-strong);
}

.rank-hero-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.rank-hero-meta {
  margin: 9px 0 4px;
}

.rank-hero-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-hero:hover .rank-hero-title {
  color: var(--accent-strong);
}

.rank-rows {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  text-decoration: none;
  color: inherit;
}

.rank-no {
  flex: 0 0 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 榜首已经是海报卡，这里给第 2、3 名上色阶，和主流热榜的视觉习惯对齐 */
.rank-rows li:nth-child(1) .rank-no {
  color: #e06a1b;
}

.rank-rows li:nth-child(2) .rank-no {
  color: #d19a1a;
}

.rank-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row:hover .rank-name {
  color: var(--accent-strong);
}

@media (max-width: 1100px) {
  .rank-boards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .rank-boards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .rank-col {
    padding: 12px;
  }

  /* 手机上 5 个榜 ×8 条要滚 5 屏，每榜砍到前 5 名 */
  .rank-rows li:nth-child(n+5) {
    display: none;
  }
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 64px 20px 40px;
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 167, 189, .1);
  position: relative;
}

.empty-icon::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid var(--accent);
  border-radius: 999px;
}

.empty-icon::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 3px;
  background: var(--accent);
  border-radius: 4px;
  transform: rotate(45deg);
  right: 17px;
  bottom: 17px;
}

.empty-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.empty-sub {
  font-size: 14px;
  color: var(--muted);
}

.cloud-hint {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 14px;
}

.cloud-hint-tip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #c2410c;
  font-weight: 800;
}

.cloud-hint-switch {
  border: 1px solid var(--accent);
  background: rgba(10, 167, 189, .08);
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease;
}

.cloud-hint-switch:hover {
  background: rgba(10, 167, 189, .18);
}

.cloud-hint-switch b {
  color: var(--accent-strong);
}

.list-footer {
  margin-top: 18px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.list-footer:empty {
  display: none;
}

.load-sentinel {
  height: 1px;
}

.result-list {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.result-card {
  min-height: 142px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cover {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  background: #e7edf4;
  object-fit: cover;
}

.cover-fallback {
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-size: 34px;
  font-weight: 900;
}

.result-main {
  min-width: 0;
}

.result-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.result-side {
  width: 148px;
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

.visit-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
}

.visit-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.visit-button:hover {
  background: var(--accent-strong);
}

.result-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
}

.result-status--pending {
  color: var(--muted);
}

.result-status--checking {
  color: var(--accent-strong);
}

.result-status--ok {
  color: #18a058; /* 绿色：链接有效 */
}

.result-status--dead {
  color: #9aa6b2; /* 灰色：已失效 */
}

.result-status--error {
  color: #d98c00; /* 橙色：无法校验 */
}

/* 校验中的小转圈 */
.status-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* 失效记录整条置灰 */
.result-card--dead {
  opacity: 0.55;
}

.result-card--dead .result-title {
  color: var(--muted);
}

.visit-button.disabled {
  pointer-events: none;
  background: #b9c5d1;
}

.empty {
  padding: 46px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  min-height: 140px;
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading-text {
  transition: opacity .2s ease;
}

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

@media (max-width: 760px) {
  .topbar {
    height: auto;
    padding: 14px 16px;
    align-items: flex-start;
    gap: 14px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .brand-name {
    font-size: 20px;
  }

  .brand-tagline {
    font-size: 12px;
  }

  .shell {
    width: min(100vw - 24px, 680px);
    margin-top: 18px;
  }

  .search-form {
    grid-template-columns: 1fr auto;
    min-height: 56px;
  }

  .search-box input {
    font-size: 16px;
  }

  .search-button {
    min-height: 48px;
    padding: 0 22px;
    font-size: 16px;
  }

  .result-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .cover {
    width: 72px;
    height: 72px;
  }

  .result-side {
    grid-column: 1 / -1;
    width: 100%;
    grid-template-columns: 1fr;
    justify-items: end;
  }

  .visit-button {
    min-width: 120px;
    padding: 0 18px;
  }
}

/* ---------------------------------------------------------- 资源弹层 */

.dialog-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 36, .45);
}

.dialog {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 28px 28px 20px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(16, 24, 36, .22);
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: #98a5b4;
  cursor: pointer;
}
.dialog-close:hover { color: #4a5768; }

.dialog-head { font-size: 18px; font-weight: 800; }
.dialog-head b { color: #0aa7bd; }

.dialog-hint {
  margin-top: 10px;
  font-size: 13px;
  color: #68778a;
}

.dialog-qr {
  display: grid;
  place-items: center;
  width: 232px;
  height: 232px;
  margin: 18px auto 0;
  padding: 8px;
  border: 1px solid #e4eaf1;
  border-radius: 10px;
}
.dialog-qr svg { display: block; width: 100%; height: 100%; }
.qr-loading { font-size: 13px; color: #8a97a7; }

.dialog-title {
  margin-top: 16px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  word-break: break-all;
}

.dialog-link {
  margin-top: 8px;
  font-size: 13px;
  color: #68778a;
  word-break: break-all;
}
.dialog-link a { color: #0aa7bd; }

.dialog-actions { margin-top: 16px; }

.dialog-copy {
  min-height: 40px;
  padding: 0 26px;
  border: 1px solid #0aa7bd;
  border-radius: 8px;
  background: #fff;
  color: #0aa7bd;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.dialog-copy:hover { background: #f0fbfd; }

.dialog-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed #e4eaf1;
  font-size: 12px;
  line-height: 1.7;
  color: #8a97a7;
  text-align: left;
}

@media (max-width: 480px) {
  .dialog { padding: 24px 18px 16px; }
  .dialog-qr { width: 200px; height: 200px; }
}
