.chat-page {
  background: var(--bg-soft);
  min-height: calc(100vh - var(--header-h));
  padding: 40px 0 60px;
}

.chat-container {
  max-width: 720px;
}

.chat-window {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.chat-window-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
}

.chat-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6de08a;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(109, 224, 138, 0.25);
}

.chat-window-header strong {
  display: block;
  font-size: 0.98rem;
}

.chat-window-header small {
  display: block;
  margin-top: 2px;
  color: #cfe0ee;
  font-size: 0.78rem;
}

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  overflow-y: auto;
}

.chat-bubble {
  max-width: 78%;
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  line-height: 1.55;
  font-size: 0.96rem;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--line);
}

.chat-option {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 0.7rem 1.05rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.chat-option:hover {
  background: #eaf4ff;
  border-color: rgba(31, 95, 159, 0.35);
}

.chat-option.is-trending {
  border-color: rgba(240, 180, 90, 0.6);
  background: #fff8ec;
  color: var(--navy-deep);
}

.chat-option.is-trending:hover {
  background: #fdf0d6;
  border-color: var(--accent);
}

.chat-options-heading {
  flex-basis: 100%;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.chat-options-heading:first-child {
  margin-top: 0;
}

@media (max-width: 640px) {
  /* 휴대폰에서 머리글 밑줄과 채팅창 시작 사이 여백이 너무 넓다는 지적(2026-09-25)에
     40px -> 16px로 좁혔다(컴퓨터 화면은 그대로 40px). */
  .chat-page {
    padding-top: 16px;
  }

  .chat-window {
    min-height: 70vh;
    border-radius: 18px;
  }

  .chat-bubble {
    max-width: 88%;
  }
}

/* ── 단계별 설문 (정부지원금 확인) ───────────────────────────────
   말풍선이 오가는 대화창이 아니라, 질문 하나에 선택지를 세로로 한 줄씩
   늘어놓는 방식이다. 어르신이 보시기에 어떤 보기가 있는지 한눈에 들어오고
   손가락으로 누르기도 쉽다. */

.survey {
  flex: 1;
  padding: 32px 28px 28px;
}

.survey-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.survey-step {
  flex-shrink: 0;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 800;
}

.survey-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.survey-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  transition: width 0.3s ease;
}

.survey-question {
  margin: 0 0 8px;
  color: var(--navy-deep);
  font-size: 1.42rem;
  line-height: 1.45;
}

.survey-hint {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

.survey-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.survey-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 1.05rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 1.08rem;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.survey-option:hover {
  border-color: rgba(31, 95, 159, 0.45);
  background: #f4f9ff;
}

/* 선택지 앞의 동그란 표시. 고른 항목은 가운데가 채워진다. */
.survey-option-mark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid #c3d3e2;
  border-radius: 50%;
  position: relative;
}

.survey-option.is-selected {
  border-color: var(--navy);
  background: #eef6ff;
}

.survey-option.is-selected .survey-option-mark {
  border-color: var(--navy);
}

.survey-option.is-selected .survey-option-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--navy);
}

.survey-nav {
  margin-top: 22px;
}

.survey-back,
.survey-restart {
  border: none;
  background: none;
  padding: 6px 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.96rem;
}

.survey-back:hover,
.survey-restart:hover {
  color: var(--navy);
}

/* 결과 화면 */

.survey-advice {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  margin: 0 0 24px;
  list-style: none;
}

.survey-advice li {
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--blue);
  border-radius: 0 12px 12px 0;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.65;
}

.survey-summary-box {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.survey-summary-box h3 {
  margin: 0 0 14px;
  color: var(--navy);
  font-size: 1rem;
}

.survey-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.survey-summary li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.survey-summary-q {
  color: var(--muted);
  font-size: 0.88rem;
}

.survey-summary-a {
  color: var(--navy-deep);
  font-size: 1rem;
}

.survey-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.survey-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

@media (max-width: 640px) {
  .survey {
    padding: 24px 20px;
  }

  .survey-question {
    font-size: 1.24rem;
  }

  .survey-actions {
    grid-template-columns: 1fr;
  }
}

/* ── 채팅 도우미 (chat.html) — 2026-09-24 ────────────────────────────────
   AI 가 아니라 "주제 → 질문"을 골라 누르는 방식이다. 어르신도 읽고 누르기 쉽게 글씨와 단추를 크게 한다.
   .chat-window.is-bot 안에서만 적용된다 (정부지원금 확인 화면 subsidy-chat.html 은 같은 창 모양을 쓰므로 건드리지 않는다). */

.chat-window.is-bot {
  height: min(84vh, 880px);
  min-height: 560px;
}

.chat-window-title {
  flex: 1;
  min-width: 0;
}

.is-bot .chat-window-header strong {
  font-size: 1.1rem;
}

.is-bot .chat-window-header small {
  font-size: 0.9rem;
}

.is-bot .chat-thread {
  position: relative;
  gap: 16px;
  padding: 24px;
}

.is-bot .chat-bubble {
  max-width: 94%;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.75;
}

.is-bot .chat-bubble.user {
  max-width: 88%;
  font-weight: 700;
}

.is-bot .chat-bubble p {
  margin: 0 0 0.65em;
}

.is-bot .chat-bubble p:last-child,
.is-bot .chat-bubble ul:last-child,
.is-bot .chat-bubble ol:last-child {
  margin-bottom: 0;
}

.is-bot .chat-bubble ul,
.is-bot .chat-bubble ol {
  margin: 0 0 0.65em;
  padding-left: 1.3em;
}

.is-bot .chat-bubble li {
  margin: 0.3em 0;
  padding-left: 0.2em;
}

.is-bot .chat-bubble strong {
  color: var(--navy-deep);
  font-weight: 800;
}

/* 답을 준비하는 동안 보이는 점 세 개 */
.chat-bubble.is-typing {
  display: flex;
  gap: 6px;
  align-items: center;
  width: fit-content;
  padding: 1rem 1.2rem;
}

.chat-bubble.is-typing span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9db4c9;
  animation: chat-typing 1s infinite ease-in-out;
}

