/* ============================================================
   style.css — 「05 / RESOURCES」增量样式
   ------------------------------------------------------------
   只服务四块内容：
     1. B 站教学排行榜
     2. AI 找视频（搜索区 / 结果卡片 / 历史）
     3. 内置使用说明（折叠面板）
     4. AI 设置抽屉
   全部复用 index.html 中的设计令牌（--bg-blue / --ink / --radius /
   --shadow-sm / --ease ...），不覆盖任何既有模块的选择器。
   ============================================================ */

/* ------------------------------------------------------------
   8.1 区块骨架（杂志感卡片 + 编号徽标）
   ------------------------------------------------------------ */
.res-module {
  position: relative;
  padding: clamp(22px, 3.4vw, 34px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.res-module + .res-module {
  margin-top: 26px;
}

/* 右上角的淡蓝光斑：让大卡片不至于太平。 */
.res-module::after {
  content: "";
  position: absolute;
  top: -120px;
  right: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.09), transparent 70%);
  pointer-events: none;
}

.res-module--ai {
  background:
    radial-gradient(640px 220px at 6% -14%, rgba(37, 99, 235, 0.1), transparent 72%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
}

.res-module-head {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 28px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px dashed var(--line);
}

.res-module-head--split {
  align-items: flex-start;
}

.res-module-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.res-module-title h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.06rem, 1.5vw, 1.22rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.res-module-title p {
  max-width: 62ch;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.8;
}

/* 01 / 02 / 03 式的编号徽标，延续页面杂志感。 */
.res-badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 12px;
  background: var(--surface-tint);
  color: var(--blue-deep);
  font-family: var(--mono);
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1;
}

.res-badge--ai {
  border-color: transparent;
  background: linear-gradient(135deg, #1d4ed8 0%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 12px 26px -16px rgba(37, 99, 235, 0.95);
}

/* 引擎状态胶囊：未配置 / 云端 / 本地 */
.ai-mode-pill {
  flex: 0 0 auto;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ai-mode-pill[data-state="cloud"] {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--surface-tint);
  color: var(--blue-deep);
}

.ai-mode-pill[data-state="local"] {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(15, 118, 110, 0.08);
  color: var(--green);
}

.res-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ------------------------------------------------------------
   8.2 分类筛选标签 & 排序切换
   ------------------------------------------------------------ */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-input);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.24s ease, border-color 0.24s ease, color 0.24s ease, transform 0.24s var(--ease);
}

.chip:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--surface-tint);
  color: var(--blue-deep);
  transform: translateY(-1px);
}

.chip.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, #1d4ed8 0%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 10px 22px -14px rgba(37, 99, 235, 0.9);
}

.sort-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-tint);
}

.sort-btn {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.sort-btn:hover {
  color: var(--blue-deep);
}

.sort-btn.is-active {
  background: var(--surface-solid);
  color: var(--blue-deep);
  box-shadow: 0 1px 3px rgba(16, 42, 80, 0.12);
}

/* ------------------------------------------------------------
   8.3 排行榜列表（序号 / 标题 / 播放量 / 分类 / 打开）
   ------------------------------------------------------------ */
.rank-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-item {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 92px 68px 68px;
  align-items: center;
  gap: 14px;
  padding: 13px 12px;
  border-radius: 14px;
  border-bottom: 1px solid var(--line);
  transition: transform 0.32s var(--ease), background 0.32s ease, box-shadow 0.32s ease;
}

.rank-item:last-child {
  border-bottom-color: transparent;
}

/* hover：背景渐变 + 右移 8px */
.rank-item:hover {
  transform: translateX(8px);
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.085), rgba(8, 145, 178, 0.035) 62%, transparent);
  box-shadow: inset 2px 0 0 rgba(37, 99, 235, 0.55);
}

