*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #ebedf0;
  --text: #1a1a1a;
  --text-muted: #8a8f99;
  --primary: #2563eb;
  --primary-active: #1d4ed8;
  --primary-soft: #eaf0ff;
  --danger: #e23d3d;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f14;
    --surface: #181c22;
    --border: #262b33;
    --text: #f0f2f5;
    --text-muted: #888f9a;
    --primary: #4d8bff;
    --primary-active: #6ba0ff;
    --primary-soft: #1c2740;
    --danger: #ff6b6b;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.hidden {
  display: none !important;
}

/* ── 顶部栏 ───────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  padding: calc(var(--safe-top) + 14px) 16px 12px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
}

.topbar-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 12px;
  padding: 0 12px;
  height: 40px;
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-field input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  height: 100%;
  outline: none;
  min-width: 0;
}

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

.clear-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: var(--text-muted);
  color: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
}

.clear-btn svg {
  width: 12px;
  height: 12px;
}

/* ── 排序栏 ───────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.sort-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sort-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sort-chip.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
  font-weight: 600;
}

.sort-chip::after {
  content: "";
  width: 0;
  height: 0;
  transition: transform 0.15s;
}

.sort-chip.is-active[data-dir="asc"]::after {
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 5px solid currentColor;
}

.sort-chip.is-active[data-dir="desc"]::after {
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 5px solid currentColor;
}

/* ── 内容区 ───────────────────────── */
.content {
  padding: 12px 16px calc(var(--safe-bottom) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

.count-bar {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 4px 2px 10px;
}

/* ── 卡片列表 ─────────────────────── */
.card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--border);
}

.file-thumb {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.file-thumb svg {
  width: 22px;
  height: 22px;
}

.thumb-video { background: linear-gradient(135deg, #6366f1, #2563eb); }
.thumb-archive { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.thumb-image { background: linear-gradient(135deg, #10b981, #059669); }
.thumb-audio { background: linear-gradient(135deg, #ec4899, #db2777); }
.thumb-doc { background: linear-gradient(135deg, #64748b, #475569); }
.thumb-other { background: linear-gradient(135deg, #94a3b8, #64748b); }

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.file-meta {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.6;
}

.download-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.download-btn:active {
  background: var(--primary);
  color: #fff;
  transform: scale(0.92);
}

.download-btn svg {
  width: 20px;
  height: 20px;
}

/* ── 状态块 ───────────────────────── */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 64px 24px;
  color: var(--text-muted);
  text-align: center;
}

.state-icon {
  font-size: 2.5rem;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.primary-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.primary-btn:active {
  background: var(--primary-active);
}

/* ── 加载更多 ─────────────────────── */
.load-more-wrap {
  padding: 18px 0 4px;
  text-align: center;
}

.load-more-btn {
  padding: 10px 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.load-more-btn:active {
  background: var(--primary-soft);
}

.load-more-btn:disabled {
  opacity: 0.5;
}

.list-end {
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 20px 0 4px;
  letter-spacing: 0.04em;
}
