body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f4f7f9;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #333;
}

/* 顶部导航栏 */
.header {
    height: 60px;
    background: #1a1a1a;
    color: #ffffff;
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

.header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: linear-gradient(45deg, #1890ff, #36cfc9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* 主体布局 */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* 左侧边栏 */
.sidebar {
    width: 320px;
    min-width: 300px; /* 增加最小宽度保护 */
    background: #ffffff;
    border-right: 1px solid #e1e4e8;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0; /* 防止被挤压 */
}

/* 侧边栏隐藏状态 */
.sidebar-collapsed {
    margin-left: -320px;
    opacity: 0;
    pointer-events: none;
}

.sidebar-section {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    margin: 0 0 18px 0;
    font-size: 13px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

/* 紧凑参数网格 */
.params-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

/* 横向排列布局 */
.row-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0 !important;
}

/* UI 组件美化 */
.input-item {
    margin-bottom: 16px;
}

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

.num-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e8e8e8;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    background: #f9f9f9;
}

.num-input:focus {
    outline: none;
    border-color: #1890ff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(24,144,255,0.1);
}

/* 颜色选择器 - 增强可见性 */
.color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 5px 0;
}

.color-dot {
    width: 36px;
    height: 36px;
    border-radius: 8px; /* 改为稍微带圆角的正方形，更有设计感 */
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.color-dot:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* 关键：显著的选中状态 */
.color-dot.active {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px #1890ff, 0 8px 15px rgba(24,144,255,0.4);
}

.color-dot.active::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #1890ff;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #d9d9d9;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.btn-primary {
    background: #1890ff;
    color: white;
    border-color: #1890ff;
}

.btn-primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
    color: white;
    box-shadow: 0 4px 12px rgba(24,144,255,0.3);
}

.btn-danger {
    color: #ff4d4f;
    border-color: #ff4d4f;
}

.btn-danger:hover {
    background: #ff4d4f;
    color: white;
    box-shadow: 0 4px 12px rgba(255,77,79,0.3);
}

/* 开关样式美化 */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: #1890ff; }
input:checked + .slider:before { transform: translateX(22px); }

/* 单选按钮美化 */
.radio-label {
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.radio-label:hover { background: #f0f0f0; }

/* 画布区域 */
.canvas-area {
    flex: 1;
    position: relative;
    background: #ffffff;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

#x6-container {
    width: 100%;
    height: 100%;
    cursor: default !important; /* 强制默认指针，防止被隐藏 */
}

/* 确保所有 X6 元素都有明确的鼠标状态 */
.x6-graph {
    cursor: default !important;
}

/* 端口（Magnet）悬停时显示十字准星，增强反馈 */
.x6-port-magnet {
    cursor: crosshair !important;
}

/* 节点悬停时显示手型，表示可交互 */
.x6-node {
    cursor: pointer !important;
}

/* 防止平移时鼠标丢失 */
.x6-graph-panning, .x6-graph-panning * {
    cursor: grabbing !important;
}

/* 说明区域 */
.help-text {
    font-size: 13px;
    color: #666;
    line-height: 1.8;
}

.help-text p {
    margin: 8px 0;
    padding-left: 12px;
    position: relative;
}

.help-text p::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #1890ff;
    font-weight: bold;
}

.help-text b { color: #222; }

/* 响应式调整 */
@media (max-height: 800px) {
    .sidebar-section { padding: 15px 20px; }
    .input-item { margin-bottom: 12px; }
}
