:root {
    --primary-color: #9d4edd;
    /* Purple */
    --primary-hover: #7b2cbf;
    /* Darker Purple */
    --accent-color: #c77dff;
    /* Light Purple */
    --bg-gradient: #f8fafc;
    /* Clean white/gray background */
    --surface-color: #ffffff;
    --surface-blur: none;
    /* Clean solid look */
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    --error-color: #ef4444;
    --warning-bg: #fffbeb;
    --warning-text: #b45309;
    --radius: 12px;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --input-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 2rem;
}

/* Header */
.app-header {
    background: var(--surface-color);
    backdrop-filter: var(--surface-blur);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    margin-bottom: 2.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.container {
    width: 92%;
    max-width: 1200px;
    margin: 0 auto;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

/* Bento Grid Layout */
.bento-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.bento-card {
    background: var(--surface-color);
    backdrop-filter: var(--surface-blur);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bento-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

/* Card Headers */
.bento-card h2 {
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.icon {
    font-size: 1rem;
    opacity: 0.8;
}

/* Mobile Sticky Preview */
.card-preview {
    position: sticky;
    top: 5rem;
    z-index: 20;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

/* Desktop Grid */
@media (min-width: 1024px) {
    .bento-layout {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto auto auto auto auto auto;
        grid-template-areas:
            "input  input   preview"
            "colors body    preview"
            "eyes   eyes    preview"
            "logo   ecc     preview"
            "notice notice  notice"
            "ad     ad      ad";
        gap: 1.5rem;
        align-items: stretch;
    }

    .card-ad {
        grid-area: ad;
    }

    .card-input {
        grid-area: input;
    }

    .card-colors {
        grid-area: colors;
    }

    .card-body-pattern {
        grid-area: body;
    }

    .card-eye-pattern {
        grid-area: eyes;
    }

    .card-layout {
        grid-area: layout;
    }

    .card-logo {
        grid-area: logo;
    }

    .card-ecc {
        grid-area: ecc;
    }

    .card-notice {
        grid-area: notice;
    }

    .card-preview {
        grid-area: preview;
        position: sticky;
        top: 6rem;
        /* Account for sticky header */
        height: fit-content;
        min-height: 600px;
        justify-content: center;
        align-items: center;
        background: #ffffff;
        border: 1px solid rgba(0, 0, 0, 0.05);
        z-index: 10;
        /* Above regular content if scrolling */
    }
}

/* Inputs */
.control-row {
    display: flex;
    gap: 1rem;
    flex-direction: column;
}

@media (min-width: 640px) {
    .control-row {
        flex-direction: row;
    }
}

.control-group {
    flex: 1;
    margin-bottom: 0.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

input[type="text"],
select,
input[type="range"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    /* Slightly tighter radius for inputs */
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text-main);
    box-shadow: var(--input-shadow);
    transition: all 0.2s;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

input[type="color"] {
    appearance: none;
    border: none;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
}

.color-value {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Radio Groups & Custom Inputs */
.radio-group-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.radio-group-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Hide default radio */
.radio-card input[type="radio"],
.radio-btn input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

/* Card Style Radio (for patterns) */
.radio-card {
    position: relative;
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 0.25rem;
    text-align: center;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.25rem;
}

.radio-card:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.radio-card:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--primary-color);
}

/* Button Style Radio (for small options) */
.radio-btn {
    flex: 1;
    position: relative;
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    color: var(--text-muted);
    min-width: 3rem;
}

.radio-btn:hover {
    border-color: var(--text-muted);
}

.radio-btn:has(input:checked) {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* File Upload */
.file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1.5rem;
    background-color: #f8fafc;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.2s;
    font-weight: 500;
}

.file-upload-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: #eff6ff;
}

input[type="file"] {
    display: none;
}

.file-name {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-main);
    font-weight: 500;
    text-align: center;
}

/* Primary Button */
.primary-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3), 0 2px 4px -1px rgba(99, 102, 241, 0.15);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4), 0 4px 6px -2px rgba(99, 102, 241, 0.2);
}

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

.secondary-btn {
    background: transparent;
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    margin-top: 0.75rem;
    font-size: 0.8rem;
    padding: 0.5rem;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    font-weight: 500;
}

.secondary-btn:hover {
    background: rgba(239, 68, 68, 0.05);
}

/* Preview Specifics */
.qr-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    margin-bottom: 2rem;
    padding: 1rem;
    /* Provide some breathing room */
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: auto;
}

/* Utility */
.hidden {
    display: none !important;
}

.error-msg {
    color: var(--error-color);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.warning-msg {
    background: var(--warning-bg);
    color: var(--warning-text);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}