/* Personal Color Pro - HAIRGATOR 테마 통일 CSS (2모드 최적화) */

/* ========== HAIRGATOR 색상 변수 ========== */
:root {
    --primary-color: #E91E63;
    --primary-dark: #C2185B;
    --primary-light: #F43D7A;
    --primary-pink: #E91E63;
    --secondary-rose: #8E24AA;
    --light-pink: #FCE4EC;
    --dark-rose: #C2185B;
    --face-color: #10b981;
    --success: #4CAF50;
    --warning: #FF9800;
    --error: #F44336;
    --info: #2196F3;
    --text: #333;
    --text-secondary: #666;
    --bg: #ffffff;
    --bg-light: #f5f5f5;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --border-radius: 8px;
}

/* 남성 테마 (블루) */
body.male-theme {
    --primary-color: #4A90E2;
    --primary-dark: #3A7BC8;
    --primary-light: #5BA0F2;
    --primary-pink: #4A90E2;
    --dark-rose: #3A7BC8;
}

/* ========== 기본 스타일 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 50%, #fafafa 100%);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
}

/* ========== 로딩 화면 (HAIRGATOR 로고 스타일) ========== */
.loading-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    z-index: 9999;
    flex-direction: column;
    overflow: hidden;
}

.loading-content {
    text-align: center;
    position: relative;
    z-index: 1;
    padding: 3rem 4rem;
}

.loading-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 1.5rem;
    object-fit: contain;
    animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.85; }
}

.loading-title {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.loading-text {
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 400;
    color: #555;
}

.loading-subtext {
    font-size: 12px;
    color: #999;
    margin-bottom: 24px;
}

.loading-progress {
    width: 180px;
    height: 2px;
    background: #eee;
    border-radius: 1px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 1px;
}

/* ========== 메인 앱 ========== */
.main-app {
    display: none;
    min-height: 100vh;
    min-height: 100dvh; /* 모바일 브라우저 주소창 대응 */
}

.main-app.loaded {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

/* ========== 헤더 (세련된 디자인) ========== */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    position: relative;
}

/* ⭐ 닫기 버튼 */
.close-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.close-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.app-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.app-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* ========== 메인 콘텐츠 ========== */
.main-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh; /* 모바일 브라우저 주소창 대응 */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 모드 선택 화면일 때 */
#mode-selection {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 4rem);
    min-height: calc(100dvh - 4rem); /* 모바일 브라우저 주소창 대응 */
}

/* ========== 섹션 ========== */
.section {
    display: none;
}

.section.active {
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

#mode-selection.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#ai-analysis.active,
#draping-mode.active {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 50%, #f8f9fa 100%);
    z-index: 100;
    overflow-y: auto;
    /* 아이폰 노치/홈바 영역 대응 (safe-area + 기본 패딩 결합) */
    padding-top: calc(env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    box-sizing: border-box;
}

/* 전체화면 모드일 때 섹션 네비게이션 - 스크롤해도 콘텐츠가 비치지 않도록 */
#ai-analysis.active .section-nav,
#draping-mode.active .section-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    margin: 0 -20px 0 -20px;
    /* 아이폰 노치 영역 대응 */
    padding: calc(50px + env(safe-area-inset-top, 0px)) 20px 25px 20px;
    border-radius: 0;
    border-bottom: 2px solid #e0e0e0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#ai-analysis.active .section-title,
#draping-mode.active .section-title {
    color: #333;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: #333;
    background-clip: unset;
}

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

/* ========== 섹션 네비게이션 ========== */
.section-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    border-radius: 16px;
    border: none;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.1);
}

.section-title {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #3a3a3c;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 0;
    font-size: 0;
    color: transparent;
    position: relative;
}

.nav-btn::after {
    content: '';
    width: 12px;
    height: 12px;
    border-left: 2.5px solid #ffffff;
    border-bottom: 2.5px solid #ffffff;
    transform: rotate(45deg) translateX(2px);
    display: block;
}

