:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1f2330;
  --muted: #8a8f9c;
  --accent: #7c5cff;
  --accent-soft: #efeaff;
  --danger: #ff5b6e;
  --line: #ececf3;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(40, 30, 90, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.brand .logo { font-size: 24px; }

.search {
  flex: 1 1 240px;
  min-width: 180px;
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  gap: 8px;
}
.search input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 15px;
  background: transparent;
  color: var(--text);
}
.search .icon { color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.05); color: #fff; }
.btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 分类 chips ---------- */
.chips {
  max-width: 1100px;
  margin: 14px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- 网格 ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 20px 60px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.card:hover { transform: translateY(-3px); }
.card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 12px;
  background: #f3f4f9;
}
.card .name {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: rgba(20, 16, 40, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.card:hover .overlay { opacity: 1; }
.overlay .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mini {
  border: none;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  color: var(--text);
}
.mini:hover { background: var(--accent-soft); color: var(--accent); }
.mini.danger { color: var(--danger); }
.mini.danger:hover { background: #ffe9ec; }
.mini.fav-on { background: #fff2c2; color: #b88000; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 40, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--panel);
  border-radius: 20px;
  width: 100%;
  max-width: 460px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--text);
  background: #fbfbfe;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.preview {
  margin-top: 12px;
  text-align: center;
}
.preview img {
  max-width: 140px;
  max-height: 140px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.help-text { font-size: 13px; color: var(--muted); line-height: 1.6; }
.help-text code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}
.help-text a { color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2330;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 加载指示 */
.loading { text-align: center; color: var(--muted); padding: 40px; font-size: 15px; }

/* 加载更多 */
.loadmore {
  text-align: center;
  padding: 26px 0 8px;
}
.loadmore .btn {
  font-size: 15px;
  padding: 11px 26px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.loadmore .btn:hover { filter: brightness(1.06); color: #fff; }
