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

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #252532;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --border: #2a2a3a;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--text-secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Preview Section */
.preview-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.canvas-wrapper {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border);
}

#canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.btn-secondary.copied {
    background: #10b981;
    border-color: #10b981;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-buttons .btn {
    flex: 1;
}

/* Controls Section */
.controls-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.controls-section::-webkit-scrollbar {
    width: 6px;
}

.controls-section::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.controls-section::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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

.control-group h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.template-btn {
    aspect-ratio: 4/3;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.template-btn:hover {
    border-color: var(--accent);
    transform: scale(1.02);
}

.template-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.template-btn span {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    font-size: 0.65rem;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    text-align: center;
}

/* Text Input */
textarea {
    width: 100%;
    padding: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea::placeholder {
    color: var(--text-secondary);
}

/* Select */
.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    pointer-events: none;
}

select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    transition: border-color 0.2s ease;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Button Group */
.button-group {
    display: flex;
    gap: 8px;
}

.btn-toggle {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.btn-toggle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="color"] {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    padding: 0;
}

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

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
}

.color-picker-wrapper span {
    color: var(--text-secondary);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
}

.gradient-colors {
    display: flex;
    gap: 16px;
}

/* Position Grid */
.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.pos-btn {
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pos-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.pos-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .controls-section {
        max-height: none;
    }

    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