.rank-no {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

/* 前三名：渐变强调色 + 左侧小竖标 */
.rank-no--top {
  color: transparent;
  background: linear-gradient(135deg, #1d4ed8 0%, #0891b2 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.rank-item--top .rank-no {
  position: relative;
}

.rank-item--top .rank-no::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -9px;
  width: 3px;
  height: 15px;
  border-radius: 99px;
  background: linear-gradient(180deg, #1d4ed8, #0891b2);
  transform: translateY(-50%);
}

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

.rank-title {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: -0.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.6;
}

.rank-meta .rank-dot {
  color: var(--line-strong);
}

.rank-author {
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-grade {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  font-size: 0.64rem;
  letter-spacing: 0.02em;
}

.rank-play-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  text-align: right;
}

.rank-play {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rank-play-label {
  color: var(--muted);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
}

.rank-fav {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  white-space: nowrap;
}

.rank-cat {
  justify-self: start;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--surface-tint);
  color: var(--blue-deep);
  font-size: 0.64rem;
  font-weight: 720;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.rank-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  font-size: 0.71rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.24s ease, color 0.24s ease, background 0.24s ease, box-shadow 0.24s ease;
}

.rank-open:hover {
  border-color: rgba(37, 99, 235, 0.4);
  background: var(--surface-tint);
  color: var(--blue-deep);
  box-shadow: 0 10px 22px -16px rgba(37, 99, 235, 0.8);
}

.rank-empty {
  margin: 22px 0 6px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ------------------------------------------------------------
   8.4 AI 找视频：搜索区
   ------------------------------------------------------------ */
.finder-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.finder-input-wrap {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  padding: 0 8px 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-input);
  transition: border-color 0.24s ease, box-shadow 0.24s ease, background 0.24s ease;
}

.finder-input-wrap:focus-within {
  border-color: rgba(37, 99, 235, 0.55);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.finder-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 50px;
  padding: 0 10px 0 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
}

.finder-input:focus {
  outline: none;
}

.finder-input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.finder-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.finder-icon-btn {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease;
}

.finder-icon-btn svg {
  width: 19px;
  height: 19px;
}

.finder-icon-btn:hover {
  background: var(--surface-tint);
  color: var(--blue-deep);
}

/* 识别中：按钮填色 + 向外扩散的脉冲圈 */
.finder-mic.is-listening {
  background: linear-gradient(135deg, #dc2626 0%, #f97316 100%);
  color: #fff;
}

.finder-mic.is-listening::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid rgba(220, 38, 38, 0.55);
  border-radius: 50%;
  animation: micPulse 1.4s ease-out infinite;
  pointer-events: none;
}

@keyframes micPulse {
  0% {
    opacity: 0.85;
    transform: scale(0.92);
  }
  100% {
    opacity: 0;
    transform: scale(1.45);
  }
}

.finder-submit {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 22px;
  white-space: nowrap;
}

.finder-spark {
  font-size: 0.9rem;
}

.finder-gear {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.22s ease, color 0.22s ease, background 0.22s ease, transform 0.3s var(--ease);
}

.finder-gear svg {
  width: 21px;
  height: 21px;
  transition: transform 0.5s var(--ease);
}

.finder-gear:hover {
  border-color: rgba(37, 99, 235, 0.4);
  background: var(--surface-tint);
  color: var(--blue-deep);
}

.finder-gear:hover svg {
  transform: rotate(42deg);
}

/* 未配置 AI 时的小红点 */
.gear-dot {
  display: none;
  position: absolute;
  top: 9px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 4px rgba(239, 68, 68, 0.18);
  animation: dotPulse 2s ease-in-out infinite;
}

.finder-gear.has-dot .gear-dot {
  display: block;
}

@keyframes dotPulse {
  0%, 100% {
    box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 3px rgba(239, 68, 68, 0.16);
  }
  50% {
    box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 7px rgba(239, 68, 68, 0);
  }
}

.finder-hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.7;
}

.finder-error {
  margin: 10px 2px 0;
  color: var(--rose);
  font-size: 0.76rem;
  line-height: 1.7;
}

.finder-error:empty {
  display: none;
}

/* ------------------------------------------------------------
   8.5 未配置引导 / 生成进度 / 停止
   ------------------------------------------------------------ */
.finder-guide {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px dashed rgba(37, 99, 235, 0.35);
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.07), rgba(8, 145, 178, 0.05));
}

.finder-guide-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
}

.finder-guide p {
  flex: 1 1 220px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.79rem;
  line-height: 1.7;
}

.finder-guide p strong {
  color: var(--blue-deep);
}

.finder-guide-btn {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #1d4ed8, #0891b2);
  color: #fff;
  font-family: inherit;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 24px -16px rgba(37, 99, 235, 0.9);
  transition: transform 0.24s var(--ease), box-shadow 0.24s ease;
}

.finder-guide-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px -16px rgba(37, 99, 235, 0.95);
}

.finder-progress {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.finder-progress-head {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 650;
}

.finder-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45);
  animation: statusPulse 1.5s ease-out infinite;
}

@keyframes statusPulse {
  to {
    box-shadow: 0 0 0 9px rgba(37, 99, 235, 0);
  }
}

