/* Toast */
#toast {
  visibility: hidden;
  min-width: 250px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 999;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  font-weight: 500;
}
#toast.show {
  visibility: visible;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* Tool buttons */
.tool-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  user-select: none;
}
.tool-btn:hover {
  background-color: #ecfdf5;
  color: #059669;
  transform: scale(1.08);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
}
.tool-btn.active {
  background-color: #d1fae5;
  color: #059669;
  border-color: #10b981;
}

/* Top toolbar button */
.top-toolbar-btn {
  height: 30px;
  min-width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  user-select: none;
  padding: 0 6px;
}
.top-toolbar-btn:hover {
  background-color: #ecfdf5;
  color: #059669;
}
.top-toolbar-btn.active {
  background-color: #10b981;
  color: #ffffff;
}
.top-toolbar-btn.active:hover {
  background-color: #059669;
  color: #ffffff;
}

/* Insert module item in toolbar */
.toolbar-insert-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #4b5563;
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
}
.toolbar-insert-item:hover {
  background-color: #ecfdf5;
  color: #059669;
}

/* 左侧菜单样式已移至 css/menu.css */

/* Tag pill */
.tag-pill {
  display: inline-block;
  padding: 2px 12px;
  font-size: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #6b7280;
  user-select: none;
}
.tag-pill:hover {
  border-color: #10b981;
  color: #059669;
}
.tag-pill.selected {
  background-color: #10b981;
  border-color: #10b981;
  color: white;
}

/* ===== Canvas Editor Styles (Absolute Positioning Mode) ===== */
/* Canvas Editor Area - 内容编辑框与工具栏间距 */
.editor-canvas-area {
  padding: 12px 16px 20px;
  position: relative;
}

#editor-content {
  position: relative;
  width: 100%;
  min-height: 800px;
  background: #fff;
  outline: none;
  border-radius: 8px;
  cursor: default;
  overflow: visible;
}
#editor-content::after {
  content: '';
  display: block;
  clear: both;
}
#editor-content .canvas-layer {
  position: absolute;
  min-width: 20px;
  min-height: 20px;
  transition: box-shadow 0.15s ease;
  padding: 4px 8px;
  border-radius: 4px;
  box-sizing: border-box;
}
/* ★ 智能排版专用：使用正常文档流，避免元素重叠 */
#editor-content .canvas-layer.smart-layout-layer {
  position: relative !important;
  left: auto !important;
  top: auto !important;
}
#editor-content .canvas-layer:hover {
  background-color: rgba(16, 185, 129, 0.05);
}
#editor-content .canvas-layer.selected {
  outline: 2px solid #10b981;
  outline-offset: 1px;
  z-index: 9999 !important;
}
#editor-content .canvas-layer.text-layer.selected {
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text !important;
}
#editor-content .canvas-layer.dragging {
  cursor: grabbing;
  opacity: 0.85;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
#editor-content .canvas-layer.text-layer {
  font-size: 15px;
  color: #374151;
  line-height: 1.6;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  background: transparent;
  min-width: 60px;
}
#editor-content .canvas-layer.text-layer[contenteditable="true"] {
  cursor: grab !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  outline: none;
  background: rgba(16, 185, 129, 0.03);
}
#editor-content .canvas-layer.text-layer[contenteditable="true"]:focus {
  outline: 2px solid #10b981;
  outline-offset: 1px;
  background: rgba(16, 185, 129, 0.03);
  cursor: text !important;
}

