/* 채팅 페이지 전용 스타일 */

/* 전체 페이지 상단(헤더 포함) 푸른색 배경 적용 */
body {
    margin: 0;
    padding: 0;
    background: #fff; /* 전체 페이지 배경 흰색 */
    font-family: 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* 화면 상하 전체를 채우되, 콘텐츠가 더 길면 자연스럽게 확장 */
    display: flex;              /* 상단 헤더/진행바 + 메인 영역을 세로로 배치 */
    flex-direction: column;
    height: 100vh;              /* 뷰포트 전체 높이 사용 */
    min-height: 100vh;          /* 최소 높이 보장 */
    max-height: 100vh;          /* 최대 높이 제한 */
    overflow: hidden;           /* body 스크롤 방지 */
}

/* 채팅 헤더: 메인과 동일 그라디언트 적용 */
.chat-header {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: white;
    padding: 0.75rem 0;         /* 헤더 높이 축소 */
    position: fixed;            /* sticky에서 fixed로 변경 */
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;             /* 헤더는 축소되지 않음 */
    /* transition: transform 0.3s ease; 헤더 스크롤 애니메이션 제거 */
}

/* 헤더 숨김 상태 - 비활성화 (헤더 항상 표시) */
/*
.chat-header.hidden {
    transform: translateY(-100%);
}
*/

/* 헤더 항상 표시 - hidden 클래스가 추가되더라도 무시 */
.chat-header {
    transform: translateY(0) !important;
}

.header-content {
    /* 메인 페이지 헤더와 동일한 그리드 레이아웃을 사용하여 메뉴가 줄바꿈되지 않도록 정렬 */
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* 좌측 로고 / 가운데 메뉴 / 우측 액션 */
    align-items: center;
    background: transparent; /* 헤더 내부는 투명하게 */
}

/* 모바일에서 햄버거 버튼이 중앙에 보이는 이슈 방지: 그리드 컬럼과 정렬을 강제 */
@media (max-width: 768px) {
    .chat-header .header-content {
        grid-template-columns: auto 1fr auto; /* 좌 로고 / 가운데 빈 공간 / 우측 햄버거 */
        max-width: 100%;
        padding: 0 15px;
        align-items: center;
    }
    /* 헤더 높이 축소 */
    .chat-header { padding: 0.6rem 0; }
    .chat-header h1 { font-size: 1.2rem; }
    .chat-header .nav-right { justify-self: end !important; }
    /* 공통 규칙과 일치하도록 +12px 이동 (기존 대비 +2px) */
    .chat-header .hamburger { transform: translateX(12px); }
    /* 모바일에서 메인 영역 상단 패딩 조정 */
    .chat-main { padding-top: 50px; }
}

.back-button {
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: 5px;
}

.back-button:hover {
    background: rgba(255,255,255,0.1);
}

/* 메인과 동일: 우측 액션 영역을 컨테이너의 맨 오른쪽으로 */
.nav-right { 
    justify-self: end; 
    display:flex; 
    align-items:center; 
    gap:.5rem; 
}

/* 상단 헤더 및 타이틀, 메뉴 텍스트를 항상 흰색으로 */
.chat-header,
.header-content {
    color: white !important;
}
.chat-header h1 {
    color: white !important;
    font-weight: 800; /* 메인과 동일 굵기 */
    margin: 0;
    font-size: 1.4rem; /* 메인과 동일 크기 */
    line-height: 1; /* 다른 페이지와 동일 */
}
.nav-link,
.nav-cta {
    color: white !important;
    font-weight: 500;
    text-decoration: none;
}
.nav-cta {
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 0.6rem 1.2rem; /* 메인과 동일 패딩으로 높이 일치 */
    margin-left: 0.7rem;
    transition: background 0.2s;
}
.nav-cta:hover {
    background: rgba(255,255,255,0.3);
}

