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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #1a1f36 0%, #2d3748 50%, #1a1f36 100%);
    color: white;
    padding: 5px 24px; /* 精简高度 */
    box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* 导航栏切换样式 - 独立按钮组 */
.nav-tabs {
    display: flex;
    gap: 4px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.08) 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 4px; /* 精简内边距 */
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.nav-tab {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    border: none;
    padding: 10px 20px; /* 与文件按钮一致 */
    font-size: 14px; /* 与文件按钮一致 */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    position: relative;
    white-space: nowrap;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-1px);
}

.nav-tab.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.22) 100%);
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 3px;
    background: linear-gradient(90deg, transparent, white, transparent);
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* 工具栏容器 - 与标签组分离 */
.toolbar-container {
    display: flex;
    align-items: center;
    margin-left: 24px; /* 与左侧标签组保持间距 */
    flex: 1;
}

/* Logo 和标题容器 */
.logo-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-right: 16px;
    padding: 2px 12px 2px 0; /* 精简padding */
    border-right: 1px solid rgba(255,255,255,0.12);
}

.header-logo {
    height: 38px; /* 精简logo高度 */
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    transition: transform 0.2s;
}

.header-logo:hover {
    transform: scale(1.05);
}

.app-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    color: white;
    letter-spacing: 0.5px;
}

/* 保持向后兼容 */
header h1 {
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 10px;
}

/* 文件菜单下拉 */
.menu-dropdown {
    position: relative;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    background: white;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
    z-index: 10000;
    animation: dropdownSlide 0.2s ease-out;
}

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

.dropdown-content::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    pointer-events: auto;
}

.menu-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: #2c3e50;
    padding: 12px 18px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.dropdown-content a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #3498db;
    transform: scaleX(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-content a:hover {
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.08) 0%, transparent 100%);
    padding-left: 22px;
}

.dropdown-content a:hover::before {
    transform: scaleX(1);
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 10px; /* 增加按钮之间的间距 */
}

.nav-toolbar {
    display: flex;
    gap: 10px; /* 工具栏按钮之间的间距 */
    align-items: center;
}

.icon-btn-toolbar {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 10px; /* 精简padding */
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px; /* 精简字体大小 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 36px; /* 精简最小宽度 */
    height: 36px; /* 精简高度 */
}

.icon-btn-toolbar i {
    font-size: 15px; /* 精简图标大小 */
}

.icon-btn-toolbar .ai-text {
    font-size: 12px; /* 精简AI文字大小 */
    font-weight: 600;
}

.icon-btn-toolbar:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.icon-btn-toolbar:active:not(:disabled) {
    transform: translateY(0);
}

.icon-btn-toolbar:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

/* AI 按钮特殊样式 */
.icon-btn-toolbar.ai-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
    border-color: rgba(139, 92, 246, 0.4);
}

.icon-btn-toolbar.ai-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(99, 102, 241, 0.3) 100%);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

/* 用户信息区域 */
.user-section {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.user-info {
    display: flex;
    align-items: center;
}

.user-dropdown {
    position: relative;
}

.user-name-btn {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.user-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1000;
    animation: dropdownSlide 0.2s ease-out;
    margin-top: -1px;
}

.user-dropdown-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
}

.user-dropdown:hover .user-dropdown-content {
    display: block;
}

