/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Elements.html 스타일 반영 - 다크 퍼플/블루 톤 */
    --primary-gradient: linear-gradient(135deg, #5e42a6 0%, #b74e91 100%);
    --secondary-gradient: linear-gradient(135deg, #b74e91 0%, #5e42a6 100%);
    --dark-bg: #312450;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --accent-pink: #b74e91;
    --accent-purple: #5e42a6;
    --hover-color: #b74e91;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 2rem;
}

/* ===== Header 오버라이드 (main.css와 충돌 방지) ===== */
#header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10001;
}

/* Wrapper 상단 여백 추가 (헤더 높이만큼) */
#wrapper {
    padding-top: 5rem;
}

body {
    font-family: "Source Sans Pro", Helvetica, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.65;
    font-weight: 300;
    font-size: 16pt;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Main Container ===== */
.avatar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

/* ===== Header ===== */
.avatar-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-md) 0;
    border-bottom: solid 1px var(--border-color);
}

.title {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.075em;
    margin-bottom: var(--spacing-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-primary);
}

.beta-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--accent-pink);
    border-radius: 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    vertical-align: middle;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.05em;
}

/* ===== Avatar Display Section - 19.png Hedra 스타일 ===== */
.avatar-display-section {
    margin-bottom: var(--spacing-xl);
}

/* 41.png 스타일: Hedra 컨테이너 */
.hedra-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
}

/* 상단 컨트롤 래퍼 (이미지 밖) */
.top-controls-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9375rem; /* 15px - 3개 컨트롤을 650px에 딱 맞게 배치 */
    margin-bottom: var(--spacing-lg);
    /* 이미지 영역과 동일한 너비로 정렬 */
    width: 100%;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    flex-wrap: nowrap; /* 한 줄에 배치 */
}

/* 좌측: 카테고리 드롭다운 (1단계) */
.top-left-control {
    flex: 0 0 200px; /* 고정 너비 200px */
}

/* 중앙: 옵션 드롭다운 (2단계) */
.top-center-control {
    flex: 0 0 200px; /* 고정 너비 200px */
}

/* 중앙: 아바타 이미지 영역 (3:4 비율) */
.avatar-image-wrapper {
    position: relative; /* 오버레이 포지셔닝을 위해 필수 */
    width: 100%;
    max-width: 650px;
    height: 867px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.4); /* 여백 배경색 - 이미지 비율 유지 시 여백 표시 */
    border: solid 1px var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 아바타 배경 이미지 */
.background-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: filter 0.3s ease; /* 블러 전환 효과 */
}

/* 업로드된 사용자 이미지: 전체 표시, 비율 유지 */
.background-img.user-uploaded {
    object-fit: contain; /* 전체 이미지 표시, 여백 허용 */
}

/* 로딩 중 이미지 블러 효과 */
.avatar-image-wrapper.loading .background-img {
    filter: blur(8px);
}

/* ===== 참고 이미지 오버레이 (Take Photo) ===== */
.reference-image-overlay {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 160px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
                0 0 0 2px rgba(255, 255, 255, 0.5);
    z-index: 50;
    animation: fadeInUp 0.4s ease;
}

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

.reference-image-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(135deg, #5e42a6 0%, #b74e91 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.reference-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff;
}

.btn-remove-reference {
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s ease;
}

.btn-remove-reference:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.btn-remove-reference:active {
    transform: scale(0.9);
}

.reference-image-body {
    position: relative;
    width: 160px;
    height: 213px; /* 3:4 비율 유지 */
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    overflow: hidden;
}

.reference-image-body img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.3s ease;
}

.reference-image-body:hover img {
    transform: scale(1.05);
}

.reference-zoom-hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.reference-image-body:hover .reference-zoom-hint {
    opacity: 1;
}

/* ===== 참고 이미지 확대 모달 ===== */
.reference-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.reference-image-modal.active {
    display: flex;
}

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

.reference-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.reference-modal-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.btn-close-reference-modal {
    position: absolute;
    top: -40px;
    right: 0;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s ease;
}

.btn-close-reference-modal:hover {
    background: rgba(183, 78, 145, 0.8);
    border-color: rgba(183, 78, 145, 1);
    transform: rotate(90deg) scale(1.1);
}