.nav-btn:hover {
    background: #4a4a4c;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Male theme (라이트모드) */
body.male-theme .nav-btn {
    background: #e5e5ea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.male-theme .nav-btn::after {
    border-left-color: #3a3a3c;
    border-bottom-color: #3a3a3c;
}

body.male-theme .nav-btn:hover {
    background: #d1d1d6;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* GUIDE 버튼 스타일 - 쨍한 핑크색 */
.nav-btn.guide-btn {
    width: auto;
    height: auto;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    background: #ff1493;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 20, 147, 0.4);
}

.nav-btn.guide-btn::after {
    content: none;
    display: none;
}

.nav-btn.guide-btn:hover {
    background: #ff69b4;
    box-shadow: 0 4px 12px rgba(255, 20, 147, 0.5);
}

body.male-theme .nav-btn.guide-btn {
    background: #ff1493;
    border: none;
    color: #ffffff;
}

body.male-theme .nav-btn.guide-btn:hover {
    background: #ff69b4;
}

/* ========== 모드 선택 ========== */
.mode-title {
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

/* 플로팅 닫기 버튼 (텍스트 스타일) */
.close-btn-floating {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.close-btn-floating:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.mode-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.mode-card {
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 0;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: none;
}

/* 이미지 기반 모드 카드 */
.mode-card-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
    padding: 0;
}

.mode-card-img-wrapper {
    width: 100%;
    max-width: 100%;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    margin-bottom: 1rem;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-card-img-wrapper:hover {
    box-shadow: 0 20px 50px rgba(233, 30, 99, 0.2);
    border-color: rgba(233, 30, 99, 0.3);
}

/* 말풍선 스타일 설명글 */
.mode-description-bubble {
    position: relative;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 1rem;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    color: #444;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    white-space: pre-line;
}

/* 말풍선 꼬리 (위쪽 방향) */
.mode-description-bubble::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid rgba(255, 255, 255, 0.5);
}

.mode-description-bubble::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid rgba(255, 255, 255, 0.9);
}

.mode-card-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s ease;
    object-fit: contain;
}

.mode-card-image:hover .mode-card-img {
    transform: scale(1.03);
}

.mode-card-image .mode-btn {
    width: 80%;
    max-width: 250px;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    transform: scaleX(0);
    transition: transform 0.4s ease;
}

.mode-card:hover::before {
    transform: scaleX(1);
}

.mode-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(-12px);
}

.mode-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    display: block;
}

.mode-card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary-pink);
}

.mode-description {
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.mode-features {
    list-style: none;
    text-align: left;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.mode-features li {
    position: relative;
    padding: 0.5rem 0 0.5rem 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.mode-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

.mode-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: none;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.35);
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(233, 30, 99, 0.45);
}

.mode-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
}

/* ========== AI 분석 모드 ========== */
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}


.camera-container {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.12);
    border: none;
    position: relative;
    overflow: hidden;
}

.camera-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.video-container {
    position: relative;
    width: 100%;
    height: 400px;
    max-height: 50vh;
    background: linear-gradient(135deg, #f0f0f5 0%, #e8e8f0 100%);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

#ai-camera {
    width: 100%;
    height: 100%;
    max-height: 400px;
    object-fit: cover;
    transform: scaleX(-1); /* 거울 효과 */
}

#draping-camera {
    display: none; /* video는 숨기고 canvas로 표시 */
}

#draping-canvas {
    width: 100%;
    height: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 12px;
}

#ai-face-overlay,
#draping-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 250px;
    border: 3px dashed var(--primary-pink);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-pink);
    font-weight: 600;
    background: rgba(255,255,255,0.1);
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
    z-index: 5;
}

.camera-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.9rem 1.8rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}

.control-btn:active:not(:disabled) {
    transform: translateY(-1px);
}

.control-btn:disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

/* ========== 분석 패널 (오른쪽) ========== */
.analysis-panel {
    background: #ffffff;
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    position: relative;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.analysis-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.analysis-panel h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 700;
}

