:root {
    --primary: #4f46e5;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 95%;
    max-width: 1100px;
    background: var(--card);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.2rem;
    margin: 0;
    letter-spacing: -1px;
}

header h1 span {
    color: var(--primary);
}

.generator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 850px) {
    .generator-grid { grid-template-columns: 1fr; }
}

.input-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: #475569;
}

input, select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border 0.2s, box-shadow 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.primary-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1.1rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    margin-top: 1rem;
}

.primary-btn:active {
    transform: scale(0.98);
}

/* --- PREVIEW BOX CONSTRAINTS --- */
.preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 2rem;
    min-height: 400px;
}

#canvas-container {
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    
    /* Force the preview to never exceed 512px */
    max-width: 512px;
    max-height: 512px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ensure the generated canvas inside follows the container size */
#canvas-container canvas {
    max-width: 100% !important;
    height: auto !important;
}

.hint {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}