:root {
    --bg-color: #f0f2f5;
    --sidebar-width: 380px;
    --accent-color: #0a66c2;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: #333;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 4px 0 15px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.sidebar-header h2 { font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.sidebar-header span { font-family: 'Courier Prime'; font-size: 0.8rem; background: #333; color: #fff; padding: 2px 6px; border-radius: 4px; }

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #ddd;
}
.section:last-child { border-bottom: none; }

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 12px;
    font-weight: 700;
}

/* Inputs */
.input-group { margin-bottom: 12px; }
label { display: block; font-size: 0.85rem; margin-bottom: 5px; font-weight: 500; }

input[type="text"], select, textarea, input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: 0.2s;
    font-family: inherit;
}
input[type="text"]:focus { border-color: var(--accent-color); }

.row { display: flex; gap: 10px; }
.col { flex: 1; }

input[type="range"] { width: 100%; cursor: pointer; }
input[type="color"] { width: 100%; height: 35px; border: none; background: none; cursor: pointer; }

.toggle-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 4px;
}
.toggle-btn.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600; }

.file-row { display: flex; gap: 5px; }
.file-upload {
    flex: 1;
    border: 1px dashed #ccc;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    background: #fafafa;
}
.btn-clear {
    padding: 0 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    color: #ff4444;
    font-weight: bold;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    background: #eef;
    padding: 10px;
    border-radius: 6px;
    color: var(--accent-color);
    font-weight: 600;
}
.checkbox-label input { width: auto; }

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}
.btn-download {
    width: 100%;
    background: #1a1a1a;
    color: #fff;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-family: 'Courier Prime', monospace;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}
.btn-download:hover { background: var(--accent-color); transform: translateY(-2px); }

/* --- Preview Area --- */
.main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #e0e0e0;
    /* Checkerboard Background */
    background-image: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

/* Fabric JS Canvas Wrapper Style Override */
.canvas-container {
    box-shadow: 0 30px 60px -12px rgba(0,0,0,0.25);
    background: transparent !important; /* 투명 배경 허용 */
}

@media (max-width: 900px) {
    body { flex-direction: column; height: auto; overflow-y: auto; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #ddd; }
    .main-stage { height: 400px; padding: 10px; }
    .sidebar-content { max-height: 50vh; }
}