.finder-stop {
  margin-left: auto;
  padding: 4px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--rose);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.finder-stop:hover {
  border-color: rgba(180, 35, 24, 0.4);
  background: var(--amber-bg);
}

.finder-stream {
  max-height: 132px;
  margin: 10px 0 0;
  padding: 0;
  overflow: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 生成结束后隐藏进度条，避免占位 */
.finder-progress.is-done .finder-status-dot {
  background: var(--green);
  animation: none;
  box-shadow: none;
}

/* ------------------------------------------------------------
   8.6 AI 推荐结果卡片流
   ------------------------------------------------------------ */
.finder-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.finder-results:empty {
  display: none;
}

.ai-rec-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  animation: recIn 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 80ms);
  transition: border-color 0.26s ease, box-shadow 0.26s ease, transform 0.26s var(--ease);
}

.ai-rec-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: var(--shadow-md);
}

@keyframes recIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ai-rec-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-rec-index {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.ai-diff {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.63rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* 入门绿 / 进阶橙 / 实战红 */
.ai-diff--beginner {
  background: rgba(15, 118, 110, 0.1);
  color: var(--green);
}

.ai-diff--mid {
  background: var(--amber-bg);
  color: var(--amber);
}

.ai-diff--hard {
  background: rgba(180, 35, 24, 0.09);
  color: var(--rose);
}

.ai-rec-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 750;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.ai-rec-reason {
  flex: 1 1 auto;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.75;
}

.ai-rec-reason::before {
  content: "“";
  margin-right: 1px;
  color: rgba(37, 99, 235, 0.5);
  font-family: Georgia, serif;
  font-size: 1.05em;
}

.ai-rec-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 9px;
  margin-top: 2px;
  border-top: 1px solid var(--line);
}

.ai-rec-kw {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.63rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-rec-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--blue-deep);
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.22s ease, border-color 0.22s ease, transform 0.22s var(--ease);
}

.ai-rec-btn:hover {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.12);
  transform: translateX(2px);
}

/* AI 返回无法解析时的原文降级 */
.ai-rec-raw {
  grid-column: 1 / -1;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 降级提示卡（AI 不可用时兜底，保证不白屏） */
.ai-fallback-card {
  display: flex;
  grid-column: 1 / -1;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(154, 91, 8, 0.24);
  border-radius: 16px;
  background: linear-gradient(120deg, var(--amber-bg), var(--surface-solid));
}

.ai-fallback-card h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
}

.ai-fallback-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.79rem;
  line-height: 1.75;
}

.ai-fallback-card .ai-fallback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.ai-fallback-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1d4ed8, #0891b2);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 24px -18px rgba(37, 99, 235, 0.9);
}

.ai-fallback-link:hover {
  color: #fff;
}

.ai-fallback-ghost {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

/* ------------------------------------------------------------
   8.7 搜索历史
   ------------------------------------------------------------ */
.finder-history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.finder-history-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.finder-history-chips {
  display: flex;
  flex: 1 1 220px;
  flex-wrap: wrap;
  gap: 6px;
}

.history-chip {
  max-width: 22ch;
  padding: 5px 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-input);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.22s ease, background 0.22s ease, color 0.22s ease;
}

.history-chip:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--surface-tint);
  color: var(--blue-deep);
}

.finder-history-clear {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.68rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.finder-history-clear:hover {
  color: var(--rose);
}

/* ------------------------------------------------------------
   8.8 内置使用说明（折叠面板）
   ------------------------------------------------------------ */
.res-guide {
  margin-top: 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.res-guide[open] {
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: var(--shadow-md);
}

.res-guide summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px clamp(20px, 3vw, 30px);
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.res-guide summary::-webkit-details-marker {
  display: none;
}

.res-guide summary:hover .res-guide-icon {
  border-color: rgba(37, 99, 235, 0.45);
  background: var(--surface-tint);
}

.res-guide-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--blue-deep);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 800;
  transition: background 0.24s ease, border-color 0.24s ease;
}

.res-guide-summary {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.res-guide-summary strong {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.res-guide-summary small {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.6;
}

.res-guide-chevron {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: var(--muted);
  transition: transform 0.32s var(--ease);
}

.res-guide[open] .res-guide-chevron {
  transform: rotate(180deg);
}

.res-guide-body {
  display: grid;
  gap: 26px;
  padding: 0 clamp(20px, 3vw, 30px) 28px;
}

.res-guide[open] .res-guide-body {
  padding-top: 22px;
  border-top: 1px dashed var(--line);
}

.guide-part h4 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 780;
  line-height: 1.5;
}

.guide-part-no {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface-tint);
  color: var(--blue-deep);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.guide-figure {
  max-width: 620px;
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.guide-figure figcaption {
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-align: right;
}

.guide-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-soft);
  font-size: 0.83rem;
  line-height: 1.9;
}

