:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --accent: #8b5cf6;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1e293b;
    --text-2: #64748b;
    --text-3: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --r: 16px;
    --r-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
        'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
}

.app {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 52px 20px 28px;
    margin: 0 -16px 16px;
    background: linear-gradient(135deg, #ec4899 0%, var(--accent) 50%, var(--primary) 100%);
    border-radius: 0 0 28px 28px;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -15%;
    width: 160px;
    height: 160px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

.header h1 {
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 2px;
    position: relative;
    z-index: 1;
}

.subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--card);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning);
    flex-shrink: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.ready {
    background: var(--success);
    animation: none;
}

.status-dot.error {
    background: var(--danger);
    animation: none;
}

.usage-notice {
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid #c7d2fe;
    border-radius: var(--r-sm);
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    line-height: 1.65;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
    animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-top h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ===== Upload ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--r-sm);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    margin-bottom: 16px;
}

.upload-area:active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.04);
}

.upload-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--primary-light);
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-3);
}

.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--r-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}

.btn-secondary:active {
    background: var(--border);
    transform: scale(0.97);
}

.btn-accent {
    background: linear-gradient(135deg, #ec4899, var(--accent));
    color: #fff;
}

.btn-accent:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.btn-block {
    width: 100%;
    margin-top: 16px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-link:active {
    background: rgba(99, 102, 241, 0.08);
}

/* ===== Canvas ===== */
.canvas-wrap {
    border-radius: var(--r-sm);
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid var(--border);
}

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

/* ===== Step Header ===== */
.step-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899, var(--accent));
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-num.face {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.step-num.leg {
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
}

.step-num.combo {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
}

.disabled-overlay {
    position: relative;
}

.disabled-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--r);
    z-index: 5;
    pointer-events: none;
}

.disabled-banner {
    background: var(--danger-bg);
    color: #991b1b;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 12px;
}

@media (prefers-color-scheme: dark) {
    .disabled-overlay::after {
        background: rgba(15, 23, 42, 0.5);
    }
}

.step-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.step-desc {
    font-size: 12px;
    color: var(--text-3);
}

/* ===== Info Box ===== */
.info-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.7;
}

.info-box .tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
}

.tag-success { background: var(--success-bg); color: #065f46; }
.tag-warning { background: var(--warning-bg); color: #92400e; }
.tag-info { background: var(--info-bg); color: #1e40af; }
.tag-danger { background: var(--danger-bg); color: #991b1b; }

/* ===== Slimming Controls ===== */
.slim-controls {
    margin-bottom: 16px;
}

.slider-group {
    margin-bottom: 12px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.slider-value {
    color: #ec4899;
    font-weight: 700;
    font-size: 15px;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--border), #f9a8d4);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899, var(--accent));
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.4);
    cursor: pointer;
    border: 3px solid #fff;
}

.slider-leg {
    background: linear-gradient(90deg, var(--border), #67e8f9) !important;
}

.slider-leg::-webkit-slider-thumb {
    background: linear-gradient(135deg, #06b6d4, #3b82f6) !important;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.4) !important;
}

.slider-combo {
    background: linear-gradient(90deg, var(--border), #c4b5fd) !important;
}

.slider-combo::-webkit-slider-thumb {
    background: linear-gradient(135deg, #8b5cf6, #ec4899) !important;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4) !important;
}

.slider-combo-arm {
    background: linear-gradient(90deg, var(--border), #60a5fa) !important;
}

.slider-combo-arm::-webkit-slider-thumb {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4) !important;
}

.slider-combo-leg {
    background: linear-gradient(90deg, var(--border), #a78bfa) !important;
}

.slider-combo-leg::-webkit-slider-thumb {
    background: linear-gradient(135deg, #7c3aed, #a855f7) !important;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4) !important;
}

.slider-combo-long {
    background: linear-gradient(90deg, var(--border), #fbbf24) !important;
}

.slider-combo-long::-webkit-slider-thumb {
    background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4) !important;
}

.slim-canvas-wrap {
    position: relative;
}

.compare-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.compare-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.compare-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ===== Loading Overlay ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay-content {
    text-align: center;
    color: #fff;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.overlay-content p {
    font-size: 15px;
    margin-bottom: 16px;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: #1e293b;
        --text: #f1f5f9;
        --text-2: #94a3b8;
        --text-3: #64748b;
        --border: #334155;
    }

    .upload-area {
        border-color: var(--border);
    }

    .canvas-wrap {
        background: #0f172a;
    }

    .info-box {
        background: rgba(0, 0, 0, 0.2);
    }
}

@media (min-width: 500px) {
    .app {
        padding: 0 24px 48px;
    }

    .header {
        margin: 0 -24px 20px;
    }
}
