:root {
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --border: #E2E8F0;
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    
    --primary: #6C5CE7;
    --primary-hover: #5A4FCF;
    --accent: #00B894;
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

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

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

/* Utilities */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.justify-center { justify-content: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Typography */
h1 { font-size: 18px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.5px;}
p { color: var(--text-secondary); }
.help-text { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; font-family: inherit;
    cursor: pointer; transition: all 0.2s; border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-surface); border-color: var(--border); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text-primary); }

/* Header */
.app-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    height: 60px;
    flex-shrink: 0;
    z-index: 10;
}
.header-content {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1400px; margin: 0 auto; height: 100%;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.brand h1 { color: var(--text-primary); }
.header-actions { display: flex; gap: 12px; }

.upload-btn-wrapper { position: relative; overflow: hidden; display: inline-block; }
.upload-btn-wrapper input[type=file] { padding: 0; font-size: 100px; position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; height: 100%; }

/* Main Layout */
.app-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

/* Dropzone */
.dropzone {
    position: absolute; top: 24px; left: 24px; right: 24px; bottom: 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; z-index: 5;
}
.dropzone.dragover {
    border-color: var(--primary); background: rgba(108, 92, 231, 0.05);
}
.dropzone-content { text-align: center; pointer-events: none; }
.dropzone-icon { color: var(--text-tertiary); margin-bottom: 16px; }

/* Workspace */
.workspace {
    width: 100%; height: 100%;
    display: flex;
    background: var(--bg-page);
    z-index: 10;
}

/* Sidebar */
.controls-sidebar {
    width: 320px; flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow-y: auto; padding: 24px;
}

.control-group { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.control-group:last-child { margin-bottom: 0; padding-bottom: 0; border: none; }

.control-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.5px; }

/* Radio Cards */
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
    position: relative; border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 12px; cursor: pointer; transition: all 0.2s; background: var(--bg-surface);
}
.radio-card:hover { border-color: #cbd5e1; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: rgba(108, 92, 231, 0.03); }

.rc-content { display: flex; flex-direction: column; }
.rc-title { font-weight: 500; font-size: 14px; color: var(--text-primary); }
.rc-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Sliders */
.slider {
    -webkit-appearance: none; width: 100%; height: 6px; border-radius: 3px;
    background: var(--border); outline: none; margin-top: 12px;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary); cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.slider:disabled { opacity: 0.5; }
.slider:disabled::-webkit-slider-thumb { background: var(--text-tertiary); cursor: not-allowed; }
.value-badge { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; color: var(--text-secondary); }

/* Segment Control */
.segment-control {
    display: flex; background: #f1f5f9; border-radius: var(--radius-md); padding: 4px; gap: 4px;
}
.segment-btn {
    flex: 1; padding: 6px; border: none; background: transparent; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all 0.2s;
}
.segment-btn.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

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

/* Canvas Area */
.canvas-container {
    flex-grow: 1; position: relative;
    padding: 24px;
    display: flex; align-items: center; justify-content: center;
    background: #e2e8f0; /* Darker bg for contrast */
    background-image: 
        linear-gradient(45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #cbd5e1 75%), 
        linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    overflow: hidden;
}

.canvas-wrapper {
    position: relative; box-shadow: var(--shadow-lg);
    background: white; border-radius: 4px;
    max-width: 100%; max-height: 100%;
}

.canvas-pane {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}
.canvas-pane canvas { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }

.pane-label {
    position: absolute; top: 12px; left: 12px;
    background: rgba(0,0,0,0.6); color: white;
    padding: 4px 10px; border-radius: 4px;
    font-size: 12px; font-weight: 500; backdrop-filter: blur(4px);
    z-index: 10; pointer-events: none;
}

#pane-simulated .pane-label { left: auto; right: 12px; }

/* Split Mode Logic */
.single-mode #pane-original { display: none; }
.single-mode .split-divider { display: none; }
.single-mode #pane-simulated .pane-label { left: 12px; right: auto; }

.split-mode #pane-original { right: 50%; border-right: none; }
.split-mode #pane-simulated { left: 50%; /* clip path handled in js for smooth slider */ }

.split-divider {
    position: absolute; top: 0; bottom: 0; left: 50%;
    width: 2px; background: white; z-index: 20;
    transform: translateX(-50%); cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
.divider-handle {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 32px; height: 32px; background: white;
    border-radius: 50%; box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center; gap: 2px; color: var(--text-secondary);
}

/* Tooltip */
.color-tooltip {
    position: absolute; z-index: 100;
    background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-md);
    padding: 12px; color: white; display: flex; flex-direction: column; gap: 8px;
    box-shadow: var(--shadow-lg); pointer-events: none;
    transform: translate(15px, 15px);
}
.tooltip-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tt-label { width: 70px; color: var(--text-tertiary); font-weight: 500; }
.tt-swatch { width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); }
.tt-hex { font-family: monospace; font-variant-numeric: tabular-nums; }


/* Toast */
.toast {
    position: fixed; bottom: -50px; left: 50%; transform: translateX(-50%);
    background: var(--text-primary); color: white;
    padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 500;
    opacity: 0; transition: all 0.3s; z-index: 1000; box-shadow: var(--shadow-md);
}
.toast.show { bottom: 24px; opacity: 1; }