.guide-steps li {
  margin-bottom: 6px;
  padding-left: 2px;
}

.guide-steps li::marker {
  color: var(--blue);
  font-family: var(--mono);
  font-weight: 700;
}

.guide-steps a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-steps code,
.guide-faq code,
.ai-field-hint code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.86em;
  word-break: break-word;
}

.guide-tip {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-left: 3px solid rgba(37, 99, 235, 0.55);
  border-radius: 0 10px 10px 0;
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.8;
}

.guide-faq {
  margin: 0;
}

.guide-faq dt {
  margin-top: 14px;
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 720;
}

.guide-faq dt:first-child {
  margin-top: 0;
}

.guide-faq dd {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.85;
}

/* ------------------------------------------------------------
   8.9 AI 设置抽屉
   ------------------------------------------------------------ */
.ai-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 240;
}

.ai-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 25, 0.58);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: overlayIn 0.28s ease both;
}

@keyframes overlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.ai-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(432px, 100%);
  height: 100%;
  max-height: 100dvh;
  border-left: 1px solid var(--line);
  background: var(--surface-solid);
  box-shadow: -40px 0 90px -50px rgba(6, 13, 25, 0.55);
  animation: drawerIn 0.42s var(--ease) both;
}

@keyframes drawerIn {
  from {
    opacity: 0.4;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ai-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 16px;
}

.ai-drawer-eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.ai-drawer-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.ai-drawer-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-modal-close);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ai-drawer-close:hover {
  border-color: var(--line-strong);
  background: var(--surface-tint);
  color: var(--ink);
}

.ai-drawer-notice {
  margin: 0 24px 16px;
  padding: 11px 13px;
  border: 1px dashed rgba(37, 99, 235, 0.32);
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.09), rgba(8, 145, 178, 0.05));
  color: var(--blue-deep);
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.75;
}

.ai-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 24px 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-tint);
}

.ai-mode-tab {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.ai-mode-tab:hover {
  color: var(--blue-deep);
}

.ai-mode-tab.is-active {
  background: var(--surface-solid);
  color: var(--blue-deep);
  box-shadow: 0 1px 4px rgba(16, 42, 80, 0.14);
}

.ai-drawer-body {
  flex: 1 1 auto;
  padding: 0 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ai-panel {
  display: grid;
  gap: 13px;
}

.ai-panel[hidden] {
  display: none !important;
}

.ai-field {
  display: grid;
  gap: 6px;
}

.ai-field > span {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ai-field input,
.ai-field select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-input);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.ai-field select {
  padding-right: 30px;
  cursor: pointer;
}

.ai-field input:focus,
.ai-field select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-field input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.ai-key-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.ai-key-wrap input {
  padding-right: 46px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.ai-key-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 0.2s ease, background 0.2s ease;
}

.ai-key-toggle:hover {
  background: var(--surface-tint);
  color: var(--blue-deep);
}

.ai-key-toggle svg {
  width: 17px;
  height: 17px;
}

.ai-key-toggle .eye-closed {
  display: none;
}

.ai-key-toggle[data-visible="true"] .eye-open {
  display: none;
}

.ai-key-toggle[data-visible="true"] .eye-closed {
  display: block;
}

.ai-test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 2px;
}

.ai-test-btn {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 10px;
  background: var(--surface-tint);
  color: var(--blue-deep);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.22s ease, border-color 0.22s ease, opacity 0.22s ease;
}

.ai-test-btn:hover {
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.12);
}

.ai-test-btn--ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
}

.ai-test-btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.ai-test-status {
  font-size: 0.73rem;
  font-weight: 650;
  line-height: 1.6;
  word-break: break-word;
}

.ai-test-status[data-state="ok"] {
  color: var(--green);
}

.ai-test-status[data-state="err"] {
  color: var(--rose);
}

.ai-test-status[data-state="busy"] {
  color: var(--muted);
}

.ai-field-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.8;
}

.ai-drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.ai-drawer-foot p {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.6;
}

/* 抽屉打开时锁住页面滚动 */
body.ai-drawer-open {
  overflow: hidden;
}

