/* ========== 主题变量 ========== */
:root {
    --viz-primary: #059669;
    --viz-primary-hover: #047857;
    --viz-toolbar-bg: linear-gradient(135deg, #059669 0%, #047857 100%);
    --viz-toolbar-text: white;
    --viz-btn-bg: #ffffff;
    --viz-btn-text: #047857;
    --viz-preview-bg: #f0fdf4;
    --viz-preview-header-bg: #dcfce7;
    --viz-preview-border: #86efac;
    --viz-accent: #10b981;
    --viz-section-border: #d1fae5;
}

/* 主题：海洋蓝 */
[data-theme="ocean"] {
    --viz-primary: #0284c7;
    --viz-primary-hover: #0369a1;
    --viz-toolbar-bg: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    --viz-btn-text: #0369a1;
    --viz-preview-bg: #f0f9ff;
    --viz-preview-header-bg: #e0f2fe;
    --viz-preview-border: #7dd3fc;
    --viz-accent: #38bdf8;
    --viz-section-border: #bae6fd;
}

/* 主题：日落橙 */
[data-theme="sunset"] {
    --viz-primary: #ea580c;
    --viz-primary-hover: #c2410c;
    --viz-toolbar-bg: linear-gradient(135deg, #ea580c 0%, #dc2626 100%);
    --viz-btn-text: #c2410c;
    --viz-preview-bg: #fff7ed;
    --viz-preview-header-bg: #ffedd5;
    --viz-preview-border: #fdba74;
    --viz-accent: #fb923c;
    --viz-section-border: #fed7aa;
}

/* 主题：紫罗兰 */
[data-theme="purple"] {
    --viz-primary: #7c3aed;
    --viz-primary-hover: #6d28d9;
    --viz-toolbar-bg: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    --viz-btn-text: #6d28d9;
    --viz-preview-bg: #faf5ff;
    --viz-preview-header-bg: #ede9fe;
    --viz-preview-border: #c4b5fd;
    --viz-accent: #a78bfa;
    --viz-section-border: #ddd6fe;
}

/* 主题：暗夜黑 */
[data-theme="dark"] {
    --viz-primary: #1e293b;
    --viz-primary-hover: #0f172a;
    --viz-toolbar-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --viz-btn-bg: #334155;
    --viz-btn-text: #94a3b8;
    --viz-preview-bg: #1e293b;
    --viz-preview-header-bg: #334155;
    --viz-preview-border: #475569;
    --viz-accent: #64748b;
    --viz-section-border: #334155;
}

/* ========== 容器 ========== */
.viz-editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    /* 仅过渡 box-shadow，避免 transition:all 监听所有属性导致重排 */
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.viz-editor-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

/* ========== 顶部工具栏 ========== */
.viz-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--viz-toolbar-bg);
    color: var(--viz-toolbar-text);
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 28px;
}

.toolbar-btn {
    padding: 6px 10px;
    background: var(--viz-btn-bg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--viz-btn-text);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s;
    white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 主内容区 ========== */
.viz-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========== 拖拽分隔条 ========== */
.resize-handle {
    width: 5px;
    background: #e2e8f0;
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
}

.resize-handle:hover,
.resize-handle.resizing {
    background: var(--viz-primary);
}

/* ========== 左侧历史面板 ========== */
.viz-history-panel {
    width: 210px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.history-clear-btn {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: background 0.2s;
}

.history-clear-btn:hover {
    background: #fde8e8;
}

.history-search {
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    background: #f8fafc;
}

.history-search input:focus {
    border-color: var(--viz-primary);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.1);
    background: white;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.history-item {
    display: flex;
    flex-direction: column;
    padding: 9px 11px;
    margin-bottom: 5px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    /* 仅对 hover 动效过渡，移除 fadeIn 避免每次过滤搜索都触发列表抄动动画 */
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.15s ease;
    position: relative;
}

.history-item:hover {
    background: #f8fafc;
    border-color: var(--viz-primary);
    transform: translateX(2px);
}

.history-item.active {
    background: var(--viz-preview-bg);
    border-color: var(--viz-primary);
    box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.1);
}

.history-item-name {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 18px;
}

.history-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.history-item-type {
    font-size: 10px;
    background: #f1f5f9;
    color: #64748b;
    padding: 1px 5px;
    border-radius: 3px;
}

.history-item-time {
    font-size: 10px;
    color: #94a3b8;
}

.history-item-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: transparent;
    color: #94a3b8;
    border: none;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0;
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: #fde8e8;
    color: #ef4444;
}

