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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    --app-min-width: 1100px; /* 更紧凑的最小宽度 */
    max-width: 1800px;
    min-width: var(--app-min-width);
    margin: 0 auto;
}

.main-content {
    display: grid;
    grid-template-columns: 260px 1fr; /* 左侧更窄，主区域更大 */
    grid-template-areas:
        "control preview"
        "bottom  bottom";
    gap: 20px;
    height: calc(100vh - 40px); /* 填满视口高度（扣除 body padding） */
    min-height: 720px; /* 设定一个最小高度 */
    grid-template-rows: 1fr auto; /* 上部自适应填充，高度自适应；底部为自适应高度 */
}

/* 左侧小标题栏 */
.brand {
    margin-bottom: 12px;
}
.brand h1 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 4px;
}
.brand p {
    font-size: 0.8rem;
    color: #888;
}

/* 控制面板 */
.control-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    height: 100%;
    overflow-y: auto; /* 面板内部滚动 */
    grid-area: control;
}

.section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

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

.section h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #333;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input[type="range"] {
    width: calc(100% - 60px);
    margin-right: 10px;
}

.form-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 2px dashed #ddd;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 8px;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    margin-bottom: 8px;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.series-count {
    margin-top: 10px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    color: #667eea;
}

/* 预览区域 */
.preview-area {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    grid-area: preview;
    height: 100%;
}

.preview-container {
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* 通过缩放避免滚动条 */
}

#previewCanvas {
    display: block;
    max-width: none; /* 允许超宽并通过容器滚动 */
    max-height: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 8px;
}

/* 系列面板（底部横条） */
.series-panel {
    grid-area: bottom;
}

.series-bar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

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

.series-list {
    display: flex;
    flex-direction: row;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 4px;
}

.series-item {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    width: 140px; /* 缩小到足够预览 */
    flex: 0 0 auto;
}

.series-item.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.2) inset;
}

.series-item:hover {
    border-color: #667eea;
    transform: scale(1.02);
}

.series-item img {
    width: 100%;
    display: block;
}

.series-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 59, 48, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.series-item-remove:hover {
    background: rgb(255, 59, 48);
    transform: scale(1.1);
}

.series-export {
    width: auto;
    white-space: nowrap;
}

/* 交互提示控件（旋转/拖拽） */
.handle-legend {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.55);
    color: #fff;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    pointer-events: none;
}

/* 滚动条样式 */
.control-panel::-webkit-scrollbar,
.series-panel::-webkit-scrollbar {
    width: 6px;
}

.control-panel::-webkit-scrollbar-track,
.series-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.control-panel::-webkit-scrollbar-thumb,
.series-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.control-panel::-webkit-scrollbar-thumb:hover,
.series-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 240px 1fr;
        grid-template-areas:
            "control preview"
            "bottom  bottom";
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "control"
            "preview"
            "bottom";
    }
    
    .control-panel,
    .series-panel {
        max-height: none;
    }
    
    .preview-container {
        max-height: 600px;
        overflow-x: auto; /* 移动端也显式允许横向滚动 */
    }
}