.progress-indicator {
    font-size: 0.9rem;
    background: rgba(255,255,255,0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
}

/* 진행률 바 - 헤더 하단에 위치 */
.progress-bar {
    background: rgba(255,255,255,0.2);
    height: 3px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 10;
}

.progress-fill {
    background: linear-gradient(90deg, #4ecdc4 0%, #44a3aa 100%);
    height: 100%;
    width: 0%; /* JS에서 width 조정 */
    border-radius: 0;
    box-shadow: 0 0 5px rgba(78, 205, 196, 0.5);
    /* transition은 JS에서 처리 */
}

/* 메인 채팅 영역 - 크기 고정, 애니메이션/트랜지션 완전 제거 */
.chat-main {
    /* 상단 요소들을 제외한 남은 세로공간을 모두 사용 */
    flex: 1 1 auto;
    min-height: 0;              /* 자식 스크롤 요소가 제대로 크기 계산 가능하도록 */
    width: 100%;
    margin: 0;
    padding: 0;
    padding-top: 60px;          /* 헤더 높이만큼 상단 패딩 */
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;        /* 내부를 수평 가운데 정렬 */
    transition: none !important;
    animation: none !important;
    transform: none !important;
    overflow: hidden;           /* 내부 스크롤 처리 */
}

/* 채팅 컨테이너 - 크기 고정, 애니메이션/트랜지션 완전 제거 */
.chat-container {
    width: 100%;
    height: 100%;
    flex: 1 1 auto;          /* 남은 공간을 모두 점유 */
    min-height: 0;           /* 자식 스크롤 요소가 제대로 동작하도록 */
    display: flex;            /* 내부 메시지 영역을 세로로 확장 */
    flex-direction: column;
    overflow: hidden;         /* 모바일에서 부모 스크롤 간섭 방지 */
    background: #fff;
    transition: none !important;
    animation: none !important;
    transform: none !important;
    padding: 0;
    margin: 0;
}

/* 채팅 메시지 영역 - 크기 고정, 애니메이션/트랜지션 완전 제거 */
.chat-messages {
    width: 100%;
    max-width: 680px;       /* 가운데 고정 폭으로 정렬 */
    margin: 0 auto;         /* 수평 가운데 배치 */
    flex: 1 1 auto;          /* 하단 입력 영역 위까지 스크롤 영역 확장 */
    min-height: 0;           /* 부모의 남는 공간 내에서 스크롤 처리 */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;            /* 메시지 간격 축소 */
    padding: 0.75rem 1rem;   /* 상하 패딩 */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS에서 관성 스크롤 활성화 */
    overscroll-behavior: contain;      /* 상하 바운스 시 상위로 전파 방지 */
    touch-action: pan-y;               /* 수직 스크롤 제스처 보장 */
    background: #fff;
    border-radius: 0;        /* 둥근 모서리 제거 */
    transition: none !important;
    animation: none !important;
    transform: none !important;
}

/* 메시지 스타일 - 더 부드러운 그림자와 그라디언트 효과 */
/* 채팅 메시지 폰트 크기 8~10% 축소 및 볼드체 유지 */
.message {
    max-width: 90%;
    padding: 1rem 1.2rem;
    border-radius: 20px;
    line-height: 1.4;
    position: relative;
    font-size: 1.32rem; /* 기존 1.44rem → 1.32rem (약 8% 감소) */
    font-weight: bold;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.message:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.message.bot {
    /* 배경을 약간 더 진하게 조정 */
    background: linear-gradient(135deg, #eef1f4 0%, #e7ebf0 100%);
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 8px;
    font-size: 1.32rem;
    font-weight: bold;
}

.message.user {
    background: linear-gradient(135deg, #7c3aed 0%, #667eea 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 8px;
    position: relative;
    font-size: 1.32rem;
    font-weight: bold;
}

/* 사용자 메시지 내 수정 아이콘 버튼(전화번호 단계 전용) */
.message.user .edit-icon-btn {
    margin-left: .5rem;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: .2rem .4rem;
    font-size: .95rem;
    cursor: pointer;
    transform: translateY(-2px); /* 아이콘 2px 위로 이동 */
}

/* 전화번호 단계: '새 전화번호 입력' 소형 버튼 스타일 */
.message.user .edit-trigger-text {
    margin-left: .5rem;
    color: #667eea;
    background: #ffffff;
    border: 2px solid #667eea;
    border-radius: 10px;
    padding: .18rem .5rem;     /* 더 작게 */
    font-size: .85rem;         /* 더 작게 */
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transform: translate(3px, -10px) !important; /* 위로 10px 이동 (추가 5px 상향) */
    line-height: 1.1;
}
.message.user .edit-trigger-text:hover,
.message.user .edit-trigger-text:focus,
.message.user .edit-trigger-text:active{
    background:#eef2ff;   /* 버블(#667eea)과 다른 연한 배경 */
    color:#3730a3;        /* 진한 텍스트 */
    border-color:#6366f1; /* 선명한 경계 */
}
/* 편집 화면에서도 동일 위치/스타일 유지 */
.message.user.editing .edit-trigger-text { transform: translate(3px, -10px) !important; }

/* 사용자 메시지의 표시된 전화번호: 아래로 2px 내림 */
.message.user .user-text {
    display: inline-block;
    transform: translate(2px, 4px); /* 우측 2px + 하향 4px */
}

/* 편집 중일 때 기존 텍스트를 우측으로 3px 이동 */
.message.user.editing .user-text {
    /* 편집 상태: 기본 우측 2px + 편집 추가 3px = 총 5px, Y는 4px 유지 */
    transform: translate(5px, 4px);
    display: inline-block;
}
.message.user .edit-icon-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* 인라인 편집 UI 스타일 */
.inline-edit {
    display:flex;
    align-items:center;
    gap:.5rem;
    margin-top:.4rem;
    background: rgba(102,126,234,0.08); /* 편집 상태 표시용 은은한 배경 */
    border: 1.5px solid rgba(102,126,234,0.20);
    border-radius: 10px;
    padding: .35rem .5rem;
}
.inline-edit input[type="tel"]{
    height: 2.4rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 .6rem;
}
.inline-edit .btn-save, .inline-edit .btn-cancel{
    background:#fff;
    color:#667eea;
    border:2px solid #667eea;
    border-radius:8px;
    /* 입력칸과 동일 높이 적용 */
    height: 2.4rem;
    padding: 0 .8rem;
    font-weight:700;
    cursor:pointer;
    white-space: nowrap; /* 버튼 글자 줄바꿈 방지 */
    transform: translateY(-1px); /* 버튼을 1px 위로 이동 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-sizing: border-box;
}
.inline-edit .btn-save:hover,
.inline-edit .btn-cancel:hover{
    background:#eef2ff; /* 연한 배경으로 대비 확보 */
    color:#3730a3;      /* 진한 남색 텍스트 */
    border-color:#6366f1;
}

/* 수정 아이콘 제거됨 */

/* 입력 영역 */
.chat-input-section {
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    padding: 0.75rem;
    flex: 0 0 auto;          /* 입력 영역은 고정 높이, 스크롤 대상에서 제외 */
    flex-shrink: 0;          /* 입력 영역은 축소되지 않음 */
}

/* 입력 필드 컨테이너도 메시지와 같은 폭으로 가운데 정렬 */
.chat-input-section #inputWrapper,
.chat-input-section .input-wrapper {
    max-width: 680px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 선택 버튼 스타일 */
/* 옵션 버튼 컨테이너: 한 줄에 여러 개 배치, 줄바꿈 허용 */
.option-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 1.5rem 0;
    justify-content: flex-start;
}

/* 옵션 버튼(답변 상자): 글자 크기 8% 축소, 볼드체, 테두리/패딩 유지 */
.option-button {
    flex: 0 1 auto;
    min-width: 160px;
    max-width: 100%;
    padding: 1.1rem 2.2rem;
    font-size: 1.71rem; /* 기존 1.86rem → 1.71rem (8% 축소) */
    font-weight: bold;
    border: 2px solid #e5e7eb;
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    color: #333;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
    text-align: center;
    margin: 0;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.option-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #7c3aed 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 16px;
}

.option-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.option-button:hover::before {
    opacity: 0.05;
}

/* 데스크탑: 옵션 항목 크기 조정 */
@media (min-width: 769px) and (min-width: 1921px), 
       (min-width: 769px) and (min-height: 1081px) {
    /* 큰 화면에서는 기존 크기 유지 */
    .option-button {
        min-width: 128px;            /* 160px → 128px (20% 감소) */
        padding: 0.88rem 1.76rem;    /* 1.1/2.2 → 0.88/1.76 (20% 감소) */
        font-size: 1.37rem;          /* 1.71rem → 약 20% 감소 */
        border-radius: 16px;         /* 20px → 16px (20% 감소) */
    }
}

.option-button.selected, .option-button:active {
    background: linear-gradient(135deg, #667eea 0%, #7c3aed 100%);
    color: #fff;
    border: 2px solid transparent;
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.option-button.selected::before {
    opacity: 0;
}

/* 모바일 환경에서 버튼도 더 크게 */
@media (max-width: 768px) {
    .option-button {
        min-width: 110px;
        max-width: 100%;
        font-size: 1.2rem; /* 모바일도 8% 축소 */
        font-weight: bold;
        padding: 0.7rem 1.2rem;
        border-width: 2px;
    }
    .option-buttons {
        gap: 0.4rem;
    }
}

/* 입력 필드 스타일 - 더 부드러운 포커스 효과 */
.input-field {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.input-field input,
.input-field textarea {
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    resize: vertical;
    background: #ffffff;
}

.input-field input:hover,
.input-field textarea:hover {
    border-color: #d1d5db;
}

.input-field input:focus,
.input-field textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

/* 개인정보 동의 체크박스 크기 및 가독성 개선 */
.input-field label[style*="align-items: center"] {
    font-size: 1.5rem;    /* 더 크게 */
    font-weight: 800;     /* 더 굵게 */
    white-space: nowrap; /* 한 줄로만 표시 */
    gap: 0.7rem;
}
.input-field .agree-text {
    color: #2a3a8f;      /* 브랜드 톤 계열 진한 파랑 */
    text-decoration: underline; /* 눈에 띄도록 밑줄 */
    font-weight: 800;    /* 문구를 볼드로 강조 */
    font-size: 1.7rem;   /* 요청: '위 내용에 동의합니다.' 글자를 조금 더 크게 */
}
.input-field input[type="checkbox"] {
    width: 28px;
    height: 28px;
    accent-color: #667eea;
    margin-right: 0.5rem;
    vertical-align: middle;
    box-shadow: none; /* 동의 체크박스 외곽선(테두리) 제거 */
}
.input-field input[type="checkbox"]:focus {
    outline: none; /* 포커스 시 외곽선 제거 */
}

/* 파일 업로드 */
.file-upload {
    border: 2px dashed #e0e0e0;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.file-upload:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.file-upload.dragover {
    border-color: #667eea;
    background: #f0f7ff;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-text {
    color: #666;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: #999;
}

/* 미리보기 이미지 */
.image-preview {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
}

/* 날짜 선택기 */
.date-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.8rem;
}

.date-option {
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.date-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.date-option.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

/* 버튼 스타일 - 더 모던한 그라디언트와 호버 효과 */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

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

.btn-primary:hover::before {
    left: 100%;
}

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

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    /* 모바일에서 배경(채팅창) 스크롤을 허용하고, 모달 컨텐츠만 클릭 가능하도록 설정 */
    pointer-events: none;
}

.modal.show {
    display: flex;
}

/* 완료 모달 등 .modal-content의 높이 10% 축소 (max-height: 90vh) 및 패딩 축소 */
/* 공통 모달 컨텐츠 스타일 */
.modal-content {
    background: #fff;
    border-radius: 16px;
    max-width: 400px;
    width: 95%;
    margin: 2rem auto;
    box-shadow: 0 4px 32px rgba(0,0,0,0.18);
    max-height: 90vh; /* 기본값: 10% 축소 */
    /* 컨텐츠 영역만 인터랙션 허용 */
    pointer-events: auto;
    /* 본문 스크롤을 위해 플렉스 레이아웃 사용 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.2rem 1.2rem 1rem 1.2rem; /* 패딩도 소폭 축소 */
    box-sizing: border-box; /* padding 포함 폭 계산 → 모바일에서 좌우 잘림 방지 */
}

@media (max-width: 768px) {
    .modal-content {
        max-width: 98vw;
        margin: 0.5rem auto;
        max-height: 86vh; /* 기본 모바일 모달 높이 */
        padding: 0.7rem 0.7rem 0.5rem 0.7rem;
    }
    /* 모바일: 달력 모달 반응형 폭(최대 90vw, 상한 432px), 내부 스크롤 숨김 */
    /* 모바일: 가로폭 20% 추가 확장(기존 대비) → 좌우 여백 최소화 */
    #calendarModal .modal-content { width: 100vw; max-width: 100vw; }
    /* 모바일 달력 모달 전용: 세로 높이 10% 추가 축소 (90vh → 81vh 기준) */
    #calendarModal .modal-content { max-height: 85vh; }
    /* 좌우 패딩을 더 줄여 가로 여유 확보 (가로폭 +20% 체감) */
    #calendarModal .modal-body { overflow: hidden; padding: 0.6rem 0.2rem 0.5rem 0.2rem !important; }
    /* 모바일: 제목과 안내 문구 시작점 일치 */
    #calendarModal .modal-header { padding: 0.6rem 0.3rem 0.4rem 0.3rem !important; }
    #calendarModal .date-multi-desc { margin-left: 0 !important; padding-left: 0 !important; text-align: left; }
    /* 스크롤 없이 모두 보이도록 JS에서 동적 scale 적용 → 기본 스케일은 1 */
    /* 모바일 달력: 상단 여백 축소, 마지막 줄 아래 여백 소폭 확대 */
    #calendarModal .custom-calendar-wrapper {
        transform: scale(1);
        transform-origin: top center;
        max-width: 100%;
        width: 100%;
        padding-top: 0.20rem;   /* 상단 여백 추가 축소 */
        padding-left: 0;  /* 패널이 좌우 끝까지 차도록 0 처리 */
        padding-right: 0;
        padding-bottom: calc(0.9rem + 8px);/* 마지막 줄 아래 여백 8px 추가 확대 */
        margin-bottom: 0.3rem; /* 모달 버튼과의 간격도 소폭 확보 */
    }
    /* 모바일에서도 패널이 날짜 전체를 덮도록 보장 */
  #calendarModal .calendar-panel { width: 100%; background:#e9eef6; padding: 0.28rem; }
  #calendarModal .custom-calendar-wrapper + .btn-primary { margin-top: 0.18rem; }
  #calendarModal .calendar-title { white-space: nowrap; }
  /* 달력 하단 여백 추가로 잘림 방지 */
  #calendarModal .custom-calendar-wrapper { padding-bottom: 1.5rem !important; }
}

/* 데스크탑: 달력 모달 가로 20% 확대 → 전체 대비 90%로 축소 반영 */
@media (min-width: 1025px) {
    #calendarModal .modal-content {
        max-width: 570px; /* 데스크탑 가로 폭 20% 추가 확대 (475px → 약 570px) */
        max-height: 88vh; /* 달력 카드/배경 확대 시 잘림 방지 */
    }
    /* 데스크탑: 달력 본문 패널을 모달 본문 폭에 맞게 풀폭으로 정렬(좌우 여백 불균형 방지) */
    #calendarModal .custom-calendar-wrapper {
        max-width: none;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    #calendarModal .modal-footer .btn-primary { transform: translateY(-10px); }
    /* 데스크탑: 헤더/본문 좌우 패딩 동일 → 제목/안내 문구 시작 위치 정렬 */
    #calendarModal .modal-header { padding-left: 2rem !important; padding-right: 2rem !important; }
    #calendarModal .modal-body   { padding-left: 2rem !important; padding-right: 2rem !important; }
    #calendarModal .date-multi-desc { margin-left: 0 !important; padding-left: 0 !important; text-align: left; }
}

/* 모바일: 확인 버튼 추가 상향 */
@media (max-width: 768px) {
  #calendarModal .modal-footer .btn-primary { transform: translateY(-2px); }
}

/* 완료 모달 전용 스타일: 높이 15% 축소, 완료 버튼 가운데 정렬 */
#completionModal .modal-content {
    max-height: 80vh; /* 추가 축소 */
}
#completionModal .modal-footer {
    justify-content: center; /* 완료 버튼 가운데 정렬 */
    padding-bottom: 2.5rem;  /* 완료 버튼 아래 여백 소폭 증가 */
}

/* 개인정보 동의(체크박스) 섹션에서 수정 버튼과 같은 인터랙션 요소가 모달 위에서도 클릭 가능하도록 보장 */
.modal .btn-primary, .modal .btn-secondary, .modal .close-btn {
    pointer-events: auto;
}

/* 작은 모바일 화면에서 더 강하게 축소하여 스크롤 없이 버튼 노출 */
@media (max-width: 480px) {
    #completionModal .modal-content {
        max-height: 75vh; /* 더 작게 */
        padding: 0.6rem 0.8rem; /* 내부 여백 축소 */
    }
    #completionModal .modal-header,
    #completionModal .modal-footer {
        padding: 0.6rem 0.8rem; /* 헤더/푸터 여백 축소 */
    }
    #completionModal .modal-body {
        padding: 0.8rem; /* 본문 여백 축소 */
    }
}

