* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow-x: hidden;
}

#app {
    width: 100vw;
    min-height: 100vh;
    padding: 10px;
}

/* ===== 顶部标题 ===== */
.header {
    text-align: center;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
}

.header h1 {
    color: #667eea;
    font-size: 26px;
    margin-bottom: 5px;
}

.header p {
    color: #666;
    font-size: 14px;
}

/* ===== 主容器：左右双屏 ===== */
.main-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 10px;
    height: calc(100vh - 100px);
}

/* ===== 左侧面板：AI对话 ===== */
.left-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffd700;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #4caf50;
}

.status-indicator.disconnected {
    background: #f44336;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== 对话容器 ===== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-message {
    display: flex;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.ai-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.user-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.message {
    max-width: 85%;
    padding: 12px 15px;
    border-radius: 10px;
    line-height: 1.6;
    font-size: 14px;
}

.ai-message {
    background: white;
    border: 1px solid #e0e0e0;
}

.user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.system-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    font-size: 13px;
}

.error-message {
    background: #f8d7da;
    border: 1px solid #f44336;
    color: #721c24;
}

/* Markdown渲染样式 */
.message h1, .message h2, .message h3 {
    margin-top: 10px;
    margin-bottom: 8px;
    color: #333;
}

.message h1 { font-size: 20px; }
.message h2 { font-size: 18px; }
.message h3 { font-size: 16px; }

.message p {
    margin-bottom: 8px;
}

.message ul, .message ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.message code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.message pre code {
    background: transparent;
    padding: 0;
    color: #f8f8f2;
}

.message blockquote {
    border-left: 4px solid #667eea;
    padding-left: 12px;
    margin: 10px 0;
    color: #666;
    font-style: italic;
}

.message strong {
    color: #667eea;
    font-weight: 600;
}

/* ===== 输入区域 ===== */
.input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

#userInput {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    resize: none;
    transition: border-color 0.3s;
}

#userInput:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: all 0.3s;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-btn .shortcut {
    font-size: 10px;
    opacity: 0.8;
}

/* ===== 快捷操作 ===== */
.quick-actions {
    padding: 10px 15px;
    background: #f9f9f9;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-btn {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ===== 右侧面板：绘图系统 ===== */
.right-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drawing-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 15px;
}

/* ===== 控制面板 ===== */
.control-panel-compact {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    height: fit-content;
}

.section-title {
    font-size: 14px;
    font-weight: bold;
    color: #667eea;
    margin: 15px 0 10px 0;
    padding: 6px 10px;
    background: white;
    border-left: 4px solid #667eea;
    border-radius: 3px;
}

.section-title:first-child {
    margin-top: 0;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn:hover {
    background: #764ba2;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    margin-top: 10px;
}

.control-group {
    margin-bottom: 10px;
}

.control-group textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    min-height: 60px;
}

.control-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.param-item label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-container input[type="range"] {
    flex: 1;
}

.slider-value {
    min-width: 50px;
    text-align: center;
    font-weight: bold;
    font-size: 12px;
    color: #667eea;
}

.checkbox-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.checkbox-group label {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ===== 统计数据 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.stat-box {
    background: white;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    border: 2px solid #667eea;
}

.stat-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 3px;
}

.stat-value {
    font-size: 16px;
    font-weight: bold;
    color: #667eea;
}

/* ===== 画布区域 ===== */
.canvas-area {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#profileCanvas {
    width: 100%;
    height: 100%;
    max-height: 500px;
    border: 2px solid #667eea;
    border-radius: 5px;
    cursor: crosshair;
    background: #f5f5f5;
}

/* ===== 图例 ===== */
.legend-box {
    grid-column: 1 / -1;
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.legend-title {
    font-size: 14px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 12px;
}

.legend-color {
    width: 24px;
    height: 16px;
    border-radius: 3px;
    margin-right: 6px;
    border: 1px solid #333;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 350px 1fr;
    }

    .drawing-container {
        grid-template-columns: 1fr;
    }

    .canvas-area {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .left-panel {
        height: 500px;
    }

    .legend-items {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== 滚动条样式 ===== */
.chat-container::-webkit-scrollbar,
.drawing-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track,
.drawing-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-container::-webkit-scrollbar-thumb,
.drawing-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.drawing-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== 加载动画 ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}
