:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-card: rgba(255,255,255,0.05);
  --bg-card-hover: rgba(255,255,255,0.08);
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --accent: #6c63ff;
  --accent-hover: #5a52d5;
  --accent-glow: rgba(108,99,255,0.3);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --success: #4caf50;
  --error: #f44336;
  --warning: #ff9800;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

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

html {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Step 1 Container */
#step1Container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
  height: 56px;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.app-header .logo svg { width: 28px; height: 28px; }

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

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  border-color: var(--accent);
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(10px);
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-section h3 svg { width: 16px; height: 16px; opacity: 0.7; }

.form-group {
  margin-bottom: 12px;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Main content */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 0 16px;
}

.tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--accent);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.tab-panel { display: none; height: 100%; }
.tab-panel.active { display: flex; flex-direction: column; }

textarea.plan-input {
  flex: 1;
  width: 100%;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.7;
  resize: none;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

textarea.plan-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea.plan-input::placeholder {
  color: var(--text-muted);
}

/* Upload area */
.upload-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone {
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108,99,255,0.05);
}

.drop-zone svg { width: 48px; height: 48px; color: var(--text-muted); }

.drop-zone .drop-text {
  font-size: 15px;
  color: var(--text-secondary);
}

.drop-zone .drop-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.2);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.file-info .file-name {
  flex: 1;
  font-size: 13px;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info .file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.file-info .file-remove:hover { color: var(--error); background: rgba(244,67,54,0.1); }

.file-content-preview {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.7;
}
.file-content-preview h1,
.file-content-preview h2,
.file-content-preview h3,
.file-content-preview h4,
.file-content-preview h5,
.file-content-preview h6 {
  color: var(--text-primary);
  margin: 16px 0 8px;
  font-weight: 600;
}
.file-content-preview h1 { font-size: 22px; }
.file-content-preview h2 { font-size: 19px; }
.file-content-preview h3 { font-size: 16px; }
.file-content-preview p { margin-bottom: 10px; }
.file-content-preview ul,
.file-content-preview ol { padding-left: 24px; margin-bottom: 10px; }
.file-content-preview li { margin-bottom: 4px; }
.file-content-preview strong { color: var(--accent); }
.file-content-preview table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.file-content-preview th,
.file-content-preview td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.file-content-preview th { background: var(--bg-card-hover); color: var(--text-primary); font-weight: 600; }
.file-content-preview code { background: var(--bg-card-hover); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.file-content-preview pre { background: var(--bg-primary); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; margin: 12px 0; }
.file-content-preview pre code { background: none; padding: 0; }
.file-content-preview blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 12px 0; color: var(--text-secondary); }

/* Generate button area */
.action-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.btn-generate {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}

.btn-generate:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-generate .spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.btn-generate.loading .spinner { display: block; }
.btn-generate.loading .btn-text { display: none; }
.btn-generate.loading .btn-loading-text { display: inline; }
.btn-generate .btn-loading-text { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Preview panel */
.preview-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

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

.preview-toolbar h3 {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.btn-action:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-action svg { width: 14px; height: 14px; }

.preview-frame-wrapper {
  flex: 1;
  background: #fff;
  position: relative;
  overflow: auto;
}

.preview-frame-wrapper iframe {
  width: 100%;
  min-height: 100%;
  border: none;
  display: block;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-primary);
}

.preview-empty svg { width: 64px; height: 64px; color: var(--text-muted); opacity: 0.4; }
.preview-empty p { color: var(--text-muted); font-size: 14px; }

/* ============ Split Container ============ */
.split-container {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.left-panel {
  display: flex;
  flex-direction: column;
  min-width: 280px;
  max-width: 70%;
  overflow: hidden;
  background: var(--bg-primary);
}

.right-panel {
  flex: 1;
  min-width: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.resize-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s;
  z-index: 10;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: var(--accent);
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: var(--text-muted);
  border-radius: 1px;
  opacity: 0.5;
}

.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: #fff;
  opacity: 1;
}

/* ============ AI Sidebar Panel ============ */
.ai-sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-primary);
}

/* AI 面板占满左侧（Step1 模式） */
.ai-sidebar-full {
  flex: 1;
}

.ai-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-sidebar-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-sidebar-header h3 svg {
  width: 16px; height: 16px;
  color: var(--accent);
}

.ai-mode-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(108,99,255,0.15);
  color: var(--accent);
  font-weight: 500;
}

/* AI 模式切换标签 */
.ai-mode-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.ai-mode-tab {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  color: #64748b;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  white-space: nowrap;
  font-weight: 500;
}
.ai-mode-tab:hover {
  background: #eef2ff;
  color: #4f46e5;
}
.ai-mode-tab.active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

/* AI sidebar messages - reuse chat styles */
.ai-sidebar-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* AI sidebar input area - Trae style */
.ai-input-resize-handle {
  height: 5px;
  cursor: row-resize;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
  z-index: 5;
}

.ai-input-resize-handle:hover,
.ai-input-resize-handle.dragging {
  background: var(--accent);
  opacity: 0.4;
}

.ai-input-resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  opacity: 0.3;
}

.ai-sidebar-input-area {
  padding: 10px 12px;
  background: var(--bg-primary);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* AI 输入区工具栏（停止按钮 + 状态提示） */
.ai-input-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 20px;
}

.btn-stop-sidebar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid #e74c3c;
  background: rgba(231,76,60,0.08);
  color: #e74c3c;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-stop-sidebar:hover {
  background: rgba(231,76,60,0.18);
}

.ai-status-hint {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 禁用态 */
.btn-ai-send:disabled,
.btn-ai-attach:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.ai-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex: 1;
  min-height: 0;
}

.ai-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.btn-ai-attach {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.btn-ai-attach:hover {
  color: var(--accent);
  background: rgba(108,99,255,0.1);
}

.ai-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  font-family: inherit;
  padding: 2px 0;
  min-height: 20px;
  align-self: stretch;
}

.ai-input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.btn-ai-send {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-ai-send:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

.btn-ai-send:active {
  transform: scale(0.95);
}

/* 导入生成按钮 */
.btn-ai-import {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-ai-import:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.05);
}

.btn-ai-import:active {
  transform: scale(0.95);
}

/* 已上传文件信息条 */
.uploaded-file-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px;
  padding: 6px 10px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 8px;
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}

.uploaded-file-bar svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.uploaded-file-bar span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uploaded-file-bar button {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.uploaded-file-bar button:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}

/* Reference content bar in AI input */
.ai-ref-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  flex-wrap: wrap;
}

