/* ==========================================================================
   AI 资源门户 · 设计系统
   --------------------------------------------------------------------------
   零依赖手写 CSS。主题通过 :root 上的 [data-theme] 切换，所有颜色走变量。
   设计语言：极简 / 科技 / 沉浸感
   ========================================================================== */

/* ---------- 1. 设计令牌 (Design Tokens) ---------- */
:root {
  /* 字体：英文优先 Inter/Geist，中文回退苹方/微软雅黑 */
  --font-sans: 'Inter', 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue',
    Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, 'Courier New', monospace;

  /* 圆角与阴影 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* 动效曲线 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 160ms;
  --dur-base: 260ms;
  --dur-slow: 420ms;

  /* 布局 */
  --container: 1240px;
  --navbar-h: 64px;
}

/* ---------- 2. 深色主题（默认） ---------- */
:root,
[data-theme='dark'] {
  color-scheme: dark;

  --bg-base: #09090b;
  --bg-subtle: #0f0f12;
  --bg-elevated: #18181b;
  --bg-card: rgba(24, 24, 27, 0.72);
  --bg-card-hover: rgba(32, 32, 38, 0.88);
  --bg-glass: rgba(9, 9, 11, 0.72);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: #3b82f6;

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;

  --brand: #3b82f6;
  --brand-hover: #60a5fa;
  --brand-soft: rgba(59, 130, 246, 0.14);
  --accent: #06b6d4;
  --accent-soft: rgba(6, 182, 212, 0.14);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
  --glow: 0 0 0 1px rgba(59, 130, 246, 0.5), 0 0 24px -4px rgba(59, 130, 246, 0.45);
}

/* ---------- 3. 浅色主题 ---------- */
[data-theme='light'] {
  color-scheme: light;

  --bg-base: #ffffff;
  --bg-subtle: #fafafa;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.78);

  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --border-focus: #2563eb;

  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;

  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: rgba(37, 99, 235, 0.08);
  --accent: #0891b2;
  --accent-soft: rgba(8, 145, 178, 0.1);

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
  --shadow-md: 0 8px 24px -8px rgba(9, 9, 11, 0.12);
  --shadow-lg: 0 24px 48px -16px rgba(9, 9, 11, 0.18);
  --glow: 0 0 0 1px rgba(37, 99, 235, 0.4), 0 8px 24px -8px rgba(37, 99, 235, 0.3);
}

/* ---------- 4. 基础重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

/* 键盘可达性：保留可见焦点环 */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* 尊重系统减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 5. 布局工具 ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

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

/* ---------- 6. 背景光效（纯 CSS，零图片请求） ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* z-index 只在定位元素上生效 —— 这里 .bg-decor 已 position:fixed */
.bg-decor::before,
.bg-decor::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.5;
}

.bg-decor::before {
  top: -180px;
  left: -120px;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.28), transparent 70%);
  animation: float-slow 22s var(--ease-out) infinite alternate;
}

.bg-decor::after {
  top: 120px;
  right: -160px;
  width: 560px;
  height: 560px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.2), transparent 70%);
  animation: float-slow 28s var(--ease-out) infinite alternate-reverse;
}

[data-theme='light'] .bg-decor::before,
[data-theme='light'] .bg-decor::after {
  opacity: 0.35;
}

@keyframes float-slow {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(60px, 80px, 0) scale(1.15);
  }
}

/* ---------- 7. Navbar（毛玻璃吸顶） ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--navbar-h);
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--dur-base) var(--ease-out);
}

.navbar.is-scrolled {
  box-shadow: var(--shadow-md);
}

.navbar__inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  font-size: 17px;
  box-shadow: var(--shadow-sm);
}

.logo__text b {
  color: var(--brand);
}

/* 全局搜索 */
.search {
  position: relative;
  flex: 1;
  max-width: 480px;
}

.search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: grid;
  place-items: center;
}

.search__input {
  width: 100%;
  height: 40px;
  padding: 0 84px 0 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.search__input::placeholder {
  color: var(--text-tertiary);
}

.search__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.search__hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ---------- 8. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--brand);
  color: #fff;
}

.btn--primary:hover {
  background: var(--brand-hover);
  box-shadow: var(--glow);
}