/* 완료 모달 내 헤더를 아이콘+텍스트 한 줄 정렬로 변경 및 라인 간격 최적화 */
.completion-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.4rem 0; /* 상하 여백 축소 */
}
.completion-header .completion-icon {
    font-size: 1.3rem;
    line-height: 1;
}
.completion-header h3 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.2;
}
.completion-desc {
    margin: 0.2rem 0 0.6rem 0; /* 설명 줄 간격 축소 */
    font-size: 0.95rem;
    line-height: 1.3;
}
.summary h4,
.next-steps h4 {
    margin: 0.4rem 0 0.4rem 0; /* 섹션 타이틀 여백 축소 */
}
.summary-item { margin: 0.2rem 0; }
.summary-item .label { margin-right: 0.3rem; }
.next-steps ul { margin: 0.2rem 0 0; padding-left: 1rem; }
.next-steps li { margin: 0.15rem 0; }

.modal-header {
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS에서 부드러운 스크롤 */
}

.modal-footer {
    padding: 1rem 2rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center; /* 모든 모달 확인 버튼을 가운데 정렬 */
}

/* 애니메이션 - 더 부드러운 이징 함수 적용 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 메시지 타이핑 효과 */
@keyframes messageTyping {
    0%, 20% {
        opacity: 0.3;
    }
    40% {
        opacity: 0.6;
    }
    60%, 100% {
        opacity: 1;
    }
}