.btn-close-reference-modal:active {
    transform: rotate(90deg) scale(0.95);
}

/* 하단: 채팅 래퍼 (이미지 밖) */
.bottom-chat-wrapper {
    width: 100%;
    max-width: 650px; /* 이미지와 동일한 너비 */
    margin: 0 auto;
    z-index: 100;
}

/* 채팅 입력 행 */
.chat-input-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
}

/* STYLE 버튼 (라운드 형태, 분홍색) */
.btn-style-label {
    background: var(--primary-gradient);
    color: #ffffff !important;
    border: none;
    padding: 0 1.5rem;
    height: 2.75rem;
    border-radius: 0.375rem;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.075em;
    text-transform: uppercase;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
    opacity: 0.9;
    flex-shrink: 0;
    min-width: 80px;
}

.btn-style-label:disabled {
    cursor: default;
    opacity: 0.9;
}

/* 커스텀 스타일 입력 필드 */
.chat-input-hedra {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.7rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: solid 1px rgba(255, 255, 255, 0.08);
    border-radius: 1.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.25s ease;
}

.chat-input-hedra:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px rgba(183, 78, 145, 0.15);
}

.chat-input-hedra::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Deprecated: 기존 오버레이 컨테이너 */
.avatar-background-image {
    display: none !important;
}

.background-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* 스타일 드롭다운 디자인 */
.style-dropdown-top {
    width: 100%; /* 부모 컨테이너 너비에 맞춤 */
    height: 44px;
    padding: 0 2.5rem 0 1.2rem;
    background: rgba(49, 36, 80, 0.35);
    backdrop-filter: blur(25px);
    border: solid 1px rgba(183, 78, 145, 0.25);
    border-radius: 22px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23b74e91' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.style-dropdown-top:hover {
    background: rgba(94, 66, 166, 0.45);
    border-color: var(--accent-pink);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(183, 78, 145, 0.3);
}

.style-dropdown-top:focus {
    background: rgba(94, 66, 166, 0.5);
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px rgba(183, 78, 145, 0.2);
}

.style-dropdown-top option {
    background: rgba(49, 36, 80, 0.98);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    padding: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: solid 1px rgba(183, 78, 145, 0.1);
}

/* 우측: Create Style 버튼 */
.top-right-control {
    flex: 0 0 220px; /* 고정 너비 220px - 버튼 텍스트 + 아이콘에 충분한 공간 */
}

/* Create Style 버튼 디자인 */
.btn-create-top {
    width: 100%; /* 부모 컨테이너 너비에 맞춤 */
    height: 44px;
    padding: 0 1.2rem;
    background: var(--primary-gradient);
    border: none;
    border-radius: 22px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(183, 78, 145, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-create-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(183, 78, 145, 0.6);
}

.btn-create-top:active {
    transform: translateY(0);
}

.btn-create-top i {
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    display: none !important;
}

/* Sample State (초기 샘플 이미지) */
.sample-state {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sample-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.sample-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* 16.png: sample overlay 제거, 컨트롤만 표시 */
.sample-overlay {
    display: none;
}

.sample-image-container:hover {
    opacity: 0.95;
}

.sample-text {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.075em;
    color: #ffffff;
    text-align: center;
    padding: 2rem;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.gallery-item:hover {
    transform: translateY(-5px);
    border-color: var(--hover-color);
    box-shadow: 0 0 20px rgba(183, 78, 145, 0.3);
}

.gallery-item:hover img {
    opacity: 0.8;
}

.gallery-item.active {
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px rgba(183, 78, 145, 0.3);
}

/* Gallery Add Button */
.gallery-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: solid 1px var(--border-color);
    transition: all 0.2s ease-in-out;
}

.add-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    transition: all 0.2s ease-in-out;
}

.add-text {
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    transition: all 0.2s ease-in-out;
}

.gallery-add:hover {
    background-color: var(--hover-color);
    border-color: var(--hover-color);
}

.gallery-add:hover .add-icon {
    transform: scale(1.1);
}

.gallery-add:hover .add-text {
    color: #ffffff;
}

/* ===== Upload Modal ===== */
.upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.upload-modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(49, 36, 80, 0.95);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background: var(--dark-bg);
    border: solid 1px var(--border-color);
    border-radius: var(--radius-md);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 10001;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* Modal Header */
.modal-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 2.5rem 2rem 1.5rem;
    border-bottom: solid 1px var(--border-color);
    position: relative;
    background: linear-gradient(135deg, rgba(94, 66, 166, 0.05) 0%, rgba(183, 78, 145, 0.05) 100%);
}