.user-dropdown-content a {
    color: #2c3e50;
    padding: 12px 18px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.user-dropdown-content a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #e74c3c;
    transform: scaleX(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-dropdown-content a:hover {
    background: linear-gradient(90deg, rgba(231, 76, 60, 0.08) 0%, transparent 100%);
    padding-left: 22px;
}

.user-dropdown-content a:hover::before {
    transform: scaleX(1);
}

.user-info .admin-badge {
    background: #f39c12;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 5px;
}

.btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn:disabled {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    cursor: not-allowed;
    opacity: 0.5;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn:disabled:hover {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    transform: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#deleteMode.active {
    background: #e74c3c;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Component Panel (Left) */
.component-panel {
    width: 250px;
    background: white;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #ddd;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.component-panel.collapsed {
    transform: translateX(-100%);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.panel-header h2 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0;
}

.panel-toggle-btn {
    background: transparent;
    border: 1px solid #ddd;
    color: #7f8c8d;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
    padding: 0;
}

.panel-toggle-btn i {
    font-size: 13px;
}

.panel-toggle-btn:hover {
    background: #f0f2f5;
    border-color: #3498db;
    color: #3498db;
}

.component-panel h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
}

/* 搜索框样式 */
.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search-input::placeholder {
    color: #95a5a6;
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 24px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

.clear-search-btn:hover {
    background: #f0f2f5;
    color: #e74c3c;
}

.search-input:not(:placeholder-shown) ~ .clear-search-btn {
    display: flex;
}

/* 分类筛选下拉框 */
.category-filter-select-wrapper {
    margin-bottom: 12px;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 12px;
    color: #7f8c8d;
    font-weight: 500;
    white-space: nowrap;
}

.category-filter-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    background: white;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #2c3e50;
    outline: none;
}

.category-filter-select:hover {
    border-color: #3498db;
}

.category-filter-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 搜索结果计数 */
.search-result-count {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
}

.search-result-count.no-results {
    color: #e74c3c;
    background: #fee;
}

.component-category {
    margin-bottom: 15px;
}

.component-category h3.category-title {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid #ecf0f1;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    user-select: none;
}

.component-category h3.category-title:hover {
    background: #f8f9fa;
    color: #3498db;
}

.category-toggle-icon {
    font-size: 10px;
    transition: transform 0.2s;
}

.component-category.collapsed .category-toggle-icon {
    transform: rotate(-90deg);
}

.category-count {
    margin-left: auto;
    font-size: 11px;
    color: #95a5a6;
    font-weight: normal;
}

.component-category.collapsed .component-item {
    display: none;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 6px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.component-item:hover {
    background: #e9ecef;
    border-color: #3498db;
    transform: translateX(2px);
}

.component-item.selected {
    background: #3498db;
    border-color: #2980b9;
    color: white;
}

.component-item.selected .component-icon {
    opacity: 0.9;
}

.component-icon {
    width: 35px;
    height: 35px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    /* 背景色通过内联样式动态设置 */
}

.component-image {
    width: 35px;
    height: 35px;
    object-fit: contain;
    border-radius: 4px;
}

/* 懒加载图片占位符样式 */
.component-image.lazy-load {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.component-info {
    flex: 1;
    min-width: 0;
}

.component-name-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.component-name {
    font-weight: 500;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.component-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 9px;
    flex-shrink: 0;
}

.component-badge i {
    font-size: 9px;
}

.component-badge.official {
    background: #27ae60;
    color: white;
    font-weight: bold;
}

.component-badge.user {
    background: #95a5a6;
    color: white;
}

.component-item.selected .component-badge.official {
    background: #2ecc71;
}

.component-item.selected .component-badge.user {
    background: #7f8c8d;
}

/* 搜索高亮 */
.component-name mark {
    background: #fff59d;
    color: #000;
    padding: 2px 0;
    border-radius: 2px;
}

.component-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.official-badge {
    background: #f39c12;
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.owner-label {
    color: #7f8c8d;
    font-size: 11px;
}

.component-item.selected .owner-label {
    color: #ecf0f1;
}

.admin-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: transparent;
    border: 1px solid #bdc3c7;
    color: #7f8c8d;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.icon-btn.danger:hover {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* 面板展开按钮 */
.panel-expand-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 80px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #7f8c8d;
    z-index: 100;
    transition: all 0.2s;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.panel-expand-btn i {
    font-size: 14px;
}

.panel-expand-btn:hover {
    background: #f0f2f5;
    border-color: #3498db;
    color: #3498db;
    width: 36px;
}

.panel-expand-btn.left-expand {
    left: 0;
    border-left: none;
}

.panel-expand-btn.right-expand {
    right: 0;
    border-right: none;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
}

/* Canvas Area (Center) */
.canvas-area {
    flex: 1;
    position: relative;
    background: #ffffff;
    overflow: hidden;
}

#gridCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#componentsContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    transform-origin: 0 0;
}

#wireCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Component in Canvas */
.canvas-component {
    position: absolute; /* 相对于 componentsContainer 绝对定位 */
    border: 4px solid #2C3E50;
    border-radius: 8px;
    cursor: move;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    width: 200px; /* 默认宽度200px(10个网格单位)，会被自定义宽度覆盖 */
    min-height: 140px; /* 最小高度 */
    user-select: none;
    padding: 0;
    overflow: visible;
    pointer-events: auto;
    z-index: 10;
    box-sizing: border-box; /* width/height 包含 border，确保引脚百分比定位准确 */
    /* 组件内的绝对定位子元素（如引脚）会相对于此组件定位 */
}

.component-delete-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e74c3c;
    color: white;
    border: 2px solid white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
    z-index: 20;
    line-height: 1;
    padding: 0;
}

.component-delete-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* 组件旋转180度时，删除按钮反向旋转保持在右上角 */
.component-delete-btn.flipped {
    transform: rotate(180deg);
}

.component-delete-btn.flipped:hover {
    transform: rotate(180deg) scale(1.1);
}

.canvas-component.selected {
    border-color: #e74c3c;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.3);
}

.canvas-component:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    transform: translateY(-2px);
}

.component-header {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    text-align: center;
}

.component-header img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.component-header span {
    font-weight: bold;
    color: black;
    font-size: inherit;
    text-align: center;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, -2px 0 0 #fff, 2px 0 0 #fff, 0 -2px 0 #fff, 0 2px 0 #fff;
    white-space: nowrap;
}

.component-pins {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 12px 10px;
    background: inherit; /* 继承父元素背景色 */
    gap: 8px;
}

/* 底部引脚样式 - 用于普通传感器模块 */
.component-pins-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px 8px 20px;  /* 左右各20px，刚好对齐网格 */
    position: absolute;
    left: 0;
    right: 0;
    bottom:-55px;
    height: auto;
    background: transparent;
    pointer-events: none;
}

.pin-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    pointer-events: auto;
}

.pin-bottom .pin-name {
    font-size: 14px;
    font-weight: 700;
    color: #000000;
    margin: -10px 0 5px;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        -2px 0 0 #fff,
        2px 0 0 #fff,
        0 -2px 0 #fff,
        0 2px 0 #fff;
    white-space: nowrap;
}

.pin-bottom .pin-wire {
    width: 5px;
    height: 45px;
    background: #2c3e50;
    position: relative;
    border-radius: 1px;
    display: flex;
    justify-content: center;
}

.pin-bottom .pin-dot {
    position: absolute;
    bottom: -12px;
    left: -5.5px; /* (16px - 5px) / 2 = 5.5px 居中对齐 */
    border-radius: 2px; /* 方形 */
    width: 16px;
    height: 16px;
    border: 2px solid #2c3e50;
}

.pin {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 80px;
}

.pin span {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 2px; /* 方形 */
    background: #3498db;
    cursor: crosshair;
    position: relative;
    z-index: 10;
    border: 2px solid #2c3e50;
    transition: all 0.2s;
}

.pin-dot:hover {
    transform: scale(1.3);
    border-color: #e74c3c;
}

.pin-dot.connected {
    border-color: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}

.pin-dot.selecting {
    transform: scale(1.5);
    border-color: #f39c12;
    border-width: 3px;
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.4);
    animation: pin-pulse 0.8s ease-in-out infinite;
}

