* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== 亮色主题变量 ===== */
:root {
  --blue: #1677ff;
  --blue-dark: #0b5ed7;
  --blue-soft: rgba(22, 119, 255, 0.12);
  --text: #1f2937;
  --muted: #8a94a6;
  --line: #e9edf3;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --hover-bg: #f2f7ff;
  --bg-grad: linear-gradient(160deg, #e7f0ff 0%, #f5f8fc 45%, #eaf1f9 100%);
  --btn-grad: linear-gradient(90deg, #1677ff, #00a3ff);
  --hero-grad: linear-gradient(135deg, #1677ff 0%, #0a63e8 48%, #00b2ff 100%);
  --shadow-card: 0 12px 40px rgba(22, 119, 255, 0.1);
  --shadow-result: 0 12px 40px rgba(22, 119, 255, 0.08);
  --shadow-toast: 0 12px 32px rgba(15, 23, 42, 0.16);
  --shadow-btn: 0 8px 20px rgba(22, 119, 255, 0.28);
}

/* ===== 暗色主题变量 ===== */
[data-theme="dark"] {
  --blue: #5b93ff;
  --blue-dark: #3b76e0;
  --blue-soft: rgba(91, 147, 255, 0.18);
  --text: #e6eaf2;
  --muted: #8b95a8;
  --line: #2a3242;
  --surface: #171d2a;
  --surface-2: #1f2735;
  --hover-bg: #222c3e;
  --bg-grad: linear-gradient(160deg, #0c111c 0%, #0e1320 50%, #0a0e18 100%);
  --btn-grad: linear-gradient(90deg, #3b76e0, #2f9dff);
  --hero-grad: linear-gradient(135deg, #14306b 0%, #0f2148 50%, #0c1a38 100%);
  --shadow-card: 0 16px 44px rgba(0, 0, 0, 0.45);
  --shadow-result: 0 16px 44px rgba(0, 0, 0, 0.4);
  --shadow-toast: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-btn: 0 8px 22px rgba(0, 0, 0, 0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg-grad);
  background-attachment: fixed;
  padding: 0;
  transition: background 0.3s ease, color 0.3s ease;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 16px 40px;
}

/* ===== 右上角主题切换按钮 ===== */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 1000;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-result);
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle .ico-sun {
  display: none;
}

.theme-toggle .ico-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .ico-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .ico-moon {
  display: none;
}

/* ===== 全屏宽度顶部横幅 ===== */
.hero {
  width: 100%;
  background: var(--hero-grad);
  position: relative;
  overflow: hidden;
  padding: 54px 16px;
}

/* 纯 CSS 装饰光晕，不依赖图片 */
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.hero::before {
  width: 320px;
  height: 320px;
  right: -80px;
  top: -140px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
}

.hero::after {
  width: 260px;
  height: 260px;
  left: -70px;
  bottom: -130px;
  background: radial-gradient(circle, rgba(0, 200, 255, 0.26), transparent 70%);
}

.hero-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.hero h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
}

.hero p {
  margin-top: 10px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
}

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
}

.field {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 14px;
  margin-bottom: 14px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
  background: var(--surface);
}

.ico {
  color: var(--muted);
  font-size: 13px;
  margin-right: 10px;
  min-width: 28px;
  display: inline-flex;
}

.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  height: 47px;
  font-size: 15px;
  color: var(--text);
}

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

.btn {
  width: 100%;
  height: 49px;
  border: none;
  border-radius: 11px;
  background: var(--btn-grad);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: var(--shadow-btn);
}

.btn:hover {
  box-shadow: 0 12px 26px var(--blue-soft);
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== 右下角 Toast 通知 ===== */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 330px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-toast);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.hide {
  opacity: 0;
  transform: translateX(24px);
}

.toast-ico {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  margin-top: 1px;
}

.toast-ico svg {
  width: 20px;
  height: 20px;
}

.toast-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

.toast-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.toast-info .toast-ico { color: #1677ff; }
.toast-success .toast-ico { color: #16a34a; }
.toast-error .toast-ico { color: #e02d2d; }
.toast-warning .toast-ico { color: #e0932f; }

/* 登录态健康警告条 */
.health-banner {
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #ad6800;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}

[data-theme="dark"] .health-banner {
  background: color-mix(in srgb, #e0932f 16%, transparent);
  border-color: color-mix(in srgb, #e0932f 38%, transparent);
  color: #f0b86a;
}

.result {
  margin-top: 18px;
  background: var(--surface);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow-result);
  border: 1px solid var(--line);
}

.hidden {
  display: none;
}

.r-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.r-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

/* 一键下载按钮 */
.dl-all-btn {
  margin-left: auto;
  border: 1px solid var(--blue);
  background: var(--surface);
  color: var(--blue);
  font-size: 12px;
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.dl-all-btn:hover {
  background: var(--blue);
  color: #fff;
}

.dl-all-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 8px;
  border-top: 1px solid var(--line);
  border-radius: 10px;
  transition: background 0.15s ease;
}

/* 鼠标悬停高亮，能清楚看到当前停在哪个文件上 */
.item:hover {
  background: var(--hover-bg);
}

/* 类型图标统一尺寸，底色用前景色的透明混合，明暗自动适配 */
.folder-ico,
.file-ico {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, currentColor 13%, transparent);
}

.folder-ico svg,
.file-ico svg {
  width: 23px;
  height: 23px;
}

/* 图标类型前景色（底色自动生成） */
.folder-ico { color: #e0932f; }
.file-ico.ico-file { color: #5b6b85; }
.file-ico.ico-archive { color: #d97b2e; }
.file-ico.ico-app { color: #7c5cff; }
.file-ico.ico-script { color: #1677ff; }
.file-ico.ico-video { color: #c026d3; }
.file-ico.ico-audio { color: #0891b2; }
.file-ico.ico-image { color: #db2777; }
.file-ico.ico-pdf { color: #dc322f; }
.file-ico.ico-word { color: #2b579a; }
.file-ico.ico-excel { color: #217346; }
.file-ico.ico-ppt { color: #d24726; }
.file-ico.ico-text { color: #6b7488; }

/* 文件主体：名称 + 元信息行 */
.file-main {
  flex: 1;
  min-width: 0;
}

.item .name {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.file-sub svg {
  width: 13px;
  height: 13px;
  margin-right: 4px;
  vertical-align: -2px;
}

.f-time,
.f-size {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.f-size {
  font-variant-numeric: tabular-nums;
}

/* 操作按钮组 */
.file-ops {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.item .meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.item .dl {
  text-decoration: none;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.item.folder .name {
  color: var(--text);
}

.single {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.single .big-dl {
  display: block;
  text-align: center;
  background: var(--btn-grad);
  color: #fff;
  text-decoration: none;
  padding: 13px;
  border-radius: 11px;
  font-weight: 600;
  margin-top: 10px;
}

.single .f-meta {
  font-size: 13px;
  color: var(--muted);
}

.foot {
  text-align: center;
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
  margin-right: 6px;
}

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

/* 面包屑导航 */
.crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}

.crumb-item {
  color: var(--blue);
  cursor: pointer;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb-item:hover {
  text-decoration: underline;
}

.crumb .sep {
  color: var(--muted);
}

/* 可点击的子文件夹 */
.item.folder.clickable {
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}

.item.folder.clickable:hover {
  background: var(--hover-bg);
}

.item.folder.clickable:active {
  background: var(--blue-soft);
}

.item .arrow {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

/* 目录加载中状态 */
.nav-loading {
  opacity: 0.55;
  pointer-events: none;
}

/* ===== 工具栏：全选 / 已选统计 / 筛选 / 排序 / 批量下载 ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.select-all-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.select-all,
.file-check {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.sel-info {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.search {
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

/* 排序控件 */
.sort-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sort-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.sort-select:hover,
.sort-select:focus {
  border-color: var(--blue);
}

.sort-dir {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sort-dir svg {
  width: 16px;
  height: 16px;
}

.sort-dir:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--hover-bg);
}

.sort-dir:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 文件行内小按钮 */
.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.mini-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.mini-btn.dl-one {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.mini-btn.dl-one:hover {
  background: var(--blue-dark);
  color: #fff;
}

.mini-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== 左右双排布局 + 右侧广告位 ===== */
.main-col {
  min-width: 0;
}

/* 窄屏单列：广告位堆叠在内容下方 */
.side-col {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* 宽屏：主内容左、广告位右，侧边栏滚动时吸顶 */
@media (min-width: 880px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
  }

  .side-col {
    margin-top: 0;
    position: sticky;
    top: 20px;
  }
}

/* 广告卡片：圆角、边框、阴影（无悬停动效） */
.ad-slot {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-result);
}

.ad-link {
  display: block;
  width: 100%;
}

/* 宽度固定填满，高度按图片原始比例自适应，任意尺寸的图都能完整显示、不裁剪 */
.ad-link img {
  display: block;
  width: 100%;
  height: auto;
}

.ad-label {
  position: absolute;
  top: 9px;
  left: 10px;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
}

/* 广告位高度由图片按比例自适应，不再固定 */
.ad-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 默认隐藏：作者样式的 display:flex 会覆盖 hidden 属性，这里显式收回 */
.ad-group[hidden] {
  display: none;
}

/* 小屏适配：工具栏换行、列表紧凑、图标缩小、全宽 */
@media (max-width: 480px) {
  body {
    padding: 32px 12px;
  }
  .theme-toggle {
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
  }
  .toolbar {
    gap: 8px;
  }
  .item {
    gap: 8px;
    padding: 10px 2px;
  }
  .folder-ico,
  .file-ico {
    width: 33px;
    height: 33px;
    border-radius: 9px;
  }
  .folder-ico svg,
  .file-ico svg {
    width: 20px;
    height: 20px;
  }
  .file-sub {
    gap: 10px;
    font-size: 11px;
  }
  .file-ops {
    gap: 6px;
  }
  .mini-btn {
    padding: 5px 8px;
  }
}
