/* ============================================================
   A Pose Partners - AI 2중 퍼널 솔루션 랜딩 페이지
   원본: apose-landing.vercel.app 기반 역분석 재현
   ============================================================ */

/* ---------- CSS 변수 ---------- */
:root {
  --bg-primary: #0a0f1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2333;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
  --text-primary: #fff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-border-hover: rgba(255, 255, 255, 0.20);
  --shadow-glow: 0 0 60px rgba(59, 130, 246, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ---------- 기본 리셋 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  /* 9:16 모바일 전체 화면 */
  min-height: 100svh;          /* Safe viewport height (노치/홈바 대응) */
  height: 100svh;
  overflow: hidden;             /* 바깥 스크롤 차단 */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* 텍스트 크기 자동조정 방지 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 스크롤바 커스텀 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

/* ---------- 전체 레이아웃 (9:16 flex 구조) ---------- */
.min-h-screen {
  display: flex;
  flex-direction: column;
  height: 100svh;          /* 노치/홈바 대응 */
  overflow: hidden;
}

/* ---------- Canvas 배경 ---------- */
#bgCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ---------- 헤더 ---------- */
.header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(0, 0, 0, 0.20);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  width: 2rem; height: 2rem;
  border-radius: 9999px;
  background: linear-gradient(to right, #00baa7, #00d2ef);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.header-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.7rem;
  color: #00d3bd;
  display: block;
}

.header-brand {
  font-size: 0.7rem;
  color: #6a7282;
}

/* ---------- 채팅 스크롤 영역 ---------- */
.chat-scroll {
  flex: 1;             /* 남은 공간 전부 차지 */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;  /* iOS 관성 스크롤 */
  padding: 1.25rem 0.875rem;
  padding-bottom: 6rem;  /* 하단 컨트롤 버튼 가림 방지 */
}

.chat-inner {
  max-width: 42rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#messagesContainer,
#chatInner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;   /* 메시지 간 간격 */
}

/* ---------- 메시지 컴포넌트 ---------- */
.message-row {
  display: flex;
  gap: 0.6rem;
  animation: fadeIn 0.3s ease-out forwards;
  /* 메시지 행 넘침 방지 */
  min-width: 0;
}

.message-row.hospital { flex-direction: row; }
.message-row.expert   { flex-direction: row-reverse; }

/* 아바타 */
.avatar {
  width: 2.5rem; height: 2.5rem;
  border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid;
  flex-shrink: 0;
}

.avatar.hospital {
  border-color: rgba(252, 187, 0, 0.5);
  background: linear-gradient(to bottom right, rgba(249, 156, 0, 0.3), rgba(254, 110, 0, 0.3));
  box-shadow: 0 0 16px rgba(249, 156, 0, 0.2);
  color: #fcbb00;
}

.avatar.expert {
  border-color: rgba(0, 210, 239, 0.5);
  background: linear-gradient(to bottom right, rgba(0, 183, 215, 0.3), rgba(48, 128, 255, 0.3));
  box-shadow: 0 0 16px rgba(0, 183, 215, 0.2);
  color: #00d2ef;
}

/* 메시지 버블 래퍼 */
.bubble-wrapper {
  max-width: 83%;      /* 모바일 기준 넓게 */
  min-width: 0;        /* flex 자식 넘침 방지 */
  display: flex;
  flex-direction: column;
}

.message-row.hospital .bubble-wrapper { align-items: flex-start; }
.message-row.expert   .bubble-wrapper { align-items: flex-end; }

.sender-name {
  font-size: 0.65rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  display: block;
  letter-spacing: 0.01em;
}

.message-row.hospital .sender-name { color: #fcbb00; }
.message-row.expert   .sender-name { color: #00d2ef; }

/* 말풍선 - 모바일 우선 기본값 */
.bubble {
  padding: 0.7rem 0.95rem;
  border-radius: 1.125rem;

  /* ━━━ 줄바꿈 핵심 설정 ━━━ */
  word-break: keep-all;        /* 한국어 단어 중간 자르기 금지 */
  overflow-wrap: break-word;   /* 매우 긴 단어만 예외 처리 */
  white-space: pre-line;       /* \n 줄바꿈 + 자동 줄바꿈 동시 허용 */
  hyphens: none;               /* 하이픈 자동 삽입 금지 */

  line-height: 1.7;
  font-size: 0.84rem;
  letter-spacing: -0.01em;     /* 한국어 가독성 개선 */

  /* 텍스트 선명도 */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.message-row.hospital .bubble {
  background: linear-gradient(to bottom right, rgba(249, 156, 0, 0.20), rgba(254, 110, 0, 0.20));
  border: 1px solid rgba(252, 187, 0, 0.30);
  border-top-left-radius: 0.25rem;
  color: #fff;
}

.message-row.expert .bubble {
  background: linear-gradient(to bottom right, rgba(0, 183, 215, 0.20), rgba(48, 128, 255, 0.20));
  border: 1px solid rgba(0, 210, 239, 0.30);
  border-top-right-radius: 0.25rem;
  color: #fff;
}

/* ---------- 타이핑 인디케이터 ---------- */
.typing-row {
  display: flex;
  gap: 0.75rem;
  animation: fadeIn 0.3s ease-out forwards;
}

.typing-row.hospital { flex-direction: row; }
.typing-row.expert   { flex-direction: row-reverse; }

.typing-bubble {
  padding: 0.75rem 1rem;
  border-radius: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.typing-row.hospital .typing-bubble {
  background: linear-gradient(to bottom right, rgba(249, 156, 0, 0.20), rgba(254, 110, 0, 0.20));
  border: 1px solid rgba(252, 187, 0, 0.30);
}

.typing-row.expert .typing-bubble {
  background: linear-gradient(to bottom right, rgba(0, 183, 215, 0.20), rgba(48, 128, 255, 0.20));
  border: 1px solid rgba(0, 210, 239, 0.30);
}

.dot {
  width: 0.5rem; height: 0.5rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 9999px;
  animation: bounce 1s infinite;
}

.dot:nth-child(2) { animation-delay: 150ms; }
.dot:nth-child(3) { animation-delay: 300ms; }

/* ---------- 상담 수락 프롬프트 ---------- */
.consult-prompt-wrap {
  margin-top: 1.5rem;
  animation: fadeIn 0.3s ease-out forwards;
}

.consult-prompt-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
  border-radius: 1.5rem;
  padding: 1.5rem;
  text-align: center;
  max-width: 28rem;
  margin: 0 auto;
}

.consult-prompt-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1rem;
}

.btn-accept {
  padding: 0.75rem 2rem;
  background: linear-gradient(to right, #00b7d7, #3080ff);
  color: #fff;
  font-weight: 700;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(0, 183, 215, 0.25);
  font-size: 0.9rem;
  font-family: inherit;
}

.btn-accept:hover {
  background: linear-gradient(to right, #00d2ef, #54a2ff);
  box-shadow: 0 8px 28px rgba(0, 183, 215, 0.40);
  transform: translateY(-2px);
}

/* ---------- 상담 신청 폼 ---------- */
.form-wrap {
  margin-top: 1.5rem;
  animation: fadeIn 0.3s ease-out forwards;
}

.form-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
  border-radius: 1.5rem;
  padding: 1.5rem;
  max-width: 36rem;
  margin: 0 auto;
}

.form-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-bottom: 0.5rem;
}

.form-subtitle {
  font-size: 0.8rem;
  color: #6a7282;
  text-align: center;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.4rem;
}

.form-label .required { color: #ff6568; }

.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.4rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #d1d5dc;
  transition: color 0.2s;
}

.radio-label:hover { color: #fff; }

.radio-label input[type="radio"] {
  width: 1.1rem; height: 1.1rem;
  accent-color: #00baa7;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}

.form-input::placeholder { color: #6a7282; }

.form-input:focus {
  border-color: #00baa7;
  box-shadow: 0 0 0 1px #00baa7;
}

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-submit {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  background: linear-gradient(to right, #00baa7, #00d2ef);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(0, 186, 167, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-submit:hover:not(:disabled) {
  background: linear-gradient(to right, #00d3bd, #53eafd);
  box-shadow: 0 8px 28px rgba(0, 186, 167, 0.40);
  transform: translateY(-2px);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-note {
  font-size: 0.72rem;
  color: #6a7282;
  text-align: center;
  margin-top: 1rem;
}

.form-error {
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(251, 44, 54, 0.10);
  border: 1px solid rgba(251, 44, 54, 0.20);
  color: #ff6568;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0.75rem;
  font-weight: 500;
}

/* 성공 화면 */
.form-success {
  text-align: center;
  padding: 2rem 0;
}

.success-icon {
  width: 4rem; height: 4rem;
  border-radius: 9999px;
  background: linear-gradient(to bottom right, rgba(0, 186, 167, 0.3), rgba(0, 199, 88, 0.3));
  border: 2px solid rgba(0, 186, 167, 0.5);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  color: #00d3bd;
  font-size: 1.5rem;
}

.success-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}

.success-desc {
  font-size: 0.85rem;
  color: #94a3b8;
  line-height: 1.6;
}

/* ---------- 컨트롤 버튼 ---------- */
.speed-btn, .show-all-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: 0.75rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.10);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.speed-btn:hover, .show-all-btn:hover {
  background: rgba(255,255,255,0.18);
}

.speed-btn.fast {
  background: rgba(234, 179, 8, 0.20);
  border-color: rgba(250, 200, 0, 0.50);
  color: #ffe02a;
}

/* ---------- 새 메시지 버튼 ---------- */
.new-msg-btn {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(0, 183, 215, 0.80);
  border: 1px solid rgba(0, 210, 239, 0.50);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(0, 183, 215, 0.25);
  animation: bounce 1s infinite;
  z-index: 50;
}

/* ---------- 푸터 ---------- */
.chat-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}

/* 약관 링크 줄 (면책 문구보다 2pt 큰 폰트) */
.footer-legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.footer-legal-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.76rem;   /* text-footer(0.68rem) + 약 2pt */
  color: #8a95a8;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  transition: color 0.18s;
}
.footer-legal-btn:hover,
.footer-legal-btn:active {
  color: #b8c4d4;
}
.footer-legal-sep {
  font-size: 0.76rem;
  color: #4a5565;
  user-select: none;
}

.text-footer {
  font-size: 0.68rem;
  color: #6a7282;
}

.text-footer-copy {
  font-size: 0.65rem;
  color: #4a5565;
}

/* ---------- 약관 팝업 오버레이 ---------- */
.legal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;       /* 모바일: 하단에서 올라오는 시트 형태 */
  justify-content: center;
  padding: 0 15% 0 15%;        /* 양 옆 15% 여백 */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.legal-overlay.hidden { display: none !important; }

/* 팝업 본체 */
.legal-popup {
  background: rgba(255, 255, 255, 0.88); /* 화이트 85% 투명도 */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.35);
  animation: slideUpPopup 0.22s ease-out;
}

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

/* 팝업 헤더 (X 닫기 버튼) */
.legal-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem 0.7rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.legal-popup-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1e2535;
  letter-spacing: -0.01em;
}
.legal-popup-close {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: #2d3748;
  transition: background 0.15s;
  flex-shrink: 0;
}
.legal-popup-close:hover,
.legal-popup-close:active {
  background: rgba(0,0,0,0.15);
}
.legal-popup-close svg {
  flex-shrink: 0;
}

/* 팝업 본문 스크롤 영역 */
.legal-popup-body {
  overflow-y: auto;
  padding: 1rem 1.1rem 1.5rem;
  -webkit-overflow-scrolling: touch;
  color: #2c3344;              /* 가시성 좋은 어두운 그레이 */
  font-size: 0.72rem;
  line-height: 1.75;
  word-break: keep-all;
}

/* 본문 내부 타이포그래피 */
.legal-popup-body .lp-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1a202c;
  margin-bottom: 0.25rem;
  text-align: center;
}
.legal-popup-body .lp-date {
  font-size: 0.68rem;
  color: #5a6478;
  text-align: center;
  margin-bottom: 1rem;
}
.legal-popup-body .lp-article {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1e2535;
  margin: 1rem 0 0.3rem;
}
.legal-popup-body .lp-p {
  margin-bottom: 0.5rem;
  color: #374151;
}
.legal-popup-body .lp-list {
  padding-left: 1.1rem;
  margin-bottom: 0.5rem;
  color: #374151;
}
.legal-popup-body .lp-list li {
  margin-bottom: 0.2rem;
}
.legal-popup-body .lp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
  margin-bottom: 0.5rem;
}
.legal-popup-body .lp-table th,
.legal-popup-body .lp-table td {
  border: 1px solid rgba(0,0,0,0.15);
  padding: 0.3rem 0.4rem;
  text-align: left;
  color: #2c3344;
}
.legal-popup-body .lp-table th {
  background: rgba(0,0,0,0.06);
  font-weight: 700;
}
.legal-popup-body .lp-indent {
  padding-left: 0.8rem;
  color: #4b5563;
}
.legal-popup-body .lp-highlight {
  font-weight: 700;
  color: #1a202c;
}

/* ---------- 유틸리티 ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-3 { gap: 0.75rem; }
.gap-2 { gap: 0.5rem; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.mx-auto { margin: 0 auto; }
.max-w-4xl { max-width: 56rem; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }
.fixed { position: fixed; }
.font-sans { font-family: 'Noto Sans KR', sans-serif; }
.relative { position: relative; }
.min-h-screen { min-height: 100vh; }

/* ---------- 애니메이션 ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8,0,1,1);
  }
  50% {
    transform: none;
    animation-timing-function: cubic-bezier(0,0,0.2,1);
  }
}

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

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

/* 스피너 */
.spinner {
  width: 1.25rem; height: 1.25rem;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 9999px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ============================================================
   📱 모바일 9:16 최적화 (360~430px 기준 / 메타광고 타겟)
   ============================================================ */

/* --- 기본 모바일 우선 (max 430px) --- */
@media (max-width: 430px) {

  /* 헤더 */
  .header-inner {
    padding: 0.55rem 0.875rem;
  }
  .header-title   { font-size: 0.82rem; }
  .header-subtitle { font-size: 0.62rem; }
  .header-brand   { font-size: 0.62rem; }
  .header-logo    { width: 1.75rem; height: 1.75rem; }

  /* 채팅 스크롤 */
  .chat-scroll {
    padding: 0.875rem 0.75rem;
    padding-bottom: 5rem; /* 컨트롤 버튼 가림 방지 */
  }

  #messagesContainer, #chatInner { gap: 0.625rem; }

  /* 아바타 */
  .avatar { width: 2rem; height: 2rem; }
  .avatar svg { width: 14px; height: 14px; }

  /* 말풍선 래퍼 - 화면 90% 사용 */
  .bubble-wrapper { max-width: 84%; }

  /* 발신자 이름 */
  .sender-name { font-size: 0.62rem; margin-bottom: 0.2rem; }

  /* ━━━ 핵심: 말풍선 텍스트 최적화 ━━━ */
  .bubble {
    font-size: 0.8rem;        /* 모바일 최적 크기 */
    line-height: 1.7;         /* 줄간격 넉넉하게 */
    padding: 0.625rem 0.875rem;
    border-radius: 1rem;

    /* 한국어 자연스러운 줄바꿈 */
    word-break: keep-all;     /* 단어 중간 절대 안 자름 */
    overflow-wrap: break-word; /* 아주 긴 단어만 예외 처리 */
    word-spacing: -0.02em;    /* 자간 살짝 줄여 밀도 개선 */

    /* 텍스트 선명도 */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  /* 메시지 간격 */
  .message-row { gap: 0.5rem; }

  /* 컨트롤 버튼 */
  .speed-btn, .show-all-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.72rem;
  }

  /* 새 메시지 버튼 */
  .new-msg-btn {
    bottom: 5.5rem;
    font-size: 0.72rem;
    padding: 0.4rem 0.875rem;
  }

  /* 폼 카드 */
  .form-card {
    padding: 1.125rem 1rem;
    border-radius: 1.25rem;
    margin: 0;
  }
  .form-title    { font-size: 1.05rem; }
  .form-subtitle { font-size: 0.75rem; margin-bottom: 1.125rem; }
  .form-label    { font-size: 0.78rem; }
  .form-input    { font-size: 0.85rem; padding: 0.65rem 0.875rem; }
  .btn-submit    { font-size: 0.9rem; padding: 0.875rem 1.25rem; }
  .form-note     { font-size: 0.67rem; }

  /* 상담 프롬프트 */
  .consult-prompt-card {
    padding: 1.25rem 1rem;
    border-radius: 1.25rem;
  }
  .consult-prompt-card h3 { font-size: 0.95rem; margin-bottom: 0.875rem; }
  .btn-accept { font-size: 0.85rem; padding: 0.65rem 1.5rem; }

  /* 푸터 */
  .text-footer        { font-size: 0.62rem; }
  .text-footer-copy   { font-size: 0.6rem; }
  .footer-legal-btn   { font-size: 0.70rem; }  /* text-footer + 2pt */
  .footer-legal-sep   { font-size: 0.70rem; }
  .chat-footer        { padding: 0.6rem 0.75rem; }

  /* 약관 팝업 - 모바일 최적화 */
  .legal-overlay      { padding: 0 15% 0 15%; }
  .legal-popup        { border-radius: 14px 14px 0 0; max-height: 80vh; }
  .legal-popup-header { padding: 0.8rem 0.9rem 0.6rem; }
  .legal-popup-body   { font-size: 0.7rem; padding: 0.875rem 0.9rem 1.25rem; }
  .legal-popup-title  { font-size: 0.85rem; }
}

/* --- 중간 모바일 (431px ~ 640px) --- */
@media (min-width: 431px) and (max-width: 640px) {
  .header-inner { padding: 0.65rem 1rem; }
  .chat-scroll  { padding: 1rem 0.875rem; padding-bottom: 5rem; }
  .bubble {
    font-size: 0.83rem;
    line-height: 1.68;
    padding: 0.65rem 0.9rem;
    word-break: keep-all;
    overflow-wrap: break-word;
  }
  .bubble-wrapper { max-width: 82%; }
  .avatar { width: 2.25rem; height: 2.25rem; }
  .form-card { padding: 1.25rem; }
  .consult-prompt-card { padding: 1.25rem; }
}

/* --- 태블릿 이상 (641px+) --- */
@media (min-width: 641px) {
  .bubble {
    font-size: 0.9rem;
    line-height: 1.7;
    word-break: keep-all;
    overflow-wrap: break-word;
  }
  .avatar         { width: 2.75rem; height: 2.75rem; }
  .bubble-wrapper { max-width: 75%; }
  .chat-scroll    { padding: 1.5rem 1.25rem; }
}

/* ─────────────────────────────────────────────
   📱 iOS 입력 줌 방지 + 터치 접근성 강화
   (font-size 16px 이상 → iOS Safari 자동 줌 없음)
───────────────────────────────────────────── */

/* 폼 입력 필드 - iOS 줌 방지 */
.form-input,
.form-input[type="text"],
.form-input[type="tel"],
.form-input[type="email"] {
  font-size: 16px !important;    /* iOS 줌 방지 임계값 */
  -webkit-appearance: none;      /* iOS 기본 스타일 제거 */
  appearance: none;
  border-radius: 0.75rem;        /* iOS border-radius 강제 */
}

/* 라디오 버튼 터치 영역 확장 */
.radio-label {
  min-height: 44px;              /* 최소 44px 터치 영역 (Apple HIG) */
  padding: 0.5rem 0;
}

/* 버튼 최소 터치 영역 */
.btn-submit,
.btn-accept {
  min-height: 48px;
}

.footer-legal-btn {
  min-height: 36px;
  padding: 0.2rem 0.25rem;
}

/* 폼 스크롤 시 고정 헤더 겹침 방지 */
.form-card,
.form-wrap {
  scroll-margin-top: 80px;
}

/* 에러 메시지 진동 애니메이션 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.form-error.shake {
  animation: shake 0.4s ease-out;
}

/* 입력 오류 상태 하이라이트 */
.form-input.error {
  border-color: rgba(251, 44, 54, 0.60) !important;
  box-shadow: 0 0 0 2px rgba(251, 44, 54, 0.15) !important;
}

/* 입력 성공 상태 */
.form-input.valid {
  border-color: rgba(0, 186, 167, 0.50);
  box-shadow: 0 0 0 1px rgba(0, 186, 167, 0.20);
}

/* 폼 카드 등장 애니메이션 */
.form-wrap {
  animation: fadeIn 0.35s ease-out forwards;
}

/* 성공 화면 애니메이션 */
.form-success {
  animation: fadeIn 0.4s ease-out forwards;
}

/* 성공 아이콘 펄스 */
@keyframes successPulse {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.success-icon {
  animation: successPulse 0.5s ease-out forwards;
}

/* ─────────────────────────────────────────────
   포커스 링 (접근성) - 키보드 / 스위치 컨트롤
───────────────────────────────────────────── */
.form-input:focus-visible {
  outline: 2px solid #00baa7;
  outline-offset: 2px;
}

.btn-submit:focus-visible,
.btn-accept:focus-visible,
.footer-legal-btn:focus-visible,
.speed-btn:focus-visible,
.show-all-btn:focus-visible {
  outline: 2px solid #00d2ef;
  outline-offset: 3px;
}

/* 팝업 닫기 버튼 포커스 */
.legal-popup-close:focus-visible {
  outline: 2px solid #1e2535;
  outline-offset: 2px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   📱 iOS Safe Area (노치 / 다이나믹 아일랜드 / 홈바 대응)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@supports (padding: max(0px)) {
  .header-inner {
    padding-top: max(0.55rem, env(safe-area-inset-top));
    padding-left:  max(0.875rem, env(safe-area-inset-left));
    padding-right: max(0.875rem, env(safe-area-inset-right));
  }
  .chat-footer {
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
  }
  #controlButtons {
    bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 1rem));
    right:  max(1rem,   env(safe-area-inset-right));
  }
}
