:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --border-color: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
}

.main-content {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.controls-panel {
    flex: 1;
    min-width: 250px;
    max-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.95rem;
    font-weight: 500;
}

input[type="number"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="number"]:focus {
    border-color: var(--accent-color);
}

input[type="file"] {
    display: none;
}

.custom-file-upload {
    display: inline-block;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed var(--text-secondary);
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s;
}

.custom-file-upload:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: white;
}

.file-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-align: center;
    word-break: break-all;
}

.primary-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: auto;
}

.primary-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}

.primary-btn:disabled {
    background: #334155;
    color: #64748b;
    cursor: not-allowed;
}

.preview-panel {
    flex: 2;
    min-width: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 1rem;
    overflow: hidden;
}

.canvas-container {
    max-width: 100%;
    max-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.placeholder-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
}

#previewImage {
    max-width: 100%;
    max-height: 550px;
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: grid;
}

.grid-cell {
    border: 1px dashed rgba(255, 255, 255, 0.9);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s;
}

.grid-cell:hover {
    background-color: rgba(59, 130, 246, 0.3);
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    .controls-panel {
        max-width: 100%;
    }
}
