:root {
    --bg-color: #0f1115;
    --surface-color: #181b21;
    --surface-hover: #22262e;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --border-color: #2d3139;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo span {
    font-size: 2.5rem;
    background: var(--accent-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Upload Section */
.upload-section {
    width: 100%;
    max-width: 600px;
}

.drop-zone {
    background-color: var(--surface-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: var(--surface-hover);
    transform: translateY(-2px);
}

.drop-zone .icon-large {
    font-size: 4rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: block;
}

.drop-zone h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.drop-zone .hint {
    font-size: 0.875rem;
    opacity: 0.7;
}

#fileInput {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Editor Section */
.editor-section {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    animation: fadeIn 0.5s ease;
}

@media (max-width: 900px) {
    .editor-section {
        grid-template-columns: 1fr;
    }
}

.canvas-container {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

canvas {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 17, 21, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-hover);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.progress-bar-container {
    width: 200px;
    height: 6px;
    background: var(--surface-hover);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Controls */
.controls-container {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: fit-content;
    box-shadow: var(--shadow-lg);
}

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

input[type="range"] {
    flex: 1;
    appearance: none;
    -webkit-appearance: none;
    height: 4px;
    background: var(--surface-hover);
    border-radius: 2px;
    outline: none;
}

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

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

.value-display {
    display: block;
    text-align: right;
    margin-top: 0.5rem;
    font-variant-numeric: tabular-nums;
    color: var(--primary-color);
    font-weight: 600;
}

.toggle-wrapper {
    display: flex;
    background: var(--bg-color);
    padding: 4px;
    border-radius: var(--radius-md);
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--surface-hover);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: auto;
}

.export-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn {
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

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

.btn.primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: var(--border-color);
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    width: 100%;
}

/* Footer */
.app-footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}