body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.main-header {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.main-title {
    color: white;
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 2px;
}

.container {
    display: flex;
    flex-direction: row; /* Side-by-side layout */
    gap: 30px; /* Increased gap */
    width: 100%;
    max-width: 1600px; /* Wider max-width for side-by-side */
    align-items: flex-start; /* Align items to the top */
    padding: 20px;
}

.controls {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex: 1; /* 与预览区 1:1 宽度 */
    display: flex;
    flex-direction: column;
    gap: 16px; /* 略微压缩垂直间距，避免过长 */
    max-height: 85vh; /* 控件区不拉太长 */
    overflow: auto; /* 超出滚动 */
}

h1, h2 {
    font-size: 24px;
    margin: 0 0 10px;
    text-align: center;
}

h2 {
    font-size: 20px;
    color: #333;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    color: #333;
}

.sub-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="file"], input[type="text"], textarea, select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: auto;
}

input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
}

textarea {
    resize: vertical;
}

button, #download-link {
    background-color: #007bff;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s;
}

button:hover, #download-link:hover {
    background-color: #0056b3;
}

.preview {
    flex: 1; /* Allow preview to take remaining space */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    /* min-height is no longer needed with flex-start alignment */
}

canvas {
    max-width: 100%;
    max-height: 85vh; /* Allow canvas to be taller */
    object-fit: contain;
    border: 1px solid #ddd;
}

#font-size-value, #line-height-value, #bg-opacity-value {
    text-align: center;
    color: #555;
    font-weight: 500;
}