@keyframes pin-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(243, 156, 18, 0.2);
    }
}

/* 绝对定位引脚容器 */
.component-pins-absolute {
    position: relative;
    width: 100%;
    height: 100%;
    background: inherit; /* 继承父元素背景色 */
}

.pin-absolute {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 5;
}

.pin-absolute.pin-left {
    flex-direction: row-reverse;
    gap: 6px;
}

.pin-absolute.pin-right {
    flex-direction: row;
    gap: 6px;
}

.component-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-family: Arial, sans-serif;
    color: black;
    text-align: center;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, -2px 0 0 #fff, 2px 0 0 #fff, 0 -2px 0 #fff, 0 2px 0 #fff;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

.pin-label-abs {
    position: absolute;
    font-size: 12px;
    font-weight: bold;
    color: #2c3e50;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
    opacity: 1; /* 默认可见 */
    transition: opacity 0.2s;
    z-index: 100;
}

/* 默认位置：下方 */
.pin-label-abs.pos-default,
.pin-label-abs.pos-bottom {
    top: 100%;
    left: 50%;
    transform: translate(-50%, 4px);
}

/* 上方 */
.pin-label-abs.pos-top {
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -4px);
}

/* 左方 */
.pin-label-abs.pos-left {
    right: 100%;
    top: 50%;
    transform: translate(-4px, -50%);
}

/* 右方 */
.pin-label-abs.pos-right {
    left: 100%;
    top: 50%;
    transform: translate(4px, -50%);
}

/* 默认隐藏的引脚标签（当 showName: false 时）*/
.pin-label-abs.hide-by-default {
    opacity: 0;
}

/* hover 引脚时显示标签（包括默认隐藏的）*/
.pin-absolute:hover .pin-label-abs {
    opacity: 1;
}

/* 当组件有图片时，调整大小 */
.canvas-component.has-custom-pins {
    min-width: 250px;
}

