:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #10b981;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 480px;
    /* Mobile width constraint for desktop look */
    background: var(--surface);
    height: 100%;
    position: relative;
    overflow-x: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
    background: var(--surface);
}

.view.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
    z-index: 0;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
    z-index: 1;
}

.app-header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.btn-icon {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
    /* hit area */
}

/* User Selection */
.user-selection {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    justify-content: center;
}

.btn {
    border: none;
    border-radius: var(--radius);
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.98);
}

.btn-user {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    color: var(--text);
    height: 80px;
    font-size: 1.2rem;
}

.btn-user:hover {
    border-color: var(--primary);
    background: #fdfdfd;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

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

/* Upload Area */
.upload-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.drop-zone {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    background: #fafafa;
    transition: border-color 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: #f0fdfa;
}

.drop-zone p {
    font-weight: 500;
    color: var(--text);
}

.drop-zone small {
    color: var(--text-muted);
}

/* Preview Area */
.preview-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 20px;
    width: 100%;
    align-items: center;
}

.preview-container.hidden {
    display: none;
}

.canvas-wrapper {
    width: 100%;
    max-height: 50vh;
    overflow: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    justify-content: center;
    background: #eee;
}

canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Error Toast */
.error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}