:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e3e6ec;
  --accent: #2563eb;
  --accent-soft: #eaf0ff;
  --image: #0f9d76;
  --image-soft: #e5f7f1;
  --video: #a855f7;
  --video-soft: #f4e9ff;
  --other: #64748b;
  --other-soft: #edf1f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1440px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; background: var(--accent-soft); color: var(--accent);
}
.brand__title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.brand__sub { margin: 1px 0 0; font-size: 12px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 9px;
  color: var(--muted); transition: border-color .15s, background .15s;
}
.search:focus-within { background: #fff; border-color: var(--accent); }
.search input {
  width: 190px; border: 0; outline: 0; background: transparent;
  color: var(--ink); font: inherit;
}
.search input::placeholder { color: #9ca3af; }
.select select, .icon-btn, .refresh-btn, .chip, .empty__btn {
  height: 36px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 9px; font: inherit; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.select select { padding: 0 10px; }
.icon-btn { width: 36px; font-size: 17px; line-height: 1; }
.refresh-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 0 14px;
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.refresh-btn svg { transition: transform .5s ease; }
.refresh-btn.is-loading svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.select select:hover, .icon-btn:hover, .chip:hover, .empty__btn:hover { border-color: #c7cdd8; background: #fafbfc; }
.refresh-btn:hover { background: #1d4ed8; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- 页面与筛选 ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 24px 28px 64px; }
.summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 0 14px; font-size: 13px; color: var(--muted); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip__count { font-variant-numeric: tabular-nums; opacity: .65; margin-left: 3px; }
.summary__hint { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- 网格 ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(16, 24, 40, .12); }
.thumb {
  position: relative; aspect-ratio: 4 / 3; border: 0; padding: 0; width: 100%;
  display: block; overflow: hidden; cursor: zoom-in; background: var(--surface-2);
  background-image: linear-gradient(45deg, #e9ecf1 25%, transparent 25%),
                    linear-gradient(-45deg, #e9ecf1 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #e9ecf1 75%),
                    linear-gradient(-45deg, transparent 75%, #e9ecf1 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb--cover img { object-fit: cover; }
.thumb__badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .4px; color: #fff; background: rgba(31, 36, 48, .72);
  backdrop-filter: blur(4px);
}
.thumb__badge[data-kind="image"] { background: var(--image); }
.thumb__badge[data-kind="video"] { background: var(--video); }
.thumb__badge[data-kind="other"] { background: var(--other); }
.thumb__play {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  background: rgba(17, 24, 39, .28); opacity: 0; transition: opacity .18s;
}
.thumb:hover .thumb__play { opacity: 1; }
.thumb__play span {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  background: #fff; color: var(--ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
.thumb__play svg { margin-left: 3px; }

.video-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(circle at 30% 20%, #ffffff, #e8eaf0);
  color: #4b5563; padding: 18px; text-align: center;
}
.video-fallback__icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--video); color: #fff; box-shadow: 0 8px 20px rgba(168, 85, 247, .28);
}
.video-fallback__icon svg { margin-left: 3px; }
.video-fallback__label { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: #7c3aed; }
.video-fallback__name {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #6b7280;
}
.file-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--other-soft); color: var(--muted);
}

.card__body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card__name {
  margin: 0; font-size: 13px; font-weight: 650; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__meta { margin: 0; font-size: 11px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.card__actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.card__kind { font-size: 11px; color: var(--muted); }
.download {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--ink); font-size: 12px; font-weight: 600; text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.download:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 空状态 ---------- */
.empty {
  margin: 40px auto; max-width: 460px; padding: 40px 28px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty__art {
  width: 72px; height: 72px; margin: 0 auto 16px; display: grid; place-items: center;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent);
}
.empty h2 { margin: 0 0 8px; font-size: 17px; }
.empty p { margin: 0 0 20px; color: var(--muted); }
.empty code { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); font-size: 12px; }
.empty__btn { padding: 0 18px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.empty__btn:hover { background: #1d4ed8; }

/* ---------- 预览弹层 ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: rgba(15, 23, 42, .78); backdrop-filter: blur(6px);
  padding: 24px;
}
.viewer[hidden] { display: none; }
.viewer__bar {
  max-width: 1120px; width: 100%; margin: 0 auto 12px; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: #fff; border-radius: 12px 12px 0 0; box-shadow: var(--shadow);
}
.viewer__title { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 650; }
.viewer__title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__badge {
  flex: none; padding: 3px 9px; border-radius: 999px; font-size: 11px;
  background: var(--accent-soft); color: var(--accent);
}
.viewer__tools { display: flex; align-items: center; gap: 6px; flex: none; }
.viewer__nav, .viewer__close {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer;
}
.viewer__nav:hover, .viewer__close:hover { background: var(--surface-2); }
.viewer__close { font-size: 24px; }
.viewer__pos { min-width: 52px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.viewer__download {
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center;
  border-radius: 8px; background: var(--accent); color: #fff; text-decoration: none;
  font-size: 12px; font-weight: 600;
}
.viewer__download:hover { background: #1d4ed8; }
.viewer__stage {
  max-width: 1120px; width: 100%; min-height: 0; flex: 1; margin: 0 auto;
  display: grid; place-items: center; padding: 18px; overflow: auto;
  background: #fff; border-radius: 0 0 12px 12px; box-shadow: var(--shadow);
}
.viewer__stage img { max-width: 100%; max-height: calc(100vh - 190px); object-fit: contain; }
.viewer__stage video {
  max-width: 100%; max-height: calc(100vh - 190px); background: #111;
  border-radius: 8px;
}
.viewer__error { color: var(--muted); text-align: center; }
body.is-locked { overflow: hidden; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: #fff;
  font-size: 13px; box-shadow: 0 8px 24px rgba(16, 24, 40, .25);
}
.toast[hidden] { display: none; }

@media (max-width: 720px) {
  .topbar__inner, .page { padding-left: 16px; padding-right: 16px; }
  .search input { width: 130px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
  .viewer { padding: 10px; }
  .viewer__bar { flex-wrap: wrap; }
  .viewer__stage { padding: 10px; }
}
