/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --glass: rgba(245, 246, 250, 0.78);
  --blob-1: rgba(99, 102, 241, 0.20);
  --blob-2: rgba(6, 182, 212, 0.15);
  --surface: rgba(255, 255, 255, 0.74);
  --surface-2: #ffffff;
  --text: #111521;
  --text-2: #5b6474;
  --line: rgba(17, 21, 33, 0.09);
  --line-strong: rgba(17, 21, 33, 0.16);
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --accent-ink: #ffffff;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --shadow: 0 1px 2px rgba(17, 21, 33, 0.04), 0 14px 34px -16px rgba(17, 21, 33, 0.22);
  --shadow-hover: 0 20px 44px -20px rgba(17, 21, 33, 0.34);
  --radius: 16px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c12;
  --glass: rgba(10, 12, 18, 0.76);
  --blob-1: rgba(99, 102, 241, 0.26);
  --blob-2: rgba(6, 182, 212, 0.16);
  --surface: rgba(22, 26, 37, 0.72);
  --surface-2: #151a25;
  --text: #e9ebf3;
  --text-2: #98a1b4;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --accent: #8b8bff;
  --accent-2: #22d3ee;
  --accent-ink: #0c0e16;
  --accent-soft: rgba(139, 139, 255, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-hover: 0 22px 50px -22px rgba(0, 0, 0, 0.85);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei UI", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(62rem 42rem at 12% -12%, var(--blob-1), transparent 64%),
    radial-gradient(52rem 38rem at 104% -4%, var(--blob-2), transparent 60%);
}

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

a { color: inherit; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--glass);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.logo {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.7);
}

.logo svg { width: 20px; height: 20px; }

.brand-txt { min-width: 0; }

.brand-txt strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.brand-txt small {
  display: block;
  margin-top: 1px;
  font-size: 0.75rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.18s;
}

.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }

.icon-sun { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ---------- hero ---------- */
.hero { padding: clamp(2.2rem, 6vw, 3.8rem) 0 1.4rem; }

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.lede {
  margin: 0.7rem 0 0;
  max-width: 54ch;
  font-size: 0.96rem;
  color: var(--text-2);
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.7rem;
}

.search {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
}

.search > svg {
  position: absolute;
  left: 0.95rem;
  width: 18px;
  height: 18px;
  color: var(--text-2);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 46px;
  padding: 0 2.8rem 0 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.93rem;
  outline: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.search input::placeholder { color: var(--text-2); opacity: 0.72; }

.search input:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search kbd {
  position: absolute;
  right: 0.75rem;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 0.35rem;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  pointer-events: none;
}

.selectwrap { position: relative; display: flex; }

.selectwrap select {
  height: 46px;
  padding: 0 2.4rem 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.selectwrap select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.selectwrap svg {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--text-2);
  pointer-events: none;
}

/* ---------- chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  min-height: 30px;
}

.chip {
  padding: 0.32rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.chip:hover { color: var(--text); border-color: var(--line-strong); }

.chip[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
  font-weight: 600;
}

.chip .n {
  margin-left: 0.3rem;
  opacity: 0.55;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- list ---------- */
.listbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 22px;
  margin: 1.3rem 0 0.7rem;
  font-size: 0.78rem;
  color: var(--text-2);
}

.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 336px), 1fr));
  align-items: start;
  gap: 0.85rem;
  padding-bottom: 3rem;
}

.card {
  --i: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s ease, border-color 0.2s, box-shadow 0.2s;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  animation-delay: calc(var(--i) * 40ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.fileicon {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ic, #64748b);
  background: var(--ic-bg, rgba(100, 116, 139, 0.13));
  box-shadow: inset 0 0 0 1px var(--ic-ring, rgba(100, 116, 139, 0.2));
}

.fileicon[data-kind="archive"] { --ic: #d97706; --ic-bg: rgba(217, 119, 6, 0.14); --ic-ring: rgba(217, 119, 6, 0.22); }
.fileicon[data-kind="app"]     { --ic: #7c3aed; --ic-bg: rgba(124, 58, 237, 0.14); --ic-ring: rgba(124, 58, 237, 0.22); }
.fileicon[data-kind="doc"]     { --ic: #2563eb; --ic-bg: rgba(37, 99, 235, 0.13); --ic-ring: rgba(37, 99, 235, 0.22); }
.fileicon[data-kind="media"]   { --ic: #db2777; --ic-bg: rgba(219, 39, 119, 0.13); --ic-ring: rgba(219, 39, 119, 0.22); }
.fileicon[data-kind="image"]   { --ic: #0891b2; --ic-bg: rgba(8, 145, 178, 0.13); --ic-ring: rgba(8, 145, 178, 0.22); }
.fileicon[data-kind="code"]    { --ic: #059669; --ic-bg: rgba(5, 150, 105, 0.13); --ic-ring: rgba(5, 150, 105, 0.22); }
.fileicon[data-kind="disk"]    { --ic: #475569; --ic-bg: rgba(71, 85, 105, 0.14); --ic-ring: rgba(71, 85, 105, 0.24); }

html[data-theme="dark"] .fileicon[data-kind="archive"] { --ic: #fbbf24; }
html[data-theme="dark"] .fileicon[data-kind="app"]     { --ic: #a78bfa; }
html[data-theme="dark"] .fileicon[data-kind="doc"]     { --ic: #60a5fa; }
html[data-theme="dark"] .fileicon[data-kind="media"]   { --ic: #f472b6; }
html[data-theme="dark"] .fileicon[data-kind="image"]   { --ic: #22d3ee; }
html[data-theme="dark"] .fileicon[data-kind="code"]    { --ic: #34d399; }
html[data-theme="dark"] .fileicon[data-kind="disk"]    { --ic: #94a3b8; }

.card-text { min-width: 0; flex: 1; }

.card-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.card-desc {
  margin: 0.24rem 0 0;
  font-size: 0.81rem;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.7rem;
  min-width: 0;
  font-size: 0.73rem;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.meta .tag {
  padding: 0.08rem 0.45rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.7rem;
}

.meta .ver { color: var(--text-2); }

.actions { display: flex; align-items: center; gap: 0.35rem; flex: 0 0 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  height: 34px;
  padding: 0 0.85rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.18s, transform 0.12s;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 14px; height: 14px; }

.icon-btn.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.icon-btn.small svg { width: 16px; height: 16px; }

/* ---------- empty / footer ---------- */
.empty {
  margin: 0.5rem 0 3rem;
  padding: 3.5rem 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 0.88rem;
  text-align: center;
}

.empty code {
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.84em;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.76rem;
}

.foot-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 1.4rem 0 2.2rem;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  z-index: 50;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.79rem;
  font-weight: 600;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .wrap { width: min(1120px, 100% - 1.6rem); }
  .brand-txt small { display: none; }
  .hero { padding-top: 1.8rem; }
  .search kbd { display: none; }
  .search input { padding-right: 1rem; }
  .selectwrap select { width: 100%; }
  .toolbar > .selectwrap { flex: 1 1 100%; }
  .card { padding: 0.95rem; }
  .fileicon { width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}