/* 隐藏属性必须压过上面的 display:flex/grid */
.ai-drawer-root[hidden],
.finder-guide[hidden],
.finder-progress[hidden],
.finder-history[hidden],
.rank-empty[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------
   8.10 暗色主题微调
   ------------------------------------------------------------ */
html[data-theme="dark"] .res-module--ai {
  background:
    radial-gradient(620px 220px at 6% -14%, rgba(37, 99, 235, 0.16), transparent 72%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
}

html[data-theme="dark"] .rank-item:hover {
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.14), rgba(34, 211, 238, 0.05) 62%, transparent);
}

html[data-theme="dark"] .rank-open {
  background: var(--surface-soft);
}

html[data-theme="dark"] .ai-rec-card,
html[data-theme="dark"] .finder-gear {
  background: var(--surface);
}

html[data-theme="dark"] .ai-drawer-panel {
  box-shadow: -40px 0 90px -40px rgba(0, 0, 0, 0.9);
}

html[data-theme="dark"] .finder-guide {
  border-color: rgba(96, 165, 250, 0.35);
  background: linear-gradient(120deg, rgba(96, 165, 250, 0.12), rgba(34, 211, 238, 0.05));
}

html[data-theme="dark"] .ai-diff--beginner {
  background: rgba(52, 211, 153, 0.14);
}

html[data-theme="dark"] .ai-diff--hard {
  background: rgba(253, 164, 175, 0.12);
}

html[data-theme="dark"] .guide-tip {
  background: var(--surface-tint);
}

/* ------------------------------------------------------------
   8.11 响应式
   ------------------------------------------------------------ */
@media (max-width: 1080px) {
  .rank-item {
    grid-template-columns: 42px minmax(0, 1fr) 84px 66px 66px;
  }
}

@media (max-width: 900px) {
  .res-module-head {
    align-items: flex-start;
  }

  .res-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .res-module-head--split {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  /* 搜索区：输入框与按钮上下排列 */
  .finder-bar {
    flex-wrap: wrap;
  }

  .finder-input-wrap {
    flex: 1 1 100%;
    order: 1;
  }

  .finder-submit {
    flex: 1 1 auto;
    order: 2;
    min-height: 46px;
  }

  .finder-gear {
    order: 3;
    width: 46px;
    height: 46px;
  }

  /* 设置面板：全屏底部弹出 */
  .ai-drawer-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(92dvh, 100%);
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 22px 22px 0 0;
    animation: sheetIn 0.4s var(--ease) both;
  }

  @keyframes sheetIn {
    from {
      opacity: 0.5;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .ai-drawer-head {
    padding: 18px 20px 12px;
  }

  .ai-drawer-notice,
  .ai-mode-tabs {
    margin-right: 20px;
    margin-left: 20px;
  }

  .ai-drawer-body {
    padding: 0 20px 18px;
  }

  .ai-drawer-foot {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .guide-figure img {
    max-height: 260px;
    object-fit: cover;
  }
}

@media (max-width: 640px) {
  .res-module {
    padding: 18px 15px;
    border-radius: 20px;
  }

  /* 小屏隐藏播放量列（连带收藏列） */
  .rank-item {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 12px 4px;
  }

  .rank-play-cell,
  .rank-fav {
    display: none;
  }

  .rank-cat {
    display: none;
  }

  .rank-title {
    font-size: 0.86rem;
    white-space: normal;
  }

  .rank-open {
    padding: 0 10px;
  }

  .res-module-title {
    gap: 10px;
  }

  .res-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 0.82rem;
  }

  .chip {
    min-height: 30px;
    padding: 0 11px;
    font-size: 0.71rem;
  }

  .sort-switch {
    width: 100%;
  }

  .sort-btn {
    flex: 1 1 0;
    padding: 0 6px;
    font-size: 0.68rem;
  }

  .finder-results {
    grid-template-columns: 1fr;
  }

  .finder-guide {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-mode-pill {
    align-self: flex-start;
  }

  .guide-steps {
    padding-left: 18px;
    font-size: 0.8rem;
  }

  .res-guide summary {
    gap: 10px;
    padding: 15px 16px;
  }

  .res-guide-body {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 400px) {
  .finder-submit {
    padding: 0 14px;
    font-size: 0.8rem;
  }

  .rank-no {
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rank-item,
  .ai-rec-card,
  .finder-gear svg,
  .res-guide-chevron {
    transition: none;
  }

  .ai-rec-card,
  .ai-drawer-panel,
  .ai-drawer-overlay,
  .finder-mic.is-listening::after,
  .finder-status-dot,
  .gear-dot {
    animation: none;
  }
}
