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

:root {
    --bg: #faf9f7;
    --text: #1a1a1a;
    --text-light: #666;
    --accent: #c5a880;
    --accent-dark: #a88b64;
    --card-bg: #fff;
    --border: #e8e4df;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --radius: 12px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3 { font-family: 'Playfair Display', serif; }

.page { display: none; }
.page.active { display: block; }

/* NAVBAR */
.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    background: rgba(250,249,247,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}
.nav-container {
    max-width: 1200px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 24px;
}
.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem; font-weight: 700;
    color: var(--text); text-decoration: none;
}
.nav-links { display: flex; gap: 24px; }
.nav-links a {
    color: var(--text-light); text-decoration: none;
    font-size: 0.95rem; font-weight: 500;
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent-dark); }

/* HERO */
.hero {
    padding: 140px 24px 80px;
    text-align: center;
    background: linear-gradient(180deg, #f5f0eb 0%, var(--bg) 100%);
}
.hero-content { max-width: 680px; margin: 0 auto; }
.hero h1 {
    font-size: 3rem; line-height: 1.15;
    margin-bottom: 20px;
}
.hero-subtitle {
    font-size: 1.15rem; color: var(--text-light);
    margin-bottom: 32px; line-height: 1.7;
}

/* BUTTONS */
.btn-primary {
    display: inline-block;
    background: var(--accent); color: #fff;
    border: none; padding: 14px 36px;
    font-size: 1rem; font-weight: 600;
    border-radius: 8px; cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    display: inline-block;
    background: transparent; color: var(--accent-dark);
    border: 2px solid var(--accent);
    padding: 10px 24px;
    font-size: 0.9rem; font-weight: 500;
    border-radius: 8px; cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { background: var(--accent); color: #fff; }

/* EXAMPLES */
.examples-section {
    padding: 80px 24px;
    max-width: 1400px; margin: 0 auto;
    text-align: center;
}
.examples-section h2 { font-size: 2.4rem; margin-bottom: 8px; }
.section-subtitle { color: var(--text-light); margin-bottom: 48px; }

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(560px, 1fr));
    gap: 40px;
}
.example-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.example-images {
    display: grid; grid-template-columns: 1fr 1fr;
    position: relative;
}
.example-images img {
    width: 100%; height: 520px; object-fit: cover;
}
.example-label {
    position: absolute; bottom: 12px;
    background: rgba(0,0,0,0.65); color: #fff;
    padding: 6px 14px; border-radius: 4px;
    font-size: 0.9rem; font-weight: 500;
    letter-spacing: 0.02em;
}
.example-label.before { left: 12px; }
.example-label.after { right: 12px; }

/* HOW IT WORKS */
.how-it-works {
    padding: 80px 24px;
    background: #f0ece6;
    text-align: center;
}
.how-it-works h2 { font-size: 2rem; margin-bottom: 48px; }
.steps {
    display: flex; gap: 40px;
    justify-content: center; flex-wrap: wrap;
    max-width: 900px; margin: 0 auto;
}
.step {
    flex: 1; min-width: 220px; max-width: 280px;
    padding: 32px 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.step-number {
    width: 48px; height: 48px; margin: 0 auto 16px;
    background: var(--accent); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 700;
    font-family: 'Playfair Display', serif;
}
.step h3 { font-size: 1.1rem; margin-bottom: 8px; }
.step p { font-size: 0.9rem; color: var(--text-light); }

/* TRY-ON PAGE */
.tryon-container {
    max-width: 1200px; margin: 0 auto;
    padding: 100px 24px 60px;
}
.tryon-container h2 {
    text-align: center; font-size: 2rem;
    margin-bottom: 40px;
}
.tryon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}
.tryon-step {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.tryon-step h3 {
    font-size: 1.1rem; margin-bottom: 16px;
    color: var(--accent-dark);
}

/* UPLOAD ZONE */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    min-height: 280px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.2s, background 0.2s;
}
.upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(197,168,128,0.05);
}
.upload-placeholder {
    text-align: center; padding: 40px; cursor: pointer;
    color: var(--text-light);
}
.upload-placeholder svg { margin-bottom: 12px; opacity: 0.5; }
.upload-placeholder p { font-size: 0.95rem; }
.upload-placeholder span { font-size: 0.85rem; color: var(--accent); }
.upload-preview { position: relative; width: 100%; text-align: center; }
.upload-preview img {
    max-width: 100%; max-height: 300px;
    border-radius: 8px; object-fit: contain;
}
.btn-remove {
    position: absolute; top: 4px; right: 4px;
    background: rgba(0,0,0,0.6); color: #fff;
    border: none; width: 28px; height: 28px;
    border-radius: 50%; cursor: pointer;
    font-size: 1.2rem; line-height: 1;
}
.btn-remove-small {
    background: rgba(0,0,0,0.4); color: #fff;
    border: none; width: 20px; height: 20px;
    border-radius: 50%; cursor: pointer;
    font-size: 0.9rem; vertical-align: middle; margin-left: 4px;
}

/* CATALOG FILTERS */
.catalog-filters {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 12px;
}
.filter-group {
    display: flex; align-items: center; gap: 8px;
}
.filter-group label {
    font-size: 0.75rem; font-weight: 600;
    color: var(--text-light); white-space: nowrap;
    min-width: 42px;
}
.filter-pills {
    display: flex; flex-wrap: wrap; gap: 4px;
}
.filter-pill {
    background: var(--bg); color: var(--text-light);
    border: 1px solid var(--border);
    padding: 3px 10px; font-size: 0.7rem;
    border-radius: 16px; cursor: pointer;
    transition: all 0.2s; font-weight: 500;
    white-space: nowrap;
}
.filter-pill:hover { border-color: var(--accent); color: var(--accent-dark); }
.filter-pill.active {
    background: var(--accent); color: #fff;
    border-color: var(--accent);
}