.modal-header h2 {
    font-size: 1.75rem;
    font-weight: 300;
    letter-spacing: 0.075em;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h2::before {
    content: "✨";
    font-size: 1.5rem;
    opacity: 0.8;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.05em;
    margin: 0;
    padding-left: 2rem;
}

/* 닫기 버튼 */
.btn-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    line-height: 1;
    opacity: 0.6;
}

.btn-close:hover {
    background: rgba(183, 78, 145, 0.15);
    color: var(--accent-pink);
    transform: rotate(90deg);
    opacity: 1;
}

.btn-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Upload Area (3:4 비율 - 세로가 더 긴 직사각형) */
.upload-area {
    position: relative;
    width: 100%;
    height: 533px;
    max-width: 400px;
    margin: 2rem auto;
    background: rgba(0, 0, 0, 0.3); /* 여백 배경색 */
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--accent-pink);
    background: rgba(183, 78, 145, 0.05);
}

.upload-area:hover .upload-icon {
    transform: scale(1.1);
    color: var(--accent-pink);
}

.upload-icon {
    font-size: 4rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease-in-out;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.upload-link {
    color: var(--accent-pink);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 400;
}

.upload-link:hover {
    color: var(--accent-purple);
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 300;
    line-height: 1.4;
    font-style: italic;
    margin-top: 0.5rem;
}

/* 이미지 미리보기 (3:4 비율) */
.image-preview {
    position: relative;
    width: 100%;
    height: 533px;
    max-width: 400px;
    margin: 2rem auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: solid 1px var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.3); /* 여백 배경색 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 전체 이미지 표시, 여백 허용 */
    object-position: center;
    display: block;
}

.btn-remove-preview {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(183, 78, 145, 0.9);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.btn-remove-preview:hover {
    background: var(--accent-pink);
    transform: scale(1.1);
}

.upload-area.has-image .upload-icon,
.upload-area.has-image .upload-text,
.upload-area.has-image .upload-hint {
    display: none;
}

.upload-area.has-image {
    padding: 0;
    border: solid 1px var(--border-color);
    border-style: solid;
    background: transparent;
}

.upload-area.has-image .image-preview {
    margin: 0;
    border-radius: var(--radius-md);
    border: none;
    box-shadow: none;
}

/* ===== Modal Actions (16.png Style Enhanced) ===== */
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 2rem;
    position: relative;
    z-index: 1000;
}

.btn-modal-action {
    padding: 14px 24px;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    min-width: 160px;
    justify-content: center;
    text-transform: none;
    letter-spacing: 0.025em;
    position: relative;
    z-index: 1001;
}

.btn-capture-image {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(183, 78, 145, 0.35);
}

.btn-capture-image:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(183, 78, 145, 0.5);
}

.btn-take-photo {
    background: var(--accent-pink);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(183, 78, 145, 0.35);
}

.btn-take-photo:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(183, 78, 145, 0.5);
}

.btn-retake-photo {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.btn-retake-photo:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.btn-use-image {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.35);
    z-index: 10002 !important;
}

.btn-use-image:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.5);
}

.btn-modal-action:active {
    transform: translateY(0) scale(0.97);
}

.btn-modal-action i {
    font-size: 1.1rem;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(49, 36, 80, 0.98);
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

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

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes flash {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

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

/* Face Guide */
.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 320px;
    border: 3px dashed rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
    animation: pulse 2s infinite;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
}

/* Camera Container */
.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Success Feedback */
.success-feedback {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
    z-index: 30000;
    animation: slideInUp 0.3s ease;
}

/* ===== Gallery Section ===== */
.avatar-gallery-section {
    padding: var(--spacing-lg) 0;
}

.gallery-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: solid 1px var(--border-color);
}