/* 拖拽手柄 */
#editor-content .canvas-layer.text-layer .drag-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: grab;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.15s ease;
}
#editor-content .canvas-layer.text-layer.selected .drag-handle {
  opacity: 1;
}
#editor-content .canvas-layer.text-layer .drag-handle:hover {
  cursor: grabbing;
  transform: scale(1.2);
}
#editor-content .canvas-layer.text-layer .drag-handle.resize-handle-tl { top: -6px; left: -6px; }
#editor-content .canvas-layer.text-layer .drag-handle.resize-handle-tr { top: -6px; right: -6px; }
#editor-content .canvas-layer.text-layer .drag-handle.resize-handle-bl { bottom: -6px; left: -6px; }
#editor-content .canvas-layer.text-layer .drag-handle.resize-handle-br { bottom: -6px; right: -6px; }
#editor-content .canvas-layer:not(.text-layer) {
  cursor: grab;
}
#editor-content .canvas-layer img:not([data-image-editable]) {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
/* 秀米内容中的图片必须可双击编辑 - 覆盖秀米的内联样式 */
#editor-content .canvas-layer section img:not([data-image-editable]),
#editor-content .canvas-layer p img:not([data-image-editable]),
#editor-content .canvas-layer div img:not([data-image-editable]) {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
/* 可编辑的图片：允许双击替换 */
#editor-content .canvas-layer img[data-image-editable] {
  pointer-events: auto !important;
  cursor: pointer;
}
#editor-content .canvas-layer img[data-image-editable]:hover {
  outline: 2px solid #10b981;
  outline-offset: 2px;
}
#editor-content .canvas-layer img.img-error {
  min-width: 200px;
  min-height: 150px;
  background: #f3f4f6;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  object-fit: none;
  padding: 0;
}
#editor-content .canvas-layer .resize-handle-br {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid white;
  border-radius: 2px;
  cursor: nwse-resize;
  z-index: 10;
  display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
#editor-content .canvas-layer.selected .resize-handle-br {
  display: block;
}
#editor-content .canvas-layer table {
  border-collapse: collapse;
  width: 100%;
  background: white;
}
#editor-content .canvas-layer table td,
#editor-content .canvas-layer table th {
  border: 1px solid #ddd;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 40px;
}

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* Theme card */
.theme-card {
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.theme-card:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 12px -4px rgba(0,0,0,0.1);
}
.theme-card.selected {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
}

/* Modal overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 20000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Confirm dialog */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50000;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }

/* Tool select */
.tool-select {
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  color: #374151;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-select:hover { border-color: #10b981; }

/* Color swatch - updated for A3: 8-color set */
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  display: inline-block;
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.25); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.color-swatch.active { border-color: #374151; box-shadow: 0 0 0 2px white, 0 0 0 4px currentColor; }

/* Gradient swatch */
.gradient-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  display: inline-block;
}
.gradient-swatch:hover { transform: scale(1.15); border-color: #10b981; }
.gradient-swatch.active { border-color: #374151; box-shadow: 0 0 0 2px white, 0 0 0 4px currentColor; }

/* ===== Template Column Styles ===== */
.quick-fn-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: #4b5563;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  line-height: 1.4;
}
.quick-fn-btn:hover {
  background-color: #ecfdf5;
  border-color: #10b981;
  color: #059669;
}
.quick-fn-btn .new-badge {
  display: inline-block;
  font-size: 9px;
  background-color: #ef4444;
  color: white;
  padding: 0 5px;
  border-radius: 8px;
  line-height: 1.4;
  margin-left: 2px;
  font-weight: 600;
}

/* Tab 按钮激活状态 */
.quick-fn-tab.active,
.quick-fn-tab[data-active="true"] {
  background-color: #10b981;
  border-color: #10b981;
  color: white;
}
.quick-fn-tab.active:hover,
.quick-fn-tab[data-active="true"]:hover {
  background-color: #059669;
  border-color: #059669;
  color: white;
}

/* 功能按钮（不可激活，保持原样） */
.quick-fn-action {
  /* 使用默认样式 */
}

/* 内容面板 */
.content-panel {
  /* 默认显示 */
}
.content-panel.hidden {
  display: none !important;
}

.cat-tab {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  color: #6b7280;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  line-height: 1.6;
}
.cat-tab:hover {
  color: #059669;
  background: #ecfdf5;
}
.cat-tab.active {
  background: #10b981;
  color: white;
}

.tpl-card {
  background: white;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tpl-card:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 16px -4px rgba(0,0,0,0.12);
}
.tpl-card .tpl-thumb {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  padding: 0 12px;
  text-align: center;
  line-height: 1.4;
}
.tpl-card .tpl-info {
  padding: 10px 12px;
}
.tpl-card .tpl-name {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  line-height: 1.4;
}
.tpl-card .tpl-count {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Compact cover upload in editor */
.compact-cover {
  width: 72px;
  height: 44px;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.compact-cover:hover {
  border-color: #10b981;
  background: #f0fdf4;
}
.compact-cover iconify-icon { color: #9ca3af; font-size: 16px; }
.compact-cover span { font-size: 9px; color: #9ca3af; margin-top: 1px; }

/* ===== NEW: Cover upload area in top navbar (A1) ===== */
.cover-upload-area {
  width: 100px;
  height: 54px;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  background: #fafafa;
}
.cover-upload-area:hover {
  border-color: #10b981;
  background: #f0fdf4;
}
.cover-upload-area iconify-icon { color: #9ca3af; font-size: 18px; }
.cover-upload-area .cover-label { font-size: 10px; color: #9ca3af; margin-top: 2px; line-height: 1.2; }
.cover-upload-area .cover-hint { font-size: 8px; color: #d1d5db; line-height: 1.1; }

/* Grid Selector Popup (6×8 Table) */
.grid-selector-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}
.grid-selector-overlay.open { display: block; }
.grid-selector-popup {
  display: none;
  position: absolute;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  padding: 12px;
  z-index: 300;
  min-width: 200px;
}
.grid-selector-popup.open { display: block; }
.grid-selector-popup .gs-label {
  font-size: 12px;
  color: #374151;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}
.grid-selector-popup .gs-grid {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  grid-template-rows: repeat(6, 20px);
  gap: 2px;
  justify-content: center;
}
.grid-selector-popup .gs-cell {
  width: 20px;
  height: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 2px;
  background: white;
  transition: background 0.1s, border-color 0.1s;
  cursor: pointer;
}
.grid-selector-popup .gs-cell.highlighted {
  background: #d1fae5;
  border-color: #10b981;
}

/* Canvas Background Settings */
.canvas-bg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: white;
  color: #4b5563;
  user-select: none;
}
.canvas-bg-btn:hover {
  border-color: #10b981;
  color: #059669;
  background: #f0fdf4;
}
.canvas-bg-btn.active {
  border-color: #10b981;
  background: #d1fae5;
  color: #047857;
  font-weight: 500;
}

/* Zoom Control Styles */
.zoom-control-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2px;
  margin-right: 4px;
}
.zoom-control-group .zoom-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #6b7280;
  font-size: 13px;
  border: none;
  background: transparent;
  user-select: none;
  line-height: 1;
}
.zoom-control-group .zoom-btn:hover {
  background-color: #ecfdf5;
  color: #059669;
}
.zoom-control-group .zoom-label {
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  min-width: 36px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  padding: 0 2px;
}
.zoom-control-group .zoom-label:hover {
  color: #059669;
}
#editor-content.zooming {
  transition: transform 0.2s ease;
}

.canvas-bg-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.canvas-bg-color-grid .bg-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.canvas-bg-color-grid .bg-color-swatch:hover {
  transform: scale(1.15);
}
.canvas-bg-color-grid .bg-color-swatch.active {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.3);
}

/* Phone Preview (iPhone-style) */
.phone-frame {
  width: 375px;
  height: 780px;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 0 1px rgba(229,231,235,0.8);
  position: relative;
  margin: 0 auto;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.phone-status-bar {
  height: 44px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  padding: 0 24px;
  flex-shrink: 0;
  font-size: 12px;
  color: #374151;
  font-weight: 600;
}
.phone-status-left {
  flex: 1;
  text-align: left;
}
.phone-status-center {
  flex: 1;
  text-align: center;
  font-size: 14px;
}
.phone-status-right {
  flex: 1;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 12px;
  color: #4b5563;
}
.phone-title-bar {
  height: 40px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  font-size: 14px;
  color: #111827;
  font-weight: 600;
}
.phone-screen {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  line-height: 1.8;
  font-size: 15px;
  color: #374151;
  position: relative;
  background: #f9fafb;
}
.phone-screen::-webkit-scrollbar { width: 4px; }
.phone-screen::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.phone-screen-content {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
/* Bottom action bar - WeChat Official Account style */
.phone-bottom-bar {
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
}
.phone-bottom-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.2s;
}
.phone-bottom-item:hover {
  color: #10b981;
}
.phone-bottom-item iconify-icon {
  font-size: 16px;
}
#previewModal .modal-content {
  background: transparent;
  box-shadow: none;
  max-width: 880px;
  width: auto;
  padding: 0;
  overflow: visible;
}
.phone-close-btn {
  position: absolute;
  top: -40px;
  right: -10px;
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #333;
  font-size: 20px;
  border: none;
}
.phone-close-btn:hover {
  background: rgba(0,0,0,0.3);
  transform: scale(1.1);
}
@media (max-width: 900px) {
  .phone-frame {
    width: 95%;
    max-width: 375px;
    height: 85vh;
    min-height: 500px;
  }
  .phone-screen {
    padding: 16px 14px;
  }
  .phone-close-btn {
    top: -36px;
    right: 0;
  }
}

/* Image Animation Classes */
.img-animate-fade-in { animation: imgFadeIn 0.7s ease forwards; }
@keyframes imgFadeIn { from { opacity: 0; } to { opacity: 1; } }
.img-animate-slide-up { animation: imgSlideUp 0.7s ease forwards; }
@keyframes imgSlideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.img-animate-pulse { animation: imgPulse 2s ease-in-out infinite; }
@keyframes imgPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.8; transform: scale(1.04); } }
.img-animate-bounce { animation: imgBounce 1s ease infinite; }
@keyframes imgBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.img-animate-rotate { animation: imgRotate 1.8s linear infinite; }
@keyframes imgRotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Element Animation Keyframes */
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.85; transform: scale(1.03); } }
@keyframes floatUpDown { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes swing { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(3deg); } 75% { transform: rotate(-3deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 20% { transform: translateY(-12px); } 40% { transform: translateY(0); } 60% { transform: translateY(-6px); } 80% { transform: translateY(0); } }

.anim-breathe { animation: breathe 3s ease-in-out infinite; animation-fill-mode: both; }
.anim-float { animation: floatUpDown 3s ease-in-out infinite; animation-fill-mode: both; }
.anim-fadeIn { animation: fadeIn 1s ease forwards; animation-fill-mode: both; }
.anim-swing { animation: swing 2s ease-in-out infinite; animation-fill-mode: both; }
.anim-pulse { animation: pulse 1.5s ease-in-out infinite; animation-fill-mode: both; }
.anim-spin { animation: spin 3s linear infinite; animation-fill-mode: both; }
.anim-bounce { animation: bounce 1.5s ease infinite; animation-fill-mode: both; }

/* Layer selected highlight */
.layer-selected {
  outline: 2px solid #10b981;
  outline-offset: 2px;
  transition: outline 0.2s;
}

/* Collapsible Panel Styles */
.collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  transition: color 0.2s;
}
.collapse-header:hover { color: #059669; }
.collapse-header .collapse-icon {
  font-size: 12px;
  transition: transform 0.3s ease;
  color: #9ca3af;
}
.collapse-header .collapse-icon.open { transform: rotate(180deg); }
.collapse-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 0;
}
.collapse-body.open { max-height: 600px; padding: 8px 0; }

/* Layer Panel Styles */
.layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12px;
  color: #374151;
  user-select: none;
}
.layer-item:hover { background: #f0fdf4; }
.layer-item.selected { background: #d1fae5; color: #047857; font-weight: 500; }
.layer-item.hidden { opacity: 0.45; text-decoration: line-through; }
.layer-item .layer-type-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.layer-item .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item .layer-vis-toggle { font-size: 14px; cursor: pointer; opacity: 0.6; transition: opacity 0.15s; flex-shrink: 0; }
.layer-item .layer-vis-toggle:hover { opacity: 1; }
.layer-item.hidden .layer-vis-toggle { opacity: 0.3; }

.layer-op-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: white;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.layer-op-btn:hover { background: #f0fdf4; border-color: #10b981; color: #059669; }
.layer-op-btn.danger:hover { background: #fef2f2; border-color: #ef4444; color: #dc2626; }
.layer-op-btn.primary { background: #10b981; border-color: #10b981; color: white; }
.layer-op-btn.primary:hover { background: #059669; }

/* Style Control */
.style-btn-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.style-btn-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.style-btn {
  padding: 5px 4px;
  font-size: 11px;
  text-align: center;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: white;
  color: #4b5563;
  user-select: none;
}
.style-btn:hover { border-color: #10b981; color: #059669; background: #f0fdf4; }
.style-btn.selected { border-color: #10b981; background: #d1fae5; color: #047857; font-weight: 500; box-shadow: 0 0 0 1px rgba(16,185,129,0.3); }

/* Animation Card */
.anim-card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.anim-card {
  padding: 8px 2px;
  text-align: center;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: white;
  user-select: none;
}
.anim-card:hover { border-color: #10b981; background: #f0fdf4; }
.anim-card.selected { border-color: #10b981; background: #d1fae5; box-shadow: 0 0 0 2px rgba(16,185,129,0.25); }
.anim-card .anim-preview-icon { font-size: 18px; display: block; margin-bottom: 2px; }
.anim-card .anim-label { font-size: 10px; color: #6b7280; }
.anim-card.selected .anim-label { color: #047857; font-weight: 500; }

.speed-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  outline: none;
  transition: background 0.2s;
}
.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #10b981;
  cursor: pointer;
  transition: all 0.15s;
}
.speed-slider::-webkit-slider-thumb:hover { transform: scale(1.2); box-shadow: 0 0 0 4px rgba(16,185,129,0.2); }
.speed-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #10b981; cursor: pointer; border: none; }

/* New toolbar action buttons (clear-format, clear-content, undo, redo) */
.toolbar-action-btn {
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 500;
  user-select: none;
  padding: 0 8px;
  border: 1px solid #d1d5db;
  background: white;
  color: #6b7280;
}
.toolbar-action-btn:hover {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #10b981;
}
.toolbar-action-btn.danger {
  color: #ef4444;
  border-color: #fca5a5;
}
.toolbar-action-btn.danger:hover {
  background-color: #fef2f2;
  color: #dc2626;
  border-color: #ef4444;
}
.toolbar-action-btn:disabled,
.toolbar-action-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 1024px) { .template-column { display: none !important; } }
/* Xiumi button */
.xiumi-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.xiumi-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* Xiumi modal */
.xiumi-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 30000;
  display: none;
  justify-content: center;
  align-items: center;
}
.xiumi-overlay.open {
  display: flex;
}
.xiumi-modal {
  background: white;
  border-radius: 12px;
  width: calc(100vw - 60px);
  height: calc(100vh - 60px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.xiumi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}
.xiumi-header h3 {
  font-size: 16px;
  color: #1f2937;
  margin: 0;
}
.xiumi-close {
  padding: 4px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: #6b7280;
}
.xiumi-close:hover {
  background: #f3f4f6;
}
.xiumi-frame {
  flex: 1;
  border: none;
}

/* 响应式 */
@media (max-width: 1024px) {
  .left-menu { display: none !important; }
}
@media (max-width: 768px) {
  .side-panel { display: none !important; }
  .template-column { display: none !important; }
  .top-bar-title { max-width: 120px; }
  .top-toolbar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .top-toolbar-inner { flex-wrap: nowrap !important; min-width: max-content; }
  .op-bar-buttons { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .op-bar-buttons-inner { flex-wrap: nowrap !important; min-width: max-content; }
  .xiumi-modal { width: 100vw; height: 100vh; border-radius: 0; }
}