/* DRESS CATALOG */
.dress-catalog {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px; max-height: 560px; overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 12px;
}
.dress-card {
    position: relative;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 10px; overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s;
}
.dress-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.dress-card.selected { border-color: var(--accent-dark); box-shadow: 0 0 0 2px var(--accent); }
.dress-card img {
    width: 100%; height: 220px; object-fit: cover;
    display: block;
}
.dress-card .zoom-icon {
    position: absolute; top: 8px; right: 8px;
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.92);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.dress-card:hover .zoom-icon { opacity: 1; }
.dress-card .zoom-icon svg { width: 16px; height: 16px; color: var(--accent-dark); }
.dress-card .selected-badge {
    position: absolute; top: 8px; left: 8px;
    background: var(--accent-dark); color: #fff;
    font-size: 0.7rem; font-weight: 600;
    padding: 4px 10px; border-radius: 999px;
    display: none;
}
.dress-card.selected .selected-badge { display: block; }
.dress-info {
    padding: 8px 10px 10px;
}
.dress-card .dress-name {
    font-size: 0.85rem;
    font-weight: 500; text-align: center;
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis;
}
.dress-meta {
    display: flex; align-items: center; justify-content: center;
    gap: 5px; font-size: 0.72rem; color: var(--text-light);
    margin-top: 3px;
}
.dress-color {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; border: 1px solid var(--border);
    flex-shrink: 0;
}
.no-results {
    grid-column: 1 / -1; text-align: center;
    color: var(--text-light); font-size: 0.85rem;
    padding: 40px 0;
}

.upload-own-dress { margin-top: 8px; text-align: center; }

/* RESULT */
.result-area {
    min-height: 280px;
    display: flex; align-items: center; justify-content: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
}
.result-placeholder { text-align: center; color: var(--text-light); padding: 40px; }
.result-loading { text-align: center; color: var(--text-light); }
.result-loading span { font-size: 0.85rem; }
.spinner {
    width: 48px; height: 48px; margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#result-image img {
    max-width: 100%; max-height: 400px;
    border-radius: 8px; object-fit: contain;
}
.result-actions {
    display: flex; gap: 12px; margin-top: 16px;
    justify-content: center;
}

/* GENERATE BUTTON */
.btn-generate {
    display: block; width: 100%; max-width: 400px;
    margin: 0 auto;
    background: var(--accent); color: #fff;
    border: none; padding: 16px 36px;
    font-size: 1.1rem; font-weight: 600;
    border-radius: 8px; cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-generate:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.btn-generate:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* FOOTER */
footer {
    text-align: center; padding: 32px 24px;
    color: var(--text-light); font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* DRESS DETAIL MODAL */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 24px;
    backdrop-filter: blur(2px);
    animation: modalFade 0.18s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: var(--card-bg);
    border-radius: 14px;
    max-width: 960px; width: 100%;
    max-height: 92vh; overflow: hidden;
    position: relative;
    box-shadow: 0 24px 60px rgba(0,0,0,0.3);
    animation: modalSlide 0.22s ease-out;
}
@keyframes modalSlide { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
    position: absolute; top: 12px; right: 12px;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.92);
    border: none; border-radius: 50%;
    font-size: 1.6rem; line-height: 1; cursor: pointer;
    color: var(--text);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.15s, transform 0.1s;
}
.modal-close:hover { background: #fff; transform: scale(1.05); }
.modal-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    max-height: 92vh;
}
.modal-image-wrap {
    background: #f4f1ec;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    min-height: 400px;
}
.modal-image-wrap img {
    width: 100%; height: 100%;
    object-fit: contain;
    max-height: 92vh;
}
.modal-details {
    padding: 36px 32px;
    display: flex; flex-direction: column;
    gap: 14px;
}
.modal-details h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    color: var(--text);
    margin: 0;
}
.modal-meta {
    display: flex; flex-wrap: wrap; gap: 10px;
}
.modal-meta-item {
    display: inline-flex; align-items: center; gap: 6px;
    background: #f7f3ec;
    color: var(--text);
    padding: 6px 12px; border-radius: 999px;
    font-size: 0.85rem;
}
.modal-details p {
    color: var(--text-light);
    line-height: 1.55;
    font-size: 0.95rem;
    margin: 0;
}
.modal-actions {
    margin-top: auto;
    display: flex; flex-direction: column;
    gap: 10px;
}
.modal-select-btn {
    width: 100%;
    text-align: center;
}
.modal-source-link {
    display: inline-block; width: 100%;
    text-align: center;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 10px 16px;
}
.modal-attribution {
    font-size: 0.72rem;
    color: var(--text-light);
    text-align: center;
    margin: 0;
    padding-top: 6px;
}
.modal-attribution a { color: var(--accent-dark); text-decoration: none; }
.modal-attribution a:hover { text-decoration: underline; }

/* RESPONSIVE */
@media (max-width: 900px) {
    .tryon-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2.2rem; }
    .examples-grid { grid-template-columns: 1fr; }
    .modal-grid { grid-template-columns: 1fr; }
    .modal-image-wrap { max-height: 50vh; min-height: 280px; }
    .modal-details { padding: 24px; }
}
@media (max-width: 600px) {
    .hero h1 { font-size: 1.8rem; }
    .steps { flex-direction: column; align-items: center; }
    .dress-catalog { grid-template-columns: 1fr; max-height: 480px; }
    .dress-card img { height: 280px; }
}