/* 有背景图片的组件样式优化 */
.canvas-component.has-background-image {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.canvas-component.has-background-image:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.component-main-image {
    max-width: 200px;
    max-height: 150px;
}

/* Property Panel (Right) */
.property-panel {
    width: 250px;
    background: white;
    padding: 20px;
    overflow-y: auto;
    border-left: 1px solid #ddd;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.3s ease;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
}

.property-panel.collapsed {
    transform: translateX(100%);
}

.property-panel h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.hint {
    color: #95a5a6;
    font-size: 14px;
    text-align: center;
    margin-top: 40px;
}

.property-group {
    margin-bottom: 20px;
}

.property-group label {
    display: block;
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.property-group input,
.property-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.property-group input:focus,
.property-group select:focus {
    outline: none;
    border-color: #3498db;
}

/* 线条属性面板样式 */
.property-section {
    padding: 0;
}

.property-section h3 {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
}

.property-item {
    margin-bottom: 15px;
}

.property-item label {
    display: block;
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 6px;
    font-weight: 500;
}

.property-value {
    font-size: 14px;
    color: #34495e;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.current-color-display {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid #ddd;
    display: inline-block;
}

/* 颜色选择器 */
.color-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px 0;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 3px solid #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-option.selected {
    border-color: #3498db;
    border-width: 4px;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 属性操作按钮 */
.property-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.property-actions .btn {
    width: 100%;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

#pinsList {
    max-height: 300px;
    overflow-y: auto;
    padding: 5px 0;
}

.pin-item {
    margin-bottom: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.pin-name-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.pin-name-input:focus {
    outline: none;
    border-color: #3498db;
    background: white;
}

/* 图片上传区域 */
.image-upload-container {
    margin-top: 8px;
}

.image-preview {
    width: 100%;
    height: 150px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.no-image {
    color: #95a5a6;
    font-size: 14px;
}

.btn-upload, .btn-remove {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.btn-upload {
    background: #3498db;
    color: white;
}

.btn-upload:hover {
    background: #2980b9;
}

.btn-remove {
    background: #e74c3c;
    color: white;
}

.btn-remove:hover {
    background: #c0392b;
}

.edit-component-btn {
    width: 100%;
    background: #667eea;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.edit-component-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.delete-component-btn {
    width: 100%;
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.delete-component-btn:hover {
    background: #c0392b;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* Arduino专用引脚样式 */
.arduino-pins-top {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: flex-start;
    gap: 7px;
    padding: 0 15px;
    transform: translateY(-50%);
    pointer-events: none;
}

.arduino-pins-bottom {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    padding: 0 15px;
    transform: translateY(50%);
    pointer-events: none;
}

.arduino-pin {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: auto;
}

.arduino-pin-top {
    flex-direction: column;
}

.arduino-pin-bottom {
    flex-direction: column-reverse;
}

.arduino-pin-box {
    width: 18px;
    height: 18px;
    background: #FF6B35;
    border: 2px solid #2c3e50;
    border-radius: 2px;
    cursor: crosshair;
    transition: all 0.2s;
    position: relative;
    z-index: 15;
}

.arduino-pin-box:hover {
    transform: scale(1.3);
    border-color: #e74c3c;
}

.arduino-pin-box.connected {
    border-color: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}

.arduino-pin-box.selecting {
    transform: scale(1.5);
    border-color: #f39c12;
    border-width: 3px;
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.4);
    animation: pin-pulse 0.8s ease-in-out infinite;
}

.arduino-pin-label {
    position: absolute;
    top: -25px; /* 标签显示在引脚上方 */
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #000;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    border: 1px solid rgba(44, 62, 80, 0.1);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}

/* hover Arduino 引脚时显示标签 */
.arduino-pin:hover .arduino-pin-label {
    opacity: 1;
}

/* 面包板专用样式 */
.breadboard-pin-container {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.breadboard-pin {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.breadboard-pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    cursor: crosshair;
    transition: all 0.2s;
    position: relative;
    z-index: 15;
    border: 2px solid #2c3e50;
}

.breadboard-pin-dot:hover {
    transform: scale(1.3);
    border-color: #e74c3c;
}

.breadboard-pin-dot.connected {
    border-color: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}

.breadboard-pin-dot.selecting {
    transform: scale(1.5);
    border-color: #f39c12;
    border-width: 3px;
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.4);
    animation: pin-pulse 0.8s ease-in-out infinite;
}

/* 面包板电源轨道连接线 */
.breadboard-power-line {
    position: absolute;
    height: 2px;
    left: 5%;
    right: 5%;
    pointer-events: none;
    z-index: 1;
}

.breadboard-power-line.positive {
    background: #FF0000;
}

.breadboard-power-line.negative {
    background: #000000;
}

/* 面包板垂直连接线 */
.breadboard-vertical-line {
    position: absolute;
    width: 2px;
    background: #FF6B35;
    pointer-events: none;
    z-index: 1;
}

/* Toast 提示系统 */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 250px;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(400px);
}

/* Toast 类型 */
.toast.success {
    background: #27ae60;
    color: white;
}

.toast.error {
    background: #e74c3c;
    color: white;
}

.toast.warning {
    background: #f39c12;
    color: white;
}

.toast.info {
    background: #3498db;
    color: white;
}

/* Toast 图标 */
.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

/* 属性面板按钮样式 */
.property-actions .btn {
    transition: all 0.2s;
}

.property-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.property-actions .btn:active {
    transform: translateY(0);
}

.property-actions .btn-primary:hover {
    background: #2980b9;
}

.property-actions .btn-danger:hover {
    background: #c0392b;
}

/* 格式选择对话框 */
.format-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.format-dialog {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease-out;
}

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

.format-dialog h3 {
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.format-options {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.format-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.format-btn:hover {
    background: #e8f4f8;
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.format-btn:active {
    transform: translateY(0);
}

.format-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.format-name {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.format-desc {
    font-size: 12px;
    color: #7f8c8d;
    text-align: center;
}

.format-cancel-btn {
    width: 100%;
    padding: 10px;
    background: #ecf0f1;
    border: none;
    border-radius: 6px;
    color: #7f8c8d;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.format-cancel-btn:hover {
    background: #bdc3c7;
    color: #2c3e50;
}

/* 确认对话框样式 */
.confirm-dialog {
    max-width: 420px;
}

.confirm-message {
    font-size: 15px;
    line-height: 1.6;
    color: #34495e;
    margin-bottom: 24px;
    text-align: center;
}

/* 保存对话框样式 */
.save-dialog {
    max-width: 480px;
}

.save-dialog-content {
    margin-bottom: 24px;
}

.project-stats {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.stat-item:not(:last-child) {
    border-bottom: 1px solid #e0e0e0;
}

.stat-label {
    font-size: 14px;
    color: #7f8c8d;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.input-group {
    position: relative;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 8px;
}

.project-name-input {
    width: 100%;
    padding: 12px 60px 12px 12px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.project-name-input:focus {
    border-color: #3498db;
}

.input-suffix {
    position: absolute;
    right: 12px;
    top: 38px;
    color: #7f8c8d;
    font-size: 14px;
    pointer-events: none;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-buttons .format-cancel-btn,
.confirm-buttons .format-confirm-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-buttons .format-cancel-btn {
    background: #ecf0f1;
    color: #7f8c8d;
}

.confirm-buttons .format-cancel-btn:hover {
    background: #bdc3c7;
    color: #2c3e50;
}

.format-confirm-btn {
    background: #3498db;
    color: white;
}

.format-confirm-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.format-confirm-btn:active {
    transform: translateY(0);
}

/* 引脚文字位置样式 - 支持组件编辑器的labelPosition设置 */
.pin-label-top {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #000;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    border: 1px solid rgba(44, 62, 80, 0.1);
    opacity: 1; /* 始终显示，不依赖hover */
    transition: opacity 0.2s;
    z-index: 100;
}

.pin-label-bottom {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #000;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    border: 1px solid rgba(44, 62, 80, 0.1);
    opacity: 1;
    transition: opacity 0.2s;
    z-index: 100;
}

.pin-label-left {
    position: absolute;
    top: 50%;
    left: -45px;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #000;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    border: 1px solid rgba(44, 62, 80, 0.1);
    opacity: 1;
    transition: opacity 0.2s;
    z-index: 100;
}

.pin-label-right {
    position: absolute;
    top: 50%;
    right: -45px;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #000;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    border: 1px solid rgba(44, 62, 80, 0.1);
    opacity: 1;
    transition: opacity 0.2s;
    z-index: 100;
}

/* 帮助按钮和面板样式 */
.help-float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.help-float-btn i {
    font-size: 24px;
}

.help-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.help-float-btn:active {
    transform: scale(0.95);
}

.help-icon {
    color: white;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}

.help-panel {
    position: fixed;
    top: 80px;
    right: 30px;
    width: 480px;
    max-height: 680px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transform: translateY(-20px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.help-panel.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.help-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
}

.help-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.help-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-close-btn i {
    font-size: 18px;
}

.help-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.help-panel-content {
    padding: 24px;
    max-height: 580px;
    overflow-y: auto;
}

.help-section {
    margin-bottom: 30px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.video-container {
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-container video {
    width: 100%;
    display: block;
}

.qrcode-container {
    text-align: center;
    background: #f8f9fa;
    padding: 24px;
    border-radius: 12px;
}

.qrcode-image {
    width: 240px;
    height: 240px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

.qrcode-text {
    font-size: 15px;
    color: #2c3e50;
    margin: 12px 0 8px 0;
    font-weight: 500;
}

.qrcode-info {
    font-size: 13px;
    color: #7f8c8d;
    margin: 0;
}

@media (max-width: 768px) {
    .help-panel {
        width: 90%;
        right: 5%;
        bottom: 90px;
        max-height: 60vh;
    }

    .help-float-btn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }

    .help-icon {
        font-size: 24px;
    }

    .qrcode-image {
        width: 200px;
        height: 200px;
    }
}

/* ==================== AI 对话面板样式 ==================== */

/* AI按钮特殊样式 */
.ai-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    font-weight: 600;
    border: none;
    transition: all 0.3s ease;
}

.ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* AI对话面板 */
.ai-chat-panel {
    position: fixed;
    top: 0;
    right: -500px;
    width: 450px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.ai-chat-panel.active {
    right: 0;
}

/* AI对话头部 */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-icon {
    font-size: 24px;
}

.ai-chat-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.ai-chat-close-btn i {
    font-size: 20px;
}

.ai-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* AI对话内容 */
.ai-chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 消息列表 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #f8f9fa 100%);
    position: relative;
    scroll-behavior: smooth;
}

.ai-welcome-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease;
}

/* 交互式按钮样式 */
.interactive-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.interactive-buttons .btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-weight: 500;
}

.interactive-buttons .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.interactive-buttons .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.interactive-buttons .btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.interactive-buttons .btn-secondary:hover {
    background: #d0d0d0;
    transform: translateY(-1px);
}

/* 高亮关键词样式 */
.highlight-keyword {
    background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: #2c3e50;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Markdown 样式 */
.message-bubble {
    word-wrap: break-word;
}

/* 标题样式 */
.markdown-h1 {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin: 8px 0 4px 0;
    line-height: 1.3;
}

.markdown-h2 {
    font-size: 16px;
    font-weight: 600;
    color: #34495e;
    margin: 6px 0 3px 0;
    line-height: 1.3;
}

.markdown-h3 {
    font-size: 14px;
    font-weight: 600;
    color: #34495e;
    margin: 5px 0 2px 0;
    line-height: 1.3;
}

.markdown-h4,
.markdown-h5,
.markdown-h6 {
    font-size: 13px;
    font-weight: 600;
    color: #34495e;
    margin: 4px 0 2px 0;
    line-height: 1.3;
}

/* 引用样式 */
.markdown-blockquote {
    background: #f0f4f8;
    border-left: 4px solid #667eea;
    padding: 8px 12px;
    margin: 6px 0;
    border-radius: 0 4px 4px 0;
    font-style: italic;
    color: #555;
}

/* 分隔线样式 */
.markdown-hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 8px 0;
    padding: 0;
}

/* 列表样式 */
.markdown-ul,
.markdown-ol {
    margin: 4px 0;
    padding-left: 20px;
}

.markdown-li,
.markdown-ol-li {
    margin: 2px 0;
    line-height: 1.5;
}

.markdown-ol {
    list-style-type: decimal;
}

.markdown-ul {
    list-style-type: disc;
}

/* 任务列表样式 */
.markdown-task-ul {
    margin: 4px 0;
    padding-left: 20px;
}

.markdown-task-li {
    margin: 2px 0;
    line-height: 1.5;
    list-style-type: none;
}

.markdown-task-checkbox {
    margin-right: 8px;
    cursor: default;
}

.markdown-task-li.completed {
    text-decoration: line-through;
    color: #95a5a6;
}

/* 代码样式 */
.markdown-code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #e74c3c;
    white-space: nowrap;
}

/* 代码块容器 */
.code-block-container {
    position: relative;
    margin: 8px 0;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 1;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.code-copy-btn.copied {
    background: rgba(72, 187, 120, 0.2);
    border-color: rgba(72, 187, 120, 0.4);
    color: #48bb78;
}

.code-copy-btn i {
    font-size: 12px;
}

.markdown-pre {
    background: #2d3748;
    border-radius: 6px;
    padding: 12px;
    padding-top: 36px;
    margin: 0;
    overflow-x: auto;
    max-width: 100%;
}

.markdown-code-block {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #e2e8f0;
    white-space: pre;
    tab-size: 2;
}

/* 链接样式 */
.markdown-link {
    color: #3498db;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.markdown-link:hover {
    color: #2980b9;
    border-bottom-color: #2980b9;
}

/* 图片样式 */
.markdown-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 10px 0;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 粗体、斜体、删除线 */
.markdown-bold {
    font-weight: 700;
    color: #2c3e50;
}

.markdown-italic {
    font-style: italic;
    color: #34495e;
}

.markdown-del {
    text-decoration: line-through;
    color: #95a5a6;
}

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

/* 消息容器 */
.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease;
}

.user-message {
    justify-content: flex-end;
}

.ai-message {
    flex-direction: row;
    justify-content: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
    border: 2px solid white;
}

.chat-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.user-message .chat-avatar {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.ai-message .chat-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    position: relative;
}

.message-bubble:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.user-bubble {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.ai-bubble {
    background: white;
    color: #2c3e50;
    border: 1px solid #e8ecf0;
    border-bottom-left-radius: 6px;
}

.error-bubble {
    background: #fee;
    border-color: #fcc;
}

/* 打字机光标动画 */
.typing-cursor {
    display: inline-block;
    color: #667eea;
    animation: typingCursorBlink 1s infinite;
    font-weight: bold;
}

@keyframes typingCursorBlink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

.ai-bubble p {
    margin: 4px 0;
    line-height: 1.5;
}

.ai-bubble p:first-child {
    margin-top: 0;
}

.ai-bubble p:last-child {
    margin-bottom: 0;
}

.ai-bubble ul,
.ai-bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}

.ai-bubble li {
    margin: 2px 0;
    line-height: 1.5;
}

.ai-bubble code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* 欢迎消息 */
.ai-welcome-message {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.ai-welcome-message .ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

/* 输入区域 - 重构优化 */
.ai-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

/* 输入容器 */
.ai-input-container {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.ai-input-container:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 输入框 */
.ai-chat-input {
    width: 100%;
    padding: 14px 16px 8px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
    overflow-y: auto; /* 超过最大高度时显示滚动条 */
    box-sizing: border-box;
}

.ai-chat-input:focus {
    outline: none;
}

.ai-chat-input::placeholder {
    color: #999;
}

.ai-chat-input:disabled {
    color: #999;
    cursor: not-allowed;
}

/* 滚动条样式 */
.ai-chat-input::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-input::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-input::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ai-chat-input::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 底部工具栏 */
.ai-input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

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

/* 工具按钮 */
.ai-tool-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ai-tool-btn:hover {
    background: #e0e4e8;
    color: #333;
}

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

/* 生成接线图按钮 */
.ai-generate-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.3);
}

.ai-generate-btn:hover {
    background: linear-gradient(135deg, #229954 0%, #1e8449 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.ai-generate-btn:active {
    transform: translateY(0);
}

/* 发送按钮 - 小巧圆形 */
.ai-send-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.ai-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.ai-send-btn:active {
    transform: translateY(0);
}

.ai-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    box-shadow: none;
}

/* 停止按钮 - 小巧圆形 */
.ai-stop-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.ai-stop-btn:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.ai-stop-btn:active {
    transform: translateY(0);
}

/* 加载状态 */
.ai-loading {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 250, 0.98) 100%);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    border-top: 1px solid rgba(102, 126, 234, 0.2);
}

.ai-loading-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.ai-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid transparent;
    border-top: 3px solid #667eea;
    border-right: 3px solid #764ba2;
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
        box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(118, 75, 162, 0.4);
    }
    100% {
        transform: rotate(360deg);
        box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
    }
}

.ai-loading p {
    margin: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
    font-size: 15px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.ai-cancel-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.ai-cancel-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.ai-cancel-btn:active {
    transform: translateY(0);
}

/* 代码显示对话框 */
.code-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.code-dialog.active {
    opacity: 1;
}

.code-dialog-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.code-dialog-header {
    padding: 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-dialog-header h3 {
    margin: 0;
    font-size: 18px;
}

.code-dialog-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.code-dialog-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.code-dialog-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.code-dialog-body pre {
    margin: 0;
    background: #f5f5f5;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
}

.code-dialog-body code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #2c3e50;
}

.code-dialog-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.copy-code-btn,
.close-code-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-code-btn {
    background: #3498db;
    color: white;
    border: none;
}

.copy-code-btn:hover {
    background: #2980b9;
}

.close-code-btn {
    background: #ecf0f1;
    color: #2c3e50;
    border: none;
}

.close-code-btn:hover {
    background: #d5dbdb;
}

/* 代码编辑区域样式 */
.code-area {
    flex: 1;
    position: relative;
    background: #ffffff;
    overflow: hidden;
}

.code-editor-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.code-header {
    background: #f8f9fa;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-header h2 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
    font-weight: 600;
}

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

.code-actions .btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.code-actions .btn-primary {
    background-color: #3498db;
    color: white;
}

.code-actions .btn-primary:hover {
    background-color: #2980b9;
}

.code-actions .btn-success {
    background-color: #2ecc71;
    color: white;
}

.code-actions .btn-success:hover {
    background-color: #27ae60;
}

.code-actions .btn-danger {
    background-color: #e74c3c;
    color: white;
}

.code-actions .btn-danger:hover {
    background-color: #c0392b;
}

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

.code-actions .btn i {
    font-size: 12px;
}

/* COM口选择器样式 */
.com-port-selector {
    display: flex;
    gap: 5px;
    align-items: center;
}

.com-port-select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    min-width: 150px;
    outline: none;
    transition: border-color 0.2s;
}

.com-port-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.com-port-select option {
    padding: 8px;
    font-size: 14px;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.code-editor {
    flex: 1;
    padding: 20px;
    overflow: hidden;
}

.code-editor-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}

.arduino-code-highlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    pointer-events: none;
    z-index: 1;
    background: #fafafa;
    color: #2c3e50;
    overflow: hidden;
}

.arduino-code {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    padding: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    background: transparent;
    color: transparent;
    outline: none;
    transition: border-color 0.2s;
    overflow: auto;
    z-index: 2;
    caret-color: #2c3e50;
}

.arduino-code:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 代码高亮样式 - Arduino */
.arduino-code-highlight .keyword {
    color: #0000ff;
    font-weight: bold;
}

.arduino-code-highlight .function {
    color: #006600;
}

.arduino-code-highlight .comment {
    color: #008000;
    font-style: italic;
}

.arduino-code-highlight .string {
    color: #a31515;
}

.arduino-code-highlight .number {
    color: #098658;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-chat-panel {
        width: 100%;
        right: -100%;
    }

    .code-dialog-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* ==================== 优化后的设备选择器样式 ==================== */

/* 覆盖旧的COM口选择器，改为设备选择器 */
.device-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.device-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    white-space: nowrap;
    margin: 0;
}

.device-label i {
    color: #3498db;
}

.device-select {
    min-width: 220px;
    padding: 7px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.device-select:hover {
    border-color: #3498db;
}

.device-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 优化编译并烧录按钮 */
.code-actions .btn-outline {
    background: white;
    color: #3498db;
    border: 1px solid #3498db;
    font-weight: 500;
}

.code-actions .btn-outline:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.code-actions .btn-outline:active {
    transform: translateY(0);
}

/* 优化主按钮样式 */
.code-actions .btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.code-actions .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.code-actions .btn:active:not(:disabled) {
    transform: translateY(0);
}

.code-actions .btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.code-actions .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
}

.code-actions .btn-success {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.code-actions .btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
}

.code-actions .btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.code-actions .btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
}

/* ==================== Modal 弹窗样式 ==================== */

/* Modal 容器 */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
}

/* Modal 遮罩层 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    pointer-events: auto;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* Modal 对话框 */
.modal-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-dialog.show {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Modal 头部 */
.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Modal 内容 */
.modal-body {
    padding: 24px;
}

.modal-message {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #555;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Modal 输入框 */
.modal-input {
    width: 100%;
    padding: 12px 16px;
    margin-top: 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.modal-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
}

/* Modal 底部 */
.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Modal 按钮 */
.modal-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
    position: relative;
    overflow: hidden;
}

.modal-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.modal-btn:active::before {
    width: 300px;
    height: 300px;
}

/* 取消按钮 */
.modal-btn-cancel {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    color: #495057;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-btn-cancel:hover {
    background: linear-gradient(135deg, #dee2e6 0%, #ced4da 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-btn-cancel:active {
    transform: translateY(0);
}

/* 确定按钮 */
.modal-btn-confirm {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.modal-btn-confirm:hover {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.4);
}

.modal-btn-confirm:active {
    transform: translateY(0);
}

/* 特定类型的 Modal 样式 */

/* 确认对话框 */
.confirm-modal .modal-title::before {
    content: '⚠️';
    font-size: 24px;
}

/* 提示对话框 */
.alert-modal .modal-title::before {
    content: 'ℹ️';
    font-size: 24px;
}

/* 输入对话框 */
.prompt-modal .modal-title::before {
    content: '✏️';
    font-size: 24px;
}

/* 危险操作的确认框（删除等） */
.modal-dialog.danger .modal-btn-confirm {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.modal-dialog.danger .modal-btn-confirm:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    box-shadow: 0 4px 16px rgba(231, 76, 60, 0.4);
}

.modal-dialog.danger .modal-title::before {
    content: '🗑️';
}

/* 响应式设计 */
@media (max-width: 600px) {
    .modal-dialog {
        width: 95%;
        max-width: none;
    }

    .modal-header {
        padding: 20px 16px 12px;
    }

    .modal-body {
        padding: 20px 16px;
    }

    .modal-footer {
        padding: 12px 16px 20px;
        flex-direction: column-reverse;
    }

    .modal-btn {
        width: 100%;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-message {
        font-size: 14px;
    }
}

/* AI 接线方案弹窗样式 */
.wiring-plan-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.wiring-plan-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.wiring-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.wiring-plan-header h3 {
    margin: 0;
    font-size: 20px;
    color: #2c3e50;
}

.wiring-plan-header .close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #95a5a6;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.wiring-plan-header .close-btn:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.wiring-plan-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.wiring-explanation {
    margin-bottom: 24px;
}

.wiring-explanation h4 {
    margin: 0 0 12px 0;
    color: #2c3e50;
    font-size: 16px;
}

.wiring-explanation p {
    margin: 0;
    color: #555;
    line-height: 1.6;
    white-space: pre-wrap;
}

.wiring-explanation .explanation-text {
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    color: #555;
    line-height: 1.8;
    font-size: 14px;
}

.wiring-explanation .explanation-text::-webkit-scrollbar {
    width: 8px;
}

.wiring-explanation .explanation-text::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.wiring-explanation .explanation-text::-webkit-scrollbar-thumb {
    background: #95a5a6;
    border-radius: 4px;
}

.wiring-explanation .explanation-text::-webkit-scrollbar-thumb:hover {
    background: #7f8c8d;
}

.wiring-explanation h4 i {
    margin-right: 8px;
    color: #f39c12;
}

.wiring-list {
    margin-top: 24px;
}

.wiring-list h4 {
    margin: 0 0 12px 0;
    color: #2c3e50;
    font-size: 16px;
}

.wiring-list h4 i {
    margin-right: 8px;
    color: #3498db;
}

.wiring-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.wiring-list ul::-webkit-scrollbar {
    width: 8px;
}

.wiring-list ul::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.wiring-list ul::-webkit-scrollbar-thumb {
    background: #95a5a6;
    border-radius: 4px;
}

.wiring-list ul::-webkit-scrollbar-thumb:hover {
    background: #7f8c8d;
}

.wiring-list li {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #3498db;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.wiring-list li .wire-number {
    background: #3498db;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.wiring-list li .wire-connection {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wiring-list li .component-name {
    color: #2c3e50;
    font-weight: 600;
    font-size: 14px;
}

.wiring-list li .pin-name {
    color: #7f8c8d;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    background: #ecf0f1;
    padding: 2px 6px;
    border-radius: 4px;
}

.wiring-list li .wire-connection i {
    color: #3498db;
    font-size: 12px;
}

.wiring-list li .wire-reason {
    color: #7f8c8d;
    font-size: 13px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
    width: 100%;
}

.wiring-list li strong {
    color: #2c3e50;
    font-weight: 600;
}

.wiring-list li small {
    color: #7f8c8d;
    display: block;
    margin-top: 4px;
}

.no-wiring-plan {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    color: #856404;
    text-align: center;
    font-size: 14px;
}

.no-wiring-plan i {
    margin-right: 8px;
    color: #ffc107;
}

.wiring-plan-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.wiring-plan-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.wiring-plan-footer .btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.wiring-plan-footer .btn-secondary:hover {
    background: #d5dbdb;
}

.wiring-plan-footer .btn-primary {
    background: #3498db;
    color: white;
}

.wiring-plan-footer .btn-primary:hover {
    background: #2980b9;
}

/* AI 进度弹窗样式 */
.ai-progress-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.3s ease;
}

.ai-progress-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 480px;
    max-width: 90%;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

.ai-progress-header {
    padding: 24px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-progress-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-progress-header i {
    font-size: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.ai-progress-content {
    padding: 32px 28px;
}

.ai-progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.ai-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
    position: relative;
    overflow: hidden;
}

.ai-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

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

.ai-progress-text {
    color: #555;
    font-size: 15px;
    margin-bottom: 8px;
    min-height: 22px;
    display: flex;
    align-items: center;
}

.ai-progress-text::before {
    content: '⚡';
    margin-right: 8px;
    font-size: 18px;
}

.ai-progress-percentage {
    color: #667eea;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    font-family: 'Arial', sans-serif;
}

/* 用户积分样式 */
.credits-badge {
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.3);
    cursor: help;
}
.credits-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.4);
}