.ai-ref-label {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.ai-ref-text {
  flex: 1;
  min-width: 100px;
  color: var(--text-secondary);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-ref-content button {
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
}

.ai-ref-content button:hover {
  color: var(--error);
  border-color: var(--error);
}

/* Original preview toggle button */
.btn-toggle-original.active {
  background: rgba(108,99,255,0.15) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* Progress bar */
.progress-bar {
  height: 3px;
  background: var(--bg-tertiary);
  position: relative;
  overflow: hidden;
  display: none;
}

.progress-bar.active { display: block; }

.progress-bar .progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-bar.indeterminate .progress-fill {
  width: 30%;
  animation: indeterminate 1.5s ease infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* 模板颜色选择器（预览工具栏内） */
.template-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpl-dot {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  position: relative;
}

.tpl-dot:hover {
  transform: scale(1.15);
}

.tpl-dot.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108,99,255,0.3);
  transform: scale(1.1);
}

/* 模板颜色（已废弃，保留兼容） */
.tpl-ai-free { background: linear-gradient(135deg, #6c63ff, #e91e63, #ff9800); background-size: 200% 200%; animation: aiGradientShift 4s ease infinite; }
.tpl-modern { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.tpl-soft { background: linear-gradient(135deg, #f5f0e8, #e8dcc8); }
.tpl-tech { background: linear-gradient(135deg, #0f172a, #1e1b4b); }
.tpl-nature { background: linear-gradient(135deg, #166534, #4ade80); }
.tpl-bold { background: linear-gradient(135deg, #000, #fff); }
.tpl-landing { background: linear-gradient(135deg, #0c2340, #f97316); }
.tpl-timeline { background: linear-gradient(135deg, #1f1f1f, #d4af37); }
.tpl-magazine { background: linear-gradient(135deg, #faf6f0, #8b1a1a); }
.tpl-docReader { background: linear-gradient(135deg, #1e3a5f, #f0f4f8); }

/* ==================== 布局选择器 ==================== */
.layout-picker {
  margin-right: 12px;
}
.layout-picker select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 28px 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.layout-picker select:hover,
.layout-picker select:focus {
  border-color: var(--accent);
}

/* ==================== 颜色主题选择器 ==================== */
.color-theme-picker {
  display: flex;
  gap: 5px;
  align-items: center;
}
.theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  position: relative;
  flex-shrink: 0;
}
.theme-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.theme-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,0.2);
  transform: scale(1.15);
}

/* 颜色主题色值 */
.theme-blue    { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.theme-green   { background: linear-gradient(135deg, #059669, #34d399); }
.theme-orange  { background: linear-gradient(135deg, #ea580c, #fb923c); }
.theme-purple  { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.theme-dark    { background: linear-gradient(135deg, #1e293b, #475569); }
.theme-warm    { background: linear-gradient(135deg, #b45309, #fbbf24); }

.btn-next-step {
  padding: 6px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-next-step:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-next-step:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ Step 2 Layout ============ */
.step2-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.step2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
  height: 56px;
}

.step2-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.step2-header-actions {
  display: flex;
  gap: 8px;
}

.step2-sidebar {
  background: var(--bg-secondary);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.step2-sidebar .sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.step2-sidebar .sidebar-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* 导入文档区域 */
.step2-import-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.import-doc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent-color, #4f46e5);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
}

.import-doc-btn:hover {
  opacity: 0.9;
}

.import-doc-btn:active {
  transform: scale(0.98);
}

.import-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  color: var(--accent-color, #4f46e5);
  border: 1px solid var(--accent-color, #4f46e5);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
  margin-top: 6px;
}

.import-action-btn:hover {
  background: var(--accent-color, #4f46e5);
  color: #fff;
}

.step2-import-section .uploaded-file-bar {
  margin-top: 6px;
}

.comp-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: var(--transition);
  user-select: none;
}

.comp-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.comp-card:active {
  cursor: grabbing;
  transform: scale(0.97);
}

.comp-card-icon {
  font-size: 20px;
  line-height: 1;
}

.comp-card-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* 占位符组件 */
.comp-placeholder {
  cursor: pointer;
}
.placeholder-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  min-height: 80px;
  transition: all 0.15s;
}
.comp-placeholder:hover .placeholder-box {
  border-color: #93c5fd;
  background: #f0f7ff;
}
.placeholder-icon-ph {
  font-size: 28px;
  margin-bottom: 6px;
  opacity: 0.5;
}
.placeholder-text-ph {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}
.placeholder-hint-ph {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

/* 章节块容器组件 */
.comp-section {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.comp-section:hover {
  border-color:#93c5fd;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12);
}
.section-container-title {
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-left: 4px solid #3b82f6;
  line-height: 1.4;
}
.section-container-body {
  padding: 14px 18px;
  min-height: 40px;
}
.section-empty-hint {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 20px 0;
  border: 2px dashed #e2e8f0;
  border-radius: 6px;
  background: #fafbfc;
  transition: all 0.2s ease;
}
.comp-section:hover .section-empty-hint {
  border-color: #93c5fd;
  color: #64748b;
  background: #f0f7ff;
}

.step2-canvas {
  background: #e8e8e8;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex: 1;
}

.step2-canvas iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

/* ===== 多文档编辑器模式（策划案模板） ===== */

/* 画布容器：主内容区(上) + 底部页签栏(下) */
.step2-canvas {
  background: #e8e8e8;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;   /* 纵向排列：内容在上，页签在下 */
  flex: 1;
}

/* 主内容区：左侧目录 + 右侧 iframe */
.editor-main-content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ===== 左侧目录栏 ===== */
.editor-toc-sidebar {
  width: 180px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
}
.editor-toc-panel { padding: 0 8px; }
.editor-toc-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 10px 6px;
}
.editor-toc-list { list-style: none; padding: 0; margin: 0; }
.editor-toc-list li { margin: 1px 0; }
.editor-toc-link {
  display: block;
  padding: 6px 10px;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.15s;
}
.editor-toc-link:hover { background: #eff6ff; color: #2563eb; }
.editor-toc-link.active { background: #dbeafe; color: #1d4ed8; font-weight: 500; }
.editor-toc-num { color: #94a3b8; margin-right: 6px; font-size: 11px; }
.editor-toc-empty { text-align: center; padding: 20px 10px; color: #cbd5e1; font-size: 12px; }

/* 右侧 iframe 容器 */
.editor-doc-frames {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.editor-doc-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ===== 底部页签栏（固定位置，不被滚动影响）===== */
.editor-proposal-tabbar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
  height: 44px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;          /* 不被压缩，始终可见 */
  z-index: 50;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
}

/* 段1：当前文档名 + 操作按钮 */
.editor-tab-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-right: 16px;
  flex-shrink: 0;
  min-width: 400px;
}
.editor-tab-cur-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-tab-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}
.editor-tab-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.editor-tab-del:hover { color: #ef4444; border-color: #fecaca; background: #fef2f2; }
.editor-tab-rename-btn:hover { color: #3b82f6; border-color: #bfdbfe; background: #eff6ff; }

/* 分隔线 */
.editor-tab-divider {
  width: 1px;
  height: 24px;
  background: #e2e8f0;
  flex-shrink: 0;
}

/* 段2：页签列表（可滚动） */
.editor-tab-list {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 8px;
}
.editor-tab-list::-webkit-scrollbar { display: none; }

/* 页签项 */
.editor-proposal-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 12px;
  color: #64748b;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.editor-proposal-tab:hover { background: #f1f5f9; color: #334155; }
.editor-proposal-tab.active {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
  font-weight: 600;
}
.editor-tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}
.editor-tab-dot.tab-dot-ui { background: #8b5cf6; }
.editor-tab-label { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }

/* 段3：添加按钮 */
.editor-tab-add-zone {
  flex-shrink: 0;
  padding-left: 8px;
}
.editor-proposal-tab-add {
  padding: 5px 12px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  white-space: nowrap;
  background: transparent;
  transition: all 0.15s;
}
.editor-proposal-tab-add:hover { color: #3b82f6; border-color: #93c5fd; background: #eff6ff; }

/* 排序按钮 */
.editor-tab-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  cursor: pointer;
  border: 1.5px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
  background: transparent;
  transition: all 0.15s;
  margin-left: 6px;
}
.editor-tab-sort-btn:hover { background: #f1f5f9; color: #475569; }
.editor-tab-sort-btn.active { background: #eff6ff; color: #3b82f6; border-color: #bfdbfe; }

/* 排序模式下的 tab 样式 */
.editor-proposal-tab.tab-sortable { cursor: grab; border-color: #e2e8f0; user-select: none; -webkit-user-select: none; }
.editor-proposal-tab.tab-sortable:hover { background: #f0f4ff; border-color: #93c5fd; }
.editor-proposal-tab.tab-dragging { opacity: 0.45; transform: scale(1.03); box-shadow: 0 4px 16px rgba(59,130,246,0.35); z-index: 10; position: relative; }
.editor-proposal-tab.tab-drop-left { border-left: 3px solid #3b82f6; }
.editor-proposal-tab.tab-drop-right { border-right: 3px solid #3b82f6; }

/* 隐藏原有单 iframe 样式在多文档模式下（通过 JS 控制 class） */

.drag-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: rgba(108,99,255,0.05);
  border: 2px dashed var(--accent);
  border-radius: 4px;
  pointer-events: none;
}
.drag-overlay.active {
  pointer-events: auto;
  background: rgba(108,99,255,0.08);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); color: #000; }

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { from { opacity:1; transform: translateX(0); } to { opacity:0; transform: translateX(40px); } }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--accent);
}

.modal p, .modal li {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.modal ul { padding-left: 20px; margin-bottom: 12px; }
.modal li { margin-bottom: 4px; }

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px;
}

.modal-close:hover { color: var(--text-primary); }

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions .btn-generate {
  width: auto;
  padding: 8px 24px;
  font-size: 13px;
}

/* Settings Modal */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-section:last-of-type {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive */
@media (max-width: 1024px) {
  .split-container {
    flex-direction: column;
  }
  .left-panel {
    max-width: 100%;
    max-height: 50%;
    border-bottom: 1px solid var(--border);
  }
  .right-panel {
    min-width: 0;
    min-height: 300px;
  }
  .resize-handle {
    width: 100%;
    height: 6px;
    cursor: row-resize;
  }
  .resize-handle::after {
    width: 40px;
    height: 2px;
  }
  .step2-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: 80px;
    padding: 8px;
    gap: 6px;
  }
  .comp-card { padding: 6px 12px; }
}

/* ==================== Home Page ==================== */
#homePage {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 40px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.home-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-header-left .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.home-header-left .logo svg { width: 32px; height: 32px; }

.home-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.home-header-actions {
  display: flex;
  gap: 10px;
}

.btn-home-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-home-action:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-home-action svg { width: 16px; height: 16px; }

/* ============ 首页页签（项目库 / 任务管理） ============ */
.home-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.home-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  margin-bottom: -1px;
}

.home-tab-btn:hover {
  color: var(--text-primary);
}

.home-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.home-tab-panel {
  display: none;
}

.home-tab-panel.active {
  display: block;
}

/* 任务管理面板需要占满剩余高度 */
.home-tab-panel#homeTabTasks.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 400px;
}

.task-mgmt-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ============ 任务编辑弹窗 ============ */
.task-edit-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.task-edit-modal.active {
  display: flex;
}

.task-edit-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

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

.task-edit-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.task-edit-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}

.task-edit-modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--error);
}

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

.task-edit-form-group {
  margin-bottom: 14px;
}

.task-edit-form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.task-edit-form-group input,
.task-edit-form-group select,
.task-edit-form-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  box-sizing: border-box;
}

.task-edit-form-group textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.task-edit-form-group input:focus,
.task-edit-form-group select:focus,
.task-edit-form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.task-edit-form-row {
  display: flex;
  gap: 12px;
}

.task-edit-form-row .task-edit-form-group {
  flex: 1;
}

.task-edit-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.task-edit-btn-cancel,
.task-edit-btn-save {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  border: 1px solid var(--border);
}

.task-edit-btn-cancel {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.task-edit-btn-cancel:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

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

.task-edit-btn-save:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.home-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.project-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.project-card-gradient {
  height: 80px;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 12px 16px;
}

.project-card-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
}

.project-card-gradient .template-label {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.3);
  padding: 2px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.project-card-info {
  padding: 16px;
  position: relative;
}

.project-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 项目概述 */
.project-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* 设计人员 */
.project-card-designer {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.project-card-designer svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.project-card-designer span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 三点菜单按钮（右下角） */
.project-card-menu-wrap {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 2;
}

.project-card-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.project-card-menu-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* 下拉菜单 */
.project-card-dropdown {
  min-width: 160px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  overflow: hidden;
  animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.dropdown-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.dropdown-item-danger:hover {
  background: rgba(244,67,54,0.1);
  color: var(--error);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* Add New Project Card */
.project-card-add {
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
}

.project-card-add:hover {
  border-color: var(--accent);
  background: rgba(108,99,255,0.05);
  transform: translateY(-2px);
}

.project-card-add .add-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.project-card-add:hover .add-icon {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108,99,255,0.1);
}

.project-card-add .add-icon svg { width: 24px; height: 24px; }

.project-card-add .add-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.project-card-add:hover .add-text {
  color: var(--accent);
}

/* Template gradient for project cards */
.tpl-gradient-modern { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.tpl-gradient-soft { background: linear-gradient(135deg, #f5f0e8, #e8dcc8); }
.tpl-gradient-tech { background: linear-gradient(135deg, #0f172a, #1e1b4b); }
.tpl-gradient-nature { background: linear-gradient(135deg, #166534, #4ade80); }
.tpl-gradient-bold { background: linear-gradient(135deg, #000, #fff); }
.tpl-gradient-landing { background: linear-gradient(135deg, #0c2340, #f97316); }
.tpl-gradient-timeline { background: linear-gradient(135deg, #1f1f1f, #d4af37); }
.tpl-gradient-magazine { background: linear-gradient(135deg, #faf6f0, #8b1a1a); }
.tpl-gradient-docReader { background: linear-gradient(135deg, #1e3a5f, #f0f4f8); }
.tpl-gradient-docPreview { background: linear-gradient(135deg, #fafafa, #6c63ff); }
.tpl-gradient-ai-free { background: linear-gradient(135deg, #6c63ff, #e91e63, #ff9800); background-size: 200% 200%; animation: aiGradientShift 4s ease infinite; }

/* ==================== Image Preview Modal ==================== */
.image-preview-modal {
  width: 90vw;
  max-width: 800px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.preview-close:hover { background: rgba(0,0,0,0.7); }

.preview-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  min-height: 200px;
  max-height: 60vh;
  overflow: hidden;
}

.preview-image-container img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 4px;
}

.preview-info {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.preview-info h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.preview-info p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
  word-break: break-word;
}

.btn-copy-note {
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy-note:hover { background: rgba(108,99,255,0.15); }

/* Home button in headers */
.btn-home {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-home:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-home svg { width: 16px; height: 16px; }

/* Sidebar project actions */
.sidebar-project-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sidebar-project-actions .btn-home-action {
  flex: 1;
  justify-content: center;
  min-width: 0;
  padding: 6px 8px;
  font-size: 12px;
}

/* Empty state */
.home-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.home-empty svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.home-empty p { font-size: 15px; }

/* ============ AI Optimize Modal ============ */
.ai-modal {
  max-width: 1100px !important;
  width: 92% !important;
  max-height: 85vh;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 头部：标题 + 关闭按钮 */
.ai-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.ai-modal-header-left h2 {
  font-size: 18px;
  color: var(--accent);
  margin: 0 0 4px !important;
  padding: 0;
}

.ai-modal-hint {
  margin: 0 !important;
  font-size: 13px !important;
  color: var(--text-muted) !important;
}

.ai-close-btn {
  float: none !important;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: -2px;
}

.ai-close-btn:hover {
  background: rgba(244,67,54,0.1);
  border-color: rgba(244,67,54,0.3);
  color: var(--error);
}

.ai-modal-body {
  flex: 1;
  display: flex;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

/* 左侧对话面板 */
.ai-chat-panel {
  width: 480px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 欢迎消息 */
.ai-welcome-msg {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: rgba(108,99,255,0.08);
  border: 1px solid rgba(108,99,255,0.15);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.ai-welcome-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: rgba(108,99,255,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.ai-welcome-msg strong {
  display: block;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 4px;
}

.ai-welcome-msg p { margin: 0 0 8px; }

.ai-welcome-msg ul {
  padding-left: 16px;
  margin: 0;
}

.ai-welcome-msg li {
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

/* 聊天消息气泡 */
.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.ai-msg-avatar.user {
  background: var(--accent);
  color: #fff;
}

.ai-msg-avatar.ai {
  background: rgba(108,99,255,0.15);
  color: var(--accent);
}

.ai-msg-bubble {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.ai-msg.user .ai-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg.ai .ai-msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.ai-msg-bubble p { margin: 0 0 8px; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble ul, .ai-msg-bubble ol { padding-left: 18px; margin: 8px 0; }
.ai-msg-bubble li { margin-bottom: 2px; }
.ai-msg-bubble code {
  background: rgba(108,99,255,0.15);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.ai-msg.user .ai-msg-bubble code {
  background: rgba(255,255,255,0.2);
}

/* 流式输出光标 */
.ai-streaming-cursor::after {
  content: '\2572';
  animation: blink 1s step-end infinite;
  color: var(--accent);
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* 输入区域 */
.ai-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.ai-chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.btn-stop-streaming {
  background: rgba(244,67,54,0.1) !important;
  border-color: rgba(244,67,54,0.3) !important;
  color: var(--error) !important;
}

.btn-stop-streaming:hover {
  background: rgba(244,67,54,0.2) !important;
}

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

#aiChatInput {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

#aiChatInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#aiChatInput::placeholder {
  color: var(--text-muted);
}

.ai-send-btn {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* 右侧预览面板 */
.ai-preview-panel {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.ai-preview-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* 底部操作栏 */
.ai-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.ai-apply-footer-btn {
  width: auto !important;
  padding: 10px 28px !important;
  font-size: 14px !important;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #4caf50, #45a049) !important;
  border: none !important;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ai-apply-footer-btn:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(76,175,80,0.4) !important;
  transform: translateY(-1px);
}

.ai-apply-footer-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

.ai-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
}

.ai-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 14px;
}

/* 预览区域内的 HTML 渲染样式 */
.ai-preview-content h1,
.ai-preview-content h2,
.ai-preview-content h3,
.ai-preview-content h4 { margin: 12px 0 8px; font-weight: 600; }
.ai-preview-content h1 { font-size: 22px; }
.ai-preview-content h2 { font-size: 19px; }
.ai-preview-content h3 { font-size: 16px; }
.ai-preview-content p { margin-bottom: 10px; line-height: 1.8; color: #333; }
.ai-preview-content ul,
.ai-preview-content ol { padding-left: 24px; margin-bottom: 10px; }
.ai-preview-content li { margin-bottom: 4px; line-height: 1.7; color: #333; }
.ai-preview-content strong { font-weight: 600; }
.ai-preview-content em { font-style: italic; }
.ai-preview-content table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.ai-preview-content th,
.ai-preview-content td { padding: 8px 12px; text-align: left; border: 1px solid #ddd; }
.ai-preview-content th { background: #f5f5f5; font-weight: 600; }
.ai-preview-content blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 12px 0; color: #666; }

/* AI 优化按钮样式 */
.btn-ai-optimize {
  background: linear-gradient(135deg, rgba(108,99,255,0.15), rgba(108,99,255,0.05)) !important;
  border-color: rgba(108,99,255,0.3) !important;
  color: var(--accent) !important;
  font-weight: 500 !important;
}

.btn-ai-optimize:hover {
  background: linear-gradient(135deg, rgba(108,99,255,0.25), rgba(108,99,255,0.1)) !important;
  border-color: var(--accent) !important;
}

/* ==================== Template Selection Cards ==================== */
.template-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.tpl-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
}

.tpl-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.tpl-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(108,99,255,0.08);
}

.tpl-card-preview {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* AI自由设计预览 */
.tpl-preview-ai-free {
  background: linear-gradient(135deg, #6c63ff, #e91e63, #ff9800);
  background-size: 200% 200%;
  animation: aiGradientShift 4s ease infinite;
}

@keyframes aiGradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.tpl-preview-icon {
  color: rgba(255,255,255,0.9);
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

/* 经典商务预览 */
.tpl-preview-modern {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  padding: 8px;
}

/* 着陆页预览 */
.tpl-preview-landing {
  background: linear-gradient(135deg, #1a1a2e, #e65100);
  padding: 8px;
}

/* 时间线预览 */
.tpl-preview-timeline {
  background: linear-gradient(135deg, #1a1a1a, #37474f);
  padding: 8px;
}

/* 杂志风预览 */
.tpl-preview-magazine {
  background: linear-gradient(135deg, #faf6f0, #d7ccc8);
  padding: 8px;
}

/* 文档阅读预览 */
.tpl-preview-docreader {
  background: linear-gradient(135deg, #1e3a5f, #f0f4f8);
  padding: 8px;
}

/* 策划案预览 */
.tpl-preview-proposal {
  background: linear-gradient(135deg, #0f172a, #334155);
  padding: 8px;
}

/* Mini layout diagrams */
.tpl-mini-layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}

.mini-header {
  height: 24px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
}

.mini-header-sm {
  height: 16px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
}

.mini-nav {
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.mini-cards {
  display: flex;
  gap: 3px;
  flex: 1;
}

.mini-card {
  flex: 1;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.mini-hero {
  height: 28px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
}

.mini-features {
  display: flex;
  gap: 3px;
  height: 20px;
}

.mini-feat {
  flex: 1;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.mini-cta {
  height: 12px;
  background: rgba(255,165,0,0.4);
  border-radius: 3px;
}

.mini-timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}

.mini-tl-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.mini-tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffc107;
  flex-shrink: 0;
}

.mini-tl-line {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.2);
}

.mini-columns {
  flex: 1;
  display: flex;
  gap: 4px;
}

.mini-main-col {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mini-side-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mini-block {
  flex: 1;
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
}

.mini-block-sm {
  flex: 1;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
}

/* 文档阅读 mini 布局 */
.mini-doc-layout {
  flex: 1;
  display: flex;
  gap: 4px;
}

.mini-toc-col {
  width: 28%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mini-toc-line {
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
}

.mini-toc-line.short {
  width: 60%;
}

.mini-doc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-doc-block {
  height: 10px;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
}

.mini-doc-side {
  width: 22%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-doc-note {
  height: 14px;
  background: rgba(37,99,235,0.2);
  border-radius: 3px;
}

.tpl-card-info {
  padding: 10px 12px;
}

.tpl-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.tpl-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.tpl-card.selected .tpl-card-name {
  color: var(--accent);
}

/* ==================== Prototype Component ==================== */
.comp-prototype .prototype-name {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

/* 文档/预览底部栏（概述 + 热区开关） */
.proto-doc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.proto-doc-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.proto-doc-hotspot-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.prototype-hotspot {
  position: absolute;
  background: rgba(59, 130, 246, 0.3);
  border: 2px solid rgba(59, 130, 246, 0.7);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.prototype-hotspot:hover {
  background: rgba(59, 130, 246, 0.5);
}

.prototype-hotspot.selected {
  border-color: #f59e0b;
  border-width: 3px;
  background: rgba(245, 158, 11, 0.3);
}

.hotspot-label {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 11px;
  color: #fff;
  background: rgba(59, 130, 246, 0.8);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 文档/预览模式：小程序胶囊按钮 */
.prototype-capsule-doc {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 4px 12px;
  height: 32px;
  pointer-events: none;
}
.pcd-dot { display: flex; gap: 4px; }
.pcd-dot span { width: 5px; height: 5px; border-radius: 50%; background: #fff; }
.pcd-line { display: flex; gap: 3px; align-items: center; }
.pcd-line span { width: 14px; height: 2.5px; border-radius: 1.5px; background: #fff; }

/* ===== 预览模式：状态切换动画 keyframes ===== */
@keyframes pt-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes pt-fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes pt-slide-left-out { from { transform: translateX(0); } to { transform: translateX(-30%); opacity: 0; } }
@keyframes pt-slide-left-in { from { transform: translateX(30%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@keyframes pt-slide-right-out { from { transform: translateX(0); } to { transform: translateX(30%); opacity: 0; } }
@keyframes pt-slide-right-in { from { transform: translateX(-30%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@keyframes pt-slide-up-out { from { transform: translateY(0); } to { transform: translateY(-20%); opacity: 0; } }
@keyframes pt-slide-up-in { from { transform: translateY(20%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@keyframes pt-slide-down-out { from { transform: translateY(0); } to { transform: translateY(20%); opacity: 0; } }
@keyframes pt-slide-down-in { from { transform: translateY(-20%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@keyframes pt-zoom-out { from { transform: scale(1); opacity: 1; } to { transform: scale(0.85); opacity: 0; } }
@keyframes pt-zoom-in { from { transform: scale(1.15); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@keyframes pt-flip-out { from { transform: perspective(600px) rotateY(0); opacity: 1; } to { transform: perspective(600px) rotateY(-90deg); opacity: 0; } }
@keyframes pt-flip-in { from { transform: perspective(600px) rotateY(90deg); opacity: 0; } to { transform: perspective(600px) rotateY(0); opacity: 1; } }

/* 出场动画类 */
.pt-out-fade { animation: pt-fade-out 0.3s ease forwards; }
.pt-out-slide-left { animation: pt-slide-left-out 0.3s ease forwards; }
.pt-out-slide-right { animation: pt-slide-right-out 0.3s ease forwards; }
.pt-out-slide-up { animation: pt-slide-up-out 0.3s ease forwards; }
.pt-out-slide-down { animation: pt-slide-down-out 0.3s ease forwards; }
.pt-out-zoom-in { animation: pt-zoom-out 0.3s ease forwards; }
.pt-out-flip { animation: pt-flip-out 0.35s ease forwards; }

/* 入场动画类 */
.pt-in-fade { animation: pt-fade-in 0.35s ease forwards; }
.pt-in-slide-left { animation: pt-slide-left-in 0.35s ease forwards; }
.pt-in-slide-right { animation: pt-slide-right-in 0.35s ease forwards; }
.pt-in-slide-up { animation: pt-slide-up-in 0.35s ease forwards; }
.pt-in-slide-down { animation: pt-slide-down-in 0.35s ease forwards; }
.pt-in-zoom-in { animation: pt-zoom-in 0.4s ease forwards; }
.pt-in-flip { animation: pt-flip-in 0.4s ease forwards; }

/* Hotspot Edit Popup */
.hotspot-popup {
  display: none;
  position: fixed;
  z-index: 10002;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.hotspot-popup.active {
  display: block;
}

.hotspot-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.hotspot-popup-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.hotspot-popup-close:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.hotspot-popup-body {
  padding: 16px;
}

.hotspot-popup-field {
  margin-bottom: 12px;
}

.hotspot-popup-field:last-child {
  margin-bottom: 0;
}

.hotspot-popup-field label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.hotspot-popup-field input,
.hotspot-popup-field select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.hotspot-popup-field input:focus,
.hotspot-popup-field select:focus {
  border-color: var(--accent);
}

.hotspot-popup-field select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.hotspot-popup-footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.hotspot-delete-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #ef4444;
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.hotspot-delete-btn:hover {
  background: rgba(239,68,68,0.2);
}

.hotspot-save-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.hotspot-save-btn:hover {
  background: var(--accent-hover);
}

/* Prototype Edit Modal */
.prototype-edit-content {
  max-width: 560px;
}

/* ===== 三栏布局（覆盖默认） ===== */
.prototype-edit-content.prototype-edit-3col {
  max-width: 1400px;
  width: 95vw;
  height: 92vh;
  display: flex;
  flex-direction: column;
}

.proto-layout {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* 左栏：信息 + 状态 + AI 输入 */
.proto-left-panel {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.proto-info-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.proto-info-group label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 1px;
}
.proto-info-group input,
.proto-info-group textarea {
  padding: 6px 8px;
  font-size: 13px;
}

.proto-state-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.proto-state-group > label {
  font-size: 11px;
  color: var(--text-muted);
}
.proto-state-group select {
  padding: 5px 6px;
  font-size: 12px;
}

.proto-state-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.proto-state-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  background: var(--bg-primary);
  transition: all 0.15s;
}
.proto-state-item:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.04);
}
.proto-state-item.active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}
.proto-state-item .state-name {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proto-state-item .state-count {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* 状态项操作按钮（编辑/删除） */
.proto-state-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.proto-state-item:hover .proto-state-actions { opacity: 1; }
.proto-state-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  transition: all 0.15s;
}
.proto-state-btn-edit { color: var(--text-muted); }
.proto-state-btn-edit:hover { background: rgba(59,130,246,0.15); color: #3b82f6; }
.proto-state-btn-del { color: var(--text-muted); }
.proto-state-btn-del:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

.proto-action-group {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

/* 中栏：画板（顶部工具栏 + 画布） */
.proto-canvas-panel {
  flex: 1;
  min-width: 300px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* 画板顶部工具栏 */
.proto-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.proto-canvas-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.proto-canvas-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 缩放控件 */
.proto-zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}
.proto-zoom-btn {
  padding: 2px 7px !important;
  font-size: 13px !important;
  line-height: 1 !important;
  min-width: 24px;
  justify-content: center;
}
.proto-zoom-level {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 32px;
  text-align: center;
  user-select: none;
}

/* 工具栏竖线分隔 */
.proto-toolbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
}

.proto-canvas-btn {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.proto-canvas-btn:hover {
  border-color: #3b82f6;
  color: var(--text-primary);
}
.proto-canvas-btn-primary {
  background: rgba(91,123,248,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.proto-canvas-btn-primary:hover {
  background: rgba(91,123,248,0.25);
}
.proto-canvas-btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
.proto-canvas-btn-accent:hover {
  opacity: 0.9;
}

/* 热区编辑按钮（与清空区分颜色） */
.proto-canvas-btn-hotspot {
  color: #60a5fa;
  border-color: rgba(96,165,250,0.3);
}
.proto-canvas-btn-hotspot:hover {
  border-color: #60a5fa;
  background: rgba(96,165,250,0.1);
}

/* 热区编辑按钮激活态 */
#protoHotspotToggleBtn.active {
  background: rgba(59,130,246,0.15);
  border-color: #3b82f6;
  color: #3b82f6;
}

/* 热区面板可隐藏 */
.proto-hotspot-panel {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: hidden;
  transition: width 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
}
.proto-hotspot-panel.hidden {
  width: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  border-color: transparent;
}

.proto-canvas-container {
  width: 100%;
  flex: 1;
  min-height: 200px;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  background: #1a1a2e;
}

.proto-canvas-container.drawing-mode {
  cursor: crosshair;
}

/* 外框内的屏幕区域 */
.proto-phone-screen {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 38px;
  background: transparent;
  position: relative;
}

/* 手机顶部听筒/刘海（默认，各模板可覆盖） */
.proto-phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}
.proto-phone-frame.portrait .proto-phone-notch {
  width: 80px; height: 24px;
  background: #000;
  border-radius: 0 0 14px 14px;
}
.proto-phone-frame.landscape .proto-phone-notch {
  width: 24px; height: 80px;
  background: #000;
  border-radius: 0 14px 14px 0;
  left: 0; top: 50%; transform: translateY(-50%);
}

/* 小程序胶囊按钮（右上角） */
.proto-miniprogram-capsule {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 4px 12px;
  height: 32px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.proto-miniprogram-capsule.visible { opacity: 1; }
.proto-mc-dot {
  display: flex;
  gap: 4px;
}
.proto-mc-dot span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
}
.proto-mc-line {
  display: flex;
  gap: 3px;
  align-items: center;
}
.proto-mc-line span {
  width: 14px;
  height: 2.5px;
  border-radius: 1.5px;
  background: #fff;
}

/* 屏幕内容：img 填满屏幕区；iframe 撑满屏幕 */
.proto-phone-screen > .proto-canvas-image {
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.proto-phone-screen > .proto-canvas-image.visible {
  opacity: 1;
}
/* 图片模式：直接填满屏幕，不留白 */
.proto-phone-screen > img.proto-canvas-image {
  width: 100%;
  height: 100%;
  object-fit: fill;
}
/* HTML模式(iframe)：撑满屏幕区域 */
.proto-phone-screen > iframe.proto-canvas-image {
  width: 100%;
  height: 100%;
  border: none;
}
/* 占位提示 */
.proto-phone-screen > .proto-canvas-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ===== 顶部工具栏（外框 + 方向 + 小程序）—— 已移至画板工具栏 ===== */
.proto-ai-input-tools {
  display: none;
}

/* 左侧控件组 */
.proto-tools-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.proto-tool-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* 外框模板选择器 */
.proto-frame-select {
  display: flex;
  align-items: center;
  gap: 2px;
}
.proto-frame-opt {
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: all 0.15s;
  user-select: none;
  line-height: 1;
}
.proto-frame-opt:hover { opacity: 0.75; }
.proto-frame-opt.active {
  opacity: 1;
  background: rgba(91,123,248,0.15);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* 小程序模式开关 */
.proto-miniprogram-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  user-select: none;
  transition: color 0.15s;
}
.proto-miniprogram-toggle:hover { color: var(--text-primary); }
.proto-miniprogram-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 14px;
  border-radius: 7px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.proto-miniprogram-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s;
}
.proto-miniprogram-toggle input[type="checkbox"]:checked {
  background: #07c160;
  border-color: #07c160;
}
.proto-miniprogram-toggle input[type="checkbox"]:checked::after {
  left: 14px;
  background: #fff;
}
.proto-miniprogram-toggle input[type="checkbox"]:checked + span {
  color: #07c160;
}

/* ===== 手机外框 - 三种模板 ===== */
.proto-phone-frame {
  position: relative;
  flex-shrink: 0;
  transition: transform 0.2s ease, all 0.3s ease;
  margin: auto;
}

/* --- 模板1：iPhone 风格（默认） --- */
.proto-phone-frame.iphone {
  background: #000;
  border-radius: 44px;
  padding: 6px;
  box-shadow:
    0 0 0 2px #333,
    0 12px 48px rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(255,255,255,0.06);
}
.proto-phone-frame.iphone .proto-phone-screen {
  border-radius: 34px;
}
.proto-phone-frame.iphone.portrait .proto-phone-notch {
  width: 100px; height: 28px;
  background: #000;
  border-radius: 0 0 18px 18px;
  top: -2px;
}
.proto-phone-frame.iphone.landscape .proto-phone-notch {
  width: 28px; height: 100px;
  background: #000;
  border-radius: 0 18px 18px 0;
  left: -2px; top: 50%; transform: translateY(-50%);
}
/* iPhone 底部横条指示器 */
.proto-phone-frame.iphone::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  pointer-events: none;
}

/* --- 模板2：Android 风格 --- */
.proto-phone-frame.android {
  background: #1a1a1a;
  border-radius: 20px;
  padding: 8px;
  box-shadow:
    0 0 0 1px #444,
    0 8px 32px rgba(0,0,0,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.04);
}
.proto-phone-frame.android .proto-phone-screen {
  border-radius: 14px;
}
.proto-phone-frame.android.portrait .proto-phone-notch {
  width: 70px; height: 20px;
  background: #1a1a1a;
  border-radius: 0 0 10px 10px;
  top: -1px;
}
.proto-phone-frame.android.landscape .proto-phone-notch {
  width: 20px; height: 70px;
  background: #1a1a1a;
  border-radius: 0 10px 10px 0;
  left: -1px; top: 50%; transform: translateY(-50%);
}
/* Android 前置摄像头小圆点 */
.proto-phone-frame.android::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 22px;
  width: 8px;
  height: 8px;
  background: #333;
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 15;
}

/* --- 模板3：极简线框 --- */
.proto-phone-frame.minimal {
  background: transparent;
  border-radius: 24px;
  padding: 3px;
  border: 2px solid rgba(91,123,248,0.35);
  box-shadow:
    0 0 0 1px rgba(91,123,248,0.08),
    0 4px 20px rgba(0,0,0,0.08);
}
.proto-phone-frame.minimal .proto-phone-screen {
  border-radius: 21px;
  background: transparent;
}
.proto-phone-frame.minimal .proto-phone-notch { display: none; }

/* 所有模板共用尺寸比例 */
.proto-phone-frame.portrait {
  aspect-ratio: 750 / 1624;
  width: min(300px, calc(100% - 32px));
  max-height: calc(100% - 32px);
}
.proto-phone-frame.landscape {
  aspect-ratio: 1624 / 750;
  width: min(calc(100% - 32px), 520px);
  max-height: calc(100% - 32px);
}

/* 中栏底部：AI 生成输入区（填充左侧边栏剩余空间） */
.proto-ai-input-area {
  flex: 1;
  min-height: 120px;
  padding: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 拖拽手柄（顶边） */
.proto-ai-drag-handle {
  width: 100%;
  height: 5px;
  cursor: ns-resize;
  flex-shrink: 0;
  background: transparent;
  transition: background 0.15s;
}
.proto-ai-drag-handle:hover {
  background: #3b82f6;
}
.proto-ai-drag-handle:active,
.proto-ai-drag-handle.dragging {
  background: #2563eb;
}

.proto-ai-type-select {
  width: auto;
  min-width: 90px;
  flex-shrink: 0;
  padding: 5px 24px 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  cursor: pointer;
}
.proto-ai-type-select:focus {
  border-color: var(--accent);
}

/* 横竖版切换按钮 */
.proto-orientation-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px;
  flex-shrink: 0;
  cursor: pointer;
}
.proto-ori-label {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  color: var(--text-muted);
  transition: all 0.2s;
  user-select: none;
}
.proto-ori-label[data-active="true"] {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* 文本框：填充剩余空间 */
.proto-ai-desc-textarea {
  flex: 1;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  border: none;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  resize: none;
  font-family: inherit;
}
.proto-ai-desc-textarea::placeholder { color: var(--text-muted); }
.proto-ai-desc-textarea:focus { box-shadow: inset 0 0 0 1px #3b82f6; }

/* 状态文字（独立行） */
.proto-ai-status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 10px 0;
  flex-shrink: 0;
  min-height: 16px;
}

/* 底部操作栏：页面类型（左） + 生成按钮（右） */
.proto-ai-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 8px;
  flex-shrink: 0;
  gap: 8px;
}
.proto-page-type-wrap {
  flex-shrink: 0;
}

.proto-ai-generate-btn,
.proto-ai-stop-btn {
  flex-shrink: 0;
  width: auto !important;
  padding: 6px 16px;
  font-size: 12px;
  white-space: nowrap;
  min-width: 0;
}
.proto-ai-regen-btn {
  background: rgba(91,123,248,0.15) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

/* 三栏弹窗 header 行（修复关闭按钮位置） */
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  margin-bottom: 4px;
}
.proto-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.proto-header-left h2 {
  margin: 0;
  font-size: 16px;
  flex-shrink: 0;
}

/* 原型图整体复制/粘贴按钮 */
.proto-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.proto-copy-btn, .proto-paste-btn {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.proto-copy-btn:hover, .proto-paste-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
  color: #3b82f6;
}

/* 标题旁 UI 类型下拉框 */
.proto-ui-type-select {
  padding: 4px 24px 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.proto-ui-type-select:hover {
  border-color: #3b82f6;
  color: var(--text-primary);
}
.proto-ui-type-select:focus {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* 画板底图（图片模式：width:100% 以确保热区百分比定位准确） */
.proto-phone-screen > img.proto-canvas-image {
  width: 100%;
  height: auto;
  display: block;
}
/* 画板HTML内容(iframe)：撑满屏幕 */
.proto-phone-screen > iframe.proto-canvas-image {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

/* 画板无底图提示 */
.proto-canvas-placeholder {
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  padding: 20px;
}
.proto-canvas-placeholder:hover { color: #3b82f6; }
.proto-canvas-placeholder-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.proto-canvas-placeholder-text {
  font-size: 14px;
  font-weight: 600;
}
.proto-canvas-placeholder-hint {
  font-size: 12px;
  margin-top: 4px;
}

/* 画板内热区 */
.proto-canvas-hotspot {
  position: absolute;
  background: rgba(59, 130, 246, 0.25);
  border: 2px solid rgba(59, 130, 246, 0.7);
  border-radius: 4px;
  cursor: pointer;
  z-index: 5;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.proto-canvas-hotspot:hover {
  background: rgba(59, 130, 246, 0.35);
  border-color: #3b82f6;
}
.proto-canvas-hotspot.selected {
  border-color: #f59e0b;
  border-width: 2px;
  background: rgba(245, 158, 11, 0.18);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.3), 0 0 8px rgba(245, 158, 11, 0.25);
  z-index: 10;
}

/* 热区四角缩放手柄（仅选中时显示） */
.proto-canvas-hotspot.selected::before,
.proto-canvas-hotspot.selected::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border: 1px solid #fff;
  border-radius: 2px;
  z-index: 11;
}
.proto-canvas-hotspot.selected::before {
  right: -4px; bottom: -4px;
  cursor: se-resize;
}
.proto-canvas-hotspot.selected::after {
  left: -4px; top: -4px;
  cursor: nwse-resize;
}

/* 拖拽中状态 */
.proto-canvas-hotspot.dragging {
  opacity: 0.85;
  cursor: grabbing;
}

.proto-hs-label-on-canvas {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 10px;
  color: #fff;
  background: rgba(59, 130, 246, 0.85);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.3;
}

/* Toast 飘字预览（编辑器画布内）— 长横条半透明样式 */
.proto-toast-preview {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 13px;
  padding: 8px 32px;
  border-radius: 6px;
  max-width: 340px;
  width: auto;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  letter-spacing: 0.5px;
  transition: opacity 0.25s ease, transform 0.25s ease-out;
}
.proto-toast-preview.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.proto-toast-preview.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity 0.35s ease, transform 0.35s ease-in;
}
/* 绘制预览框 */
.proto-draw-preview {
  position: absolute;
  border: 2px dashed #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  pointer-events: none;
  z-index: 10;
}

/* 右栏：热区面板 */
.proto-hotspot-panel {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: hidden;
}

.proto-hotspot-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.proto-hs-header-actions {
  display: flex;
  gap: 2px;
}

.proto-hs-clip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  transition: all 0.15s;
}
.proto-hs-clip-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(91,123,248,0.08);
}

/* 右栏分区标题 */
.proto-section-block {
  margin-bottom: 8px;
}
.proto-section-block--last {
  margin-bottom: 0;
}
.proto-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

/* 顶部编辑区：选中热区的标签+跳转类型 */
.proto-hs-edit-area {
  flex-shrink: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.proto-hs-edit-placeholder {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}
.proto-hs-edit-form .proto-hs-field { margin-bottom: 6px; }
.proto-hs-edit-form .proto-hs-field:last-child { margin-bottom: 0; }

/* 底部目标列表：可滚动选择状态/原型图 */
.proto-hs-target-list {
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.proto-hs-target-item {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
}
.proto-hs-target-item:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}
.proto-hs-target-item.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: #3b82f6;
  color: #3b82f6;
  font-weight: 600;
}
.proto-hs-target-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

.proto-hotspot-list {
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.proto-hotspot-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 30px 10px;
}

.proto-hotspot-item {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.proto-hotspot-item:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.04);
}
.proto-hotspot-item.selected {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.06);
}

.proto-hs-number {
  font-size: 11px;
  font-weight: 700;
  color: #3b82f6;
  margin-right: 8px;
  flex-shrink: 0;
}

.proto-hs-field {
  margin-bottom: 5px;
}
.proto-hs-field label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.proto-hs-field input,
.proto-hs-field select {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}
.proto-hs-field input:focus,
.proto-hs-field select:focus {
  border-color: #3b82f6;
}

.proto-hs-delete {
  font-size: 11px;
  color: #ef4444;
  cursor: pointer;
  text-align: right;
  padding-top: 4px;
  opacity: 0.6;
}
.proto-hs-delete:hover { opacity: 1; }

/* 隐藏的文件输入 */
#protoImageInput { display: none; }

/* 右栏底部：绘制热区按钮区 */
.proto-hs-draw-area {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.proto-hs-draw-btn,
.proto-hs-cancel-btn {
  width: 100%;
}

.prototype-info-section {
  margin-bottom: 16px;
}

.prototype-states-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.states-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.state-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}

.state-card .state-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.state-card .state-image-status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============ 全屏表格编辑弹窗 ============ */
.modal.table-edit-fullscreen {
  width: 96vw;
  height: 94vh;
  max-width: 96vw;
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal.table-edit-fullscreen .modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 10;
  float: none;
  font-size: 22px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal.table-edit-fullscreen .modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* 头部 */
.table-edit-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 48px 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.table-edit-header h2 {
  margin: 0;
  font-size: 16px;
  color: var(--accent);
}

.table-edit-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 字段释义开关 */
.fielddef-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-secondary);
}
.fielddef-toggle-wrap input[type="checkbox"] {
  display: none;
}
.fielddef-toggle-track {
  width: 34px;
  height: 18px;
  background: #cbd5e1;
  border-radius: 9px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.fielddef-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.fielddef-toggle-wrap input:checked + .fielddef-toggle-track {
  background: #10b981;
}
.fielddef-toggle-wrap input:checked + .fielddef-toggle-track .fielddef-toggle-thumb {
  transform: translateX(16px);
}
.fielddef-toggle-label {
  white-space: nowrap;
}

/* ==================== 登录弹窗 ==================== */
.login-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}
.login-overlay.active { display: flex; }

.login-modal {
  background: #1e1e2e;
  border-radius: 16px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  overflow: hidden;
  animation: loginModalIn 0.25s ease-out;
}
@keyframes loginModalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.login-logo {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.login-close-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}
.login-close-btn:hover { color: #fff; }

.login-tabs {
  display: flex;
  gap: 0;
  margin: 16px 24px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.login-tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: rgba(255,255,255,0.45);
  border: none;
  transition: all 0.2s;
}
.login-tab.active {
  background: rgba(124,92,252,0.12);
  color: #a78bfa;
}
.login-tab:hover:not(.active) { color: rgba(255,255,255,0.7); }

.login-form {
  display: none;
  padding: 20px 24px;
}
.login-form.active { display: block; }

.login-field {
  margin-bottom: 14px;
}
.login-field label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 6px;
  font-weight: 500;
}
.login-field input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.login-field input:focus {
  border-color: #7c5cfc;
  box-shadow: 0 0 0 3px rgba(124,92,252,0.15);
}
.login-field input::placeholder { color: rgba(255,255,255,0.25); }

.login-code-row {
  display: flex;
  gap: 8px;
}
.login-code-row input { flex: 1; }
.login-send-code-btn {
  padding: 10px 14px;
  white-space: nowrap;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #7c5cfc, #a78bfa);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.login-send-code-btn:hover:not(:disabled) { opacity: 0.88; }
.login-send-code-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.login-submit-btn {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c5cfc, #a78bfa);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.login-submit-btn:hover:not(:disabled) { opacity: 0.9; }
.login-submit-btn:active:not(:disabled) { transform: scale(0.98); }
.login-submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.login-footer {
  text-align: center;
  padding: 0 24px 20px;
  font-size: 13px;
  color: rgba(255,255,255,0.35);
}
.login-footer a {
  color: #a78bfa;
  text-decoration: none;
  font-weight: 500;
}
.login-footer a:hover { text-decoration: underline; }

/* ==================== 用户信息栏 ==================== */
.user-info-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  background: rgba(124,92,252,0.1);
  border: 1px solid rgba(124,92,252,0.2);
  border-radius: 20px;
  margin-right: 4px;
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cfc, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.user-name {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-user-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-user-logout:hover {
  color: #f87171;
  background: rgba(248,113,113,0.1);
}

/* 登录入口按钮（未登录状态） */
.btn-login-entry {
  background: linear-gradient(135deg, #7c5cfc, #a78bfa) !important;
  color: #fff !important;
  font-weight: 600 !important;
}
.btn-login-entry:hover {
  opacity: 0.88 !important;
}

/* 主体：横向三分（AI → 字段释义 → 配置表格） */
.table-edit-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

/* AI 区段（最左，可收缩） */
.table-edit-ai-section {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
}

.table-edit-ai-section.collapsed {
  display: none;
}

/* 字段释义 / 配置表格区段 */
.table-edit-section {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* 配置表格区段占更大空间 */
.table-edit-section-config {
  flex: 2;
  border-right: none;
}

/* 拖拽分隔条 */
.table-edit-resizer {
  flex-shrink: 0;
  width: 6px;
  cursor: col-resize;
  background: var(--border);
  position: relative;
  transition: background 0.15s;
  z-index: 2;
}

.table-edit-resizer::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  background: var(--text-tertiary, #cbd5e1);
  border-radius: 1px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.table-edit-resizer:hover {
  background: var(--accent, #3b82f6);
}

.table-edit-resizer:hover::before {
  opacity: 1;
  background: #fff;
}

.table-edit-resizer.resizing {
  background: var(--accent, #3b82f6);
}

.table-edit-resizer.hidden {
  display: none;
}

.table-edit-section-title {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.table-edit-section-title svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

/* 工具栏 */
.table-edit-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* 表格网格容器（白底，可滚动） */
.table-edit-grid-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
  background: #fff;
  padding: 8px;
}

.table-edit-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-edit-grid input {
  font-family: inherit;
}

.table-edit-grid input:focus {
  background: rgba(99, 102, 241, 0.08) !important;
  outline: 1px solid #6366f1;
}

/* AI 面板头部 */
.table-ai-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

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

.table-ai-collapse {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
}

.table-ai-collapse:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* AI 消息区 */
.table-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-ai-welcome {
  padding: 18px 16px;
  background: rgba(108, 99, 255, 0.08);
  border: 1px solid rgba(108, 99, 255, 0.15);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.table-ai-welcome strong {
  display: block;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 4px;
}

/* AI 消息气泡 */
.table-ai-msg {
  display: flex;
  max-width: 100%;
  animation: msgIn 0.3s ease;
}

.table-ai-msg-user {
  justify-content: flex-end;
}

.table-ai-msg-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.table-ai-msg-user .table-ai-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.table-ai-msg-assistant .table-ai-msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.table-ai-msg-bubble code {
  background: rgba(108, 99, 255, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.table-ai-msg-user .table-ai-msg-bubble code {
  background: rgba(255, 255, 255, 0.2);
}

/* AI 输入区 */
.table-ai-input-area {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-secondary);
}

.table-ai-input-area textarea {
  width: 100%;
  resize: none;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

.table-ai-input-area textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.table-ai-input-area textarea::placeholder {
  color: var(--text-muted);
}

.table-ai-input-area .btn-generate {
  width: auto;
  padding: 8px 16px;
  font-size: 13px;
}

/* 底部操作栏 */
.modal.table-edit-fullscreen .modal-actions {
  flex-shrink: 0;
  margin-top: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* ==================== MD 编辑模式样式 ==================== */

/* 模式切换按钮组 */
.edit-mode-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.edit-mode-switcher .mode-btn {
  padding: 5px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.edit-mode-switcher .mode-btn:hover:not(:disabled):not(.active) {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.edit-mode-switcher .mode-btn.active {
  background: var(--accent-color, #4f46e5);
  color: #fff;
}

.edit-mode-switcher .mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* MD 编辑器面板 */
.md-editor-panel {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 左侧大纲导航 */
.md-outline {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-y: auto;
  padding: 12px 0;
}

.md-outline-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 16px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.md-outline-item {
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.md-outline-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.md-outline-section {
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

.md-outline-heading {
  color: var(--text-secondary);
}

/* 右侧 CodeMirror 编辑器容器 */
.md-editor-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.md-editor-wrap .CodeMirror {
  height: 100% !important;
  font-size: 14px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  line-height: 1.8;
}

/* 标记区块只读样式 — 柔和琥珀色 */
.md-readonly-marker {
  background: #fff8e1;
  border-left: 3px solid #b8860b;
  padding: 1px 4px;
  border-radius: 2px;
  color: #7c5e10;
  font-style: italic;
  cursor: not-allowed;
  display: inline-block;
}

.md-readonly-marker:hover {
  background: #fff3c4;
}

/* CodeMirror 基础样式 — 护眼浅色配色（GitHub Light 风格） */
.md-editor-wrap .CodeMirror {
  background: #fafbfc !important;
  color: #24292e !important;
}

/* 语法高亮颜色覆盖 */
.md-editor-wrap .CodeMirror .cm-header {
  color: #0550ae;
  font-weight: 600;
}

.md-editor-wrap .CodeMirror .cm-strong {
  color: #24292e;
  font-weight: 700;
}

.md-editor-wrap .CodeMirror .cm-em {
  color: #6f42c1;
  font-style: italic;
}

.md-editor-wrap .CodeMirror .cm-link {
  color: #0969da;
  text-decoration: underline;
}

.md-editor-wrap .CodeMirror .cm-url {
  color: #0969da;
}

.md-editor-wrap .CodeMirror .cm-quote {
  color: #57606a;
  font-style: italic;
}

.md-editor-wrap .CodeMirror .cm-hr {
  color: #d0d7de;
}

.md-editor-wrap .CodeMirror .cm-comment {
  color: #6e7781;
}

.md-editor-wrap .CodeMirror .cm-variable-2,
.md-editor-wrap .CodeMirror .cm-variable-3 {
  color: #24292e;
}

.md-editor-wrap .CodeMirror .cm-keyword {
  color: #cf222e;
}

.md-editor-wrap .CodeMirror .cm-string {
  color: #0a3069;
}

.md-editor-wrap .CodeMirror .cm-number {
  color: #0550ae;
}

.CodeMirror-cursor {
  border-left-color: #0969da !important;
  border-left-width: 2px !important;
}

.md-editor-wrap .CodeMirror-selected {
  background: rgba(9, 105, 218, 0.12) !important;
}

.md-editor-wrap .CodeMirror-focused .CodeMirror-selected {
  background: rgba(9, 105, 218, 0.2) !important;
}

/* 大纲导航也用浅色 */
.md-outline {
  background: #f6f8fa !important;
}

.md-outline-item {
  color: #57606a;
}

.md-outline-item:hover {
  background: #eaeef2;
  color: #24292e;
}

.md-outline-section {
  color: #24292e;
}

.md-outline-title {
  color: #6e7781;
}
