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

:root {
    --bg-gradient-start: #f0f4f8;
    --bg-gradient-end: #d9e2ec;
    --card-bg: rgba(255, 255, 255, 0.98);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --upload-bg: #f8fafc;
    --upload-border: #cbd5e1;
    --chip-bg: #e2e8f0;
    --footer-text: #64748b;
    --card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

body.dark {
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.98);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --upload-bg: #1e293b;
    --upload-border: #475569;
    --chip-bg: #334155;
    --footer-text: #94a3b8;
    --card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(145deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 1.5rem;
    position: relative;
    transition: background 0.3s ease, color 0.3s ease;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="10" cy="10" r="2" fill="rgba(100,100,255,0.05)"/><circle cx="90" cy="20" r="3" fill="rgba(100,100,255,0.05)"/><circle cx="50" cy="80" r="2" fill="rgba(100,100,255,0.05)"/></svg>') repeat;
    opacity: 0.5;
    pointer-events: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Header Section */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0.7rem 1.8rem;
    border-radius: 100px;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.logo i {
    font-size: 1.8rem;
    color: white;
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 0.7rem 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
}

.dark-mode-toggle:hover {
    transform: scale(1.05);
}

.dark-mode-toggle i {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.dark-mode-toggle span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.8rem;
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }
    .main-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }
    .dark-mode-toggle {
        top: 1rem;
        right: 1rem;
        padding: 0.5rem 1rem;
    }
    .dark-mode-toggle span {
        display: none;
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 1.5rem;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 30px 50px -15px rgba(0, 0, 0, 0.2);
}

.card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.2rem 1.5rem;
    color: white;
}

.card-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header p {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 0.3rem;
}

.card-body {
    padding: 1.5rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--upload-border);
    border-radius: 1.2rem;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--upload-bg);
}

.upload-area:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.01);
}

.upload-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 0.8rem;
}

.upload-area h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

#fileInput {
    display: none;
}

/* Preview Image */
.preview-container {
    margin-top: 1.2rem;
    text-align: center;
    background: var(--upload-bg);
    border-radius: 1rem;
    padding: 0.8rem;
}

.preview-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: 0.8rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.info-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--chip-bg);
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.6rem;
}

/* Input Groups */
.input-group {
    margin-bottom: 1.2rem;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 0.8rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: 'Inter', monospace;
    background: var(--upload-bg);
    color: var(--text-primary);
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Aspect Ratio Lock Button */
.aspect-ratio-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.lock-btn {
    background: var(--upload-bg);
    border: 2px solid var(--border-color);
    border-radius: 0.8rem;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.lock-btn:hover {
    transform: scale(1.02);
}

.lock-btn i {
    font-size: 1rem;
}

.lock-btn.locked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.ratio-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.5rem;
    background: var(--chip-bg);
    border-radius: 0.5rem;
    flex: 1;
    text-align: center;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: 0.8rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0.8rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

/* Result Preview */
.result-card {
    background: var(--upload-bg);
    border-radius: 1.2rem;
    padding: 1.2rem;
    margin-top: 1rem;
    text-align: center;
}

.result-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.result-canvas {
    max-width: 100%;
    max-height: 220px;
    border-radius: 0.8rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    background: var(--upload-bg);
}

.dimension-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #667eea;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.8rem;
}

/* Tool Description Section */
.description-section {
    margin-top: 2rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem;
    background: var(--upload-bg);
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.feature-item i {
    font-size: 1.5rem;
    color: #667eea;
}

.feature-item span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.howto-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.step {
    flex: 1;
    min-width: 150px;
    text-align: center;
    padding: 0.8rem;
    background: var(--upload-bg);
    border-radius: 1rem;
}

.step .step-number {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.step p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #1e293b;
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 0.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    font-weight: 500;
    font-size: 0.85rem;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

/* Footer Styles */
.custom-footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 1rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-social a {
    font-size: 1.5rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.footer-social a:hover {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.footer-text {
    margin: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-copyright {
    margin: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-online {
    color: #10b981;
    font-weight: 600;
}

.heart-icon {
    color: #ef4444;
}

.brand-gradient {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 600;
}

@media (max-width: 480px) {
    .card-body {
        padding: 1rem;
    }
    .feature-grid {
        grid-template-columns: 1fr;
    }
    .step {
        min-width: 100%;
    }
    .aspect-ratio-group {
        flex-direction: column;
        align-items: stretch;
    }
    .footer-social {
        gap: 0.8rem;
    }
    .footer-social a {
        font-size: 1.2rem;
    }
}