:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1c1f28;
  --line: #262a36;
  --text: #e8eaf0;
  --muted: #8b91a3;
  --accent: #9d7bff;
  --accent-2: #4ff0d0;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* 关键：hidden 属性必须能压过后面任何 display 声明，
   否则 .lightbox { display: grid } 会让它从加载起就铺满全屏并吃掉所有点击。 */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: radial-gradient(1200px 600px at 80% -10%, #241a3d 0%, transparent 60%),
              radial-gradient(900px 500px at 0% 0%, #10262a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font: 15px/1.6 "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  padding: 0 clamp(14px, 4vw, 48px) 64px;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */

.top { padding: 40px 0 18px; }

.brand { display: flex; align-items: center; gap: 12px; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 14px var(--accent-2);
  flex: none;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3.2vw, 32px);
  font-weight: 700;
  letter-spacing: .02em;
}

h1 .sub {
  margin-left: 10px;
  font-size: .5em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .18em;
  vertical-align: middle;
}

.tagline { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.tagline a { margin-left: 6px; }

/* ---------- toolbar ---------- */

.bar {
  display: flex;
  gap: 10px;
  margin: 22px 0 14px;
  flex-wrap: wrap;
}

#search {
  flex: 1 1 320px;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 123, 255, .16);
}

#sort {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
}

/* ---------- tags ---------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: all .16s;
}

.chip:hover { color: var(--text); border-color: #3a4053; }

.chip.on {
  background: rgba(157, 123, 255, .16);
  border-color: var(--accent);
  color: #d7ccff;
}

.chip .n { opacity: .55; margin-left: 6px; font-size: 11px; }

/* 分类条：一级文件夹，比标签更显眼 */
#collections { margin-bottom: 10px; }

#collections .chip {
  font-size: 14px;
  padding: 7px 16px;
  font-weight: 600;
  letter-spacing: .01em;
}

#tags { margin-bottom: 8px; }

/* ---------- grid ---------- */

.stats {
  color: var(--muted);
  font-size: 13px;
  margin: 14px 0 18px;
  font-variant-numeric: tabular-nums;
}

.grid {
  columns: 5 240px;
  column-gap: 14px;
}

.card {
  break-inside: avoid;
  margin: 0 0 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform .18s, border-color .18s, box-shadow .18s;
  position: relative;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #3d3355;
  box-shadow: 0 14px 34px -18px rgba(157, 123, 255, .55);
}

.frame { position: relative; background: var(--panel-2); overflow: hidden; }

.frame img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .35s ease;
}

.card:hover .frame img { transform: scale(1.03); }

.size {
  position: absolute;
  right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
  color: #d8dbe6;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

/* 卡片左上角的分类标记 */
.col {
  position: absolute;
  left: 8px; top: 8px;
  background: rgba(10, 12, 16, .66);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, .07);
  color: #cfd4e2;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
}

figcaption {
  padding: 9px 11px 11px;
  font-size: 13px;
  color: #c3c8d6;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

figcaption .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

figcaption .dl {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid transparent;
}

figcaption .dl:hover { color: var(--accent-2); text-decoration: none; }

/* ---------- empty ---------- */

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty .big { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.empty .hint { font-size: 12px; opacity: .8; }
code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  color: #cfc4ff;
}

/* ---------- lightbox ---------- */

/* 只有移除 hidden 属性时才显示：从根上避免和 [hidden] 打架 */
.lightbox:not([hidden]) {
  display: grid;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 7, 10, .92);
  backdrop-filter: blur(8px);
  place-items: center;
  padding: clamp(12px, 4vw, 44px);
}

.lb-inner {
  margin: 0;
  max-width: min(1100px, 92vw);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
}

.lb-inner img {
  max-height: 68vh;
  max-width: 100%;
  width: auto;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  object-fit: contain;
}

.lb-inner figcaption h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.lb-meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.lb-tags { margin: 6px 0 0; color: var(--accent); font-size: 12px; }

.lb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 15px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all .16s;
}

.btn:hover { border-color: #40465c; background: var(--panel-2); text-decoration: none; }

.btn.primary {
  background: linear-gradient(135deg, #7d5cff, #9d7bff);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover { filter: brightness(1.08); }

.lb-toast { margin: 8px 0 0; font-size: 12px; color: var(--accent-2); min-height: 1em; }

.lb-close {
  position: fixed;
  top: 18px; right: 20px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}

.lb-close:hover { color: var(--text); }

.lb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(22, 24, 31, .8);
  border: 1px solid var(--line);
  color: var(--text);
  width: 44px; height: 64px;
  border-radius: 10px;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

.lb-nav:hover { border-color: var(--accent); }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }

/* ---------- footer ---------- */

footer {
  margin-top: 54px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

footer p { margin: 6px 0; }
footer .muted { opacity: .65; font-size: 12px; }
footer strong { color: var(--text); }

/* ---------- doc page ---------- */

.doc { max-width: 780px; }
.doc h2 { font-size: 19px; margin: 34px 0 10px; }
.doc h3 { font-size: 15px; margin: 22px 0 6px; color: #cfd4e2; }
.doc p, .doc li { color: #c3c8d6; }
.doc ul, .doc ol { padding-left: 20px; }
.doc .note {
  border-left: 3px solid var(--accent);
  background: rgba(157, 123, 255, .07);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 13.5px;
}
.doc textarea {
  width: 100%;
  min-height: 180px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: 13px/1.65 ui-monospace, Consolas, monospace;
  padding: 12px 14px;
  resize: vertical;
}
.doc .back { display: inline-block; margin-top: 34px; color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .grid { columns: 2 140px; column-gap: 10px; }
  .card { margin-bottom: 10px; }
  .lb-nav { display: none; }
  .lb-inner img { max-height: 60vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- 整类打包下载 ---------- */

.bundles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
}

.blabel {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
  margin-right: 2px;
}

.bundle {
  text-decoration: none;
  border-style: dashed;
}

.bundle:hover {
  text-decoration: none;
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.bundle .n { opacity: .6; }