.gallery-header h3 {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.075em;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.gallery-header i {
    color: var(--accent-pink);
}

/* ===== Gallery Grid Layout ===== */
.avatar-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--card-bg);
    border: solid 1px var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Responsive - 41.png 스타일 (3:4 비율 유지) */
@media (max-width: 980px) {
    .hedra-container {
        max-width: 100%;
        padding: 1.5rem 1rem;
        gap: 1.25rem;
    }
    
    .avatar-image-wrapper {
        height: 700px;
        max-width: 525px;
    }
    
    .bottom-chat-wrapper {
        max-width: 525px;
    }
    
    .style-dropdown-top {
        min-width: 150px;
        font-size: 0.85rem;
        padding: 0.5rem 2rem 0.5rem 0.85rem;
    }
    
    .btn-create-top {
        padding: 0.5rem 1.25rem;
        font-size: 0.8rem;
    }
    
    .chat-input-row {
        gap: 0.5rem;
    }
    
    .chat-input-hedra {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-voice-mic {
        width: 44px;
        height: 40px;
        font-size: 1rem;
        border-radius: 10px;
    }
    
    .btn-chat-send {
        padding: 0 1.5rem;
        font-size: 0.9rem;
        height: 40px;
        border-radius: 20px;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .btn-modal-action {
        width: 100%;
    }
    
    /* 모달 내부 업로드 영역 반응형 (3:4 비율 유지) */
    .upload-area {
        height: 480px;
        max-width: 360px;
    }
    
    .image-preview {
        height: 480px;
        max-width: 360px;
    }
    
    .face-guide-circle {
        width: 240px;
        height: 305px;
    }
}

@media (max-width: 736px) {
    .avatar-image-wrapper {
        height: 600px;
        max-width: 450px;
    }
    
    .bottom-chat-wrapper {
        max-width: 450px;
    }
    
    .style-dropdown-top {
        min-width: 120px;
        font-size: 0.8rem;
        padding: 0.45rem 1.75rem 0.45rem 0.75rem;
    }
    
    .btn-create-top {
        padding: 0.45rem 1rem;
        font-size: 0.75rem;
    }
    
    .btn-create-top i {
        display: none;
    }
    
    .chat-input-row {
        gap: 0.4rem;
    }
    
    .chat-input-hedra {
        padding: 0.55rem 0.85rem;
        font-size: 0.85rem;
    }
    
    .btn-voice-mic {
        width: 38px;
        height: 36px;
        font-size: 0.95rem;
        border-radius: 9px;
    }
    
    .btn-chat-send {
        padding: 0 1.25rem;
        font-size: 0.85rem;
        height: 36px;
        border-radius: 18px;
    }
    
    .title {
        font-size: 1.75rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .avatar-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    /* 모달 내부 업로드 영역 반응형 (3:4 비율 유지) */
    .upload-area {
        height: 400px;
        max-width: 300px;
    }
    
    .image-preview {
        height: 400px;
        max-width: 300px;
    }
    
    .face-guide-circle {
        width: 200px;
        height: 255px;
    }
}

/* 추가: 작은 모바일 화면 (3:4 비율 유지) */
@media (max-width: 480px) {
    .hedra-container {
        padding: 1rem 0.5rem;
        gap: 1rem;
    }
    
    .avatar-image-wrapper {
        height: 500px;
        max-width: 375px;
    }
    
    .bottom-chat-wrapper {
        max-width: 375px;
    }
    
    .chat-input-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .btn-style-label {
        width: 100%;
        text-align: center;
    }
    
    .chat-input-hedra {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .btn-voice-mic {
        width: 36px;
        height: 34px;
        font-size: 0.9rem;
    }
    
    .btn-chat-send {
        padding: 0 1rem;
        font-size: 0.8rem;
        height: 34px;
    }
    
    /* 모달 내부 업로드 영역 반응형 (3:4 비율 유지) */
    .upload-area {
        height: 360px;
        max-width: 270px;
        padding: 1.5rem;
    }
    
    .image-preview {
        height: 360px;
        max-width: 270px;
    }
    
    .face-guide-circle {
        width: 180px;
        height: 230px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .upload-text {
        font-size: 1rem;
    }
    
    .avatar-gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: var(--spacing-sm);
    }
}

/* ===== 반응형: 참고 이미지 오버레이 ===== */
@media (max-width: 768px) {
    .reference-image-overlay {
        width: 120px;
        bottom: 15px;
        right: 15px;
    }
    
    .reference-image-body {
        width: 120px;
        height: 160px; /* 3:4 비율 유지 */
    }
    
    .reference-label {
        font-size: 0.65rem;
    }
    
    .btn-remove-reference {
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
    }
    
    .reference-zoom-hint {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .reference-image-overlay {
        width: 100px;
        bottom: 10px;
        right: 10px;
    }
    
    .reference-image-body {
        width: 100px;
        height: 133px; /* 3:4 비율 유지 */
    }
    
    .reference-image-header {
        padding: 6px 10px;
    }
    
    .reference-label {
        font-size: 0.6rem;
    }
    
    .btn-remove-reference {
        width: 16px;
        height: 16px;
        font-size: 0.55rem;
    }
    
    .btn-close-reference-modal {
        width: 35px;
        height: 35px;
        top: -35px;
        font-size: 1.3rem;
    }
}

/* ===== 반응형: 모바일에서 3개 컨트롤 세로 스택 ===== */
@media (max-width: 768px) {
    .top-controls-wrapper {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .top-left-control,
    .top-center-control,
    .top-right-control {
        flex: 1 1 100%;
        width: 100%;
    }
    
    .style-dropdown-top,
    .btn-create-top {
        width: 100%;
    }
}

/* getstyle.html 햄버거 메뉴 및 모바일 네비게이션 스타일 (파일 하단에 추가) */
.mobile-hamburger-wrapper {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  left: auto;
  z-index: 2001;
  display: none;
}
.mobile-hamburger-btn {
  background: none;
  border: none;
  border-radius: 0.6rem;
  width: 32px;
  height: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: none;
  padding: 0;
  transition: transform 0.35s cubic-bezier(0.4,0.2,0.2,1);
}
.mobile-hamburger-btn.rotated {
  transform: rotate(90deg);
}
.hamburger-bar {
  width: 24px;
  height: 0.7px;
  background: rgba(255,255,255,0.7);
  margin: 4px 0;
  border-radius: 2px;
  transition: background 0.18s;
}
.mobile-hamburger-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  max-width: 100vw;
  height: 220px;
  background: linear-gradient(90deg, #8B5CF6 0%, #EC4899 100%);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(139,92,246,0.13);
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  z-index: 9999;
  display: none;
  animation: fadeInMenu 0.3s ease;
}
@keyframes fadeInMenu {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
.mobile-hamburger-content {
  padding: 28px 18px 0 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 140px;
  justify-content: flex-start;
}
.mobile-hamburger-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 100vw;
}
.mobile-hamburger-list li {
  margin-bottom: 0;
  padding: 0;
  width: 100%;
}
.mobile-hamburger-list a {
  font-family: 'Pretendard', 'Montserrat', 'Apple SD Gothic Neo', 'Noto Sans KR', Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 12px 0 10px 0;
  letter-spacing: 0.01em;
  border-bottom: none;
  background: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  position: relative;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-hamburger-list a:hover {
  background: rgba(255,255,255,0.10);
  color: #E3D6FF;
}
.menu-close-x {
  position: absolute;
  top: 12px;
  right: 18px;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 600;
  background: none;
  border: none;
  box-shadow: none;
  cursor: pointer;
  line-height: 1;
  text-align: center;
  z-index: 1001;
}
@media (max-width: 900px) {
  .mobile-hamburger-wrapper { display: block; }
  .mobile-hamburger-list a.active {
    font-weight: 800;
    color: #fff !important;
    background: rgba(162,89,255,0.13);
    border-radius: 0.9em;
    position: relative;
    box-shadow: none;
    padding-left: 1.2em;
    /* 좌측 컬러 바 */
  }
  .mobile-hamburger-list a.active::before {
    content: '';
    display: block;
    position: absolute;
    left: 0.3em;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 1.7em;
    border-radius: 3px;
    background: linear-gradient(180deg, #a259ff 0%, #6a00f4 100%);
    box-shadow: 0 0 6px 1px #a259ff44;
  }
}
