* { box-sizing: border-box; }
:root {
  /* 颜色、字号、间距以 tokens.css 为准。这里只留本模块要用、而 token 里没有的别名 */
  --bg-2: var(--surface-0);
  --ok: var(--up);
  --err: var(--down);
  --btn-bg: linear-gradient(135deg, #2dd4bf, #14b8a6);
  --btn-text: #032521;
  --radius: var(--r-4);
  --shadow: var(--sh-3);
}
body {
  margin: 0;
  font: var(--fs-4)/1.5 system-ui, -apple-system, "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(79,140,255,.18) 0%, transparent 55%),
    radial-gradient(800px 480px at 98% 0%, rgba(250,204,21,.10) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }

/* 搜索栏（位于「收集素材」面板内） */
.gl-tools { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.search {
  flex: 1; max-width: 520px;
  height: 36px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-soft); background: var(--card-2); outline: none;
}
.search::placeholder { color: var(--muted-2); }
.search:focus { border-color: var(--line-strong); box-shadow: var(--focus-ring); }
.count { margin-left: auto; white-space: nowrap; font-size: var(--fs-2); color: var(--text-3); font-variant-numeric: tabular-nums; }

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface-1); font-size: var(--fs-3); font-weight: 600; white-space: nowrap;
  transition: border-color var(--dur-1), color var(--dur-1), background-color var(--dur-1);
}
.pill-btn:hover { border-color: var(--border); }
.pill-btn.primary { border: none; background: var(--btn-bg); color: var(--btn-text); box-shadow: var(--sh-1); }
.pill-btn.primary:hover { filter: brightness(1.08); }
.pill-btn.danger { color: var(--err); border-color: rgba(248,113,113,.35); }
.pill-btn.sm { height: 32px; padding: 0 12px; font-size: var(--fs-2); }
.pill-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.link { border: none; background: none; padding: 0; font-size: var(--fs-2); color: var(--text-3); }
.link:hover { color: var(--text); }
.link.danger:hover { color: var(--err); }

/* 布局 */
.layout { display: flex; align-items: flex-start; gap: 20px; }

.sidebar {
  position: sticky; top: 22px;
  width: 220px; flex-shrink: 0;
  max-height: calc(100vh - 44px); overflow-y: auto;
  padding: 16px;
  background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 14px;
  scrollbar-width: none;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 4px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.active-filters:not(:empty) { margin: 8px 0 4px; }
.filter-group { padding: 12px 0 2px; border-top: 1px dashed var(--border-soft); margin-top: 10px; }
.filter-title {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-3); font-weight: 650; cursor: pointer; user-select: none;
}
.filter-title .sq { width: 8px; height: 8px; border-radius: 2px; background: rgb(var(--c)); }
.filter-title::after { content: "▸"; margin-left: auto; color: var(--text-3); font-size: var(--fs-1); transition: transform var(--dur-1); }
.filter-title.open::after { transform: rotate(90deg); }
.filter-body { display: none; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
.filter-title.open + .filter-body { display: flex; }

/* 标签 chip */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 11px; border-radius: 999px;
  border: 1px solid var(--border-soft); background: var(--card-2);
  color: var(--text-2); font-size: var(--fs-2); font-weight: 500; line-height: 18px; white-space: nowrap;
  transition: all .15s ease;
}
.chip small { color: var(--text-3); font-size: var(--fs-1); font-variant-numeric: tabular-nums; }
button.chip:hover { color: var(--text); border-color: rgba(var(--c),.5); }
.sidebar .chip, .tag-row .chip { max-width: 100%; min-width: 0; }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar .muted, .tag-row .muted, .drawer-head .muted { font-size: var(--fs-2); }
.chip.on { color: #fff; border-color: rgba(var(--c),.75); background: rgba(var(--c),.18); }
.chip.on small { color: rgba(255,255,255,.65); }
.chip .x { opacity: .6; }
.chip.mini { padding: 0 8px; font-size: var(--fs-1); color: rgb(var(--c)); background: rgba(var(--c),.1); border-color: rgba(var(--c),.25); }

/* 瀑布流 */
.main { flex: 1; min-width: 0; }
.grid { column-width: 230px; column-gap: 16px; }
.card {
  break-inside: avoid; margin-bottom: 16px; position: relative;
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 6px 18px rgba(0,0,0,.25);
  cursor: pointer; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-1px); border-color: rgba(var(--c),.4); box-shadow: var(--sh-2); }