.history-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 24px 12px;
    line-height: 1.8;
}

/* ========== 中间编辑面板 ========== */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: white;
    border-right: 1px solid #e2e8f0;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.editor-panel::-webkit-scrollbar { width: 4px; }
.editor-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* ========== Form Section ========== */
.form-section {
    border-bottom: 1px solid #f1f5f9;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 11px 14px;
    cursor: pointer;
    user-select: none;
    background: #fafafa;
    gap: 8px;
    transition: background 0.15s;
}

.section-header:hover {
    background: #f1f5f9;
}

.section-icon { font-size: 14px; }

.section-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.section-badge {
    font-size: 11px;
    background: var(--viz-section-border);
    color: var(--viz-primary);
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.section-toggle {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-toggle.collapsed {
    transform: rotate(-90deg);
}

.section-content {
    padding: 12px 14px;
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                padding 0.35s;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

/* ========== 数据输入区 ========== */
.format-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.format-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

.format-option {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #475569;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
}

.format-option:hover {
    border-color: var(--viz-primary);
    color: var(--viz-primary);
}

.format-option input[type="radio"] { cursor: pointer; }

.format-hint {
    font-size: 11px;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

.data-input-wrapper {
    position: relative;
}

.data-textarea {
    width: 100%;
    min-height: 140px;
    max-height: 240px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    background: #fafafa;
    color: #1e293b;
    line-height: 1.5;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.data-textarea:focus {
    border-color: var(--viz-primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
    background: white;
}

.data-textarea::-webkit-scrollbar { width: 4px; }
.data-textarea::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.copy-input-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 4px 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-input-btn:hover {
    border-color: var(--viz-primary);
    color: var(--viz-primary);
}

.quick-examples {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.quick-label {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
}

.quick-btn {
    padding: 3px 9px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.quick-btn:hover {
    background: var(--viz-preview-bg);
    border-color: var(--viz-primary);
    color: var(--viz-primary);
}

/* ========== 图表类型网格 ========== */
.chart-type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.chart-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    user-select: none;
}

.chart-type-btn:hover {
    border-color: var(--viz-primary);
    background: var(--viz-preview-bg);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(5, 150, 105, 0.15);
}

.chart-type-btn.active {
    border-color: var(--viz-primary);
    background: var(--viz-preview-bg);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.type-icon { font-size: 18px; line-height: 1; }
.type-name { font-size: 11px; color: #475569; margin-top: 3px; font-weight: 500; }
.chart-type-btn.active .type-name { color: var(--viz-primary); font-weight: 600; }

/* ========== 图表选项 ========== */
.option-group { display: flex; flex-direction: column; gap: 8px; }

.option-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.option-label {
    font-size: 12px;
    color: #475569;
    min-width: 80px;
    font-weight: 500;
    flex-shrink: 0;
}

.option-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.option-input:focus {
    border-color: var(--viz-primary);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.1);
}

.option-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 12px;
    outline: none;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.option-select:focus { border-color: var(--viz-primary); }

/* 开关样式 */
.toggle-switch {
    position: relative;
    display: inline-flex;
    width: 38px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 20px;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--viz-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ========== 生成按钮区 ========== */
.generate-area {
    padding: 14px;
    background: white;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.generate-btn {
    width: 100%;
    padding: 11px 16px;
    background: var(--viz-toolbar-bg);
    color: white;
    border: none;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}

.generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
}

.generate-btn:active { transform: translateY(0); }

.generate-btn .btn-icon { font-size: 16px; }

.shortcut-hint {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    opacity: 0.75;
    font-size: 11px;
}

.shortcut-hint kbd {
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 10px;
    font-family: inherit;
}

/* ========== 右侧预览面板 ========== */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fafafa;
    min-width: 300px;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--viz-preview-header-bg);
    border-bottom: 1px solid var(--viz-preview-border);
    flex-shrink: 0;
}

.preview-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.preview-actions {
    display: flex;
    gap: 6px;
}

.preview-action-btn {
    padding: 5px 10px;
    background: white;
    border: 1px solid var(--viz-preview-border);
    border-radius: 5px;
    font-size: 11px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.preview-action-btn:hover {
    border-color: var(--viz-primary);
    color: var(--viz-primary);
    transform: translateY(-1px);
}

.preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
    position: relative;
    background: white;
}

.chart-placeholder {
    text-align: center;
    color: #94a3b8;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.placeholder-text {
    font-size: 13px;
    line-height: 1.8;
    margin: 0;
}

.placeholder-text kbd {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 11px;
    font-family: inherit;
    color: #475569;
}

#chartCanvas {
    max-width: 100%;
    max-height: 100%;
}

.preview-footer {
    padding: 8px 14px;
    font-size: 11px;
    color: #94a3b8;
    background: var(--viz-preview-bg);
    border-top: 1px solid var(--viz-preview-border);
    flex-shrink: 0;
    min-height: 28px;
}

/* ========== AI侧边栏 ========== */
.ai-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    /* 使用 transform 替代 right 进行帧动画，避免触发重排 */
    transform: translateX(100%);
    width: 360px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-sidebar.open { transform: translateX(0); }

.ai-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: var(--viz-toolbar-bg);
    color: white;
    flex-shrink: 0;
}

.ai-sidebar-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.ai-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-close-btn:hover { background: rgba(255,255,255,0.35); }

.ai-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.ai-sidebar-body::-webkit-scrollbar { width: 4px; }
.ai-sidebar-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.ai-input-group { margin-bottom: 14px; }

.ai-input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 7px;
}

.ai-input-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    line-height: 1.5;
}

.ai-input-group textarea:focus {
    border-color: var(--viz-primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.ai-actions { display: flex; gap: 8px; margin-bottom: 16px; }

.ai-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s;
}

.ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ai-btn-primary {
    background: var(--viz-toolbar-bg);
    color: white;
}

.ai-btn-cancel { background: #fee2e2; color: #dc2626; }

.ai-tips {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 14px;
}

.ai-tips p { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: #374151; }
.ai-tips ul { margin: 0; padding-left: 16px; }
.ai-tips li { font-size: 12px; color: #64748b; margin-bottom: 4px; line-height: 1.5; }

.ai-overlay {
    visibility: hidden;
    pointer-events: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s;
    opacity: 0;
}

.ai-overlay.open {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.modal.open { display: flex; }

.modal-content {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-width: 680px;
    width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(to bottom, #fafafa, #f5f5f5);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.modal-header h3 { margin: 0; font-size: 15px; color: #1e293b; }

.modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.modal-close:hover { background: #fee2e2; color: #ef4444; }

.modal-body {
    overflow-y: auto;
    padding: 18px 20px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* 模板网格 */
.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.template-card {
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.template-card:hover {
    border-color: var(--viz-primary);
    background: var(--viz-preview-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.15);
}

.template-icon { font-size: 28px; margin-bottom: 8px; }
.template-name { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.template-desc { font-size: 11px; color: #94a3b8; line-height: 1.4; }

/* 主题网格 */
.theme-modal { max-width: 480px; }

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.theme-card {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-card:hover, .theme-card.active {
    border-color: var(--viz-primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.theme-icon { font-size: 22px; }
.theme-name { font-size: 12px; color: #475569; margin-top: 4px; }

/* 快捷键 */
.shortcut-modal { max-width: 440px; }

.shortcut-grid { display: flex; flex-direction: column; gap: 8px; }

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
}

.shortcut-key {
    font-size: 12px;
    font-family: 'Courier New', monospace;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 3px 8px;
    color: #374151;
    font-weight: 600;
}

.shortcut-desc { font-size: 12px; color: #64748b; }

/* ========== Toast通知 ========== */
.viz-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: #1e293b;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 20000;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 320px;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.viz-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.viz-toast.success { background: #059669; }
.viz-toast.error { background: #dc2626; }
.viz-toast.warning { background: #d97706; }

/* ========== 工具类 ========== */
.viz-hidden { display: none !important; }

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.93); }
    to { opacity: 1; transform: scale(1); }
}

/* AI加载动画 */
.ai-loading .btn-icon {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .viz-history-panel { width: 170px; }
    .chart-type-grid { grid-template-columns: repeat(3, 1fr); }
    .preview-actions { flex-wrap: wrap; }
}

@media (max-width: 768px) {
    .viz-history-panel { width: 140px; }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
    .preview-action-btn { font-size: 10px; padding: 4px 7px; }
}

@media (max-width: 640px) {
    .viz-main-content { flex-direction: column; }
    .viz-history-panel { width: 100%; height: 120px; border-right: none; border-bottom: 1px solid #e2e8f0; }
    .resize-handle { display: none; }
    .chart-type-grid { grid-template-columns: repeat(4, 1fr); }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
}