.message.typing {
    animation: messageTyping 1.5s ease-in-out infinite;
}

/* 입력 UI 등장용 부드러운 애니메이션 (컨테이너는 고정, 요소만 살짝 나타남) */
@keyframes uiFadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ui-appear {
    animation: uiFadeInUp 0.22s cubic-bezier(0.23, 1, 0.32, 1) both;
    will-change: transform, opacity;
}

/* 등장 애니메이션을 2배 느리게 적용해야 하는 요소 전용 보조 클래스 */
.ui-appear.ui-appear-slow {
    animation-duration: 0.44s !important;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 옵션 버튼 등장 애니메이션 (fade-in + slide-up) */
@keyframes optionFadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.option-buttons.fade-in {
    animation: optionFadeInUp 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 옵션 버튼 사라질 때 애니메이션 (fade-out + slight scale down) */
@keyframes optionFadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }
}

.option-buttons.fade-out {
    animation: optionFadeOutDown 0.22s ease-out both;
}

/* 옵션 버튼 순차 등장 애니메이션 */
@keyframes optionItemFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.option-buttons.stagger .option-button {
    opacity: 0;
}
.option-buttons.stagger .option-button.item-appear {
    animation: optionItemFadeIn 0.28s cubic-bezier(0.23, 1, 0.32, 1) both;
}

