:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-border: #e5e7eb;
  --rail-bg: #ffffff;
  --rail-active: #8b3dff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #8b3dff;
  --canvas-bg: #eef0f4;
  --topbar-bg: #ffffff;
  --topbar-border: #e5e7eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }

.editor-app {
  display: flex; flex-direction: column; height: 100vh; background: var(--bg);
  --editor-topbar-h: 53px;
}

.editor-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--topbar-bg); color: var(--text);
  border-bottom: 1px solid var(--topbar-border); box-shadow: 0 1px 0 rgba(0,0,0,.04);
  min-height: var(--editor-topbar-h); flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 0;
  margin-right: 4px;
  border-right: 1px solid var(--topbar-border);
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  border-radius: 8px;
}
.topbar-brand:hover { background: #f3f4f6; text-decoration: none; }
.topbar-brand img { border-radius: 8px; object-fit: cover; display: block; }
.topbar-brand-text { font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.topbar-center { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; flex: 1; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-divider { width: 1px; height: 22px; background: #e5e7eb; flex-shrink: 0; }
.design-name-field { display: flex; align-items: center; max-width: min(280px, 32vw); }
.design-name-input {
  width: 100%; min-width: 140px; max-width: 280px;
  border: 1px solid #d1d5db; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  font-family: inherit; color: #374151; background: #f9fafb;
  outline: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.design-name-input::placeholder { color: #9ca3af; font-weight: 500; }
.design-name-input:hover { border-color: #c4b5fd; background: #fff; }
.design-name-input:focus {
  border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px rgba(139, 61, 255, .12);
}
.save-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent;
  transition: opacity .3s;
}
.save-badge.pending { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.save-badge.saving { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.save-badge.saved { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.save-badge.error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; cursor: pointer; }
.save-badge.fade { opacity: .55; }

.page-tab {
  border: 1px solid #d1d5db; background: #fff; color: #374151;
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.page-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(139,61,255,.08); }
.page-tab.saved::after { content: " ✓"; color: #059669; }

.btn {
  border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-ghost { background: transparent; color: #374151; text-decoration: none; display: inline-flex; align-items: center; border: 1px solid transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; line-height: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:disabled { opacity: .4; }
.btn:hover { opacity: .92; }

/* Canva 式文字工具栏 — 画布区上方居中浮动 */
.text-toolbar {
  position: absolute;
  left: 50%;
  top: 48px;
  transform: translateX(-50%);
  z-index: 34;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  max-width: calc(100% - 24px);
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  overflow: visible;
}
.text-toolbar[hidden] { display: none !important; }
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-divider { width: 1px; height: 24px; background: #e5e7eb; margin: 0 2px; flex-shrink: 0; }
.tb-select, .tb-size-input {
  border: 1px solid #d1d5db; border-radius: 6px; padding: 6px 8px; font-size: 13px; background: #fff;
}
.tb-font { min-width: 120px; }
.tb-size-input { width: 52px; text-align: center; }
.tb-icon {
  border: 1px solid transparent; background: transparent; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 14px; color: #374151;
  flex-shrink: 0;
}
.tb-icon:hover { background: #f3f4f6; }
.tb-icon.active { background: rgba(139,61,255,.12); color: var(--accent); border-color: rgba(139,61,255,.25); }
.tb-color-wrap { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.tb-color-a { font-weight: 700; font-size: 16px; padding: 4px 8px; }
.tb-color-wrap input[type="color"] { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.editor-main { flex: 1; display: flex; min-height: 0; overflow: hidden; }

.editor-rail {
  width: 72px; background: var(--rail-bg); display: flex; flex-direction: column;
  align-items: center; padding: 12px 0; gap: 4px; flex-shrink: 0;
  border-right: 1px solid var(--panel-border);
}
.rail-btn {
  width: 56px; border: none; background: transparent; color: #6b7280;
  border-radius: 10px; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.rail-btn:hover { background: #f3f4f6; color: #111; }
.rail-btn.active { background: rgba(139,61,255,.1); color: var(--accent); }
.rail-icon { font-size: 18px; line-height: 1; }
.rail-label { font-size: 10px; }

.rail-chat-toggle {
  margin-bottom: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
}
.rail-chat-toggle.active {
  background: rgba(139, 61, 255, .1);
  color: var(--accent);
}

.editor-panel {
  width: 280px; background: var(--panel); border-right: 1px solid var(--panel-border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.panel-search { padding: 12px; border-bottom: 1px solid var(--panel-border); background: #fafafa; }
.panel-search input {
  width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; background: #fff;
}
.panel-body { flex: 1; overflow-y: auto; padding: 12px; }

.bg-panel-custom {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--panel-border);
}
.bg-panel-custom-label { font-size: 12px; font-weight: 600; color: #374151; flex-shrink: 0; }
.bg-custom-picker {
  position: relative; width: 36px; height: 36px; flex-shrink: 0; cursor: pointer;
}
.bg-custom-input {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.bg-custom-preview {
  display: block; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid #e5e7eb; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.bg-current-label { font-size: 11px; word-break: break-all; }
.bg-panel-section { margin-bottom: 18px; }
.bg-panel-title {
  font-size: 12px; font-weight: 600; color: #374151; margin: 0 0 10px;
}
.bg-swatch-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
}
.bg-swatch {
  aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; transition: transform .12s, box-shadow .12s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.bg-swatch:hover { transform: scale(1.08); }
.bg-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,61,255,.2), inset 0 0 0 1px rgba(0,0,0,.08);
}
.bg-swatch-grid-pattern {
  background-color: #e8f4fc !important;
  background-image:
    linear-gradient(45deg, #bfdbfe 25%, transparent 25%),
    linear-gradient(-45deg, #bfdbfe 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #bfdbfe 75%),
    linear-gradient(-45deg, transparent 75%, #bfdbfe 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

.editor-canvas-area {
  flex: 1; display: flex; flex-direction: column; align-items: stretch;
  background: var(--canvas-bg); min-width: 0; min-height: 0; overflow: hidden;
  padding: 16px 20px;
}
.canvas-toolbar { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: center; flex-shrink: 0; }

.pages-scroller {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  overflow-anchor: none;
  display: flex; flex-direction: column; align-items: center;
  gap: 0; padding-bottom: 24px; min-height: 0;
}

.page-block {
  width: min(100%, calc(var(--canvas-w, 540px) + 48px));
  margin-bottom: 8px;
}
.page-block.active .page-canvas-mount { display: block; }
.page-block:not(.active) .page-canvas-mount { display: none; }
.page-block.active .page-thumb-btn { display: none; }

.page-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 4px; margin-bottom: 6px;
}
.page-bar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.page-num { font-size: 13px; font-weight: 600; color: #374151; white-space: nowrap; }
.page-bar-sep { color: #9ca3af; }
.page-title-input {
  flex: 1; min-width: 0; border: none; background: transparent;
  font-size: 13px; color: #6b7280; outline: none; padding: 4px 0;
}
.page-title-input:focus { color: #111; border-bottom: 1px solid var(--accent); }
.page-bar-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.page-act {
  border: none; background: transparent; color: #6b7280;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.page-act:hover:not(:disabled) { background: #e5e7eb; color: #111; }
.page-act:disabled { opacity: .35; cursor: default; }
.page-act.active { background: rgba(139,61,255,.12); color: var(--accent); }
.page-act-icon { width: 18px; height: 18px; display: block; }
.page-bar-divider { width: 1px; height: 20px; background: #d1d5db; margin: 0 4px; }
.page-lock-badge {
  font-size: 11px; color: #92400e; background: #fef3c7;
  border: 1px solid #fcd34d; border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.page-block.page-locked .page-canvas-mount { outline: 2px dashed #fcd34d; outline-offset: 2px; border-radius: 2px; }

.page-canvas-mount {
  display: flex; justify-content: center;
  width: var(--canvas-w, 540px); margin: 0 auto;
}

.page-thumb-btn {
  display: block; width: var(--canvas-w, 540px); margin: 0 auto;
  border: 2px solid transparent; border-radius: 4px; padding: 0;
  background: #fff; cursor: pointer; overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.page-thumb-btn:hover { border-color: var(--accent); }
.page-thumb-btn img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.page-thumb-empty {
  width: 100%; aspect-ratio: 3/4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: #9ca3af; font-size: 14px; background: #fff; padding: 16px; text-align: center;
}
.page-thumb-empty strong { color: #6b7280; font-size: 15px; }
.page-thumb-empty span { font-size: 13px; line-height: 1.4; }
.page-thumb-btn.drop-target,
.page-block.tpl-drop-target .page-thumb-btn,
.page-block.tpl-drop-target .page-canvas-mount {
  outline: 3px dashed var(--accent);
  outline-offset: 2px;
}

.page-add-wrap {
  width: min(100%, calc(var(--canvas-w, 540px) + 48px));
  margin-top: 4px;
}
.page-add-btn {
  width: 100%; display: flex; align-items: center; justify-content: center;
  padding: 14px 16px; border: 1px dashed #cbd5e1; border-radius: 10px;
  background: rgba(255,255,255,.7); color: #64748b; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: border-color .15s, background .15s;
}
.page-add-btn:hover { border-color: var(--accent); color: var(--accent); background: #fff; }
.page-add-label { font-weight: 500; }

.canvas-wrap {
  --canvas-w: 540px; --canvas-h: 720px;
  position: relative;
  width: var(--canvas-w); height: var(--canvas-h);
  box-shadow: 0 4px 24px rgba(0,0,0,.08); border-radius: 2px; overflow: hidden;
  background: #fff;
}
.canvas-wrap[hidden] { display: none !important; }
.canvas-wrap > div { width: 100% !important; height: 100% !important; }
.konva-text-editor {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  z-index: 1000;
  pointer-events: auto;
}
.konva-text-editor.text-all-selected {
  user-select: all;
  cursor: text;
}
.konva-text-editor.editing-table-cell {
  outline: none !important;
  box-shadow: inset 0 0 0 2px #8b3dff;
}

.muted { color: var(--muted); font-size: 13px; }

.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl-card {
  border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; cursor: grab; background: #fff;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.tpl-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(139,61,255,.12); }
.tpl-card:active { cursor: grabbing; }
.tpl-card.dragging { opacity: 0.55; border-color: var(--accent); }
.tpl-card img { width: 100%; aspect-ratio: 3/4; object-fit: contain; display: block; background: #f3f4f6; }
.tpl-caption { padding: 8px 6px 6px; border-top: 1px solid var(--border, #e5e7eb); }
.tpl-name { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--text, #111827); }
.tpl-desc { font-size: 10px; line-height: 1.35; margin-top: 2px; max-height: 2.7em; overflow: hidden; }
.tpl-thumb-loading {
  width: 100%; aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center;
  font-size: 11px; background: #f3f4f6; color: var(--muted);
}

.tpl-apply-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(4px);
}
.tpl-apply-modal {
  position: relative; width: min(420px, calc(100vw - 32px));
  background: #fff; border-radius: 16px; padding: 28px 28px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}
.tpl-apply-close {
  position: absolute; top: 12px; right: 14px;
  border: none; background: transparent; font-size: 22px; line-height: 1;
  color: #9ca3af; cursor: pointer; padding: 4px 8px;
}
.tpl-apply-close:hover { color: #374151; }
.tpl-apply-title {
  margin: 0 0 20px; font-size: 18px; font-weight: 700; color: #111827; text-align: center;
}
.tpl-apply-skip {
  display: flex; align-items: center; gap: 8px; margin-bottom: 24px;
  font-size: 14px; color: #4b5563; cursor: pointer; user-select: none;
}
.tpl-apply-skip input { width: 16px; height: 16px; accent-color: var(--accent); }
.tpl-apply-actions { display: flex; gap: 12px; }
.tpl-apply-actions .btn { flex: 1; justify-content: center; padding: 10px 16px; }

.elem-group { margin-bottom: 16px; }
.elem-group-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; color: #374151; }
.elem-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.elem-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 6px 6px;
  background: #fff; cursor: grab; font-size: 10px; color: #666;
}
.elem-item:hover { border-color: var(--accent); }
.elem-item.dragging { opacity: 0.55; }
.elem-item img { display: block; object-fit: contain; max-width: 48px; max-height: 48px; }
.elem-filter-bar {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
}
.elem-filter-chip {
  border: 1px solid #e5e7eb; background: #fff; border-radius: 999px;
  padding: 4px 10px; font-size: 11px; color: #4b5563; cursor: pointer;
}
.elem-filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.elem-filter-chip.active {
  background: rgba(139, 61, 255, .1); border-color: var(--accent); color: var(--accent); font-weight: 600;
}
.elem-table-thumb {
  width: 52px; height: 40px; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr);
  gap: 1px; border: 1px solid var(--b, #93c5fd); border-radius: 3px; overflow: hidden;
}
.elem-table-thumb .cell { background: #fff; border: 1px solid var(--b, #93c5fd); }
.elem-table-thumb.style-header .cell.head,
.elem-table-thumb.style-solid .cell.head { background: var(--p, #2563eb); border-color: var(--p); }
.elem-table-thumb.style-solid .cell.body { background: var(--l, #bfdbfe); border-color: var(--b); }
.elem-collage-thumb {
  position: relative; width: 52px; height: 40px;
  background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 3px;
}
.elem-collage-thumb i {
  position: absolute; box-sizing: border-box;
  background: #fff; border: 1px dashed #9ca3af; border-radius: 1px;
}
.elem-line-thumb {
  width: 52px; height: 20px; display: flex; align-items: center; padding: 0 4px;
}
.elem-line-thumb i {
  display: block; width: 100%; height: 0; border-top: 2px solid #111827;
}
.elem-line-thumb.dotted i { border-top-style: dotted; }
.elem-line-thumb.dashed i { border-top-style: dashed; }
.elem-frame-thumb {
  width: 44px; height: 44px; border: 2px solid #9ca3af; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.elem-frame-thumb i {
  width: 28px; height: 28px; border: 1px dashed #9ca3af; border-radius: 3px; background: #f9fafb;
}
.elem-frame-thumb.kind-circle { border-radius: 50%; }
.elem-frame-thumb.kind-circle i { border-radius: 50%; }
.elem-frame-thumb.kind-heart { border: none; background: transparent; clip-path: path("M50,88 C20,60 0,45 0,28 C0,12 12,0 28,0 C40,0 50,8 50,8 C50,8 60,0 72,0 C88,0 100,12 100,28 C100,45 80,60 50,88 Z"); transform: scale(0.42); }
.elem-frame-thumb.kind-heart i { border: none; background: #f9fafb; clip-path: path("M50,88 C20,60 0,45 0,28 C0,12 12,0 28,0 C40,0 50,8 50,8 C50,8 60,0 72,0 C88,0 100,12 100,28 C100,45 80,60 50,88 Z"); transform: scale(0.55); }
.elem-frame-thumb.kind-wavy-circle { border-radius: 50%; border-style: dashed; }
.elem-frame-thumb.kind-torn { border-style: dashed; clip-path: polygon(0 12%, 8% 0, 16% 10%, 24% 0, 32% 10%, 40% 0, 48% 10%, 56% 0, 64% 10%, 72% 0, 80% 10%, 88% 0, 96% 10%, 100% 12%, 100% 88%, 96% 100%, 88% 90%, 80% 100%, 72% 90%, 64% 100%, 56% 90%, 48% 100%, 40% 90%, 32% 100%, 24% 90%, 16% 100%, 8% 90%, 0 88%); }
.elem-frame-thumb.kind-filmstrip { border: none; background: #111827; border-radius: 2px; position: relative; }
.elem-frame-thumb.kind-filmstrip i { border: none; background: #e5e7eb; width: 32px; height: 22px; border-radius: 1px; }
.elem-frame-thumb.kind-polaroid { border: none; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.12); border-radius: 3px; position: relative; }
.elem-frame-thumb.kind-polaroid i { border: none; background: #f3f4f6; width: 30px; height: 24px; border-radius: 1px; }
.elem-frame-thumb.kind-diamond { transform: rotate(45deg) scale(0.82); }
.elem-frame-thumb.kind-diamond i { transform: rotate(-45deg) scale(0.9); }
.elem-frame-thumb.kind-star { clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); border: none; }
.elem-mockup-thumb {
  width: 36px; height: 48px; background: #111827; border-radius: 8px; position: relative;
}
.elem-mockup-thumb::after {
  content: ""; position: absolute; left: 5px; top: 8px; right: 5px; bottom: 10px;
  background: #e5e7eb; border-radius: 4px;
}
.elem-mockup-thumb.mockup-tablet { width: 42px; height: 52px; border-radius: 6px; }
.elem-mockup-thumb.mockup-tablet::after { left: 6px; top: 8px; right: 6px; bottom: 8px; border-radius: 2px; }
.elem-mockup-thumb.mockup-laptop { width: 48px; height: 34px; border-radius: 4px; background: transparent; border: none; }
.elem-mockup-thumb.mockup-laptop::before {
  content: ""; position: absolute; left: 0; top: 0; width: 48px; height: 24px;
  background: #1f2937; border-radius: 4px;
}
.elem-mockup-thumb.mockup-laptop::after { left: 6px; top: 4px; right: 6px; bottom: auto; height: 14px; border-radius: 1px; }
.elem-mockup-thumb.mockup-tv { width: 52px; height: 36px; border-radius: 3px; }
.elem-mockup-thumb.mockup-tv::after { left: 5px; top: 4px; right: 5px; bottom: 10px; border-radius: 1px; }
.elem-mockup-thumb.mockup-browser { width: 52px; height: 38px; background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 4px; }
.elem-mockup-thumb.mockup-browser::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 8px;
  background: #e5e7eb; border-radius: 4px 4px 0 0;
}
.elem-mockup-thumb.mockup-browser::after { left: 5px; top: 11px; right: 5px; bottom: 4px; background: #fff; border-radius: 1px; }
.elem-frame-thumb.kind-instagram { border-radius: 10px; width: 32px; height: 48px; }
.elem-frame-thumb.kind-instagram i { width: 22px; height: 36px; border-radius: 6px; }
.elem-frame-thumb.kind-compare { width: 48px; }
.elem-frame-thumb.kind-compare i { width: 18px; height: 28px; }
.elem-frame-thumb.kind-hexagon { clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); border: none; }
.elem-frame-thumb.kind-hexagon i { clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); border: none; }
.elem-shape-thumb.kind-hexagon { clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); }
.elem-shape-thumb.kind-octagon { clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%); }
.elem-shape-thumb.kind-pentagon { clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%); }
.elem-shape-thumb {
  width: 40px; height: 40px; border-radius: 4px;
}
.elem-shape-thumb.kind-circle { border-radius: 50%; }
.elem-shape-thumb.kind-diamond { transform: rotate(45deg) scale(0.82); }
.elem-shape-thumb.kind-star { clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.elem-shape-thumb.kind-heart { clip-path: path("M50,88 C20,60 0,45 0,28 C0,12 12,0 28,0 C40,0 50,8 50,8 C50,8 60,0 72,0 C88,0 100,12 100,28 C100,45 80,60 50,88 Z"); border-radius: 0; }
.elem-shape-thumb.kind-wavy-circle { border-radius: 50%; border: 2px solid rgba(0,0,0,0.08); }
.elem-shape-thumb.kind-torn { clip-path: polygon(0 12%, 10% 0, 20% 10%, 30% 0, 40% 10%, 50% 0, 60% 10%, 70% 0, 80% 10%, 90% 0, 100% 12%, 100% 88%, 90% 100%, 80% 90%, 70% 100%, 60% 90%, 50% 100%, 40% 90%, 30% 100%, 20% 90%, 10% 100%, 0 88%); }
.elem-item img { display: block; object-fit: contain; max-width: 48px; max-height: 48px; }

.mat-group { margin-bottom: 16px; }
.mat-group-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; color: #374151; }
.mat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mat-item {
  border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; cursor: grab; background: #fff;
}
.mat-item:hover { border-color: var(--accent); }
.mat-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.mat-item span { display: block; font-size: 10px; padding: 4px; text-align: center; color: #666; }

.font-catalog-title { font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 8px; }
.tb-font-group { position: relative; min-width: 148px; flex-shrink: 0; }

.font-picker-wrap { position: relative; }
.font-picker-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; min-width: 140px; max-width: 168px;
  border: 1px solid #d1d5db; border-radius: 8px; padding: 6px 10px; background: #fff;
  cursor: pointer; font-size: 13px; text-align: left;
}
.font-picker-btn:hover { border-color: var(--accent); }
.font-picker-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-picker-caret { color: var(--muted); font-size: 10px; flex-shrink: 0; }
.font-picker-pop {
  position: fixed;
  width: 300px;
  max-height: 460px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, .16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.font-picker-pop[hidden] { display: none !important; }
.font-picker-head {
  flex-shrink: 0;
  border-bottom: 1px solid #f1f5f9;
  padding: 10px 10px 8px;
}
.font-picker-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  margin-bottom: 8px;
}
.font-picker-search:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(139,61,255,.12); }
.font-picker-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.font-picker-chips::-webkit-scrollbar { display: none; }
.font-picker-chip {
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  color: #374151;
  cursor: pointer;
}
.font-picker-chip:hover { border-color: #c4b5fd; background: #faf5ff; }
.font-picker-chip.active {
  border-color: var(--accent);
  background: rgba(139,61,255,.1);
  color: var(--accent);
  font-weight: 600;
}
.font-picker-list { overflow-y: auto; flex: 1; min-height: 120px; padding: 4px 0 8px; }
.font-picker-cat {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.font-picker-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0 8px;
  align-items: center;
  width: calc(100% - 8px);
  margin: 0 4px;
  border: none;
  background: transparent;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}
.font-picker-row:hover, .font-picker-row.active { background: rgba(139,61,255,.08); }
.font-picker-row-name { font-size: 15px; color: #111; line-height: 1.2; grid-column: 1; }
.font-picker-row-sample { font-size: 12px; color: var(--muted); grid-column: 1; }
.font-picker-row-check {
  grid-column: 2;
  grid-row: 1 / span 2;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
}
.font-picker-row.active .font-picker-row-check { opacity: 1; }
.font-picker-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

.font-panel-wrap { margin-top: 8px; }
.font-panel-wrap.font-panel-focus {
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(139, 61, 255, .28);
  transition: box-shadow .2s ease;
}
.font-panel-chips { margin-bottom: 10px; flex-wrap: wrap; }
.font-sidebar-trigger .font-picker-caret { transform: rotate(0); opacity: .55; }
.font-panel-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px;
}
.font-panel-tabs button {
  border: 1px solid #e5e7eb; background: #fff; border-radius: 999px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
}
.font-panel-tabs button.active { border-color: var(--accent); color: var(--accent); background: rgba(139,61,255,.08); }
.font-panel-list { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow-y: auto; }
.font-panel-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  border: 1px solid transparent; border-radius: 8px; padding: 10px 12px;
  background: #fff; cursor: pointer; text-align: left; width: 100%;
}
.font-panel-row:hover { border-color: #e5e7eb; background: #fafafa; }
.font-panel-name { font-size: 16px; color: #111; }
.font-panel-sample { font-size: 12px; color: var(--muted); }

.font-catalog { display: flex; flex-direction: column; gap: 2px; }

.text-presets { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn-add-textbox {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
}
.btn-add-textbox:hover { opacity: .92; }
.btn-add-textbox:active { transform: scale(.98); }
.btn-add-textbox-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(255,255,255,.2);
  font-weight: 700;
  font-size: 13px;
}
.text-preset-btn {
  text-align: left; padding: 14px 16px; border: 1px solid #e5e7eb; border-radius: 10px;
  background: #fff; cursor: pointer; font-family: inherit;
}
.text-preset-btn:hover { border-color: var(--accent); }
.text-preset-btn .preset-title { font-weight: 900; font-size: 22px; color: #1a1a1a; }
.text-preset-btn .preset-sub { font-size: 14px; color: #666; margin-top: 4px; }
.text-preset-btn .preset-body { font-size: 13px; color: #333; margin-top: 4px; }

.panel-empty { text-align: center; padding: 24px 12px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.panel-hint { margin: 0 0 12px; font-size: 12px; }

.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer-row {
  display: flex; align-items: center; gap: 6px; padding: 8px;
  border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; cursor: pointer;
}
.layer-row.active { border-color: var(--accent); background: rgba(139,61,255,.06); }
.layer-icon { flex-shrink: 0; font-size: 14px; }
.layer-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-actions { display: flex; gap: 2px; flex-shrink: 0; }
.layer-actions button {
  border: 1px solid #d1d5db; background: #fff; border-radius: 4px; width: 22px; height: 22px;
  font-size: 11px; cursor: pointer; padding: 0;
}
.layer-actions button:hover { border-color: var(--accent); }
.layer-toolbar { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--panel-border); }
.layer-template-note {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.45;
}
.layer-section { margin-bottom: 14px; }
.layer-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.layer-tree { display: flex; flex-direction: column; gap: 4px; }
.layer-tree-group { border-radius: 8px; }
.layer-tree-group.active > summary { border-color: var(--accent); background: rgba(139,61,255,.06); }
.layer-tree-summary { list-style: none; cursor: pointer; }
.layer-tree-summary::-webkit-details-marker { display: none; }
.layer-tree-summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  margin-right: 2px;
  color: var(--muted);
  transition: transform 0.15s;
}
.layer-tree-group[open] > .layer-tree-summary::before { transform: rotate(90deg); }
.layer-tree-children {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.layer-tree-leaf.nested { margin-left: 0; }
.layer-row.nested .layer-name { font-size: 11px; }
.panel-empty-inline { padding: 8px 0; font-size: 12px; }

.canvas-wrap.drop-active {
  outline: 3px dashed var(--accent);
  outline-offset: 4px;
}
.mat-item.dragging { opacity: 0.55; border-color: var(--accent); }
.mat-item:active { cursor: grabbing; }

#btnUndo:disabled, #btnRedo:disabled { opacity: 0.35; cursor: not-allowed; }

.muted-link { color: var(--muted) !important; font-size: 12px; margin-left: 4px; }
.mat-upload-bar { margin-bottom: 12px; }
.mat-upload-btn { display: inline-flex; align-items: center; cursor: pointer; width: 100%; justify-content: center; }

.table-panel { display: flex; flex-direction: column; gap: 10px; }
.panel-subsection {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}
.table-op-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.table-op-grid button {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 12px;
  cursor: pointer;
}
.table-op-grid button:hover { border-color: var(--accent); }
.table-op-grid button:disabled { opacity: .45; cursor: not-allowed; }

/* 右键上下文菜单 */
.ctx-menu {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  max-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
}
.ctx-submenu { z-index: 10001; }
.ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 14px;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  gap: 12px;
}
.ctx-item:hover:not(:disabled) { background: #f3f4f6; }
.ctx-item:disabled { opacity: 0.4; cursor: not-allowed; }
.ctx-item.ctx-danger span:first-child { color: #dc2626; }
.ctx-item kbd {
  font-size: 11px;
  color: #9ca3af;
  font-family: inherit;
  font-weight: 400;
}
.ctx-sep { height: 1px; background: #e5e7eb; margin: 4px 0; }
.ctx-has-sub .ctx-arrow { color: #9ca3af; font-size: 14px; }

.editor-body-row { display: flex; flex: 1; min-height: 0; }
.studio-panel {
  width: var(--studio-width, 320px);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width .2s;
}
.studio-panel.resizing { transition: none; }
.studio-panel.collapsed { width: 0; overflow: hidden; border: none; }
.studio-panel.collapsed .studio-resize-handle { display: none; }
.studio-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  touch-action: none;
}
.studio-resize-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 48px;
  border-radius: 2px;
  background: transparent;
  transition: background .15s;
}
.studio-resize-handle:hover::after,
.studio-panel.resizing .studio-resize-handle::after {
  background: var(--accent);
}
.studio-panel-body { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.studio-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-shrink: 0; }
.studio-tab {
  flex: 1; border: 1px solid #e5e7eb; background: #f9fafb; border-radius: 6px;
  padding: 6px 4px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.studio-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(139,61,255,.08); }
.studio-tab-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.studio-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.studio-msgs { flex: 1; overflow-y: auto; min-height: 120px; margin-bottom: 8px; }
.studio-msg { font-size: 12px; padding: 6px 8px; margin-bottom: 6px; border-radius: 8px; white-space: pre-wrap; }
.studio-msg-user { background: #ede9fe; }
.studio-msg-assistant { background: #f3f4f6; }
.studio-input-row { display: flex; flex-direction: column; gap: 6px; }
.studio-input { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px; font-family: inherit; font-size: 12px; resize: vertical; }
.studio-copy-body { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px; font-size: 12px; font-family: inherit; }
.studio-btn-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.studio-status { font-size: 11px; margin-bottom: 6px; }
.studio-coach {
  position: fixed; bottom: 24px; left: calc(var(--studio-width, 320px) + 20px); z-index: 9999;
  background: #fff; border: 1px solid var(--accent); border-radius: 12px;
  padding: 14px 16px; max-width: 280px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  font-size: 13px;
}
.studio-coach ol { margin: 8px 0; padding-left: 18px; }
.materials-highlight { animation: matPulse 1s ease 2; }
@keyframes matPulse { 0%,100% { box-shadow: none; } 50% { box-shadow: inset 0 0 0 2px var(--accent); } }

/* 我的项目 */
.projects-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.projects-panel-title { font-size: 14px; font-weight: 700; }
.projects-panel-meta { font-size: 11px; }
.projects-create-btn { flex-shrink: 0; }
.projects-grid {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.project-card {
  border: 1px solid var(--panel-border); border-radius: 10px; background: #fff;
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.project-card:hover { border-color: #c4b5fd; box-shadow: 0 4px 12px rgba(139,61,255,.08); }
.project-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(139,61,255,.25); }
.project-thumb {
  display: block; width: 100%; aspect-ratio: 3 / 4; border: none; padding: 0;
  background: #f3f4f6; cursor: pointer; overflow: hidden;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.project-thumb-placeholder {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  font-size: 11px; color: var(--muted);
}
.project-card-body { padding: 8px 10px 4px; }
.project-card-title {
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-card-meta { font-size: 11px; margin-top: 2px; }
.project-card-actions {
  display: flex; gap: 4px; padding: 4px 8px 8px; justify-content: flex-end;
}
.project-delete-btn { color: #b91c1c !important; }
.project-delete-btn:hover { background: #fef2f2 !important; }

/* 账号菜单 */
.user-menu-wrap { position: relative; flex-shrink: 0; }
.user-avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #e5e7eb;
  background: linear-gradient(135deg, #8b3dff 0%, #6366f1 100%);
  color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; transition: box-shadow .15s, border-color .15s;
}
.user-avatar-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,61,255,.15); }
.user-avatar-btn.has-avatar-img {
  background: transparent;
  border-color: #e5e7eb;
  padding: 0;
  overflow: hidden;
}
.user-avatar-letter { line-height: 1; }
.user-avatar-letter[hidden] { display: none !important; }
.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
.user-avatar-img[hidden] { display: none !important; }
.user-menu-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; width: 320px;
  background: #fff; border: 1px solid #eef0f4; border-radius: 12px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12); padding: 0; z-index: 2000;
  overflow: hidden;
}
.user-menu-dropdown[hidden] { display: none !important; }
.user-menu-login-btn {
  display: block; width: 100%; border: none; background: transparent;
  padding: 14px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--accent); text-align: center;
}
.user-menu-login-btn:hover { background: #f8fafc; }
.user-menu-login-btn[hidden] { display: none !important; }

/* 飞鱼风格用户卡片 */
.user-card { padding: 0; }
.user-card[hidden] { display: none !important; }
.user-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 16px 16px 12px;
}
.user-card-profile { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.user-card-avatar-wrap {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #8b3dff 0%, #6366f1 100%);
  color: #fff; font-weight: 700; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; border: 1px solid #e8ecf3;
}
.user-card-avatar-wrap.has-img {
  background: transparent; border-color: #e5e7eb;
}
.user-card-avatar-letter { line-height: 1; }
.user-card-avatar-letter[hidden] { display: none !important; }
.user-card-avatar-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.user-card-avatar-img[hidden] { display: none !important; }
.user-card-text { min-width: 0; }
.user-card-name {
  font-size: 15px; font-weight: 700; color: #1a1d26;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card-meta {
  margin-top: 4px; font-size: 12px; color: #8b93a1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card-logout {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  border: none; background: transparent; color: #8b93a1; font-size: 12px;
  cursor: pointer; padding: 4px 0; font-family: inherit;
}
.user-card-logout:hover { color: #64748b; }
.user-card-logout svg { flex-shrink: 0; }
.user-card-actions {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 8px 12px 14px; border-top: 1px solid #f1f5f9;
}
.user-card-action {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; border-radius: 10px; border: none; background: transparent;
  color: #475569; font-size: 12px; text-decoration: none; cursor: pointer;
  font-family: inherit; transition: background .15s;
}
.user-card-action:hover { background: #f8fafc; color: #1e293b; }
.user-card-action-icon {
  width: 36px; height: 36px; border-radius: 50%; background: #f1f5f9;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}

/* 登录弹窗 */
.login-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 5000;
}
.login-modal-backdrop[hidden] { display: none !important; }
.login-modal {
  position: relative; width: min(400px, calc(100vw - 32px));
  background: #fff; border-radius: 16px; padding: 28px 24px 24px;
  box-shadow: 0 24px 48px rgba(0,0,0,.18);
}
.login-modal h2 { margin: 0 0 6px; font-size: 18px; }
.login-tabs { display: flex; gap: 0; margin: 0 0 16px; border-bottom: 1px solid #e5e7eb; }
.login-tab {
  flex: 1; border: none; background: transparent; padding: 10px 0; font-size: 14px;
  font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: inherit;
}
.login-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.phone-mode-head { min-height: 28px; margin-bottom: 8px; }
.phone-mode-title { margin: 0; font-size: 16px; text-align: center; }
.login-back-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 0; font-family: inherit;
}
.login-back-btn:hover { color: var(--accent); }
.login-phone-links {
  display: flex; justify-content: space-between; align-items: center;
  margin: 4px 0 12px; font-size: 13px;
}
.login-link-btn {
  border: none; background: transparent; color: var(--accent); cursor: pointer;
  padding: 0; font-family: inherit; font-size: 13px;
}
.login-link-btn:hover { text-decoration: underline; }
.login-modal-actions.phone-signin-only .btn-primary { width: 100%; }
.login-panel[hidden] { display: none !important; }
.login-qr-wrap {
  width: 220px; height: 220px; margin: 0 auto 12px; border: 1px solid #e5e7eb;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: #fafafa; overflow: hidden;
}
.login-qr-img { width: 100%; height: 100%; object-fit: contain; }
.login-qr-img[hidden] { display: none !important; }
.login-qr-loading { font-size: 13px; color: var(--muted); text-align: center; padding: 16px; line-height: 1.5; }
.login-qr-loading[hidden] { display: none !important; }
.login-qr-hint { text-align: center; font-size: 13px; margin: 0 0 8px; }
.login-qr-hint em { font-style: normal; color: #e11d48; font-weight: 600; }
.login-agreement {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  cursor: pointer;
}
.login-agreement input { margin-top: 3px; flex-shrink: 0; }
.login-agreement a { color: #8b3dff; text-decoration: none; }
.login-agreement a:hover { text-decoration: underline; }
.login-bind-title { margin: 0 0 6px; font-size: 16px; text-align: center; font-weight: 600; }
.login-bind-sub { text-align: center; margin-bottom: 12px !important; }
#loginTabs[hidden], #loginAgreement[hidden] { display: none !important; }
.login-field-label { display: block; font-size: 13px; }
.login-code-row {
  display: flex; gap: 8px; margin-top: 6px; align-items: stretch;
}
.login-code-input {
  flex: 1; min-width: 0; padding: 10px 12px;
  border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; box-sizing: border-box;
}
.btn-code {
  flex-shrink: 0; white-space: nowrap; padding: 10px 12px;
  border: none; border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-code:disabled { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }
.login-modal-actions.bind-submit-only .btn-primary { width: 100%; flex: none; }
.login-modal-sub { margin: 0 0 16px; font-size: 13px; }
.login-modal-close {
  position: absolute; top: 12px; right: 14px; border: none; background: transparent;
  font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted);
}
.login-field { display: block; margin-bottom: 12px; font-size: 13px; }
.login-field[hidden],
.login-phone-links[hidden],
#loginSendBtn[hidden],
#phoneBackBtn[hidden],
.phone-mode-title[hidden],
.login-modal-sub[hidden] { display: none !important; }
.login-field input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; box-sizing: border-box;
}
.login-modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.login-modal-actions .btn { flex: 1; }
.login-mock-code {
  background: #f0f7ff; padding: 8px 12px; border-radius: 8px;
  font-size: 13px; color: #1d4ed8; margin-top: 4px;
}
.login-error { color: #b91c1c; font-size: 13px; min-height: 1.2em; margin-top: 8px; }

/* Canva 式画笔工具条 */
.editor-canvas-area { position: relative; }
.draw-toolbar {
  position: absolute;
  left: 8px;
  top: 52px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  overflow: visible;
}
.draw-toolbar[hidden] { display: none !important; }
.draw-tool-btn {
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: #f9fafb; color: #374151; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .12s;
  position: relative;
}
.draw-tool-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  z-index: 40;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .18);
}
.draw-tool-btn[data-tip]::before {
  content: "";
  position: absolute;
  left: calc(100% + 2px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #111827;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.draw-tool-btn[data-tip]:hover::after,
.draw-tool-btn[data-tip]:hover::before {
  opacity: 1;
}
.shape-pick-btn[data-tip] { position: relative; }
.shape-pick-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  background: #111827;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  z-index: 41;
}
.shape-pick-btn[data-tip]:hover::after { opacity: 1; }
.draw-tool-btn:hover { background: #f3f4f6; }
.draw-tool-btn.active {
  background: rgba(139, 61, 255, .12);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(139, 61, 255, .35);
}
.draw-color-btn {
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db;
}
.draw-toolbar.eraser-active .draw-color-btn { opacity: .35; pointer-events: none; }
.draw-pop {
  position: absolute;
  left: 58px;
  z-index: 31;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  padding: 12px 14px;
  min-width: 220px;
}
.draw-settings-pop { top: 210px; }
.draw-colors-pop { top: 250px; }
.draw-pop-title { font-size: 12px; font-weight: 600; margin-bottom: 10px; color: #374151; }
.draw-setting-row {
  display: grid;
  grid-template-columns: 44px 1fr 36px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #374151;
}
.draw-setting-row:last-child { margin-bottom: 0; }
.draw-setting-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.draw-setting-row output {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #6b7280;
}
.draw-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.draw-color-swatch {
  width: 28px; height: 28px; border-radius: 999px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db; cursor: pointer; padding: 0;
}
.draw-color-swatch:hover { transform: scale(1.08); }
.draw-color-custom {
  width: 28px; height: 28px; border-radius: 999px; overflow: hidden;
  border: 2px dashed #d1d5db; display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
}
.draw-color-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.draw-color-custom span { font-size: 16px; color: #6b7280; pointer-events: none; }
.draw-panel-intro { margin-bottom: 16px; }
.draw-panel-title { margin: 0 0 8px; font-size: 15px; }
.draw-panel-list { margin: 12px 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.draw-panel-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.canvas-wrap.draw-mode { cursor: crosshair; }
.canvas-wrap.draw-mode[data-draw-tool="eraser"] { cursor: cell; }
.draw-panel-tool { min-width: 96px; }

.draw-shapes-pop { top: 120px; min-width: 180px; }
.draw-shapes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.shape-pick-btn {
  width: 48px; height: 48px; border: 1px solid #e5e7eb; border-radius: 10px;
  background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.shape-pick-btn:hover { background: #f3f4f6; }
.shape-pick-btn.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(139, 61, 255, .35);
  background: rgba(139, 61, 255, .08);
}
.shape-pick-icon { font-size: 22px; line-height: 1; color: #111; }

.canvas-wrap.shape-mode { cursor: crosshair; }

.shape-props-toolbar {
  position: absolute;
  left: 50%;
  top: 48px;
  transform: translateX(-50%);
  z-index: 32;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.shape-props-toolbar[hidden] { display: none !important; }
.shape-props-label { font-size: 12px; font-weight: 600; color: #374151; }
.shape-fill-btn {
  width: 28px; height: 28px; border-radius: 999px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db; cursor: pointer; padding: 0;
}
.shape-props-divider { width: 1px; height: 24px; background: #e5e7eb; }
.shape-props-row {
  display: grid; grid-template-columns: 36px 88px 32px; align-items: center; gap: 6px;
  font-size: 11px; color: #374151; margin: 0;
}
.shape-props-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.shape-props-row output { text-align: center; color: #6b7280; font-variant-numeric: tabular-nums; }
.shape-color-pop {
  position: absolute;
  top: 44px;
  left: 56px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  padding: 10px;
  z-index: 33;
}
.shape-color-pop[hidden] { display: none !important; }
.shape-color-grid { display: flex; flex-wrap: wrap; gap: 8px; max-width: 180px; }
.shape-color-swatch {
  width: 24px; height: 24px; border-radius: 999px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db; cursor: pointer; padding: 0;
}
.shape-color-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.shape-color-custom {
  width: 24px; height: 24px; border-radius: 999px; overflow: hidden;
  border: 2px dashed #d1d5db; display: flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
}
.shape-color-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.shape-color-custom span { font-size: 14px; color: #6b7280; pointer-events: none; }

.table-props-toolbar {
  position: absolute;
  left: 50%;
  top: 48px;
  transform: translateX(-50%);
  z-index: 32;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.table-props-toolbar[hidden] { display: none !important; }
.table-props-label { font-size: 12px; font-weight: 600; color: #374151; margin-right: 4px; }
.table-props-btn {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  color: #374151;
}
.table-props-btn:hover { background: #eef2ff; border-color: #c7d2fe; }
.table-props-divider { width: 1px; height: 24px; background: #e5e7eb; }
.table-props-row {
  display: grid;
  grid-template-columns: 40px 72px 32px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #374151;
  margin: 0;
}
.table-props-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.table-props-row output { text-align: center; color: #6b7280; font-variant-numeric: tabular-nums; }

.tb-spacing-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  padding: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tb-spacing-pop[hidden] { display: none !important; }
.tb-spacing-row {
  display: grid;
  grid-template-columns: 52px 1fr 36px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #374151;
  margin: 0;
}
.tb-spacing-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.tb-spacing-row output { text-align: center; color: #6b7280; font-variant-numeric: tabular-nums; }
