
:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-glow: rgba(59, 130, 246, 0.16);
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(148, 163, 184, 0.22);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --shadow-lg: 0 28px 80px rgba(15, 23, 42, 0.14);
  --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
  --user: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  --bot: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(248,250,252,0.96) 100%);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, var(--bg-glow), transparent 34%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: Inter, Pretendard, "Noto Sans KR", Arial, sans-serif;
}
body[data-embedded="true"] { background: transparent; }
.chat-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body[data-embedded="true"] .chat-shell {
  min-height: 100dvh;
  height: 100dvh;
  padding: 8px;
}
.chat-topbar { display: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.chat-body {
  width: min(1520px, 100%);
  margin: 0 auto;
  display: grid;
  /* 아내 FAQ | 채팅 | 남편 FAQ */
  grid-template-columns: minmax(240px, 300px) minmax(360px, 1fr) minmax(240px, 300px);
  gap: 16px;
  padding: 20px 16px;
  flex: 1;
  align-items: stretch;
}
body[data-embedded="true"] .chat-body {
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  padding: 0;
  min-height: 0;
}
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 28px;
  overflow: hidden;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
}
body[data-embedded="true"] .chat-panel {
  height: 100%;
  border-radius: 22px;
}
.chat-messages {
  min-height: 460px;
  max-height: calc(100vh - 270px);
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.45), transparent 42%),
    linear-gradient(180deg, rgba(248,250,252,0.65) 0%, rgba(255,255,255,0.2) 100%);
}
body[data-embedded="true"] .chat-messages {
  max-height: none;
  min-height: 0;
  padding: 16px 16px 12px;
}
.chat-messages::-webkit-scrollbar { width: 10px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.chat-message { display: flex; align-items: flex-start; }
.chat-message.is-user { justify-content: flex-end; }
.chat-message-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: min(88%, 760px);
}
.chat-message.is-user .chat-message-content {
  max-width: min(82%, 720px);
  justify-content: flex-end;
}
.chat-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.2);
  position: relative;
  overflow: hidden;
}
.chat-avatar::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,0.18);
}
.chat-avatar-initials {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.chat-message-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.chat-message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 4px;
}
.chat-message.is-user .chat-message-head {
  justify-content: flex-end;
  padding-left: 0;
  padding-right: 4px;
}
.chat-speaker {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}
.chat-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
}
.chat-bubble {
  max-width: 100%;
  padding: 16px 18px;
  border-radius: 22px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.chat-message.is-user .chat-bubble {
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 8px;
}
.chat-message.is-bot .chat-bubble {
  background: var(--bot);
  border: 1px solid rgba(255,255,255,0.86);
  border-bottom-left-radius: 8px;
}
.chat-message.is-user .chat-speaker {
  color: #475569;
}
.chat-message.is-user .chat-role-badge {
  background: rgba(148, 163, 184, 0.12);
  color: #475569;
}
.chat-text {
  font-size: 14px;
  letter-spacing: -0.01em;
}
.chat-meta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
}
.chat-compose {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(18px);
  padding: 18px 22px 22px;
}
body[data-embedded="true"] .chat-compose { padding: 12px 14px 14px; }
.chat-form { display: block; margin: 0; }
.chat-compose-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
}
.chat-textarea {
  flex: 1;
  min-width: 0;
  width: auto;
  min-height: 118px;
  resize: vertical;
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255,255,255,0.96);
  border-radius: 20px;
  outline: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.65;
}
body[data-embedded="true"] .chat-textarea {
  min-height: 88px;
  max-height: 132px;
  padding: 14px 15px;
}
.chat-textarea::placeholder { color: #94a3b8; }
.chat-textarea:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.08), 0 10px 24px rgba(37, 99, 235, 0.06);
}
.chat-actions {
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  flex-shrink: 0;
}
.chat-submit {
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  padding: 14px 18px;
  font: inherit;
  font-size: 14px;
  line-height: 1.65;
  font-weight: 700;
  cursor: pointer;
  min-width: 72px;
  width: auto;
  align-self: flex-end;
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.26);
}
.chat-submit[disabled] { opacity: 0.55; cursor: wait; }
.chat-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}
.chat-card--faq {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 40px);
}
.chat-card--faq h2 {
  flex-shrink: 0;
}
.chat-faq-side-hint {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.45;
  flex-shrink: 0;
}
.chat-side--wife .chat-card--faq {
  background: linear-gradient(180deg, rgba(253, 242, 248, 0.75) 0%, rgba(255, 255, 255, 0.88) 100%);
  border-color: rgba(251, 207, 232, 0.45);
}
.chat-side--husband .chat-card--faq {
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.85) 0%, rgba(255, 255, 255, 0.92) 100%);
  border-color: rgba(191, 219, 254, 0.55);
}
.chat-side--faq .chat-suggestions--stack {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 0;
  padding-right: 2px;
}
.chat-side--faq .chat-suggestions--stack::-webkit-scrollbar { width: 7px; }
.chat-side--faq .chat-suggestions--stack::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}
body[data-embedded="true"] .chat-side { display: none; }
.chat-card {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 22px;
  padding: 18px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-sm);
}
.chat-card h2 {
  margin: 0 0 12px;
  font-size: 15px;
}
.chat-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.chat-suggestions--stack {
  flex-direction: column;
  flex-wrap: nowrap;
  margin-top: 0;
  gap: 8px;
}
.chat-suggestion {
  border: 1px solid rgba(191, 219, 254, 0.7);
  background: rgba(255,255,255,0.94);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chat-suggestion--block {
  border-radius: 14px;
  width: 100%;
  text-align: left;
  white-space: normal;
  line-height: 1.5;
  padding: 11px 14px;
  font-weight: 600;
}
.chat-suggestion:hover {
  border-color: rgba(96, 165, 250, 0.9);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.08);
}
.chat-consult-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
}
.chat-consult-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}
.chat-consult-btn svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
.chat-consult-btn:hover {
  transform: translateY(-1px);
}
.chat-consult-btn:active {
  transform: translateY(0);
}
/* 전화상담: 밝은 말풍선에서도 글자·아이콘이 확실히 보이도록 (진한 테두리·글자색 고정) */
.chat-consult-btn.is-call {
  background: #fff !important;
  color: #3d291f !important;
  border: 2px solid #6b4f42 !important;
  box-shadow: 0 4px 14px rgba(94, 64, 55, 0.18);
}
.chat-consult-btn.is-call span {
  color: #3d291f !important;
}
.chat-consult-btn.is-call svg,
.chat-consult-btn.is-call svg path {
  stroke: #5e4037 !important;
  fill: none !important;
}
.chat-consult-btn.is-call:hover {
  background: #faf6f3 !important;
  border-color: #5e4037 !important;
}
.chat-consult-btn.is-apply {
  background: linear-gradient(135deg, #7c5a4d 0%, #5e4037 100%);
  color: #ffffff;
  border-color: rgba(94, 64, 55, 0.35);
  box-shadow: 0 10px 18px rgba(94, 64, 55, 0.28);
}
.chat-consult-btn.is-apply svg {
  stroke: #fff;
  fill: none;
}
/* 상담 접수 모달 */
.consult-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.consult-modal.is-open {
  opacity: 1;
  visibility: visible;
}
.consult-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}
.consult-modal-panel {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #f9f7f2;
  border-radius: 20px;
  padding: 28px 24px 24px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(124, 90, 77, 0.12);
}
.consult-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  border-radius: 10px;
}
.consult-modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}
.consult-modal-panel h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 800;
  text-align: center;
  color: #3d2c26;
}
.consult-modal-subtitle {
  margin: 0 0 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #c41e3a;
}
.consult-modal-hint {
  margin: 0 0 20px;
  text-align: center;
  font-size: 13px;
  line-height: 1.65;
  color: #64748b;
}
.consult-modal-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}
.consult-modal-form input,
.consult-modal-form textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: #0f172a;
}
.consult-modal-form textarea {
  min-height: 120px;
  resize: vertical;
}
.consult-modal-form input:focus,
.consult-modal-form textarea:focus {
  outline: none;
  border-color: rgba(124, 90, 77, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 90, 77, 0.12);
}
.consult-modal-submit {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px 20px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #7c5a4d 0%, #5e4037 100%);
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(94, 64, 55, 0.3);
}
.consult-modal-submit:hover {
  filter: brightness(1.03);
}
.consult-modal-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}
.consult-modal-error {
  font-size: 13px;
  color: #b91c1c;
  margin-bottom: 10px;
  display: none;
}
.consult-modal-error.is-visible {
  display: block;
}
.chat-message.is-user .chat-consult-actions {
  display: none;
}
@media (max-width: 1100px) {
  .chat-body {
    grid-template-columns: 1fr;
    grid-auto-flow: row dense;
  }
  .chat-side--wife { order: 1; }
  .chat-panel { order: 2; }
  .chat-side--husband { order: 3; }
  .chat-card--faq { max-height: min(48vh, 420px); }
}
@media (max-width: 900px) {
  .chat-compose-row { gap: 8px; }
  .chat-submit { min-width: 64px; padding: 12px 14px; }
}
