/* ============================================================
   icons+ design system — v0.3.1
   Aligned with modern-web-guidance:
   - color-scheme + light-dark() theming (manual override via
     <meta name="color-scheme"> mapped back through :root:has())
   - native <dialog> modals with @starting-style entry/exit
   - compositor-friendly motion (opacity/translate/scale) with
     prefers-reduced-motion handling
   - rem type scale, text-wrap: balance, no fixed heights
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root {
  color-scheme: light dark;

  --bg-l: #f4f5f7;          --bg-d: #0e1014;
  --surface-l: #ffffff;     --surface-d: #171a20;
  --surface-2-l: #eef0f4;   --surface-2-d: #20242c;
  --text-l: #1a1d23;        --text-d: #e8eaee;
  --muted-l: #5d6470;       --muted-d: #a2abb8;
  --border-l: #e2e5ea;      --border-d: #2b303a;
  --primary-l: #4f46e5;     --primary-d: #7c74ff;
  --primary-hover-l: #4338ca; --primary-hover-d: #8f88ff;
  --primary-2-l: #7c3aed;   --primary-2-d: #a78bfa;
  --ok-l: #15803d;          --ok-d: #4ade80;
  --err-l: #dc2626;         --err-d: #f87171;
  --shadow-l: 0 1px 2px rgb(16 24 40 / 0.05), 0 2px 8px rgb(16 24 40 / 0.06);
  --shadow-d: 0 1px 2px rgb(0 0 0 / 0.5), 0 2px 8px rgb(0 0 0 / 0.35);
  --shadow-pop-l: 0 4px 12px rgb(16 24 40 / 0.08), 0 20px 48px rgb(16 24 40 / 0.18);
  --shadow-pop-d: 0 4px 12px rgb(0 0 0 / 0.45), 0 20px 48px rgb(0 0 0 / 0.6);
  --topbar-h: 60px;
  --radius: 12px;

  /* resolved tokens — fallback path (no light-dark() support) */
  --bg: var(--bg-l);       --surface: var(--surface-l);
  --surface-2: var(--surface-2-l); --text: var(--text-l);
  --muted: var(--muted-l); --border: var(--border-l);
  --primary: var(--primary-l); --primary-hover: var(--primary-hover-l);
  --primary-2: var(--primary-2-l);
  --ok: var(--ok-l);       --err: var(--err-l);
  --shadow: var(--shadow-l); --shadow-pop: var(--shadow-pop-l);
}
/* flat fallback branch (kept out of :root for parser robustness) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--bg-d);       --surface: var(--surface-d);
    --surface-2: var(--surface-2-d); --text: var(--text-d);
    --muted: var(--muted-d); --border: var(--border-d);
    --primary: var(--primary-d); --primary-hover: var(--primary-hover-d);
    --primary-2: var(--primary-2-d);
    --ok: var(--ok-d);       --err: var(--err-d);
    --shadow: var(--shadow-d); --shadow-pop: var(--shadow-pop-d);
  }
}

/* Modern path: tokens follow color-scheme, which the manual
   <meta name="color-scheme"> override drives through :root:has(). */
@supports (color: light-dark(#fff, #000)) {
  :root {
    --bg: light-dark(var(--bg-l), var(--bg-d));
    --surface: light-dark(var(--surface-l), var(--surface-d));
    --surface-2: light-dark(var(--surface-2-l), var(--surface-2-d));
    --text: light-dark(var(--text-l), var(--text-d));
    --muted: light-dark(var(--muted-l), var(--muted-d));
    --border: light-dark(var(--border-l), var(--border-d));
    --primary: light-dark(var(--primary-l), var(--primary-d));
    --primary-hover: light-dark(var(--primary-hover-l), var(--primary-hover-d));
    --primary-2: light-dark(var(--primary-2-l), var(--primary-2-d));
    --ok: light-dark(var(--ok-l), var(--ok-d));
    --err: light-dark(var(--err-l), var(--err-d));
    --shadow: light-dark(var(--shadow-l), var(--shadow-d));
    --shadow-pop: light-dark(var(--shadow-pop-l), var(--shadow-pop-d));
  }
}

/* Manual override: <meta name="color-scheme"> is the source of truth.
   CSS must not depend on JS — without it, the site follows the system. */
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }

/* gradient interpolation space (progressive enhancement) */
:root { --in-oklab: ; }
@supports (linear-gradient(in oklab, red, blue)) {
  :root { --in-oklab: in oklab; }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html {
  accent-color: var(--primary);
  scrollbar-width: thin;
}
@supports (color: light-dark(#fff, #000)) {
  html { scrollbar-color: light-dark(#c3c8cf, #3a4048) transparent; }
}
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
.muted { color: var(--muted); font-size: 0.8125rem; }
.hidden { display: none !important; }

/* ---------- 底部悬浮栏（版权 / 致谢 / 备案 / 项目主页 / 版本） ---------- */
.site-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
  flex-wrap: wrap;
  padding: 9px 18px;
  font-size: 0.75rem;
  color: var(--muted);
  background: color-mix(in oklab, var(--surface) 72%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--muted); transition: color 0.15s; }
.site-footer a:hover { color: var(--primary); }
.site-footer #ftIcp, .site-footer #ftGongan { display: inline-flex; align-items: center; gap: 4px; }
.beian-icon {
  width: 14px; height: 14px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
/* 页脚高度由 JS 实测写入 --footer-h：内容多时（多行/窄屏）不会盖住底部卡片 */
body.has-footer { padding-bottom: calc(var(--footer-h, 54px) + 10px); }
@media (prefers-reduced-motion: no-preference) {
  .site-footer { animation: footer-in 0.4s ease-out both; }
  @keyframes footer-in {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}

/* ---------- 危险操作按钮 ---------- */
.btn-danger {
  background: light-dark(#dc2626, #b91c1c);
  border-color: transparent;
  color: #fff;
}
.btn-danger:hover {
  background: light-dark(#b91c1c, #991b1b);
  border-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection { background: color-mix(in oklab, var(--primary) 30%, transparent); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  min-height: var(--topbar-h);
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px) saturate(1.3);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; flex-shrink: 0; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; }
.brand-title { font-size: 1.125rem; letter-spacing: 0.2px; text-wrap: balance; }

.search { flex: 1; max-width: 460px; position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 13px; width: 18px; height: 18px;
  fill: none; stroke: var(--muted); stroke-width: 2;
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 9px 84px 9px 39px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 18%, transparent);
}
/* 搜索框内的「标签」筛选入口 */
.search-filter {
  position: absolute; right: 5px; top: 50%; translate: 0 -50%;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit; font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.search-filter svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}
.search-filter:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.search-filter.is-active {
  color: var(--primary);
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  border-color: color-mix(in oklab, var(--primary) 35%, transparent);
}
.filter-count {
  min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; border-radius: 999px;
  background: var(--primary); color: #fff;
  font-size: 0.625rem; font-variant-numeric: tabular-nums;
}

/* 标签筛选浮层 */
.tag-panel {
  position: absolute; top: calc(100% + 10px); left: 0; right: 0; z-index: 40;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  max-height: min(56vh, 400px);
  overflow: auto;
}
.tag-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
}
.tag-panel-hint { margin: 9px 0 0; font-size: 0.6875rem; color: var(--muted); }
.link-btn {
  border: 0; background: none; padding: 2px 4px;
  color: var(--primary); font-family: inherit; font-size: 0.75rem;
  cursor: pointer; border-radius: 6px;
}
.link-btn:hover { text-decoration: underline; }

.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit; font-size: 0.75rem; line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.tag-chip:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
.tag-chip.selected {
  color: var(--primary);
  border-color: color-mix(in oklab, var(--primary) 55%, var(--border));
  background: color-mix(in oklab, var(--primary) 14%, var(--surface));
  font-weight: 600;
}
.tag-chip.is-static { cursor: default; color: var(--muted); }
.tag-chip.is-static:hover { border-color: var(--border); }
.tag-chip-count {
  font-size: 0.625rem; font-variant-numeric: tabular-nums;
  color: var(--muted); opacity: 0.8;
}
.tag-chip.selected .tag-chip-count { color: var(--primary); opacity: 1; }

/* 已选标签提示条 */
.active-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.active-tags-label { font-size: 0.6875rem; letter-spacing: 0.08em; color: var(--muted); }

/* 预览弹窗里的标签 */
.preview-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; justify-content: center; }

/* 标签编辑 / 上传选标签 */
.tag-editor { max-height: 220px; overflow: auto; padding: 2px; margin: 2px 0 10px; }
.tag-custom { display: flex; gap: 8px; margin: 4px 0 6px; }
.tag-custom input {
  flex: 1; min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 0.8125rem; outline: none;
}
.tag-custom input:focus { border-color: var(--primary); }
.tag-hint { font-size: 0.71875rem; margin: 2px 0 8px; }
.upload-tags-hint { font-size: 0.6875rem; margin: 4px 0 0; }

.actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.2;
  min-block-size: 36px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: color-mix(in oklab, var(--primary) 55%, var(--border)); }
.btn:active { box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.12); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); }
.cat-move, .tag-move { min-inline-size: 32px; padding: 6px; font-size: 1rem; }
/* 图标管理表格里的标签列：chips 换行 + 编辑按钮 */
.icon-tags-cell { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 220px; }
.icon-tags-cell .tag-chip { font-size: 0.625rem; padding: 2px 8px; }
.icon-tags-cell .icon-tag-edit { padding: 2px 9px; font-size: 0.6875rem; min-block-size: 24px; }
/* 窄屏用的短文案（默认隐藏长文案，移动端互换） */
.t-short { display: none; }

.btn-primary {
  background: linear-gradient(to bottom right var(--in-oklab), var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
}
.btn-primary:hover {
  background: linear-gradient(to bottom right var(--in-oklab), var(--primary-hover), var(--primary-2));
  border-color: transparent;
}
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { min-inline-size: 38px; padding: 8px; font-size: 1.125rem; }
.btn-sm { padding: 5px 11px; font-size: .72rem; min-block-size: 30px; }

/* Theme icon follows the resolved color scheme (pure CSS, no JS state) */
.theme-moon { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-sun { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-sun { display: none; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-moon { display: inline; }
}

/* ---------- Layout ---------- */
.layout { display: flex; }
.sidebar {
  width: 224px; flex-shrink: 0;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  position: sticky; top: var(--topbar-h);
  align-self: flex-start;
  max-height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
}
.cat-heading {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--muted);
  padding: 2px 12px 10px;
}
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.cat-item {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  text-align: start;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.cat-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.cat-item:active { transform: scale(0.98); }
.cat-item.active {
  background: color-mix(in oklab, var(--primary) 12%, var(--surface));
  color: var(--primary); border-color: color-mix(in oklab, var(--primary) 35%, var(--border));
  font-weight: 600;
}
.cat-item .count {
  font-size: 0.7rem; font-variant-numeric: tabular-nums;
  min-width: 24px; text-align: center;
  padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.cat-item.active .count { background: var(--primary); color: #fff; }

.content { flex: 1; padding: 20px 24px 48px; min-width: 0; }
.content-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.content-head h1 { font-size: 1.25rem; margin: 0; text-wrap: balance; }

/* ---------- Icon grid ---------- */
.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
.card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, translate 0.15s ease; }
  .card:hover, .card:focus-visible { translate: 0 -2px; }
}
.card:hover, .card:focus-visible {
  border-color: color-mix(in oklab, var(--primary) 60%, var(--border));
  box-shadow: var(--shadow-pop);
}
.card img {
  width: 52px; height: 52px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}
.card .name {
  font-size: 0.6875rem;
  color: var(--text);
  word-break: break-all;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .alias {
  font-size: 0.625rem;
  color: color-mix(in oklab, var(--muted) 80%, transparent);
  line-height: 1.3;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: -3px;
}
.preview-alias {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: -6px 0 8px;
}

.empty { text-align: center; color: var(--muted); padding: 72px 0; font-size: 0.9375rem; }

/* ---------- Native dialog modals ---------- */
dialog.modal-card {
  width: min(480px, calc(100vw - 40px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-pop);
  font-family: inherit;
}
dialog.modal-card h2 { font-size: 1.125rem; margin: 0 0 6px; text-wrap: balance; }

dialog.modal-card[open] {
  opacity: 1; translate: 0 0; scale: 1;
}
dialog.modal-card {
  opacity: 0; translate: 0 12px; scale: 0.98;
  transition:
    opacity 0.22s ease,
    translate 0.22s ease,
    scale 0.22s ease,
    overlay 0.22s ease,
    display 0.22s ease;
  transition-behavior: allow-discrete;
}
@starting-style {
  dialog.modal-card[open] { opacity: 0; translate: 0 12px; scale: 0.98; }
}

dialog.modal-card::backdrop {
  background: rgb(8 10 14 / 0.48);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition:
    opacity 0.22s ease,
    overlay 0.22s ease,
    display 0.22s ease;
  transition-behavior: allow-discrete;
}
dialog.modal-card[open]::backdrop { opacity: 1; }
@starting-style { dialog.modal-card[open]::backdrop { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  dialog.modal-card,
  dialog.modal-card::backdrop { transition-duration: 0.01s; }
}

/* scroll containment (no overflow hacks on body) */
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { overflow: hidden; overscroll-behavior: contain; }

.modal-close {
  /* 放在磨砂面板内部右上角，避免面板开启时按钮浮到面板外 */
  position: absolute; top: 26px; right: 24px;
  z-index: 20;
  border: none; background: transparent;
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
dialog.modal-card { position: relative; }

/* 预览与上传弹窗：全屏无外框 lightbox（样式在文件末尾「v1.1.0 lightbox」区） */
dialog#previewModal, dialog#uploadModal { border: 0; }
.preview-name { font-weight: 600; margin: 0 0 4px; word-break: break-all; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 0.8125rem; color: var(--muted);
}
.form input, .form textarea {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 0.875rem;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.form input::placeholder, .form textarea::placeholder { color: var(--muted); opacity: 0.75; }
.form input:focus, .form textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 18%, transparent);
}
.form-hint { font-size: 0.75rem; color: var(--muted); margin: 0; }
.form-hint code { background: var(--surface-2); padding: 2px 5px; border-radius: 5px; word-break: break-all; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.is-dirty { box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary, #6366f1) 45%, transparent); }
.form-msg { font-size: 0.8125rem; min-height: 1.2em; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--err); }

/* 下拉与文件选择：原生控件默认样式在深色/浅色下都不统一，这里统一成表单风格 */
.form select {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 34px 9px 11px;
  font-size: 0.875rem;
  background-color: var(--surface-2);
  color: var(--text);
  outline: none;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b88a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.form select:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 18%, transparent);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.8125rem; color: var(--muted); }
.field-optional {
  font-size: 0.7rem; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; margin-inline-start: 4px;
}
dialog.modal-card.modal-upload { width: min(640px, calc(100vw - 28px)); } /* 仅旧样式兜底，上传弹窗已迁移到 lightbox */
.upload-sub { font-size: 0.8125rem; line-height: 1.65; margin: 0 0 2px; }
.upload-drop {
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  padding: 24px 18px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.upload-drop:hover,
.upload-drop.is-over {
  border-color: var(--primary);
  background: color-mix(in oklab, var(--primary) 6%, var(--surface-2));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 14%, transparent);
}
.upload-drop:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.upload-drop-icon {
  width: 34px; height: 34px;
  fill: none; stroke: var(--primary); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.upload-drop-title { font-size: 0.875rem; font-weight: 600; color: var(--text); margin: 8px 0 4px; }
.upload-drop-hint { font-size: 0.75rem; color: var(--muted); margin: 0; }
.upload-file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.upload-file-list:empty { display: none; }
.upload-file-list li {
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto;
  grid-template-areas: 'thumb name size rm' 'thumb alias alias rm';
  align-items: center; gap: 6px 10px;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 0.75rem; color: var(--text);
}
/* 本地缩略图（object URL 预览，不入库） */
.upload-file-list .fthumb {
  grid-area: thumb; width: 46px; height: 46px;
  object-fit: contain; border-radius: 7px;
  padding: 3px; box-sizing: border-box;
  background:
    linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-color: #fff; background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  border: 1px solid var(--border);
}
.upload-file-list li.is-bad .fthumb { opacity: 0.45; }
/* 单条移除按钮（点 × 即从选择中删掉，不出库） */
.upload-file-list .fremove {
  grid-area: rm; align-self: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; font: inherit;
  font-size: 0.85rem; line-height: 1; padding: 0;
  transition: all .12s ease;
}
.upload-file-list .fremove:hover { color: var(--err, #e11d48); border-color: var(--err, #e11d48); }
.upload-file-list .fname { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-list .fsize { grid-area: size; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.upload-alias-input {
  grid-area: alias; width: 100%;
  border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 8px; font-size: 0.75rem;
  background: var(--surface); color: var(--text);
  font-family: inherit; outline: none;
}
.upload-alias-input::placeholder { color: var(--muted); opacity: 0.75; }
.upload-alias-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 16%, transparent);
}
.upload-file-list li.is-bad { border-color: color-mix(in oklab, var(--err) 45%, var(--border)); }
.upload-file-list li.is-bad .fsize { color: var(--err); }
.upload-denied { text-align: center; padding: 22px 8px 6px; }
.upload-denied-icon {
  width: 58px; height: 58px; border-radius: 17px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  color: var(--primary);
  background: color-mix(in oklab, var(--primary) 12%, var(--surface-2));
}
.upload-denied-icon svg {
  width: 30px; height: 30px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.upload-denied h2 { font-size: 1.125rem; margin: 0 0 6px; }
.upload-denied p { color: var(--muted); font-size: 0.875rem; line-height: 1.7; margin: 0; }
.upload-denied .form-actions { justify-content: center; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  translate: -50% 10px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.875rem;
  z-index: 100;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, translate 0.25s ease, visibility 0.25s;
  pointer-events: none;
}
.toast:not(.hidden) { opacity: 1; visibility: visible; translate: -50% 0; }

/* ---------- Account chip ---------- */
.account-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.account-chip:hover {
  border-color: color-mix(in oklab, var(--primary) 55%, var(--border));
  box-shadow: var(--shadow);
}
.account-chip.small { padding: 4px 8px 4px 4px; }
.avatar {
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  background-size: cover;
  background-position: center;
  color: #fff;
  font-weight: 700;
  flex: none;
}
.avatar.has-img { color: transparent; }
.account-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff;
  font-size: 0.75rem; font-weight: 700;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.account-chip .avatar.has-img { color: transparent; }
.avatar.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; border-radius: 16px; }
.avatar-editor {
  display: flex; align-items: center; gap: 16px;
  margin: 0 0 24px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-2);
  max-width: 640px;
}
.avatar-editor-body { min-width: 0; }
.avatar-editor-actions { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.avatar-editor .field-hint { margin: 0; }
.account-chip .account-name { font-weight: 600; }

/* ---------- Role badges ---------- */
.role-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.role-badge.role-super { background: #ede9fe; color: #5b21b6; }
.role-badge.role-uploader { background: #dbeafe; color: #1e40af; }
.role-badge.role-viewer { background: #e5e7eb; color: #374151; }
@media (prefers-color-scheme: dark) {
  .role-badge.role-super { background: #372a66; color: #d6c9ff; }
  .role-badge.role-uploader { background: #173250; color: #a9ccff; }
  .role-badge.role-viewer { background: #2c313a; color: #c2c8d0; }
}
/* light-dark() path wins where supported (incl. manual meta override) */
@supports (color: light-dark(#fff, #000)) {
  .role-badge.role-super { background: light-dark(#ede9fe, #372a66); color: light-dark(#5b21b6, #d6c9ff); }
  .role-badge.role-uploader { background: light-dark(#dbeafe, #173250); color: light-dark(#1e40af, #a9ccff); }
  .role-badge.role-viewer { background: light-dark(#e5e7eb, #2c313a); color: light-dark(#374151, #c2c8d0); }
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
}
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.failed { background: #fde2e2; color: #b91c1c; }
.badge.importing { background: #dbeafe; color: #1e40af; }
@media (prefers-color-scheme: dark) {
  .badge.pending { background: #4a3a12; color: #fcd34d; }
  .badge.approved { background: #143a26; color: #6ee7a0; }
  .badge.rejected, .badge.failed { background: #4a1d1d; color: #fca5a5; }
  .badge.importing { background: #173250; color: #a9ccff; }
}
@supports (color: light-dark(#fff, #000)) {
  .badge.pending { background: light-dark(#fef3c7, #4a3a12); color: light-dark(#92400e, #fcd34d); }
  .badge.approved { background: light-dark(#dcfce7, #143a26); color: light-dark(#166534, #6ee7a0); }
  .badge.rejected { background: light-dark(#fee2e2, #4a1d1d); color: light-dark(#991b1b, #fca5a5); }
  .badge.failed { background: light-dark(#fde2e2, #4a1d1d); color: light-dark(#b91c1c, #fca5a5); }
  .badge.importing { background: light-dark(#dbeafe, #173250); color: light-dark(#1e40af, #a9ccff); }
}
@media (prefers-reduced-motion: no-preference) {
  .badge.importing { animation: pulse 1.2s ease-in-out infinite; }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Token box ---------- */
.token-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.token-box code { flex: 1; font-size: 0.75rem; word-break: break-all; color: var(--text); }

.role-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8125rem;
  outline: none;
  font-family: inherit;
}
.role-select:focus { border-color: var(--primary); }

/* ---------- Forced colors fallback ---------- */
@media (forced-colors: active) {
  .card, .btn, .account-chip, .token-box, dialog.modal-card { border: 1px solid CanvasText; }
  .btn-primary { border: 1px solid ButtonBorder; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  /* 顶栏收紧：只留 logo + 搜索 + 头像 + 上传 */
  .topbar { gap: 8px; padding: 8px 10px; min-height: 54px; }
  .brand-logo { width: 28px; height: 28px; }
  .search { max-width: none; }
  .search input { padding: 8px 46px 8px 34px; font-size: 0.8125rem; }
  .search-icon { left: 11px; width: 16px; height: 16px; }
  .search-filter > span:not(.filter-count) { display: none; }
  .tag-panel { max-height: 62vh; }
  .brand-title { display: none; }
  /* 权限相关文字（用户名 / 角色）不占位，只保留头像 */
  .account-chip .account-name,
  .account-chip .role-badge { display: none; }
  .account-chip { padding: 3px; gap: 0; }
  .account-chip .avatar { width: 28px; height: 28px; }
  .t-full { display: none; }
  .t-short { display: inline; }
  .content { padding: 16px 14px 24px; }
  .cat-heading { display: none; }

  /* 移动端：分类改为顶部横向滚动条 + 右侧排序按钮，可切换分类 */
  .layout { flex-direction: column; }
  .sidebar {
    display: block; align-self: stretch;
    width: 100%; position: static; max-height: none;
    padding: 8px 10px; overflow: visible;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  /* 删除分类行下方的标题与统计两行（排序按钮已移到分类行右侧） */
  .content-head { display: none; }
  .sidebar nav { overflow: visible; }
  .cat-row { gap: 6px; }
  .cat-list {
    flex: 1; min-width: 0;
    flex-direction: row; flex-wrap: nowrap; gap: 6px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .cat-list::-webkit-scrollbar { display: none; }
  .cat-item {
    width: auto; flex: none; white-space: nowrap;
    padding: 6px 12px; border-radius: 999px;
    background: var(--surface-2); font-size: 0.8125rem;
  }
  .cat-item.active { background: var(--primary); color: #fff; }
  .cat-item.active .count { background: rgb(255 255 255 / 0.25); color: #fff; }

  /* 移动端：底部信息栏回到文档最底部（不再固定悬浮、不占用常驻空间） */
  body.has-footer { padding-bottom: 0; }
  .site-footer {
    position: static;
    padding: 18px 14px 22px;
    gap: 6px 12px;
    background: var(--surface);
  }
}

/* 手机竖屏：图标固定一行 4 个，卡片同步收紧 */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 10px 4px 8px; gap: 6px; border-radius: 12px; }
  .card img { width: 42px; height: 42px; }
  .card .name { font-size: 0.625rem; line-height: 1.3; }
  .card .alias { font-size: 0.5625rem; }
  .content-head { gap: 8px; margin-bottom: 12px; }
  .content-head h1 { font-size: 1.0625rem; }
}

/* ============ 本次优化新增样式 ============ */

/* 任务2：主页图标加轮廓阴影（drop-shadow 跟随透明 PNG 的真实轮廓，不是方框） */
.card img { filter: drop-shadow(0 2px 3px rgb(15 23 42 / 0.22)); transition: filter .18s ease; }
.card:hover img { filter: drop-shadow(0 4px 7px rgb(15 23 42 / 0.28)); }

/* 任务8：排序控件（单个图标按钮 + 下拉菜单，放在结果标题右侧；移动端挂到分类行右侧） */
.content-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sort-dd { position: relative; display: inline-flex; }
.sort-dd-btn {
  appearance: none; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: light-dark(rgb(255 255 255 / .6), rgb(255 255 255 / .05));
  color: var(--muted); font-size: .75rem; font-weight: 600;
  transition: all .15s ease; white-space: nowrap;
}
.sort-dd-btn:hover { color: var(--text); border-color: var(--primary); }
.sort-dd-btn[aria-expanded="true"] { color: var(--text); border-color: var(--primary); }
.sort-dd-btn[aria-expanded="true"] .sort-ico { transform: rotate(90deg); }
.sort-ico { transition: transform .18s ease; opacity: .8; }
.sort-dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 70;
  min-width: 150px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-pop, 0 12px 32px rgb(15 23 42 / .18));
  display: none; flex-direction: column; gap: 2px;
  animation: pop-in .14s ease-out;
}
.sort-dd-menu.open { display: flex; }
.sort-dd-item {
  appearance: none; border: 0; cursor: pointer; font: inherit; text-align: left;
  padding: 7px 12px; border-radius: 8px; font-size: .78rem; font-weight: 500;
  color: var(--muted); background: transparent; transition: all .12s ease; white-space: nowrap;
}
.sort-dd-item:hover { color: var(--text); background: light-dark(rgb(15 23 42 / .05), rgb(255 255 255 / .08)); }
.sort-dd-item.is-active { color: #fff; background: var(--primary, #6366f1); }

/* 分类行：横向滚动分类 + 右侧排序插槽（移动端排序按钮挂到这里） */
.cat-row { display: flex; align-items: center; gap: 8px; }
.cat-row .cat-list { flex: 1; min-width: 0; }
.m-sort-slot { flex: none; }
.m-sort-slot .sort-dd-btn { padding: 6px 10px; }

/* 搜索记录下拉：点击搜索框弹出，含一键清空 */
.search-history-panel {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  width: auto; padding: 10px 12px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-pop, 0 12px 32px rgb(15 23 42 / .18));
  animation: pop-in .14s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.search-history-panel .tag-panel-head { margin-bottom: 8px; }
.search-history-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; }
.history-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); cursor: pointer; font: inherit; font-size: .8125rem;
}
.history-item:hover { background: light-dark(rgb(15 23 42 / .06), rgb(255 255 255 / .1)); }
.history-item svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; color: var(--muted); flex: none; }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 任务10：相近图标推荐 */
.suggest-box { margin: 28px 0; padding: 18px 20px; border: 1px dashed var(--border); border-radius: 14px; background: light-dark(rgb(99 102 241 / .04), rgb(99 102 241 / .08)); }
.suggest-box h3 { margin: 0 0 14px; font-size: .9375rem; color: var(--text); font-weight: 650; }
.suggest-box h3 span { color: var(--primary, #6366f1); }
.suggest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.suggest-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.suggest-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop, 0 8px 20px rgb(15 23 42 / .14)); }
.suggest-item img { width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(0 1px 2px rgb(15 23 42 / .2)); }
.suggest-item span { font-size: .6875rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 任务12：上传模式切换（v1.1.0 拉长加大气：等宽双列大按钮） */
.upload-mode-switch {
  width: 100%; max-width: 680px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 4px 0 0; padding: 6px; border-radius: 16px;
  background: light-dark(rgb(255 255 255 / .55), rgb(255 255 255 / .07));
  border: 1px solid var(--border);
}
.upload-mode-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer; font: inherit; text-align: center;
  transition: all .15s ease;
}
.upload-mode-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--primary, #6366f1); stroke-width: 1.8; }
.upload-mode-btn span { font-size: .95rem; font-weight: 700; color: var(--text); }
.upload-mode-btn small { font-size: .72rem; color: var(--muted); }
.upload-mode-btn:hover { border-color: rgb(99 102 241 / .45); }
.upload-mode-btn.is-active {
  border-color: var(--border); background: light-dark(#fff, rgb(255 255 255 / .12));
  box-shadow: 0 6px 18px rgb(15 23 42 / .12);
}
.upload-mode-btn.is-active::after {
  content: '✓'; position: absolute; top: 10px; right: 12px;
  color: var(--primary, #6366f1); font-weight: 800; font-size: .9rem;
}
.edit-workspace { display: grid; grid-template-columns: minmax(250px, 310px) minmax(0, 1fr) minmax(250px, 310px); gap: 16px; margin-top: 8px; width: 100%; align-items: start; }
/* 中列：画布居中 */
.edit-center-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
/* 原图裁剪放在左列，四向裁剪 2×2 网格压缩高度 */
.edit-crop-field { width: 100%; margin-top: 0; }
.edit-crop-field .edit-transform { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.edit-crop-field .edit-transform .xform-actions { grid-column: 1 / -1; }
.edit-crop-field .xform-row { grid-template-columns: 32px 1fr 38px; gap: 6px; }
/* 标签在右列末尾 */
.edit-tags-field { border-top: 1px solid var(--border); padding-top: 12px; }
.edit-canvas-wrap { position: relative; display: inline-block; }
#editOverlay {
  position: absolute; inset: 0; pointer-events: none;
  background: none !important; border: none !important;
}
.edit-overlay-toggles { display: flex; gap: 10px; }
.ov-toggle {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 0.75rem; color: var(--muted); user-select: none;
}
.ov-toggle input { accent-color: var(--primary, #6366f1); cursor: pointer; }
.edit-center-col canvas {
  width: min(100%, 340px); height: auto; aspect-ratio: 1; border-radius: 14px;
  /* 画框底色 90% 不透明（约 10% 透出磨砂背景），棋盘格铺在其上 */
  background-color: light-dark(rgb(255 255 255 / 0.9), rgb(24 30 44 / 0.92));
  background-image: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border: 1px solid var(--border);
}
.edit-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.edit-side .field { margin: 0; }
.seg-control { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; width: fit-content; }
.seg-control button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit;
  padding: 5px 12px; border-radius: 6px; font-size: .75rem; font-weight: 600;
}
.seg-control button.is-active { color: #fff; background: var(--primary, #6366f1); }
.edit-colors { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.edit-colors label { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--muted); }
.edit-colors input[type=color] { width: 34px; height: 28px; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; }
.edit-side input[type=range] { width: 100%; accent-color: var(--primary, #6366f1); }

/* 渐变样式预设（PPT 风格方向） */
.grad-style { display: flex; flex-direction: column; }
.grad-preset-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 4px; }
.grad-preset-grid button {
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
  color: var(--text); cursor: pointer; font: inherit; font-size: .95rem; line-height: 1;
  padding: 7px 0; transition: all .12s ease;
}
.grad-preset-grid button:hover { border-color: var(--primary, #6366f1); }
.grad-preset-grid button.is-active {
  color: #fff; background: var(--primary, #6366f1); border-color: var(--primary, #6366f1);
}

/* 图片变换（缩放 / 左右 / 上下 / 裁剪） */
.edit-transform { display: flex; flex-direction: column; gap: 6px; }
.xform-row { display: grid; grid-template-columns: 34px 1fr 42px; align-items: center; gap: 8px; }
.xform-row label { font-size: .75rem; color: var(--muted); }
.xform-row input[type=range] { width: 100%; height: 20px; margin: 0; accent-color: var(--primary, #6366f1); }
.xform-row b { font-size: .7rem; font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.xform-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.xform-actions .btn { padding: 4px 10px; font-size: .72rem; min-block-size: 26px; }
#editCanvas { cursor: grab; touch-action: none; }
#editCanvas:active { cursor: grabbing; }
/* 编辑引导弹窗 */
dialog.guide-modal { width: min(380px, calc(100vw - 32px)); }
dialog.guide-modal p { font-size: .8125rem; line-height: 1.6; margin: 6px 0; }

/* ===== 图库右键菜单（自定义） ===== */
.ctx-menu {
  position: fixed; z-index: 3000;
  min-width: 148px;
  padding: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  animation: ctxIn .12s ease-out;
}
@keyframes ctxIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.ctx-menu.hidden { display: none; }
.ctx-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: 0; background: none; cursor: pointer;
  border-radius: 8px; font-size: .8125rem; color: var(--text);
  font-family: inherit;
}
.ctx-item:hover { background: var(--surface-2); }
.ctx-item.danger { color: var(--err); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ===== 预览「原图加载中」转圈（叠在缩略图上，原图就绪后随交叉渐变淡出） ===== */
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 上传进度弹窗 ===== */
dialog.progress-modal, dialog.done-modal { width: min(400px, calc(100vw - 32px)); text-align: center; }
.progress-ring { position: relative; width: 120px; height: 120px; margin: 4px auto 12px; }
.progress-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: light-dark(rgb(18 24 38 / 0.08), rgb(255 255 255 / 0.1)); stroke-width: 8; }
.progress-ring-fg {
  fill: none; stroke: var(--primary, #6366f1); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 0; stroke-dashoffset: 0; transition: stroke-dashoffset .2s ease;
}
.progress-ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1px; }
.progress-ring-num b { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.progress-ring-num span { font-size: .9rem; color: var(--muted); margin-top: 10px; }
.progress-title { margin: 0 0 4px; font-size: 1.05rem; }
.progress-desc { margin: 0 0 16px; font-size: .82rem; color: var(--muted); min-height: 1.1em; }
.progress-track {
  height: 8px; border-radius: 99px; overflow: hidden;
  background: light-dark(rgb(18 24 38 / 0.08), rgb(255 255 255 / 0.1));
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary, #6366f1), var(--primary-2, #7c3aed));
  transition: width .2s ease;
}
.progress-count { font-size: .75rem; margin: 10px 0 0; min-height: 1em; }

/* ===== 上传完成确认弹窗 ===== */
.done-icon {
  width: 66px; height: 66px; margin: 2px auto 12px; border-radius: 50%;
  display: grid; place-items: center;
  background: light-dark(rgb(21 128 61 / 0.12), rgb(74 222 128 / 0.16));
  color: var(--ok, #15803d);
}
.done-icon svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done-icon.is-warn {
  background: light-dark(rgb(245 158 11 / 0.14), rgb(245 158 11 / 0.2));
  color: #d97706;
}
.done-title { margin: 0 0 14px; font-size: 1.15rem; }
.done-body { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; text-align: left; }
.done-stat {
  padding: 9px 14px; border-radius: 10px; font-size: .86rem;
  background: light-dark(rgb(18 24 38 / 0.04), rgb(255 255 255 / 0.05));
}
.done-stat.ok { color: var(--ok, #15803d); }
.done-stat.err { color: var(--err, #dc2626); }
.done-stat.wait { color: #d97706; }
.done-stat.muted { color: var(--muted); }
.done-note {
  font-size: .78rem; line-height: 1.6; margin: 0 0 18px;
  padding: 10px 12px; border-radius: 10px;
  background: light-dark(rgb(79 70 229 / 0.07), rgb(124 116 255 / 0.1));
}

@media (max-width: 720px) {
  .edit-workspace { grid-template-columns: 1fr; }
  .edit-center-col { order: -1; }
  .edit-center-col canvas { width: min(100%, 260px); }
}

/* ============================================================
   v1.1.0 全屏无外框 lightbox（预览 + 上传/编辑共用玻璃体系）
   ★ 跳变防护：dialog 容器不做透明度动画（祖先 opacity<1 会形成
     新 backdrop root，导致 backdrop-filter 突然失效/生效产生跳跃）；
     容器只用 visibility+display(allow-discrete) 开关，
     压暗层/磨砂层/光晕/内容各自独立渐变，全程 GPU 平滑。
   ============================================================ */
:root { --halo-rgb: 99, 102, 241; }

dialog.lightbox {
  width: 100vw; height: 100dvh;
  max-width: none; max-height: none;
  border: 0; border-radius: 0; padding: 0;
  background: transparent; color: var(--text);
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  visibility: hidden;
  transition:
    visibility 0s linear .42s,
    overlay .42s ease allow-discrete,
    display .42s ease allow-discrete;
  transition-behavior: allow-discrete;
}
dialog.lightbox[open] {
  pointer-events: auto; visibility: visible;
  transition:
    visibility 0s,
    overlay .42s ease allow-discrete,
    display .42s ease allow-discrete;
  transition-behavior: allow-discrete;
}
dialog.lightbox::backdrop { background: none; backdrop-filter: none; }

/* 压暗层（独立渐变） */
.lb-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: light-dark(rgb(15 23 42 / 0.14), rgb(0 0 0 / 0.32));
  opacity: 0; transition: opacity .3s ease;
}
dialog.lightbox[open] .lb-scrim { opacity: 1; transition: opacity .45s ease; }

/* 渐进磨砂玻璃：模糊值恒定，透明度错峰渐入；关闭统一 .3s 无延迟退场 */
.lb-frost { position: absolute; inset: 0; pointer-events: none; }
.lb-frost i { position: absolute; inset: 0; opacity: 0; will-change: opacity; transition: opacity .3s ease; }
.lb-frost .g1 {
  backdrop-filter: blur(6px) saturate(1.35);
  -webkit-backdrop-filter: blur(6px) saturate(1.35);
  background: light-dark(rgb(255 255 255 / 0.12), rgb(10 12 20 / 0.16));
  -webkit-mask-image: radial-gradient(ellipse 85% 80% at 50% 47%, #000 0%, rgb(0 0 0 / 0.7) 55%, transparent 98%);
  mask-image: radial-gradient(ellipse 85% 80% at 50% 47%, #000 0%, rgb(0 0 0 / 0.7) 55%, transparent 98%);
}
.lb-frost .g2 {
  backdrop-filter: blur(13px) saturate(1.5);
  -webkit-backdrop-filter: blur(13px) saturate(1.5);
  background: light-dark(rgb(255 255 255 / 0.1), rgb(10 12 20 / 0.14));
  -webkit-mask-image: radial-gradient(ellipse 64% 60% at 50% 47%, #000 0%, #000 38%, transparent 92%);
  mask-image: radial-gradient(ellipse 64% 60% at 50% 47%, #000 0%, #000 38%, transparent 92%);
}
.lb-frost .g3 {
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  background: light-dark(rgb(255 255 255 / 0.08), rgb(10 12 20 / 0.12));
  -webkit-mask-image: radial-gradient(ellipse 46% 44% at 50% 47%, #000 0%, #000 42%, transparent 88%);
  mask-image: radial-gradient(ellipse 46% 44% at 50% 47%, #000 0%, #000 42%, transparent 88%);
}
dialog.lightbox[open] .lb-frost .g1 { opacity: 1; transition: opacity .5s ease; }
dialog.lightbox[open] .lb-frost .g2 { opacity: 1; transition: opacity .62s ease .06s; }
dialog.lightbox[open] .lb-frost .g3 { opacity: 1; transition: opacity .78s ease .14s; }

/* 全局环境光晕 */
.lb-aura {
  position: absolute; z-index: 1; pointer-events: none; border-radius: 50%;
  width: min(1150px, 128vw); height: min(680px, 88vh);
  background: radial-gradient(ellipse closest-side,
    rgb(var(--halo-rgb) / 0.26) 0%,
    rgb(var(--halo-rgb) / 0.11) 45%,
    transparent 74%);
  filter: blur(34px);
  opacity: 0; transform: scale(.88);
  transition: opacity .3s ease, transform .3s ease;
  will-change: opacity, transform;
}
dialog.lightbox[open] .lb-aura {
  opacity: 1; transform: scale(1);
  transition: opacity .85s ease .08s, transform .85s cubic-bezier(.2,.8,.3,1) .08s;
}

/* 局部光晕段：::before 色晕 + ::after 可读性雾层 */
.lb-stage { position: relative; display: flex; flex-direction: column; align-items: center; }
.lb-stage::before, .lb-stage::after {
  content: ''; position: absolute; z-index: -1; border-radius: 50%;
  pointer-events: none; opacity: 0;
  transition: opacity .3s ease;
}
dialog.lightbox[open] .lb-stage::before,
dialog.lightbox[open] .lb-stage::after {
  opacity: 1; transition: opacity .65s ease .18s;
}
.lb-stage::before {
  inset: var(--halo-pad, -48px -70px);
  background: radial-gradient(ellipse closest-side,
    rgb(var(--halo-rgb) / var(--halo-a, 0.5)) 0%,
    rgb(var(--halo-rgb) / var(--halo-a, 0.5)) 30%,
    rgb(var(--halo-rgb) / calc(var(--halo-a, 0.5) * 0.45)) 58%,
    transparent 100%);
  filter: blur(10px);
}
.lb-stage::after {
  inset: calc(var(--halo-pad, -48px -70px) + 10px);
  background: radial-gradient(ellipse closest-side,
    light-dark(rgb(255 255 255 / var(--fog, 0.55)), rgb(12 15 24 / var(--fog, 0.55))) 0%,
    light-dark(rgb(255 255 255 / calc(var(--fog, 0.55) * 0.5)), rgb(12 15 24 / calc(var(--fog, 0.55) * 0.5))) 55%,
    transparent 92%);
  filter: blur(5px);
}

/* ---------- 预览层内容 ---------- */
.lb-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; transform: translateY(14px);
  transition: opacity .3s ease, transform .3s ease;
}
dialog.lightbox[open] .lb-content {
  opacity: 1; transform: none;
  transition: opacity .5s ease, transform .6s cubic-bezier(.2,.8,.3,1);
}

.lb-stage-icon { --halo-a: 0.44; --fog: 0.26; --halo-pad: -64px -100px; padding: 8px 44px; }
.lb-icon-box {
  position: relative; z-index: 1;
  width: min(34vh, 280px); height: min(34vh, 280px);
  will-change: transform;
}
.lb-icon {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain;
}
/* 缩略图：加载中的临时态，轻模糊+降饱和；原图就绪后交叉渐变覆盖，边缘保持干净 */
.lb-icon.is-thumb { filter: blur(1.5px) saturate(0.92); }
/* 原图：就绪后交叉渐变盖到缩略图上 */
.lb-icon.is-full { opacity: 0; transition: opacity .55s ease; }
.lb-icon-box.is-ready .lb-icon.is-full { opacity: 1; }
/* 原图加载中：缩略图上叠转圈 */
.lb-spin {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  opacity: 1; transition: opacity .35s ease; pointer-events: none;
}
.lb-icon-box.is-ready .lb-spin { opacity: 0; }
.lb-spin-ring {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid light-dark(rgb(255 255 255 / 0.55), rgb(255 255 255 / 0.2));
  border-top-color: var(--primary, #6366f1);
  animation: spin .8s linear infinite;
  box-shadow: 0 2px 10px rgb(15 23 42 / 0.1);
}
.lb-spin-text { font-size: .8rem; color: var(--muted); font-weight: 600; }

.lb-stage-text { --halo-a: 0.36; --fog: 0.58; --halo-pad: -38px -110px; padding: 12px 38px 8px; }
/* 文字区渐变白底：位于光晕(z:-1)之上、文字(z:1)之下，中心实、四周渐隐，提升可读性 */
.lb-text-wash {
  position: absolute; z-index: 0; pointer-events: none; border-radius: 40px;
  background: radial-gradient(ellipse closest-side,
    light-dark(rgb(255 255 255 / 0.85), rgb(12 15 24 / 0.72)) 0%,
    light-dark(rgb(255 255 255 / 0.85), rgb(12 15 24 / 0.72)) 42%,
    light-dark(rgb(255 255 255 / 0.42), rgb(12 15 24 / 0.38)) 72%,
    transparent 100%);
  filter: blur(2px);
  opacity: 0; transition: opacity .3s ease;
}
.lb-stage-text > .lb-text-wash { inset: -24px -64px; }
dialog.lightbox[open] .lb-text-wash,
dialog.lightbox-upload[open] .lb-text-wash { opacity: 1; transition: opacity .6s ease .24s; }
.lb-stage-actions { --halo-a: 0.32; --fog: 0.46; --halo-pad: -34px -90px; padding: 10px 34px; }
.lb-stage-text, .lb-stage-actions {
  opacity: 0; transform: translateY(14px);
  transition: opacity .3s ease, transform .3s ease;
}
dialog.lightbox[open] .lb-stage-text,
dialog.lightbox[open] .lb-stage-actions {
  opacity: 1; transform: none;
  transition: opacity .55s ease .28s, transform .55s cubic-bezier(.2,.8,.3,1) .28s;
}

.lb-name {
  position: relative; z-index: 1; margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 1.9rem); font-weight: 800; letter-spacing: 0.01em;
  word-break: break-all; text-align: center;
}
.lb-alias { position: relative; z-index: 1; margin: 6px 0 0; font-size: 0.95rem; color: var(--muted); }
.lb-meta {
  position: relative; z-index: 1; margin: 10px 0 0;
  font-size: 0.78rem; color: var(--muted); letter-spacing: 0.04em;
}
.lb-stage-text .preview-tags { position: relative; z-index: 1; margin: 14px 0 0; }
.lb-url {
  position: relative; z-index: 1;
  margin-top: 16px; font-size: 0.78rem; color: var(--muted);
  padding: 8px 16px; border-radius: 999px;
  background: light-dark(rgb(255 255 255 / 0.72), rgb(255 255 255 / 0.1));
  border: 1px solid var(--border);
  max-width: 82vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-guest {
  position: relative; z-index: 1;
  margin: 10px 0 0; font-size: 0.8125rem; text-align: center;
}
.lb-stage-actions .preview-actions { position: relative; z-index: 1; }

/* 关闭按钮：右上角悬浮胶囊 */
.lb-close {
  position: absolute; top: 20px; right: 22px; z-index: 3;
  width: 44px; height: 44px; border-radius: 50%;
  border: 2.5px solid var(--text);
  background: light-dark(rgb(255 255 255 / 0.78), rgb(255 255 255 / 0.12));
  backdrop-filter: blur(10px);
  color: var(--text); font-size: 1.35rem; font-weight: 700; line-height: 1;
  cursor: pointer; padding: 0;
  opacity: 0; transition: transform .14s ease, opacity .3s ease;
}
dialog.lightbox[open] .lb-close { opacity: 1; transition: transform .14s ease, opacity .5s ease .2s; }
.lb-close:hover { transform: rotate(90deg); }

/* ---------- 上传 / 编辑层（宽幅，仅 × 退出） ---------- */
.lb-upload-content { width: min(1000px, 95vw); padding: 0 50px; max-height: calc(100dvh - 96px); overflow-y: auto; overflow-x: hidden; }
.lb-upload-content.mode-edit { width: min(1180px, 96vw); }
.up-frame { width: 100%; display: flex; flex-direction: column; align-items: center; }
.up-mode { --halo-a: 0.2; --fog: 0.36; --halo-pad: -16px -24px; padding: 4px 16px; width: 100%; box-sizing: border-box; }
.up-mode .upload-mode-switch { position: relative; z-index: 1; }
/* 模式切换框下方的注释行（随模式换文案） */
.up-sub { position: relative; z-index: 1; margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }

.up-form-frame { width: 100%; margin-top: 8px; gap: 12px; }
.up-pane { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.up-row { display: flex; gap: 16px; align-items: flex-start; width: 100%; }
.up-cat-field { flex: 0 0 300px; }
.up-tags-field { flex: 1; min-width: 0; }
.up-drop-field { flex: 1.15; min-width: 0; }
.up-list-field { flex: 1; min-width: 0; }
.up-list-field .upload-file-list { max-height: 260px; overflow-y: auto; }
.upload-quality-hint { font-size: 0.72rem; margin: 8px 0 0; }
.up-actions-row { display: flex; justify-content: center; gap: 12px; margin-top: 4px; }
.up-actions-row .btn { min-width: 160px; padding: 9px 24px; font-size: 0.9rem; border-radius: 13px; }
.up-actions-row { opacity: 0; transform: translateY(14px); transition: opacity .3s ease, transform .3s ease; }
dialog.lightbox-upload[open] .up-actions-row {
  opacity: 1; transform: none;
  transition: opacity .5s ease .38s, transform .5s cubic-bezier(.2,.8,.3,1) .38s;
}
/* 各段错峰入场（关闭统一快速退场） */
.up-stage, .up-mode, .up-pane, .up-sub { opacity: 0; transform: translateY(14px); transition: opacity .3s ease, transform .3s ease; }
dialog.lightbox-upload[open] .up-mode {
  opacity: 1; transform: none;
  transition: opacity .5s ease .14s, transform .5s cubic-bezier(.2,.8,.3,1) .14s;
}
dialog.lightbox-upload[open] .up-sub {
  opacity: 1; transform: none;
  transition: opacity .5s ease .2s, transform .5s cubic-bezier(.2,.8,.3,1) .2s;
}
dialog.lightbox-upload[open] .up-pane {
  opacity: 1; transform: none;
  transition: opacity .5s ease .3s, transform .5s cubic-bezier(.2,.8,.3,1) .3s;
}

/* 无权限提示居中 */
#uploadDenied { text-align: center; padding: 40px 8px 20px; width: 100%; }
#uploadDenied .up-actions-row { justify-content: center; margin-top: 20px; opacity: 1; transform: none; transition: none; }

/* 编辑页（上传并编辑）宽幅三列：左工具 / 中画布 / 右信息 */
.edit-mini-hint { font-size: 0.72rem; margin: 0; text-align: center; }
.edit-tags-field { display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 900px) {
  .lb-upload-content, .lb-upload-content.mode-edit { width: min(760px, 94vw); }
  .edit-workspace { grid-template-columns: 1fr; }
  .edit-center-col { order: -1; }
}
@media (max-width: 720px) {
  .lb-icon-box { width: min(30vh, 220px); height: min(30vh, 220px); }
  .up-row { flex-direction: column; }
  .up-cat-field { flex: none; width: 100%; }
  .up-list-field { width: 100%; }
  .lb-stage-text { --halo-pad: -30px -40px; padding: 10px 20px 8px; }
  .lb-stage-text > .lb-text-wash { inset: -16px -28px; }
  .lb-stage-actions { --halo-pad: -26px -30px; padding: 8px 16px; }
}