.analysis-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.analysis-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem;
    background: white;
    border-radius: 12px;
    border-left: 4px solid #e0e7ff;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.analysis-step.active {
    border-left-color: var(--primary-color);
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
    transform: translateX(8px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
}

.analysis-step.completed {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #f0fdf9 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.analysis-step.active .step-number {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    animation: pulseStep 1.5s infinite;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.analysis-step.completed .step-number {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

@keyframes pulseStep {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.step-content h4 {
    margin-bottom: 0.5rem;
    color: var(--text);
    font-size: 1rem;
}

.step-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ========== AI 분석 결과 ========== */
.analysis-results {
    margin-top: 2rem;
    padding: 2.5rem;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-radius: 20px;
    border: none;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.15);
    position: relative;
    overflow: hidden;
}

.analysis-results::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #059669);
}

.result-summary {
    text-align: center;
    margin-bottom: 2rem;
}

.season-result {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.confidence-score {
    display: inline-block;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.color-analysis-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.color-data,
.lab-data,
.expert-analysis {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.color-data:hover,
.lab-data:hover,
.expert-analysis:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
}

.skin-color-sample {
    border: 3px solid white;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ========== 드래이핑 모드 ========== */
.draping-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.draping-camera-section {
    background: #ffffff;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

.draping-camera-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.color-palette-section {
    background: #ffffff;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

.color-palette-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.color-palette-section h3 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
}

/* ========== 계절 탭 ========== */
.season-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.season-tab {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    color: #333;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.season-tab:hover {
    border-color: var(--primary-color);
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.season-tab.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

/* ========== 색상 그리드 ========== */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.color-item {
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.color-item:hover {
    transform: scale(1.15) translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.color-item.selected {
    border-color: var(--primary-color);
    border-width: 4px;
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ========== 색상 조정 ========== */
.color-adjustments {
    margin-bottom: 2rem;
}

.color-adjustments h4 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.adjustment-slider {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1.2rem;
    padding: 1.2rem;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

.adjustment-slider label {
    flex-shrink: 0;
    width: 70px;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.adjustment-slider input[type="range"] {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.adjustment-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
}

.adjustment-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

.adjustment-slider input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
}

.adjustment-slider input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

.adjustment-slider span {
    flex-shrink: 0;
    width: 48px;
    text-align: center;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1rem;
}

/* ========== 저장된 색상 ========== */
.saved-colors {
    margin-top: 2.5rem;
}

.saved-colors h4 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.saved-colors-list {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.saved-color-item {
    border-radius: 50%;
    border: 3px solid white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.saved-color-item:hover {
    transform: scale(1.15) translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2), 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* ========== 비교 섹션 ========== */
.comparison-section {
    margin-top: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    border: none;
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.15);
    position: relative;
    overflow: hidden;
}

.comparison-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2196F3, #1976D2);
}

.comparison-section h4 {
    color: #2196F3;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
}

.comparison-controls {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.comparison-btn {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
}

.comparison-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.35);
}

/* ========== 결과 섹션 ========== */
.results-section {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border-radius: 24px;
    padding: 3rem;
    margin-top: 2rem;
    box-shadow: 0 12px 48px rgba(16, 185, 129, 0.2);
    border: none;
    position: relative;
    overflow: hidden;
}

.results-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #10b981, #059669);
}

.results-section h3 {
    color: #10b981;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2.5rem;
}

.final-results {
    text-align: center;
    margin-bottom: 2rem;
}

.result-header h3 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.confidence {
    display: inline-block;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0.7rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.result-colors {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.result-color {
    box-shadow: var(--shadow);
    border: 3px solid white;
    transition: all 0.3s ease;
}

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

/* ========== 제품 추천 ========== */
.product-recommendations {
    margin-top: 3rem;
}

.product-recommendations h4 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
    text-align: center;
}

.brand-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.brand-section {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.brand-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), var(--primary-dark));
}

.brand-section:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
}

.brand-section h5 {
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.product-item {
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid #e0e7ff;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text);
}

.product-item:hover {
    background: linear-gradient(135deg, #e0e7ff 0%, #f8f9ff 100%);
    transform: translateX(8px);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

/* ========== 토스트 메시지 ========== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    background: white;
    padding: 1.2rem 1.8rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--info);
    max-width: 380px;
    font-weight: 500;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    animation: toastSlideIn 0.4s ease;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}
.toast.error {
    border-left-color: #F44336;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}
.toast.warning {
    border-left-color: #FF9800;
    background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
}
.toast.info {
    border-left-color: #2196F3;
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

/* ========== 반응형 디자인 ========== */

/* 모바일 우선: 작은 화면에서 1단 레이아웃 */
@media (max-width: 600px) {
    .mode-cards {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        margin: 0 auto 2rem !important;
        padding: 0 !important;
        gap: 1.5rem !important;
    }

    .mode-card-image {
        width: 100%;
        max-width: 100%;
    }

    .mode-card-img-wrapper {
        width: 100%;
        max-width: 100%;
    }

    .mode-card-img {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .main-content {
        padding: 1rem;
        max-width: 100%;
        overflow-x: hidden;
    }

    #mode-selection {
        min-height: auto;
        padding: 1rem 0;
    }

    .mode-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .mode-description-bubble {
        font-size: 12px;
        padding: 10px 12px;
    }

    .mode-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 1024px) {
    .analysis-grid,
    .draping-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .mode-cards {
        grid-template-columns: 1fr;
        max-width: 500px;
        margin: 0 auto 3rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .mode-cards {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .mode-card {
        padding: 0;
    }

    .mode-card-image .mode-btn {
        width: 100%;
        max-width: none;
    }

    .close-btn-floating {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .video-container {
        height: 280px;
        max-height: 35vh;
    }

    #ai-camera,
    #draping-camera {
        max-height: 280px;
    }

    .season-tabs {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .season-tab {
        padding: 0.8rem 0.5rem;
        font-size: 0.85rem;
    }

    .section-nav {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    /* 드래이핑 모드 모바일 최적화 */
    .draping-layout {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .draping-camera-section {
        padding: 1rem;
        border-radius: 12px;
    }

    .color-palette-section {
        padding: 1rem;
        border-radius: 12px;
    }

    .color-palette-section h3 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .color-adjustments h4 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .adjustment-slider {
        padding: 0.8rem;
        gap: 0.8rem;
    }

    .adjustment-slider label {
        width: 50px;
        font-size: 0.85rem;
    }

    .adjustment-slider span {
        width: 40px;
        font-size: 0.9rem;
    }

    .camera-controls,
    .comparison-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-btn,
    .comparison-btn {
        width: 100%;
    }

    .analysis-steps {
        gap: 0.8rem;
    }

    .analysis-step {
        padding: 0.8rem;
        flex-direction: column;
        text-align: center;
    }

    .brand-sections {
        grid-template-columns: 1fr;
    }

    /* 분석 결과 2단 그리드 → 모바일에서 1단 */
    .results-grid {
        grid-template-columns: 1fr !important;
    }

    /* 모바일에서 카메라 컨테이너 스크롤 가능하도록 */
    .camera-container {
        overflow: visible !important;
    }

    /* 모바일에서 분석 결과 표시 + 스크롤바 */
    .realtime-results-wrapper {
        margin-top: 20px;
    }

    .realtime-results,
    #realtime-results-container {
        max-height: 50vh;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #ffffff rgba(255,255,255,0.3);
    }

    .realtime-results::-webkit-scrollbar,
    #realtime-results-container::-webkit-scrollbar {
        width: 8px;
    }

    .realtime-results::-webkit-scrollbar-track,
    #realtime-results-container::-webkit-scrollbar-track {
        background: rgba(255,255,255,0.3);
        border-radius: 4px;
    }

    .realtime-results::-webkit-scrollbar-thumb,
    #realtime-results-container::-webkit-scrollbar-thumb {
        background: #ffffff;
        border-radius: 4px;
    }

    /* 분석 패널도 스크롤 가능 */
    .analysis-panel {
        overflow: visible !important;
    }
}

@media (max-width: 480px) {
    .mode-card {
        padding: 1.5rem;
    }
    
    .mode-icon {
        font-size: 3rem;
    }
    
    .mode-card-title {
        font-size: 1.2rem;
    }
    
    .mode-btn {
        padding: 0.8rem 2rem;
        font-size: 0.9rem;
    }
    
    .video-container {
        height: 220px;
        max-height: 30vh;
    }

    #ai-camera,
    #draping-camera {
        max-height: 220px;
    }

    .color-analysis-data {
        grid-template-columns: 1fr;
    }
    
    .adjustment-slider {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .adjustment-slider label {
        width: auto;
    }
    
    .control-btn {
        font-size: 0.8rem;
        padding: 0.7rem 1rem;
    }
}

/* ========== 접근성 및 다크모드 대응 ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --text: #e0e0e0;
        --text-secondary: #b0b0b0;
        --bg: #121212;
        --bg-light: #1e1e1e;
        --border: #333;
    }
    
    .mode-card,
    .camera-container,
    .analysis-panel,
    .color-palette-section,
    .draping-camera-section {
        background: var(--bg-light);
        color: var(--text);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== 인쇄 스타일 ========== */
@media print {
    .loading-screen,
    .nav-btn,
    .camera-controls,
    .comparison-controls {
        display: none !important;
    }
    
    .main-app {
        display: block !important;
    }
    
    .video-container {
        height: auto;
        min-height: 200px;
        border: 1px solid #000;
        background: #f5f5f5;
    }
    
    .results-section {
        page-break-inside: avoid;
    }
}

/* ========== 헤어컬러 시뮬레이션 섹션 스타일 ========== */
#hair-simulate-mode.active {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 50%, #f8f9fa 100%);
    z-index: 100;
    overflow-y: auto;
    padding-top: calc(env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    box-sizing: border-box;
}

#hair-simulate-mode.active .section-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    margin: 0 -20px 0 -20px;
    padding: calc(50px + env(safe-area-inset-top, 0px)) 20px 25px 20px;
    border-radius: 0;
    border-bottom: 2px solid #e0e0e0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#hair-simulate-mode.active .section-title {
    color: #333;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: #333;
    background-clip: unset;
}

/* 시뮬레이션 색상 아이템 */
.ar-color-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e0e0e0;
}

.ar-color-item:hover {
    background: #ffffff;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ar-color-item.selected {
    border-color: #E91E63;
    background: rgba(233, 30, 99, 0.1);
}

.ar-color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.ar-color-info {
    flex: 1;
    min-width: 0;
}

.ar-color-name {
    color: #333;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ar-color-hex {
    color: #666;
    font-size: 11px;
}

/* 스피너 애니메이션 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 시뮬레이션 모바일 반응형 */
@media (max-width: 768px) {
    #hair-simulate-mode .simulate-layout {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    #hair-simulate-mode .simulate-color-panel {
        max-height: 300px !important;
    }

    #hair-simulate-mode .image-compare {
        grid-template-columns: 1fr !important;
    }
}

/* ========== 분석 결과 패널 텍스트 색상 ========== */
.analysis-results h4 {
    color: #333 !important;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.analysis-results .season-result,
.analysis-results #ai-season-result {
    color: #333 !important;
    font-size: 1.5rem;
    font-weight: 700;
}

.analysis-results .confidence-score,
.analysis-results #ai-confidence {
    color: #333 !important;
}

.analysis-results #ai-analysis-data {
    color: #333 !important;
}

.analysis-results #ai-analysis-data span,
.analysis-results #ai-analysis-data div {
    color: #333 !important;
}

/* ========== 태블릿 가로모드 (landscape) ========== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .mode-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        max-width: 100% !important;
        margin: 0 0 3rem 0 !important;
        gap: 2rem;
    }

    .mode-card {
        padding: 2rem;
    }

    .analysis-grid,
    .draping-layout {
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem;
    }

    .camera-container {
        min-width: 0;
    }

    .analysis-panel {
        min-width: 0;
    }
}

/* ========== 태블릿 세로모드 및 큰 태블릿 ========== */
@media (min-width: 768px) and (max-width: 1024px) {
    .mode-cards {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
        margin: 0 0 3rem 0;
    }
}

/* ========== 태블릿 세로모드: 분석 결과 1단 레이아웃 ========== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .results-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ========== 큰 태블릿 가로모드 ========== */
@media (min-width: 1024px) and (max-width: 1366px) {
    .mode-cards {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
    }

    .analysis-grid,
    .draping-layout {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========== 태블릿 가로모드 AI 분석 섹션 위치 조정 ========== */
@media (min-width: 768px) and (orientation: landscape) {
    #ai-analysis,
    #draping-mode {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    #ai-analysis.active .section-nav,
    #draping-mode.active .section-nav {
        margin-top: 0 !important;
        padding-top: 25px;
    }

    .analysis-grid {
        margin-top: 20px;
    }
}

/* ========== 태블릿용 커스텀 스크롤바 ========== */

/* 기본적으로 숨김 */
.camera-wrapper {
    display: contents;
}

.custom-scrollbar {
    display: none;
}

/* 태블릿에서만 표시 */
@media (min-width: 768px) and (max-width: 1366px) {
    /* 왼쪽/오른쪽 패널 높이 맞추기 */
    .analysis-grid {
        align-items: stretch;
    }

    .camera-wrapper {
        display: flex;
        position: relative;
        flex: 1;
        height: calc(100vh - 180px);
    }

    .camera-container {
        flex: 1;
        height: 100%;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .camera-container::-webkit-scrollbar {
        display: none;
    }

    .analysis-panel {
        height: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 커스텀 스크롤바 트랙 */
    .custom-scrollbar {
        display: block;
        position: absolute;
        right: 4px;
        top: 10px;
        bottom: 10px;
        width: 6px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 3px;
        z-index: 50;
    }

    /* 커스텀 스크롤바 썸 */
    .scrollbar-thumb {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        min-height: 40px;
        background: var(--primary-color);
        border-radius: 3px;
        opacity: 0.8;
        transition: opacity 0.2s;
    }

    .scrollbar-thumb:hover,
    .scrollbar-thumb.active {
        opacity: 1;
    }

    .custom-scrollbar.hidden {
        display: none;
    }

    /* ===== 분석결과 영역 스크롤바 (흰색) ===== */
    .realtime-results-wrapper {
        position: relative;
        margin-top: 20px;
        background: rgba(255,255,255,0.05);
        border-radius: 8px;
    }

    .realtime-results {
        padding: 20px;
        padding-right: 12px;
        max-height: 400px;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #ffffff rgba(255,255,255,0.3);
    }

    .realtime-results::-webkit-scrollbar {
        width: 8px;
    }

    .realtime-results::-webkit-scrollbar-track {
        background: rgba(255,255,255,0.3);
        border-radius: 4px;
    }

    .realtime-results::-webkit-scrollbar-thumb {
        background: #ffffff;
        border-radius: 4px;
    }

    .realtime-results::-webkit-scrollbar-thumb:hover {
        background: #ffffff;
    }

    /* 흰색 스크롤바 트랙 */
    .results-scrollbar {
        position: absolute;
        right: 6px;
        top: 15px;
        bottom: 15px;
        width: 5px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
        z-index: 100;
    }

    /* 흰색 스크롤바 썸 */
    .results-scrollbar-thumb {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        min-height: 30px;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 3px;
        transition: background 0.2s, top 0.1s ease-out;
    }

    .results-scrollbar-thumb:hover,
    .results-scrollbar-thumb.active {
        background: #fff;
    }

    .results-scrollbar.hidden {
        display: none;
    }
}
