:root {
    /* Color Palette */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --border-color: #e5e7eb;
    --input-focus: #4f46e5;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* Animation speeds */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(30, 41, 59, 0.95);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-gradient);
    padding: 20px;
    color: var(--text-main);
    transition: background var(--transition-normal);
}

/* Container & Card */
.container {
    width: 100%;
    max-width: 480px;
    perspective: 1000px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

/* Typography */
h1 {
    font-size: 1.875rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: -0.025em;
}

p.subtitle {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

input[type="number"]:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    margin-top: 10px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.2);
}

.error-message {
    color: var(--accent-red);
    font-size: 0.75rem;
    margin-top: 4px;
    height: 15px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.error-message.visible {
    opacity: 1;
}

input.invalid {
    border-color: var(--accent-red) !important;
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Gender Selection */
.gender-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 2rem;
}

.gender-option {
    flex: 1;
    position: relative;
}

.gender-option input {
    position: absolute;
    opacity: 0;
}

.gender-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.gender-option input:checked + .gender-label {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
    color: var(--primary);
}

.gender-label i {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

/* Button */
#submitBtn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
}

#submitBtn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

#submitBtn:active:not(:disabled) {
    transform: translateY(0);
}

#submitBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results Section */
.results-container {
    margin-top: 2.5rem;
    display: none;
    animation: fadeInUp 0.5s ease-out forwards;
}

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

.bmi-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

.bmi-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.bmi-category {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.progress-container {
    position: relative;
    height: 12px;
    background: #e5e7eb;
    border-radius: 10px;
    margin: 2rem 0;
    overflow: hidden;
    display: flex;
}

.progress-section {
    height: 100%;
}

.underweight { background: var(--accent-yellow); flex: 1.85; }
.normal { background: var(--accent-green); flex: 0.65; }
.overweight { background: var(--accent-yellow); flex: 0.5; }
.obese { background: var(--accent-red); flex: 1; }

.indicator {
    position: absolute;
    top: -4px;
    width: 4px;
    height: 20px;
    background: var(--text-main);
    transition: left 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.tips-card {
    background: rgba(0, 0, 0, 0.03);
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
}

[data-theme="dark"] .tips-card {
    background: rgba(255, 255, 255, 0.03);
}

/* Unit Toggle */
.unit-toggle {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.unit-btn {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
}

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

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 480px) {
    .card {
        padding: 1.5rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}