.card img, .card video { display: block; width: 100%; height: auto; background: var(--card-2); }
.card .badge {
  position: absolute; top: 10px; font-size: var(--fs-1); line-height: 20px; padding: 0 9px; border-radius: var(--r-pill);
  background: rgba(7,11,22,.72); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.12);
}
.card .cover { position: relative; }
.card .badge.status { left: 44px; color: rgb(var(--c)); border-color: rgba(var(--c),.45); }
.card .badge.multi { top: auto; bottom: 10px; right: 10px; color: var(--muted); }
.card .sel, .card .edit {
  position: absolute; top: 8px; z-index: 2; opacity: 0; transition: opacity .15s;
  border: 1px solid rgba(255,255,255,.25); background: rgba(7,11,22,.7); backdrop-filter: blur(8px);
}
.card .sel { left: 8px; width: 32px; height: 32px; border-radius: var(--r-2); font-size: var(--fs-4); font-weight: 700; color: var(--btn-text); }
.card .edit { right: 8px; height: 32px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-2); }
.card .edit:hover { border-color: rgba(255,255,255,.5); }
.card:hover .sel, .card:hover .edit, .card.selected .sel, body.selecting .card .sel { opacity: 1; }
.card.selected { border-color: rgba(var(--c),.75); box-shadow: 0 0 0 1px rgba(var(--c),.45); }
.card.selected .sel { background: rgb(var(--c)); border-color: rgb(var(--c)); color: #3b2800; }
.price { margin-top: 4px; font-size: var(--fs-2); font-weight: 650; color: var(--money); line-height: 1.4; font-variant-numeric: tabular-nums; }
.price.big { font-size: var(--fs-4); margin-top: 0; }

/* 大图浏览 */
.lightbox { position: fixed; inset: 0; z-index: 80; display: flex; background: rgba(3,6,14,.94); backdrop-filter: blur(6px); }
.lb-stage { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 28px 80px 96px; }
.lb-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lb-media img, .lb-media video {
  height: calc(100vh - 124px); width: auto; max-width: 100%; object-fit: contain;
  border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.6); background: #000;
}
.lb-media img { cursor: zoom-in; }
.lb-media.zoom { overflow: auto; align-items: flex-start; justify-content: safe center; }
.lb-media.zoom img { height: calc((100vh - 124px) * 2); max-width: none; cursor: zoom-out; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(19,28,48,.85); font-size: 26px; line-height: 1; color: var(--text);
}
.lb-nav:hover { border-color: var(--muted-2); }
.lb-nav.prev { left: 20px; } .lb-nav.next { right: 20px; }
.lb-thumbs { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.lb-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; overflow: hidden; opacity: .55; }
.lb-thumbs button.on { border-color: rgb(var(--c)); opacity: 1; }
.lb-thumbs img, .lb-thumbs video { height: 58px; display: block; }
.lb-counter { position: absolute; top: 24px; left: 28px; font-size: var(--fs-2); color: var(--text-3); font-variant-numeric: tabular-nums; }
.lb-close {
  position: absolute; top: 18px; right: 20px; z-index: 2; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(19,28,48,.85); color: var(--text); font-size: 24px; line-height: 1;
}
.lb-close:hover { border-color: var(--err); color: var(--err); }
.lb-close small { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); font-size: var(--fs-1); color: var(--text-3); white-space: nowrap; }
.lb-info {
  width: 340px; flex-shrink: 0; overflow-y: auto; padding: 20px 22px;
  background: var(--bg-2); border-left: 1px solid var(--border-soft);
}
.lb-head { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.lb-title { font-size: var(--fs-5); font-weight: 700; }
.lb-sub { font-size: var(--fs-2); color: var(--text-3); margin-top: 2px; }
.lb-row { margin-top: 10px; }
.lb-block { margin-top: 14px; }
.lb-block label { display: block; font-size: var(--fs-2); color: var(--text-3); margin-bottom: 4px; }
.lb-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.lb-text { font-size: var(--fs-3); color: var(--text-2); white-space: pre-wrap; line-height: 1.6; text-wrap: pretty; }
.lb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border-soft); }
.lb-keys { margin-top: 14px; font-size: var(--fs-2); color: var(--text-3); }

