:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2733;
  --muted: #8a94a3;
  --primary: #2f6bff;
  --primary-dark: #1f4fd6;
  --danger: #e5484d;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 20px 60px; }
.wrap.wide { max-width: 1440px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: #1a9c5b; margin-bottom: 6px; }

/* 顶栏 */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0 14px; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.wb-name { font-size: 17px; font-weight: 600; cursor: pointer; border-bottom: 1px dashed transparent; }
.wb-name:hover { border-bottom-color: var(--primary); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* 按钮/输入 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); cursor: pointer; font-size: 13px;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; margin-bottom: 8px; }
.input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); outline: none; width: 100%;
}
.input:focus { border-color: var(--primary); }
input.color { padding: 2px; height: 32px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 6px 0; }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .input { width: 220px; }
.toolbar .input[placeholder*="搜索"] { width: 240px; }

/* 卡片网格（图片满铺，参考模板市场风格） */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 20px rgba(30, 50, 90, .12); transform: translateY(-2px); }
/* 首页缩略图固定竖版 3:4 比例，图片居中裁切 */
.card-thumb { position: relative; background: #eef1f5; display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { color: var(--muted); font-size: 12px; padding: 40px 0; }
.card-hover {
  position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 10px; background: linear-gradient(180deg, rgba(0,0,0,.12), transparent 40%);
  opacity: 0; transition: opacity .15s;
}
.card:hover .card-hover { opacity: 1; }
.card-edit {
  background: rgba(255,255,255,.95); border-radius: 8px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.fav-badge {
  position: absolute; top: 8px; left: 8px; background: rgba(245,166,35,.92); color: #fff;
  border-radius: 6px; padding: 1px 7px; font-size: 13px;
}
.card-body { padding: 12px; }
.card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.card-meta { font-size: 12px; margin-bottom: 10px; }
.card-actions { display: flex; gap: 6px; }
.card-actions .btn { padding: 5px 10px; font-size: 12px; flex: 1; }
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 80px 0; font-size: 15px; }

.star { background: none; border: none; font-size: 18px; cursor: pointer; color: #c9ced6; }
.star.on { color: #f5a623; }

/* 标签 chip */
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: #eef3ff; color: var(--primary); border-radius: 20px;
  padding: 2px 8px; font-size: 12px;
}
.chip i { opacity: .5; font-style: normal; }
.chip-x { background: none; border: none; color: inherit; cursor: pointer; font-size: 13px; padding: 0 0 0 2px; }
.chip-add {
  background: none; border: 1px dashed var(--border); border-radius: 20px;
  color: var(--muted); font-size: 12px; padding: 2px 8px; cursor: pointer;
}
.chip-add:hover { color: var(--primary); border-color: var(--primary); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 30, 50, .35);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal { background: #fff; border-radius: 12px; width: 460px; max-width: 92vw; max-height: 80vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-head button { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.tag-form > div { flex: 1; min-width: 120px; }
.tag-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* 工作台布局 */
.wb-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .wb-grid { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel h3 { font-size: 14px; margin-bottom: 12px; }

/* 背景图列表 */
.bg-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 8px; }
.bg-item {
  position: relative; border: 2px solid var(--border); border-radius: 8px;
  overflow: hidden; cursor: pointer; background: #f2f4f7;
}
.bg-item.active { border-color: var(--primary); }
/* 缩略图宽度不变，高度按图片实际比例自适应 */
.bg-item img { width: 100%; height: auto; display: block; }
.bg-name { font-size: 11px; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer; font-size: 13px; line-height: 1;
  display: none;
}
.bg-item:hover .bg-del { display: block; }

/* 字体 */
.font-list { max-height: 160px; overflow: auto; }
.font-item { padding: 5px 2px; border-bottom: 1px solid #f0f2f5; font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.font-item .font-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-del {
  flex: none; border: none; background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.font-del:hover { color: #d33; background: #fdecec; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* 预览：面板贴合作画布，不留空白边缘 */
.preview-panel { width: fit-content; max-width: 100%; margin: 0 auto; }
.preview-box {
  display: flex; justify-content: center;
  padding: 0; border: none; background: none;
  min-height: 0;
}
.pv-stack { position: relative; line-height: 0; }
#wb-preview { display: block; max-width: 100%; max-height: 80vh; box-shadow: 0 2px 14px rgba(0,0,0,.16); background: #fff; }
#pv-overlay { position: absolute; inset: 0; pointer-events: none; }
.slot-box {
  position: absolute; border: 1.5px dashed rgba(47,107,255,.85);
  background: rgba(47,107,255,.06); pointer-events: auto; cursor: move;
}
.slot-box:hover { background: rgba(47,107,255,.14); border-style: solid; }
.slot-box.dragging { z-index: 10; border-style: solid; background: rgba(47,107,255,.12); box-shadow: 0 0 0 1px rgba(47,107,255,.5); }
.slot-box-tag {
  position: absolute; top: -1px; left: -1px; background: var(--primary); color: #fff;
  font-size: 11px; line-height: 1; padding: 2px 5px; border-radius: 0 0 4px 0; pointer-events: none;
}
/* 图片槽位（剪切蒙版组）标注框：外观与文本框一致，仅点击定位（不可拖拽） */
.slot-box.img-box { cursor: pointer; }
.preview-nav { display: flex; gap: 8px; margin-top: 10px; justify-content: center; }

/* 文本槽 */
.slot { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.slot summary { padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.warn-tag { font-size: 11px; font-weight: 600; color: #b45309; background: #fef3c7; border: 1px solid #fcd34d; border-radius: 4px; padding: 1px 5px; margin-left: 6px; cursor: help; }
.img-thumbs { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 12px 12px; }
.img-thumb { position: relative; width: 64px; height: 64px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-thumb .suf { position: absolute; left: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 1px 4px; border-radius: 0 4px 0 0; }
.img-thumb .img-del { position: absolute; top: 0; right: 0; width: 16px; height: 16px; line-height: 14px; text-align: center; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; cursor: pointer; border-radius: 0 0 0 4px; padding: 0; }
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 4px 12px 12px; }
.slot textarea.input { resize: vertical; font-family: inherit; }
.btn-sm { font-size: 12px; padding: 5px 10px; width: 100%; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Excel 预览 */
.excel-preview { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 6px; }
.excel-preview th, .excel-preview td { border: 1px solid var(--border); padding: 3px 6px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.excel-preview th { background: #f5f7fa; }

/* 导出进度 */
.progress { height: 6px; background: #eef1f5; border-radius: 4px; margin: 10px 0 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

/* 导出进度角标（导出按钮已移至顶栏） */
.export-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; box-shadow: 0 6px 20px rgba(20, 35, 70, .18);
  max-width: 360px; font-size: 12px;
}

/* ---------- 账号登录 / 权限 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef3ff 0%, #f5f6f8 45%, #f7f2ff 100%);
  padding: 24px;
}
.login-card {
  width: 380px; max-width: 100%; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 26px; box-shadow: 0 12px 40px rgba(30, 50, 90, .12);
}
.login-logo { font-size: 19px; font-weight: 700; letter-spacing: 1px; color: var(--text); }
.login-label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }
.login-err { min-height: 18px; font-size: 12px; color: var(--danger); margin-bottom: 8px; }
.login-card .input { width: 100%; }

/* 顶栏用户标识 */
.user-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 220px;
  background: #eef3ff; color: var(--primary); border: 1px solid #d8e3ff;
  border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 模板卡片可见等级角标 */
.acc-badge {
  display: inline-block; margin-left: 6px; background: #eef3ff; color: var(--primary);
  border-radius: 4px; padding: 0 5px; font-size: 11px;
}
.acc-badge.all { background: #eaf7ee; color: #1a9c5b; }

/* 账号管理表格 */
.acc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.acc-table th, .acc-table td {
  border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: left; vertical-align: middle;
}
.acc-table th { background: #f5f7fa; font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; }
.acc-table .btn-sm { width: auto; }
.acc-table td:last-child { text-align: right; }

/* 等级多选 */
.tag-pick { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 8px 0; }
.tag-pick .chk { margin: 0; color: var(--text); font-weight: 600; }

/* 账号管理：会员分组重命名区 */
.acc-groups { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fafbfd; }
.acc-groups-head { margin-bottom: 6px; }
.tag-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-groups .chip { font-size: 12px; padding: 3px 10px; }
.tag-groups .chip-x { font-size: 12px; opacity: .75; }
.tag-groups .chip-x:hover { opacity: 1; }

/* 工作台「可见分组」标题带重命名按钮 */
.panel h3.with-action { display: flex; align-items: center; gap: 8px; }
.panel h3.with-action .muted { flex: 0 1 auto; }
.panel h3.with-action .btn { margin-left: auto; }