.btn--ghost {
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn--ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.btn--icon {
  width: 38px;
  padding: 0;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn--icon:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn--sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* 免登录 / 全免费 徽标 */
.free-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.32);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ---------- 9. Hero ---------- */
.hero {
  position: relative;
  padding: 60px 0 44px;
  text-align: center;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.hero__badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.grad {
  background: linear-gradient(120deg, var(--brand) 10%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero__desc {
  max-width: 600px;
  margin: 0 auto 24px;
  font-size: clamp(14.5px, 1.8vw, 16px);
  color: var(--text-secondary);
}

/* Hero 内的搜索（已改为紧凑尺寸） */
.hero__search {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

.hero__search .search__input {
  height: 42px;
  padding: 0 104px 0 44px;
  font-size: 14.5px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.hero__search .search__icon {
  left: 16px;
  width: 17px;
  height: 17px;
}

.hero__search .search__icon svg {
  width: 17px;
  height: 17px;
}

.hero__search .btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 16px;
  font-size: 13.5px;
}

.hero__stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 34px;
  flex-wrap: wrap;
}

.hero__stats div {
  text-align: center;
}

.hero__stats dt {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.hero__stats dd {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ---------- 10. 分类 Tab + 排序 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0 20px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  flex: 1;
}

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

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}

.tab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.tab.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

[data-theme='light'] .tab.is-active {
  color: #fff;
}

.tab__count {
  font-size: 12px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.sorts {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sorts button {
  height: 30px;
  padding: 0 14px;
  font-size: 13px;
  color: var(--text-tertiary);
  border-radius: var(--radius-full);
  transition: all var(--dur-fast) var(--ease-out);
}

.sorts button:hover {
  color: var(--text-primary);
}

.sorts button.is-active {
  color: var(--text-primary);
  background: var(--brand-soft);
}

/* ---------- 开关（仅看全免费） ---------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.switch__input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch__track {
  position: relative;
  width: 38px;
  height: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: left var(--dur-base) var(--ease-spring),
    background-color var(--dur-fast) var(--ease-out);
}

.switch__input:checked + .switch__track {
  background: var(--success);
  border-color: var(--success);
}

.switch__input:checked + .switch__track .switch__thumb {
  left: 19px;
  background: #fff;
}

.switch__input:focus-visible + .switch__track {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.switch:hover .switch__track {
  border-color: var(--border-strong);
}

.switch:hover .switch__label {
  color: var(--text-primary);
}

/* ---------- 11. 资源卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  padding-bottom: 40px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    background-color var(--dur-base) var(--ease-out);
  animation: card-in var(--dur-slow) var(--ease-out) both;
  will-change: transform;
}

/* Hover：Z 轴上浮 + 主色微光 */
.card:hover,
.card:focus-visible {
  transform: translateY(-4px) scale(1.02);
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: var(--glow), var(--shadow-lg);
  z-index: 1;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card__top {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 13px;
}

.card__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 23px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.card__head {
  flex: 1;
  min-width: 0;
}

.card__title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__cat {
  font-size: 12px;
  color: var(--text-tertiary);
}

.card__summary {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag {
  padding: 2px 9px;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

/* ---------- 免费等级标签 ---------- */
.access-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
}

.access-tag--free {
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.32);
}

.access-tag--freemium {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: rgba(59, 130, 246, 0.32);
}

.access-tag--paid {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.32);
}

/* 详情弹窗标题旁的等级标签 */
#modalAccess {
  margin-left: 10px;
  font-size: 12px;
  vertical-align: middle;
}

.card__foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color var(--dur-fast) var(--ease-out);
}

.stat svg {
  width: 14px;
  height: 14px;
}

.stat--like.is-liked {
  color: var(--danger);
}

.card__date {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* AI软件分类：金色描边突出 */
.card--ai-software {
  border-color: rgba(245, 158, 11, 0.42);
}

.card--ai-software:hover,
.card--ai-software:focus-visible {
  border-color: rgba(245, 158, 11, 0.75);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.45),
    0 0 28px -6px rgba(245, 158, 11, 0.4), var(--shadow-lg);
}

/* 我的 / 自研 徽标 */
.badge-mine {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #78350f;
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  border-radius: var(--radius-full);
  vertical-align: middle;
}

/* 卡片右上角热度徽标 */
.card__rank {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-bottom-left-radius: var(--radius-md);
}

/* ---------- 12. 空状态 ---------- */
.empty {
  grid-column: 1 / -1;
  padding: 72px 20px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty__icon {
  font-size: 44px;
  margin-bottom: 14px;
  opacity: 0.6;
}

.empty p {
  font-size: 15px;
  margin-bottom: 6px;
}

.empty span {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---------- 13. Footer ---------- */
.footer {
  margin-top: 40px;
  padding: 40px 0 32px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.footer__note {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.7;
}

.footer__links {
  display: flex;
  gap: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.footer__links a:hover {
  color: var(--brand);
}

/* ---------- 14. 详情弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

.modal.is-open {
  display: block;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in var(--dur-base) var(--ease-out);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 940px;
  max-height: 88dvh;
  margin: 6dvh auto 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-up var(--dur-base) var(--ease-out);
}

@keyframes modal-up {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-size: 26px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.modal__title {
  flex: 1;
  min-width: 0;
}

.modal__title h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.modal__title p {
  font-size: 14px;
  color: var(--text-secondary);
}

.modal__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-out);
}

.modal__close:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
}

/* 右侧悬浮获取面板 */
.getbox {
  position: sticky;
  top: 0;
  padding: 16px;
  margin-bottom: 22px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  float: right;
  width: 280px;
  margin-left: 20px;
}

.getbox__title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.getbox__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--dur-fast) var(--ease-out);
}

.getbox__btn:hover {
  border-color: var(--brand);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

.getbox__btn span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.getbox__btn small {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.getbox__tip {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-tertiary);
}

.modal__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

/* ---------- 15. Markdown 正文排版 ---------- */
.md {
  font-size: 14.5px;
  line-height: 1.78;
  color: var(--text-secondary);
}

.md > * + * {
  margin-top: 14px;
}

.md h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  margin-top: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.md h3 {
  font-size: 15.5px;
  font-weight: 650;
  color: var(--text-primary);
  margin-top: 22px;
}

.md p {
  color: var(--text-secondary);
}

.md strong {
  color: var(--text-primary);
  font-weight: 650;
}

.md a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.md a:hover {
  color: var(--brand-hover);
}

.md ul,
.md ol {
  padding-left: 4px;
}

.md li {
  position: relative;
  padding-left: 20px;
  margin-top: 7px;
}

.md ul li::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
}

.md ol {
  counter-reset: ol;
}

.md ol li {
  counter-increment: ol;
}

.md ol li::before {
  content: counter(ol) '.';
  position: absolute;
  left: 0;
  top: 0;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  font-weight: 600;
}

.md blockquote {
  padding: 12px 16px;
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-primary);
  font-style: normal;
}

.md blockquote p {
  color: inherit;
}

.md code {
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent);
}

.md pre {
  padding: 16px;
  margin-top: 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.md pre code {
  padding: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.7;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: 14px;
}

.md th,
.md td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.md th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.md hr {
  height: 1px;
  background: var(--border);
  border: none;
  margin: 24px 0;
}

/* ---------- 16. Toast ---------- */
.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90vw;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-base) var(--ease-spring);
}

.toast.is-out {
  animation: toast-out var(--dur-base) var(--ease-out) forwards;
}

.toast--success {
  border-color: rgba(16, 185, 129, 0.5);
}

.toast--error {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast__icon {
  font-size: 16px;
  line-height: 1;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-14px) scale(0.94);
  }
}

/* ---------- 17. 响应式 ---------- */

/* 中等宽度：分类 tab 与右侧排序/开关分两行，避免右侧被挤出可视区 */
@media (max-width: 1080px) {
  .toolbar {
    gap: 12px;
  }

  .tabs {
    flex: 1 1 100%;
    width: 100%;
  }

  .sorts,
  .switch {
    margin-left: auto;
  }
}

@media (max-width: 900px) {
  .getbox {
    float: none;
    width: 100%;
    margin-left: 0;
    position: static;
  }

  .hero__stats {
    gap: 28px;
  }
}

@media (max-width: 768px) {
  :root {
    --navbar-h: 58px;
  }

  .container {
    padding-inline: 16px;
  }

  /* 移动端隐藏导航搜索，聚焦内容 */
  .navbar .search {
    display: none;
  }

  .hero {
    padding: 40px 0 32px;
  }

  .hero__search .search__input {
    height: 40px;
    padding: 0 96px 0 42px;
    font-size: 14px;
  }

  .hero__stats {
    gap: 24px;
    margin-top: 32px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .toolbar {
    gap: 12px;
  }

  .sorts {
    width: 100%;
    justify-content: space-between;
  }

  .sorts button {
    flex: 1;
    padding: 0 10px;
  }

  .modal__panel {
    max-width: 100%;
    max-height: 92dvh;
    margin: 4dvh auto 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .modal__head,
  .modal__body,
  .modal__foot {
    padding: 18px;
  }

  .footer__inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .hero__search .btn {
    padding: 0 12px;
    font-size: 13px;
  }

  .btn--text-long {
    display: none;
  }

  /* 窄屏只保留锁图标，省出横向空间 */
  .free-badge {
    padding: 0 9px;
  }

  .free-badge__text {
    display: none;
  }

  .switch {
    font-size: 12.5px;
  }
}

/* 打印样式：省墨 */
@media print {
  .navbar,
  .bg-decor,
  .toolbar,
  .modal,
  .toasts {
    display: none !important;
  }
}
