:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #dbeafe;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 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);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: #0f172a;
    line-height: 1.5;
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.header {
    margin-bottom: 24px;
    text-align: center;
}

h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

p.lead {
    color: var(--muted);
    margin: 0 0 20px 0;
    font-size: 16px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.controls {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}

.dropzone {
    padding: 24px;
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    background: linear-gradient(180deg, #fff, #f8fafc);
    cursor: pointer;
    min-width: 260px;
    text-align: center;
    transition: all 0.2s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.dropzone:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.dropzone-icon {
    font-size: 32px;
    color: var(--accent);
    margin-bottom: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
}

label {
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}

.btn {
    background: var(--accent);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.btn.secondary {
    background: white;
    color: #374151;
    border: 1px solid var(--border);
}

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

.btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

.canvas-container {
    background: #f8fafc;
    border-radius: var(--radius);
    padding: 20px;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

canvas {
    max-width: 100%;
    height: auto;
    display: block;
    touch-action: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.sidebar-card {
    background: linear-gradient(180deg, #fff, #f8fafc);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: fit-content;
}

.row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.stat {
    font-size: 14px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.stat-value {
    font-weight: 600;
    color: #1e293b;
}

.tool-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.tool-toggle button {
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 500;
    flex: 1;
    transition: all 0.2s ease;
}

.tool-toggle button.active {
    background: white;
    color: var(--accent);
    box-shadow: var(--shadow);
}

.small {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.footer-note {
    font-size: 13px;
    color: var(--muted);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

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

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: #f0f9ff;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}

.mode-indicator i {
    color: var(--accent);
}

.tips-list {
    padding-left: 18px;
    margin: 12px 0;
}

.tips-list li {
    margin-bottom: 8px;
}

hr {
    margin: 16px 0;
    border: none;
    height: 1px;
    background: var(--border);
}

/* Brush cursor overlay */
.brush-cursor {
    position: fixed;
    pointer-events: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.45);
    transform: translate(-50%, -50%);
    transition: background-color 120ms ease, border-color 120ms ease, width 60ms ease, height 60ms ease, opacity 120ms ease;
    z-index: 99999;
    mix-blend-mode: normal;
    opacity: 0;
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.12);
    background-color: transparent;
}

.brush-cursor.outline {
    background-color: transparent;
    border-style: solid;
    border-width: 2px;
    opacity: 0.95;
}

.brush-cursor.pressed {
    border-width: 0;
    opacity: 0.95;
}

.brush-cursor.erase {
    border-color: rgba(239, 68, 68, 0.95);
    background-color: rgba(239, 68, 68, 0.18);
}

.brush-cursor.erase.pressed {
    background-color: rgba(239, 68, 68, 0.50);
}

.brush-cursor.restore {
    border-color: rgba(16, 185, 129, 0.95);
    background-color: rgba(16, 185, 129, 0.18);
}

.brush-cursor.restore.pressed {
    background-color: rgba(16, 185, 129, 0.45);
}

.brush-cursor.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Toast notification */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #1e293b;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 10000;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.warning {
    background: var(--warning);
}

.toast.error {
    background: var(--error);
}

/* Loading state */
.loading {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    border-radius: var(--radius);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.empty-state i {
    font-size: 48px;
    color: var(--muted-light);
}

.empty-state h3 {
    margin: 0;
    font-size: 18px;
    color: var(--muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
    }

    .field {
        width: 100%;
    }

    .toolbar .btn {
        min-width: 100px;
    }

    h1 {
        font-size: 24px;
    }
}