/* 접근성: 모션 최소화 선호 시 애니메이션 제거 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
    }
}

/* 모바일에서 채팅/옵션 등장 애니메이션을 더 자연스럽게(덜 튀게) 조정 */
@media (max-width: 768px) {
    /* 메시지 버블: 이동량 축소, 더 부드러운 이징과 약간 긴 지속시간 */
    @keyframes fadeInUpMobile {
        from { opacity: 0; transform: translateY(10px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .message { animation: fadeInUpMobile 0.38s cubic-bezier(0.25, 0.8, 0.25, 1); will-change: opacity, transform; }

    /* 옵션 컨테이너: 이동량 30→14px, 지속시간 0.35→0.55s */
    @keyframes optionFadeInUpMobile {
        from { opacity: 0; transform: translateY(14px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .option-buttons.fade-in { animation: optionFadeInUpMobile 0.55s cubic-bezier(0.25, 0.8, 0.25, 1); will-change: opacity, transform; }

    /* 옵션 아이템: 이동량 12→6px, 지속시간 0.22→0.32s, 지연은 JS 로직 유지 */
    @keyframes optionItemFadeInMobile {
        from { opacity: 0; transform: translateY(6px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .option-buttons.stagger .option-button.item-appear {
        animation: optionItemFadeInMobile 0.32s cubic-bezier(0.25, 0.8, 0.25, 1) both;
        will-change: opacity, transform;
    }

    /* 옵션 사라짐도 과한 이동을 줄여 더 자연스럽게 */
    @keyframes optionFadeOutDownMobile {
        from { opacity: 1; transform: translateY(0) scale(1); }
        to   { opacity: 0; transform: translateY(4px) scale(0.99); }
    }
    .option-buttons.fade-out { animation: optionFadeOutDownMobile 0.24s ease-out both; }
}

/* 태블릿 및 모바일 반응형 */
@media (max-width: 1024px) {
    .chat-main {
        width: 100%;
        margin: 0;
    }
    
    .header-content {
        max-width: 100%;
    }
}

/* 데스크탑: 세로 전체 화면 사용 및 모바일과 유사한 플렉스 채우기 적용 */
@media (min-width: 1025px) {
    body {
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
    }
    .chat-main {
        height: 100%;
        width: 100%;
        margin: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .chat-container {
        height: 100%;
        flex: 1 1 auto;     /* 남는 세로 공간을 모두 차지 */
        overflow: hidden;
    }
    .chat-messages {
        flex: 1 1 auto;     /* 내부 스크롤 영역이 세로를 채우도록 */
        padding: 1rem 1.5rem;
    }
}

/* 1920x1080 이하 데스크탑: 글자 크기 축소로 더 많은 메시지 표시 */
@media (min-width: 769px) and (max-width: 1920px) and (max-height: 1080px) {
    /* 헤더 높이 축소 */
    .chat-header {
        padding: 0.5rem 0;
    }
    
    .chat-header h1 {
        font-size: 1.2rem;
    }
    
    .nav-link {
        font-size: 0.85rem;
    }
    
    .nav-cta {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    /* 메시지 크기 및 간격 축소 - 약 30% 축소 */
    .message {
        font-size: 0.92rem;  /* 1.32rem → 0.92rem */
        padding: 0.7rem 0.9rem;
        max-width: 85%;
    }
    
    .message.bot {
        font-size: 0.92rem;
    }
    
    .message.user {
        font-size: 0.92rem;
    }
    
    /* 메시지 간격 축소 */
    .chat-messages {
        gap: 0.5rem;  /* 0.75rem → 0.5rem */
        padding: 0.5rem 1rem;
    }
    
    /* 옵션 버튼 크기 축소 */
    .option-button {
        font-size: 1.2rem;  /* 1.71rem → 1.2rem */
        padding: 0.8rem 1.6rem;
        min-width: 120px;
    }
    
    /* 입력 영역 축소 */
    .chat-input-section {
        padding: 0.5rem;
    }
    
    .input-field input,
    .input-field textarea {
        padding: 0.7rem;
        font-size: 0.9rem;
    }
    
    /* 버튼 크기 축소 */
    .btn-primary {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* 진행률 바 높이 축소 */
    .progress-bar {
        height: 2px;
    }
    
    /* 개인정보 동의 체크박스 크기 축소 */
    .input-field label[style*="align-items: center"] {
        font-size: 1.1rem;
        font-weight: 700;
    }
    
    .input-field .agree-text {
        font-size: 1.2rem;
    }
    
    .input-field input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    /* 날짜 선택 설명 텍스트 크기 축소 */
    .date-multi-desc {
        font-size: 0.85rem;
        margin: 0.3rem 0 0.1rem 0;
    }
    
    /* 달력 크기 축소 */
    .custom-calendar-wrapper {
        margin: 0.8rem auto 1rem auto;
        padding: 1rem;
        max-width: 360px;
    }
    
    .calendar-title {
        font-size: 1.1rem;
        margin: 0 0.8rem;
    }
    
    .calendar-nav {
        width: 2.2rem;
        height: 2.2rem;
        font-size: 1.1rem;
    }
    
    .calendar-day, .calendar-day-header {
        padding: 0.6rem 0;
        font-size: 0.95rem;
        min-width: 2.4rem;
        min-height: 2.4rem;
    }
    
    .calendar-day {
        height: 2.4rem;
    }
    
    .calendar-day .day-number {
        width: 1.7rem;
        height: 1.7rem;
    }
    
    .calendar-days-row, .calendar-dates-grid {
        gap: 0.2rem;
    }
    
    /* 모달 크기 축소 */
    .modal-content {
        max-height: 85vh;
        padding: 1rem;
    }
    
    .modal-header {
        padding: 1rem 1.5rem 0.8rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-footer {
        padding: 0.8rem 1.5rem 1.5rem;
    }
    
    /* 상세주소 입력 높이 축소 */
    :root { 
        --detail-row-h: 42px; 
    }
    
    /* 사용자 메시지 수정 버튼 크기 축소 */
    .message.user .edit-trigger-text {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
        transform: translate(3px, -8px) !important;
    }
    
    /* 인라인 편집 UI 크기 축소 */
    .inline-edit {
        padding: 0.25rem 0.4rem;
        gap: 0.4rem;
        margin-top: 0.3rem;
    }
    
    .inline-edit input[type="tel"] {
        height: 2rem;
        padding: 0 0.5rem;
        font-size: 0.85rem;
    }
    
    .inline-edit .btn-save, .inline-edit .btn-cancel {
        height: 2rem;
        padding: 0 0.6rem;
        font-size: 0.8rem;
    }
    
    /* 전화번호 입력 높이 축소 */
    .message-group .input-field:has(input[type="tel"]) input[type="tel"] {
        height: 2.8rem;
    }
    
    .message-group .input-field:has(input[type="tel"]) .btn-primary {
        height: 2.8rem;
        padding: 0 1rem;
        font-size: 0.85rem;
    }
    
    /* 텍스트 입력 항목 다음 버튼 크기 축소 */
    .input-field .btn-primary {
        height: 2.4rem;
        font-size: 0.85rem;
        padding: 0.2rem 1.2rem;
    }
    
    /* 날짜 chip 크기 축소 */
    .date-chip {
        font-size: 0.85rem;
        padding: 0.2em 0.7em;
        border-radius: 12px;
    }
    
    /* 파일 업로드 영역 축소 */
    .file-upload {
        padding: 1.5rem;
    }
    
    .upload-icon {
        font-size: 2.5rem;
        margin-bottom: 0.7rem;
    }
    
    .upload-text {
        font-size: 0.85rem;
    }
    
    .upload-hint {
        font-size: 0.75rem;
    }
    
    /* 미리보기 이미지 크기 축소 */
    .preview-item {
        width: 80px;
        height: 80px;
    }
    
    /* 애니메이션 속도 증가 */
    .message {
        animation: fadeInUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .option-buttons.fade-in {
        animation: optionFadeInUp 0.35s cubic-bezier(0.23, 1, 0.32, 1);
    }
    
    .option-buttons.stagger .option-button.item-appear {
        animation: optionItemFadeIn 0.2s cubic-bezier(0.23, 1, 0.32, 1) both;
    }
    
    .calendar-fade-wrapper.calendar-appear {
        animation: calendarFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    
    .ui-appear {
        animation: uiFadeInUp 0.15s cubic-bezier(0.23, 1, 0.32, 1) both;
    }
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    body {
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
        /* 모바일 브라우저 주소창 고려 */
        height: -webkit-fill-available;
    }
    
    .chat-main {
        height: 100%;
        width: 100%;
        margin: 0;
        overflow: hidden;
    }
    
    .chat-container {
        height: 100%;
        overflow: hidden;
    }
    
    /* 입력 필드 포커스 시 추가 여백 */
    .input-field:focus-within {
        padding-bottom: 2rem;
    }
    
    .header-content {
        max-width: 100%;
        padding: 0 15px;
    }
    
    .message {
        max-width: 90%;
        font-size: 1.2rem;  /* 약간 축소 */
        padding: 0.8rem 1rem;
    }
    
    .date-picker {
        grid-template-columns: 1fr 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .chat-messages { 
        padding: 0.5rem 0.75rem;
        gap: 0.6rem;  /* 메시지 간격 축소 */
    }
    
    .chat-input-section { 
        padding: 0.5rem 0.75rem;
    }
}

/* 텍스트 입력 항목 아래의 '다음' 버튼: 세로 50% 더 크게, 가로는 글자보다 약간만 크게 */
.input-field .btn-primary {
    font-size: 1rem;
    padding: 0.3rem 1.5rem;   /* 가로 패딩만 약간 넓게 */
    min-width: 0;             /* 글자 크기보다 약간만 크게 */
    height: 3rem;             /* 기존 2rem → 3rem (50% 증가) */
    border-radius: 12px;
    box-shadow: none;
    margin-top: 0.5rem;
    margin-bottom: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 다음 버튼을 위로 약 20% 올렸던 것을, 시각적 균형을 위해 2px 아래로 하향 보정 */
    transform: translateY(calc(-20% + 2px));
}

/* textarea 입력에서 '다음' 버튼 가로 크기 조정 */
.input-field .btn-primary {
    width: fit-content !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0.4rem 1rem !important;
    font-size: 1rem !important;
    font-weight: bold !important;
    border-radius: 10px !important;
    margin: 0.5rem auto 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    /* 위로 20% 이동 값을 기준으로 2px 아래로 하향 보정 (중복 정의에서도 유지) */
    transform: translateY(calc(-20% + 2px)) !important;
}

/* textarea 입력 필드에서 버튼 가운데 정렬 */
.input-field {
    text-align: center;
}

/* 복수 날짜 선택 설명 텍스트 스타일 */
.date-multi-desc {
    font-size: 1.05rem;
    color: #3b5998;
    margin: 0.4rem 0 0.15rem 0; /* 상하 간격 10~25% 축소 */
    font-weight: 500;
}

/* 달력(Date Picker) 입력 필드가 항상 보이도록 명시적으로 지정 */
input[type='date'], .multi-date-input {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 120px;
    min-height: 2.2rem;
    font-size: 1rem;
    margin-bottom: 0.2rem;
    background: #fff;
    color: #333;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

input[type='date']:hover, .multi-date-input:hover {
    border-color: #d1d5db;
}

input[type='date']:focus, .multi-date-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* 커스텀 달력 스타일 - 완전히 새로운 모던 디자인 */
.custom-calendar-wrapper {
    margin: 1rem auto;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 1.75rem;
    max-width: 460px;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* 배경 그라디언트 효과 */
.custom-calendar-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.03) 0%, transparent 70%);
    pointer-events: none;
}

/* 데스크탑에서만 hover 효과 적용 */
@media (min-width: 769px) {
    .custom-calendar-wrapper:hover {
        transform: translateY(-3px);
        box-shadow: 0 25px 70px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
    }
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.calendar-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1a202c;
    letter-spacing: -0.02em;
    flex: 1;
    text-align: center;
    user-select: none;
}

/* 네비게이션 버튼 - 더 미니멀하고 세련된 디자인 */
.calendar-nav {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    font-size: 1.25rem;
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.calendar-nav:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.calendar-nav:active {
    transform: scale(0.95) translateY(0);
}
/* 달력 패널 - 그리드를 감싸는 컨테이너 */
.calendar-panel {
    background: #f8fafc;
    border-radius: 20px;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

.calendar-days-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.calendar-dates-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
}

/* 요일 헤더 스타일 */
.calendar-day-header {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: #718096;
    padding: 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 날짜 셀 기본 스타일 */
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 1.125rem;
    font-weight: 500;
    color: #2d3748;
    background: white;
    border-radius: 16px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

/* 데스크탑 hover 효과 */
@media (hover: hover) and (pointer: fine) {
    .calendar-day:hover:not(.disabled):not(.empty) {
        background: #eef2ff;
        border-color: #667eea;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    }
}

/* 모바일 터치 최적화 */
.calendar-day {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 날짜 숫자 스타일 */
.calendar-day .day-number {
    font-size: 1.125rem;
    font-weight: 500;
    transition: none; /* 즉각적인 반응 */
}

/* 오늘 날짜 스타일 - 더 섬세한 표시 */
.calendar-day.today {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f1ff 100%);
    border-color: #b3d1ff;
    position: relative;
}

.calendar-day.today .day-number {
    color: #667eea;
    font-weight: 700;
}

/* 오늘 텍스트 - 작고 세련되게 */
.calendar-day.today .today-text {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.625rem;
    color: #667eea;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* 선택된 날짜 - 그라디언트 배경 */
.calendar-day.selected {
    background: linear-gradient(135deg, #667eea 0%, #7c3aed 100%);
    border-color: transparent;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.calendar-day.selected .day-number {
    color: white;
    font-weight: 600;
}

.calendar-day.selected.today .today-text {
    color: white;
    opacity: 0.9;
}

/* 비활성화된 날짜 (과거) */
.calendar-day.disabled {
    background: #f7fafc;
    cursor: not-allowed;
    opacity: 0.5;
}

.calendar-day.disabled .day-number {
    color: #a0aec0;
}

/* 빈 날짜 셀 */
.calendar-day.empty {
    background: transparent;
    cursor: default;
    pointer-events: none;
}

/* 날짜 선택 관련 설명 텍스트 */
.date-multi-desc {
    font-size: 0.875rem;
    color: #4a5568;
    margin-bottom: 1rem;
    font-weight: 500;
    text-align: center;
}

/* 달력 등장 애니메이션 */
@keyframes calendarFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.calendar-fade-wrapper.calendar-appear {
    animation: calendarFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* 달력 사라짐 애니메이션 */
.calendar-fade-wrapper.fade-out {
    animation: calendarFadeOut 0.2s ease-out both;
}

@keyframes calendarFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

/* 모바일 반응형 달력 스타일 */
@media (max-width: 768px) {
    .custom-calendar-wrapper {
        padding: 1.25rem;
        margin: 0.75rem auto;
        max-width: calc(100vw - 3rem);
    }
    
    .calendar-header {
        margin-bottom: 1.25rem;
        padding: 0;
    }
    
    .calendar-title {
        font-size: 1.25rem;
    }
    
    .calendar-nav {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .calendar-panel {
        padding: 0.75rem;
        border-radius: 16px;
    }
    
    .calendar-days-row,
    .calendar-dates-grid {
        gap: 0.25rem;
    }
    
    .calendar-day-header {
        font-size: 0.75rem;
        padding: 0.375rem 0;
    }
    
    .calendar-day {
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .calendar-day .day-number {
        font-size: 1rem;
    }
    
    .calendar-day.today .today-text {
        font-size: 0.5rem;
    }
    
    .date-multi-desc {
        font-size: 0.8125rem;
        margin-bottom: 0.75rem;
    }
}

/* 매우 작은 화면 (SE, Mini) 최적화 */
@media (max-width: 375px) {
    .custom-calendar-wrapper {
        padding: 1rem;
    }
    
    .calendar-panel {
        padding: 0.5rem;
    }
    
    .calendar-days-row,
    .calendar-dates-grid {
        gap: 0.125rem;
    }
    
    .calendar-day {
        font-size: 0.875rem;
    }
}
/* 달력 모달 특별 스타일 */
#calendarModal .modal-content {
    max-width: 520px;
    padding: 0;
    overflow: visible;
}

#calendarModal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #7c3aed 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    padding: 1.5rem 2rem;
    margin: 0;
}

#calendarModal .modal-header h2 {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

#calendarModal .modal-body {
    padding: 1.5rem;
    background: #f8fafc;
}

#calendarModal .custom-calendar-wrapper {
    box-shadow: none;
    background: transparent;
    padding: 0;
    margin: 0;
}

#calendarModal .modal-footer {
    background: #f8fafc;
    padding: 0 1.5rem 1.5rem;
    border-radius: 0 0 16px 16px;
}

#calendarModal .btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #7c3aed 100%);
    border: none;
    color: white;
    font-weight: 600;
    transition: all 0.2s ease;
}

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

#calendarModal .btn-primary:active {
    transform: translateY(0);
}
/* 모바일 달력 모달 반응형 */
@media (max-width: 768px) {
    #calendarModal .modal-content {
        max-width: calc(100vw - 2rem);
        margin: 1rem;
        border-radius: 20px;
    }
    
    #calendarModal .modal-header {
        padding: 1.25rem 1.5rem;
        border-radius: 20px 20px 0 0;
    }
    
    #calendarModal .modal-header h2 {
        font-size: 1.25rem;
    }
    
    #calendarModal .modal-body {
        padding: 1.25rem 1rem;
    }
    
    #calendarModal .modal-footer {
        padding: 0 1rem 1.25rem;
    }
    
    #calendarModal .btn-primary {
        padding: 0.875rem;
        font-size: 1rem;
    }
}
/* 키보드 접근성 개선 */
.calendar-day:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.calendar-nav:focus {
    outline: 3px solid white;
    outline-offset: 2px;
}

/* 일반 날짜의 숫자 색상 명시 */
.calendar-day:not(.disabled):not(.selected) .day-number { color: #333 !important; }
.calendar-day.empty .day-number { color: #333 !important; }
.calendar-day-header { color: #3b5998; }
.calendar-day:focus { outline: none; }

/* 달력 헤더, 요일, 날짜 그리드 모두 가운데 정렬 */
.calendar-header,
.calendar-days-row,
.calendar-dates-grid {
    justify-content: center;
    text-align: center;
}

/* 요일+날짜를 하나의 패널로 감싸 전체 영역에 동일 배경이 깔리도록 */
.calendar-panel {
    width: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f4 100%);
    border-radius: 16px;
    padding: 0.5rem;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

/* 패널 내부의 기존 배경/라운드를 제거해 패널과 맞닿도록 조정 */
.calendar-days-row,
.calendar-dates-grid {
    background: transparent;
    padding: 0;
}

/* 커스텀 달력 아래 확인 버튼: 가로 크기를 글자에 맞게 줄임 */
.custom-calendar-wrapper + .btn-primary {
    margin: 1rem auto 0 auto;
    display: block;
    width: auto;
    min-width: 0;
    max-width: none;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 0.5rem 1.5rem;
    text-align: center;
}

/* 선택된 날짜 답변을 채팅창과 어울리는 색상(파란색)으로 버튼처럼 보이게 + 테두리 추가 */
.date-chip {
    display: inline-block;
    background: #667eea;
    color: #fff;
    border-radius: 16px;
    padding: 0.25em 0.9em;
    margin: 0 0.2em 0.2em 0;
    font-size: 1.05rem;
    font-weight: 600;
    border: 2px solid #3b5998; /* 진한 파란색 테두리 추가 */
    box-shadow: 0 1px 4px rgba(102,126,234,0.10);
    vertical-align: middle;
    transition: background 0.2s, color 0.2s, border 0.2s;
}

/* 달력 애니메이션 - 더 부드럽고 자연스러운 효과 */
@keyframes calendarFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* 달력 등장 애니메이션: 살짝 위로 떠오르며 투명도/스케일 업 */
@keyframes calendarFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.calendar-fade-wrapper.calendar-appear {
    /* 모바일에서는 애니메이션 없이 즉시 표시 */
    animation: none;
    opacity: 1;
    transform: none;
}

/* 데스크탑에서만 애니메이션 적용 */
@media (min-width: 769px) {
    .calendar-fade-wrapper.calendar-appear {
        animation: calendarFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
        will-change: opacity, transform;
    }
}

.calendar-fade-wrapper.fade-out {
    animation: calendarFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.calendar-fade-wrapper {
    margin-top: 0.7rem;
}

/* 초소형 모바일(≤390px) 최적화: 7열이 화면에 정확히 들어오도록 셀 크기/간격 축소 */
@media (max-width: 390px) {
  /* 배경 카드(래퍼)를 좌우 20% 더 넓게 확장 (가운데 유지) */
  /* 가운데 정렬: 폭 확장 후 좌우 마진을 자동으로 하여 정확히 중앙 배치 */
  #calendarModal .custom-calendar-wrapper { width: calc(100% + 20%); margin: 0 auto; }
  /* 패널 내부 여백을 더 줄여 유효 폭 확보 */
  #calendarModal .calendar-panel { padding: 0.06rem; }
  /* 그리드 간격 축소 → 전체 폭 절감 */
  .calendar-days-row, .calendar-dates-grid { gap: 0.12rem; }
  /* 날짜/요일 셀 기본 크기 축소 (가로 7칸이 정확히 들어오도록) */
  .calendar-day, .calendar-day-header {
    min-width: 3.5rem;   /* 기존 대비 약 +10% 확대 */
    min-height: 3.5rem;
    padding: 0.98rem 0;
    font-size: 1.26rem;
  }
  /* 숫자 원 배지 크기도 비율에 맞춰 축소 */
  .calendar-day .day-number { width: 2.2rem; height: 2.2rem; }
  /* 제목 크기/간격 살짝 축소로 전체 균형 유지 */
  .calendar-title { font-size: 1.22rem; margin: 0 0.4rem; }
  /* 월 이동 버튼은 기본 크기 유지로 터치 편의 보장 */
  .calendar-nav { width: 2.6rem; height: 2.6rem; font-size: 1.2rem; }
}

/* iPhone 13(390px)~Pro Max(428px) 구간 추가 보정 */
@media (min-width: 391px) and (max-width: 428px) {
  /* iPhone 13~Pro Max: 좌우 여백 더 줄이고 셀/폰트 확대 */
  #calendarModal .modal-body { padding: 0.6rem 0.18rem 0.5rem 0.18rem !important; }
  #calendarModal .modal-header { padding: 0.6rem 0.18rem 0.4rem 0.18rem !important; }
  #calendarModal .custom-calendar-wrapper { width: calc(100% + 20%); margin: 0 auto; }
  #calendarModal .calendar-panel { padding: 0.08rem; }
  .calendar-days-row, .calendar-dates-grid { gap: 0.12rem; }
  .calendar-day, .calendar-day-header {
    min-width: 3.6rem;   /* 기존 대비 약 +10% 확대 */
    min-height: 3.6rem;
    padding: 1.02rem 0;
    font-size: 1.28rem;
  }
  .calendar-day .day-number { width: 2.3rem; height: 2.3rem; }
  .calendar-title { font-size: 1.3rem; }
}

/* 모바일 공통(≤428px): 요구사항
   1) 달력(요일+날짜) 가로폭을 모달 가로의 90%로 고정
   2) 달력을 감싸는 배경(패널)은 달력보다 더 넓게(100%) 표시 */
@media (max-width: 428px) {
  /* 외곽 카드: 중앙 정렬, 가로는 모달 폭을 그대로 사용 */
  #calendarModal .custom-calendar-wrapper {
    width: 100% !important;
    margin: 0 auto !important;
  }
  /* 패널(배경)은 항상 100%로 달력보다 넓게, 여백 최소화 */
  #calendarModal .calendar-panel {
    width: 100% !important;
    padding: 0.2rem !important; /* 배경 여유를 줄여 모달 내부 여백 축소 */
  }
  /* 실제 달력(요일/날짜) 컨텐츠는 모달 폭에 맞춰 100%로 확장 */
  #calendarModal .calendar-panel .calendar-days-row,
  #calendarModal .calendar-panel .calendar-dates-grid {
    width: 100% !important;
    margin: 0 auto !important;
  }
  /* 칸이 잘리지 않도록 최소 너비 제한 해제 */
  #calendarModal .calendar-panel .calendar-day,
  #calendarModal .calendar-panel .calendar-day-header {
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 1.15rem 0; /* 약 15% 추가 확대 */
    font-size: 1.36rem; /* 약 15% 추가 확대 */
  }
  /* 간격을 적절히 줄여 90% 폭 내에 7열이 안정적으로 들어오도록 */
  #calendarModal .calendar-panel .calendar-days-row,
  #calendarModal .calendar-panel .calendar-dates-grid {
    gap: 0.12rem !important; /* 셀 확대에 맞춰 간격 소폭 축소 */
  }

  /* 숫자 원 배지도 비례 확대 */
  #calendarModal .calendar-panel .calendar-day .day-number {
    width: 2.4rem;
    height: 2.4rem;
  }

  /* 모달 내부 여백 자체를 줄여 달력이 더 크게 보이도록 */
  #calendarModal .modal-body { padding: 0.4rem 0.12rem 0.3rem 0.12rem !important; }
  #calendarModal .modal-header { padding: 0.45rem 0.12rem 0.25rem 0.12rem !important; }
}

/* 상세주소 입력창/버튼: 동일 높이 통일 */
:root { --detail-row-h: 56px; }
.detail-address-input {
    flex: 1 1 0;
    width: 100%;
    font-size: 1.05rem;
    height: auto;
    block-size: var(--detail-row-h);
    padding: 0 1.1rem; /* 수직 패딩 0으로 텍스트 중앙정렬 */
    border-radius: 12px;
    border: 2.5px solid #93c5fd; /* 더 선명한 기본 테두리 */
    background: #fff;
    box-sizing: border-box;
    line-height: 1; /* 버튼과 동일 베이스라인 */
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    appearance: none;
    caret-color: var(--brand-primary);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.detail-address-input::placeholder { color:#9aa6b2; }

/* 입력 대기 상태(내용 비어있고 포커스 아님)에서 미세한 펄스로 대기중 느낌 제공 */
.detail-address-input:placeholder-shown:not(:focus) {
  border-color: #7fb6ff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.10);
  animation: addressIdlePulse 1.8s ease-in-out infinite;
}

/* 포커스 시 또렷한 강조 링 */
.detail-address-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px rgba(59,130,246,.18);
}

@keyframes addressIdlePulse {
  0%   { box-shadow: 0 0 0 1px rgba(99,102,241,.12); }
  50%  { box-shadow: 0 0 0 5px rgba(99,102,241,.20); }
  100% { box-shadow: 0 0 0 1px rgba(99,102,241,.12); }
}
.btn-primary.detail-address-next {
    width: auto;
    min-width: 0;
    height: auto;
    block-size: var(--detail-row-h);
    padding: 0 1.3rem; /* 수직 패딩 0 */
    font-size: 1rem;
    font-weight: bold;
    border-radius: 10px;
    margin-left: 0.2rem;
    box-sizing: border-box;
    border: 2px solid transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    appearance: none;
}

/* 전화번호 입력 전용: 같은 줄 정렬과 높이 일치 보장 */
.message-group .input-field:has(input[type="tel"]) {
    flex-direction: row;
    align-items: stretch;
    gap: 0.7rem;
}
.message-group .input-field:has(input[type="tel"]) input[type="tel"] {
    height: 3.6rem;
}
.message-group .input-field:has(input[type="tel"]) .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 3.6rem; /* 자바스크립트 동기화 전에 기본값 제공 */
    padding: 0 1.2rem;
    /* 전화번호 행 버튼 위치 보정: 기존 -5px에서 1px 더 아래 → -4px */
    transform: translateY(-4px) !important;
}

/* 상세주소 입력 행의 버튼은 행 정렬을 유지해야 하므로 이동 해제 */
.btn-primary.detail-address-next {
    transform: none !important;
}

/* 상세주소 단계 전용 미세 정렬: 버튼을 1px 위로 보정 */
.message-group .input-field:has(.detail-address-input) .btn-primary.detail-address-next {
    /* 상세주소 단계 버튼: 기존 상향(10px)에서 2px 하향 보정 → 실질적으로 8px 상향 */
    transform: translateY(-8px) !important;
}

/* 상세주소 입력행: 항상 한 줄 정렬 및 높이 일치 보장 */
.message-group .input-field:has(.detail-address-input) {
    flex-direction: row;
    align-items: stretch; /* 두 요소를 동일 높이로 스트레치 */
    gap: 0.7rem;
    height: var(--detail-row-h);
}
.message-group .input-field:has(.detail-address-input) .detail-address-input {
    height: auto;
    block-size: var(--detail-row-h);
    -webkit-appearance: none;
    appearance: none;
}
.message-group .input-field:has(.detail-address-input) .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    block-size: var(--detail-row-h);
    padding: 0 1.2rem;
    border: 2px solid transparent; /* 입력창과 시각적 높이 일치 */
    box-sizing: border-box;
    line-height: 1; /* 버튼 텍스트 수직 중앙 */
    -webkit-appearance: none;
    appearance: none;
    transform: none !important;
}

/* 수정 기능 안내 토스트 메시지 스타일 */
.edit-toast {
    display: block;
    background: #3b5998;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    padding: 0.6em 1.3em;
    margin: 0.3em 0 0.7em 0;
    box-shadow: 0 2px 8px rgba(60,90,180,0.13);
    text-align: center;
    animation: fadeInOut 1.5s;
    z-index: 10;
}
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* 전화번호 입력창 placeholder 색상 조정 */
input[type="tel"]::placeholder {
    color: #999 !important;
    opacity: 0.6 !important;
}

input[type="tel"]::-webkit-input-placeholder {
    color: #999 !important;
    opacity: 0.6 !important;
}

input[type="tel"]::-moz-placeholder {
    color: #999 !important;
    opacity: 0.6 !important;
}

input[type="tel"]:-ms-input-placeholder {
    color: #999 !important;
    opacity: 0.6 !important;
}