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

:root {
    --primary-color: #0071e3;
    --primary-hover: #0077ed;
    --bg-color: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --border-color: #d2d2d7;
    --success-color: #34c759;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Ad Containers */
.ad-container {
    padding: 10px 20px;
}

.ad-banner {
    max-width: 1400px;
    margin: 0 auto;
}

.ad-placeholder {
    background: #e8e8ed;
    border: 2px dashed #c7c7cc;
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-sidebar {
    width: 160px;
    flex-shrink: 0;
}

.ad-vertical {
    min-height: 600px;
    position: sticky;
    top: 20px;
}

/* Main Content Layout */
.content-wrapper {
    display: flex;
    gap: 20px;
    padding: 20px 0;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    background: var(--card-bg);
    border: 3px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-subtext {
    color: var(--text-secondary);
}

/* Section Styling */
section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Device Selection */
.device-category {
    margin-bottom: 24px;
}

.device-category:last-child {
    margin-bottom: 0;
}

.device-category h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.device-btn {
    background: var(--bg-color);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.device-btn.active {
    border-color: var(--primary-color);
    background: #e5f1ff;
}

.device-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.device-size {
    font-size: 0.8125rem;
    color: var(--primary-color);
    font-weight: 500;
}

.device-models {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Orientation Toggle */
.orientation-toggle {
    display: flex;
    gap: 12px;
}

.orientation-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-color);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.orientation-btn:hover {
    border-color: var(--primary-color);
}

.orientation-btn.active {
    border-color: var(--primary-color);
    background: #e5f1ff;
    color: var(--primary-color);
}

/* Fit Options */
.fit-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.fit-btn {
    flex: 1;
    min-width: 150px;
    padding: 14px;
    background: var(--bg-color);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.fit-btn:hover {
    border-color: var(--primary-color);
}

.fit-btn.active {
    border-color: var(--primary-color);
    background: #e5f1ff;
}

.fit-name {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
}

.fit-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Background Color */
.color-options {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

#bgColor {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
}

.color-presets {
    display: flex;
    gap: 8px;
}

.color-preset {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-preset:hover {
    transform: scale(1.1);
}

/* Preview Section */
.preview-section {
    text-align: center;
}

.preview-container {
    background: #e8e8ed;
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    overflow: hidden;
}

#previewCanvas {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.preview-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.preview-info span {
    background: var(--bg-color);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Download Buttons */
.download-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

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

.download-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.download-btn.secondary {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.download-btn.secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 30px 20px;
    margin-top: 40px;
}

footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

footer p {
    opacity: 0.7;
    font-size: 0.875rem;
}

footer nav {
    display: flex;
    gap: 20px;
}

footer a {
    color: white;
    text-decoration: none;
    opacity: 0.7;
    font-size: 0.875rem;
    transition: opacity 0.2s ease;
}

footer a:hover {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .ad-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

    header p {
        font-size: 1rem;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

    .orientation-toggle,
    .fit-options {
        flex-direction: column;
    }

    .download-buttons {
        flex-direction: column;
    }

    .download-btn {
        width: 100%;
        justify-content: center;
    }

    footer .container {
        flex-direction: column;
        text-align: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1d1d1f;
        --card-bg: #2c2c2e;
        --text-primary: #f5f5f7;
        --text-secondary: #98989d;
        --border-color: #3a3a3c;
    }

    .upload-area:hover,
    .upload-area.dragover {
        background: #1a2a3a;
    }

    .device-btn:hover,
    .device-btn.active,
    .orientation-btn.active,
    .fit-btn.active {
        background: #1a2a3a;
    }

    .ad-placeholder {
        background: #2c2c2e;
        border-color: #3a3a3c;
    }
}
