/* 内置加载原版字体（统一走独立 @font-face 文件，避免系统字重替换，且使用原生轮廓合成加粗彻底杜绝描边重影） */
@font-face {
  font-family: 'CVM_Dutch801';
  src: url('fonts/Dutch801BT-Roman.otf') format('opentype'),
       local('Dutch 801'),
       local('Dutch801BT-Roman');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'CVM_HiraginoW3';
  src: url('fonts/HiraginoMinchoPro-W3.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'CVM_HiraginoW6';
  src: url('fonts/HiraginoMinchoPro-W6.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --bg-app: #f3f4f6;
  --bg-panel: #ffffff;
  --bg-canvas-stage: #e5e7eb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text-main: #111827;
  --text-sub: #4b5563;
  --text-muted: #9ca3af;
  --primary: #18181b;
  --primary-hover: #27272a;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --success: #059669;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部工具栏 */
.topbar {
  height: 58px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 20;
}

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

.brand-logo {
  width: 44px;
  height: 38px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "CVM_Dutch801", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 9.5px;
  line-height: 1.15;
  letter-spacing: 0.6px;
  flex-shrink: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.project-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
}

.project-name-wrap label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.project-name-input {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  width: 190px;
  outline: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 按钮通用样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-sub);
}

.btn-ghost:hover {
  background: #f3f4f6;
  border-color: transparent;
}

.badge-count {
  background: #eef2ff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 99px;
}

/* 主体双栏/三栏布局 */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 400px 1fr 310px;
  min-height: 0;
}

.sidebar-left,
.sidebar-right {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-left {
  border-right: 1px solid var(--border);
}

.sidebar-right {
  border-left: 1px solid var(--border);
}

.panel-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* 像素尺寸切换胶囊 */
.size-pills {
  display: grid;
  grid-template-columns: 1fr 1fr 90px;
  gap: 8px;
}

.size-pill {
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.size-pill .dim {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.size-pill .desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.size-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.size-pill.active .dim {
  color: var(--accent);
}

.custom-size-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.custom-size-row.visible {
  display: flex;
}

.input-num {
  width: 90px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
}

/* 模板网格 */
.template-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.tpl-card {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 4px;
  background: #fafafa;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.14s;
}

.tpl-card:hover {
  border-color: #9ca3af;
  background: #fff;
}

.tpl-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.tpl-mini {
  width: 38px;
  height: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.tpl-mini-row {
  display: flex;
  justify-content: center;
  gap: 2px;
  flex: 1;
}

.tpl-mini-box {
  background: #9ca3af;
  border-radius: 1.5px;
  height: 100%;
}

.tpl-card.active .tpl-mini-box {
  background: var(--accent);
}

.tpl-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
}

.tpl-card.active .tpl-label {
  color: var(--accent);
}

/* 批量上传拖拽区 */
.upload-dropzone {
  border: 1.5px dashed #9ca3af;
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  background: #f9fafb;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.upload-dropzone-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* 颜色与图片列表 */
.slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.slot-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.slot-index {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f3f4f6;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.slot-item.active .slot-index {
  background: var(--accent);
  color: #fff;
}

.slot-thumb {
  width: 50px;
  height: 58px;
  border-radius: 6px;
  border: 1px dashed var(--border-strong);
  background: #f9fafb;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.slot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-thumb-empty {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.slot-thumb-hover {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.slot-thumb:hover .slot-thumb-hover {
  opacity: 1;
}

.slot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slot-input {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
}

.slot-input:focus {
  border-color: var(--accent);
}

.slot-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.slot-zoom-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.slot-zoom-wrap input[type="range"] {
  width: 68px;
  height: 4px;
  cursor: pointer;
}

.slot-mini-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #f3f4f6;
  color: var(--text-main);
}

.icon-btn.danger:hover {
  background: #fef2f2;
  color: var(--danger);
}

/* 中间画布预览舞台 */
.canvas-stage {
  background: var(--bg-canvas-stage);
  background-image: radial-gradient(#cfd4dc 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.stage-toolbar {
  height: 42px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.stage-tips {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stage-scroll {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px;
}

.canvas-wrapper {
  background: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  line-height: 0;
  user-select: none;
}

#previewCanvas {
  display: block;
  cursor: grab;
}

#previewCanvas:active {
  cursor: grabbing;
}

/* 画布文字原位划选修改层（像 PS 文字工具一样直接鼠标划过去选中改字） */
.canvas-text-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.canvas-inline-input {
  position: absolute;
  pointer-events: auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 2px;
  margin: 0;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.canvas-inline-input:hover {
  border-color: rgba(37, 99, 235, 0.45);
  background-color: rgba(37, 99, 235, 0.04);
}

.canvas-inline-input:focus {
  border-color: #2563eb;
  background-color: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
  z-index: 5;
}

.canvas-inline-input::selection {
  background: rgba(37, 99, 235, 0.24);
}

/* 右侧词库与排版微调 */
.preset-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  background: #f3f4f6;
  padding: 3px;
  border-radius: 7px;
}

.preset-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 5px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
  border-radius: 5px;
  cursor: pointer;
}

.preset-tab.active {
  background: #fff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.preset-search {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 9px;
  font-size: 12px;
  margin-bottom: 8px;
  outline: none;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 2px;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 11.5px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.12s;
}

.color-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.chip-hint {
  color: var(--text-muted);
  font-size: 10.5px;
}

.custom-word-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* 表单控件 */
.form-row {
  margin-bottom: 11px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 9px;
  font-size: 12.5px;
  background: #fff;
  color: var(--text-main);
}

.range-full {
  width: 100%;
  cursor: pointer;
}

.inline-checks {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-sub);
}

.inline-checks label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* 历史作品库抽屉弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 720px;
  max-width: 92vw;
  max-height: 82vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: all 0.15s;
}

.history-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}

.history-thumb {
  height: 170px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
}

.history-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.history-meta {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.history-btns {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

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

/* 轻提示 Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #18181b;
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