.chat-bubble.is-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-bubble.is-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-typing {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble.is-typing span {
    animation: none;
    opacity: 0.7;
  }
}

/* 답변 아래 이동 버튼 (다른 화면으로 가기 · 전화 · 주소 복사) */
.chat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: -4px;
}

.chat-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.65rem 1.2rem;
  border: 1px solid #9db8d6;
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
}

.chat-link:hover {
  background: #eaf4ff;
  border-color: rgba(31, 95, 159, 0.55);
}

.chat-link.is-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
}

.chat-link.is-primary:hover {
  filter: brightness(1.12);
}

/* 선택 버튼 — 큰 주제는 2열, 작은 질문은 한 줄에 하나씩 */
.is-bot .chat-options {
  padding: 0;
  border-top: 0;
  gap: 10px;
}

.is-bot .chat-options.is-topics {
  display: grid;
  grid-template-columns: 1fr;
}

.is-bot .chat-option {
  min-height: 54px;
  padding: 0.75rem 1.1rem;
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.is-bot .chat-option.is-topic {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 72px;
  padding: 0.85rem 1.3rem;
  border: 1px solid #9db8d6;
  background: #f4f9ff;
  text-align: left;
}

/* 큰 틀 버튼: 굵은 이름 한 줄 + 그 밑에 무엇이 들어 있는지 작은 설명 한 줄 */
.chat-topic-name {
  color: var(--navy);
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.35;
}

.chat-topic-desc {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

.is-bot .chat-option.is-topic:hover {
  background: #e3f0ff;
}

.is-bot .chat-options.is-questions,
.is-bot .chat-options.is-followups {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}

.is-bot .chat-option.is-nav {
  min-height: 46px;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
}

/* "처음으로" — 2026-09-26. 옅은 하늘색(#eaf4ff)으로 한 번 해봤는데
   다른 버튼과 거의 구분이 안 될 만큼 약했다("여전히 눈에 안 띈다").
   이번에는 색을 채우는 대신 진한 남색 바탕 + 흰 글씨로, 다른 흰
   바탕 버튼들 사이에서 확실히 도드라지게 한다. 크기·글자 크기는
   그대로 두고 색만 바꾼다. */
.is-bot .chat-option.is-restart {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-color: transparent;
  color: #fff;
}

.is-bot .chat-option.is-restart:hover {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-deep) 100%);
  border-color: transparent;
}

/* 답변 바로 아래 "처음으로" 줄 — 채팅 창 아래쪽에 붙어 늘 보인다 */
.is-bot .chat-navrow {
  position: sticky;
  bottom: -24px; /* 채팅 창 안쪽 여백(24px)만큼 내려서 바닥에 딱 붙인다 */
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 -24px;
  padding: 10px 24px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.is-bot .chat-navrow .chat-option {
  flex: 0 0 auto;
  min-height: 46px;
  font-weight: 800;
}

.is-bot .chat-options-heading {
  flex-basis: auto;
  margin: 8px 0 0;
  font-size: 0.92rem;
}

/* 아래에 붙어 있는 도움말 줄 */
.chat-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 14px 24px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 500;
}

.chat-help-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin: 0;
}

.chat-help a {
  color: var(--navy);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 640px) {
  .chat-window.is-bot {
    height: calc(100vh - var(--header-h) - 40px);
    min-height: 520px;
  }

  .is-bot .chat-thread {
    padding: 16px;
  }

  .is-bot .chat-navrow {
    bottom: -16px;
    margin: 0 -16px;
    padding: 10px 16px 12px;
  }

  .is-bot .chat-bubble {
    max-width: 98%;
    font-size: 1.05rem;
  }

  .chat-topic-name {
    font-size: 1.1rem;
  }

  .chat-help {
    padding: 12px 16px 14px;
  }
}