/* 多选底栏 */
.selbar {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid rgba(var(--c),.45); box-shadow: var(--sh-3);
  font-size: var(--fs-3);
}
.selbar b { color: rgb(var(--c)); font-variant-numeric: tabular-nums; }
.selbar .pill-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 并排对比 */
.compare { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; }
.cmp-head { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border-soft); }
.cmp-head h3 { margin: 0; font-size: var(--fs-5); }
.cmp-head .spacer { flex: 1; }
.cmp-cols { flex: 1; min-height: 0; display: flex; gap: 16px; overflow: auto; padding: 20px 24px 40px; align-items: flex-start; }
.cmp-col {
  flex: 0 0 300px; background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column;
}
.cmp-media { cursor: zoom-in; background: #000; }
.cmp-media img, .cmp-media video { display: block; width: 100%; max-height: 58vh; object-fit: contain; }
.cmp-info { padding: 12px 14px 4px; }
.cmp-col > .link { align-self: flex-start; margin: 8px 14px 12px; }
.card .meta { padding: 10px 12px 12px; }
.card .title { font-weight: 650; font-size: var(--fs-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { font-size: var(--fs-2); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.empty { text-align: center; padding: 110px 0; }
.grid > .empty { column-span: all; }
.empty .big { font-size: var(--fs-5); font-weight: 700; margin-bottom: var(--sp-2); }
.empty .hint { color: var(--text-2); font-size: var(--fs-3); line-height: 1.6; text-wrap: pretty; }

/* 详情抽屉 */
.drawer {
  position: fixed; top: 0; right: 0; z-index: 30;
  width: min(560px, 100vw); height: 100vh; overflow-y: auto;
  background: var(--bg-2); border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0,0,0,.55);
  padding: 20px 22px 40px;
  animation: slide .2s ease;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.drawer-head .id { font-weight: 700; font-size: var(--fs-5); color: var(--text); }
.drawer-head .spacer { flex: 1; }
.shots { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.shot { position: relative; flex-shrink: 0; }
.shot img, .shot video { height: 320px; border-radius: 12px; display: block; border: 1px solid var(--border-soft); background: #000; }
.shot img { cursor: zoom-in; }
.shot video + .ops { bottom: 48px; }
.shot .ops { position: absolute; bottom: 8px; left: 6px; right: 6px; display: none; gap: 4px; justify-content: center; }
.shot:hover .ops { display: flex; }
.shot .ops button { font-size: var(--fs-1); padding: 2px 9px; border-radius: var(--r-pill); border: none; background: rgba(7,11,22,.8); }
.shot.cover::after { content: "封面"; position: absolute; top: 8px; left: 8px; font-size: var(--fs-1); font-weight: 700; background: rgb(var(--c)); color: #3b2800; padding: 0 7px; border-radius: var(--r-1); }
.add-shot {
  flex-shrink: 0; width: 110px; height: 320px; border-radius: 12px;
  border: 1.5px dashed var(--border); background: var(--card-2); color: var(--muted-2);
}
.add-shot:hover { color: var(--text); border-color: var(--muted-2); }

.box { margin-top: 14px; padding: 14px; background: var(--card); border: 1px solid var(--border-soft); border-radius: 14px; }
.box-title { font-size: var(--fs-2); color: var(--text-2); margin-bottom: 8px; display: flex; justify-content: space-between; }
.field + .field, .row + .field { margin-top: 12px; }
.field label { display: block; font-size: var(--fs-2); color: var(--text-3); margin-bottom: 4px; }
.field input, .field textarea, .new-tag input, .new-tag select, .mg-add input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-soft); border-radius: 10px;
  background: var(--card-2); outline: none;
}
.field input, .field textarea, .new-tag input, .new-tag select { min-height: 36px; }
.field input:focus, .field textarea:focus, .new-tag input:focus, .new-tag select:focus, .mg-add input:focus { border-color: var(--line-strong); box-shadow: var(--focus-ring); }
.field textarea { min-height: 70px; resize: vertical; }
::placeholder { color: var(--muted-2); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; margin-top: 0 !important; }

.status-pick { display: flex; gap: 6px; flex-wrap: wrap; }

.tag-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.tag-row + .tag-row { border-top: 1px dashed var(--border-soft); }
.tag-row .gname { flex: 0 0 64px; font-size: var(--fs-2); color: rgb(var(--c)); padding-top: 3px; }
.tag-row .list { display: flex; flex-wrap: wrap; gap: 6px; }
.new-tag { display: flex; gap: 6px; margin-top: 10px; }
.new-tag input { flex: 1; }
.new-tag select { width: auto; }

/* 管理标签弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 40; background: rgba(3,6,14,.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  width: min(640px, 94vw); max-height: 86vh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-top: 3px solid rgb(var(--c));
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { margin: 0; font-size: var(--fs-5); }
.modal-tip { margin: 0 0 8px; font-size: var(--fs-2); color: var(--text-3); }
.mg { padding: 12px 0; border-top: 1px dashed var(--border-soft); }
.mg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mg-head .sq { width: 8px; height: 8px; border-radius: 2px; background: rgb(var(--c)); }
.mg-head b { font-size: var(--fs-3); cursor: pointer; }
.mg-head b:hover { color: rgb(var(--c)); }
.mg-head .link { margin-left: auto; }
.mg-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mg-tags .chip { cursor: pointer; }
.mg-tags .chip .x { margin-left: 2px; padding: 0 2px; }
.mg-tags .chip .x:hover { color: var(--err); opacity: 1; }
.mg-add input { width: 110px; padding: 3px 11px; border-radius: var(--r-pill); font-size: var(--fs-2); }
.new-group { margin-top: 12px; }
.new-group input { width: 180px; padding: 6px 12px; border: 1px dashed var(--line); border-radius: var(--r-pill); background: none; outline: none; font-size: var(--fs-2); }

/* 素材文件夹连接状态 */
.conn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface-1); font-size: var(--fs-3); font-weight: 600; white-space: nowrap;
}
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c-dot, var(--text-3)); }
.conn.ok { --c-dot: var(--ok); color: var(--muted); cursor: default; }
.conn.idle { --c-dot: var(--muted-2); color: var(--muted-2); font-weight: 500; }
.conn.idle:hover { color: var(--text); border-color: var(--border); }
.conn.err { --c-dot: var(--err); color: var(--err); border-color: rgba(248,113,113,.4); }
.empty .pill-btn { margin-top: 18px; }

/* 上传后快速打标签 */
.quick-box { width: min(620px, 94vw); }
.quick-thumbs { display: flex; gap: 8px; overflow-x: auto; margin: 10px 0 4px; padding-bottom: 4px; }
.quick-thumbs .qt { flex: none; }
.quick-thumbs img, .quick-thumbs video { height: 120px; border-radius: 10px; border: 1px solid var(--border-soft); display: block; background: #000; }
.quick-box .field { margin: 10px 0 6px; }

/* 其他 */
.drop-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(var(--brand-rgb),.08);
  border: 3px dashed rgb(var(--brand-rgb)); display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-6); font-weight: 700; color: rgb(var(--brand-rgb)); pointer-events: none;
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 9px 18px; border-radius: var(--r-pill); font-size: var(--fs-3); box-shadow: var(--sh-3);
}
.toast.error { border-color: rgba(248,113,113,.5); color: var(--err); }
[hidden] { display: none !important; }

@media (max-width: 920px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; max-height: none; }
  .grid { column-width: 160px; column-gap: 12px; }
}
@media (hover: none) {
  .card:hover { transform: none; }
}
@media (max-width: 640px) {
  .gl-tools { flex-wrap: wrap; margin-bottom: 12px; }
  .search { max-width: none; }
  .count { width: 100%; margin-left: 0; }
  .pill-btn, .conn { height: 40px; }
  .pill-btn.sm { height: 36px; }
  .card .sel, .card .edit, body.selecting .card .sel { opacity: 1; }
  .card .sel { width: 36px; height: 36px; }
  .card .edit { height: 36px; }
  .drawer { width: 100vw; height: calc(100dvh - 86px - env(safe-area-inset-bottom)); }
  .lightbox { flex-direction: column; overflow-y: auto; }
  .lb-stage { flex: none; height: 78vh; padding: 20px 12px 90px; }
  .lb-media img, .lb-media video { height: calc(78vh - 110px); }
  .lb-info { width: 100%; border-left: 0; border-top: 1px solid var(--border-soft); }
  .lb-nav { display: none; }
  .lb-close, .field input, .new-tag input, .new-tag select { min-height: 40px; }
}
