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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(90deg, #4b6cb7 0%, #182848 100%);
    color: white;
    padding: 25px 30px;
    text-align: center;
}

h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;
    gap: 20px;
    min-height: 600px;
}

.left-panel {
    flex: 1;
    min-width: 300px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.right-panel {
    flex: 2;
    min-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    margin-bottom: 25px;
}

h2 {
    color: #4b6cb7;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eaeaea;
    font-size: 1.4em;
}

h3 {
    color: #555;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(90deg, #4b6cb7 0%, #3a56a4 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn:hover {
    background: linear-gradient(90deg, #3a56a4 0%, #2a468c 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(90deg, #6c757d 0%, #5a6268 100%);
}

.btn-secondary:hover {
    background: linear-gradient(90deg, #5a6268 0%, #484e53 100%);
}

.btn-success {
    background: linear-gradient(90deg, #28a745 0%, #218838 100%);
}

.btn-success:hover {
    background: linear-gradient(90deg, #218838 0%, #1e7e34 100%);
}

.image-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    background: white;
    margin-bottom: 15px;
}

.image-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
}

.image-item:hover {
    background: #f0f7ff;
    border-color: #4b6cb7;
}

.image-item.active {
    background: #e3f2fd;
    border-color: #4b6cb7;
    box-shadow: 0 2px 5px rgba(75, 108, 183, 0.2);
}

.image-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 15px;
}

.image-info {
    flex: 1;
    min-width: 0;
}

.image-name {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.image-size {
    font-size: 12px;
    color: #777;
}

.image-actions {
    display: flex;
    gap: 5px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 18px;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #f0f0f0;
    color: #4b6cb7;
}

.editor-container {
    flex: 1;
    border: 2px solid #eaeaea;
    border-radius: 10px;
    overflow: hidden;
    background: #f5f5f5;
    position: relative;
    min-height: 500px;
}

#p5-canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-height: 500px;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.control-point {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #ff4757;
    border: 2px solid white;
    border-radius: 50%;
    cursor: move;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: auto;
}

.output-controls {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border 0.3s;
}

.form-control:focus {
    border-color: #4b6cb7;
    outline: none;
    box-shadow: 0 0 0 3px rgba(75, 108, 183, 0.2);
}

.instructions {
    background: #e3f2fd;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    font-size: 14px;
    border-left: 4px solid #4b6cb7;
}

.instructions h3 {
    color: #4b6cb7;
    margin-bottom: 10px;
}

.instructions ul {
    padding-left: 20px;
    color: #555;
}

.instructions li {
    margin-bottom: 5px;
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.toolbar-btn {
    flex: 1;
    min-width: 120px;
}

.status-indicator {
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 14px;
    display: none;
}

.status-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.status-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .left-panel, .right-panel {
        width: 100%;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .toolbar-btn {
        min-width: 100%;
    }
}