:root {
  color-scheme: light;
  --blue: #2962ff;
  --blue-dark: #1746d1;
  --blue-soft: #edf3ff;
  --navy: #101828;
  --text: #263244;
  --muted: #697586;
  --line: #e4e9f0;
  --surface: #ffffff;
  --app-bg: #edf1f6;
  --green: #19b56b;
  --shadow: 0 24px 70px rgba(19, 33, 68, 0.14);
}

* { box-sizing: border-box; }

.typing-message .message-bubble { color: #64748b; font-size: 13px; }
.result-detail-link { display: block; padding: 14px 18px; font-size: 13px; text-align: center; color: #475569; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(41, 98, 255, 0.09), transparent 27rem),
    radial-gradient(circle at 86% 72%, rgba(25, 181, 107, 0.07), transparent 24rem),
    var(--app-bg);
  color: var(--navy);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

button,
input { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { cursor: pointer; }

a {
  color: inherit;
  text-decoration: none;
}

h1,
p { margin: 0; }

p,
a,
button,
input { overflow-wrap: anywhere; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(219, 226, 236, 0.88);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto minmax(96px, 1fr);
  align-items: center;
  width: min(920px, calc(100% - 32px));
  min-height: 68px;
  margin: 0 auto;
  gap: 12px;
}

.header-home,
.header-call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-weight: 800;
}

.header-home {
  justify-self: start;
  color: #3d4a5d;
  font-size: 14px;
}

.brand-logo { justify-self: center; }

.brand-logo img {
  display: block;
  width: clamp(116px, 28vw, 158px);
  max-height: 42px;
  object-fit: contain;
}

.header-call {
  justify-self: end;
  border-radius: 14px;
  background: var(--navy);
  color: #fff;
  padding: 0 15px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.18);
}

.consult-main {
  width: min(900px, calc(100% - 32px));
  min-height: calc(100svh - 68px);
  margin: 0 auto;
  padding: 20px 0 24px;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 100%;
  height: calc(100svh - 112px);
  min-height: 650px;
  max-height: 920px;
  overflow: hidden;
  border: 1px solid rgba(213, 222, 234, 0.94);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 20px;
}

.advisor-profile {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.advisor-avatar {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 16px;
  background: linear-gradient(145deg, #3774ff, #1746d1);
  color: #fff;
  box-shadow: 0 10px 24px rgba(41, 98, 255, 0.28);
}

.advisor-avatar svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.advisor-copy { min-width: 0; }

#chatHeaderTitle { font-size: 18px; font-weight: 850; letter-spacing: -0.025em; }
#chatHeaderTitle h1 { display: inline; font-size: inherit; white-space: normal; }

.advisor-copy h1 {
  overflow: hidden;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advisor-copy p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(25, 181, 107, 0.12);
}

.text-button {
  min-height: 44px;
  border: 1px solid #d9e1ec;
  border-radius: 13px;
  background: #f8fafc;
  color: #4b5b70;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 88% 8%, rgba(41, 98, 255, 0.07), transparent 15rem),
    linear-gradient(180deg, #f6f8fb 0%, #f2f5f9 100%);
  padding: 24px 22px 30px;
  scrollbar-color: #c7d1df transparent;
  scrollbar-width: thin;
}

.chat-log::-webkit-scrollbar { width: 6px; }

.chat-log::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #c7d1df;
}

.message-row {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: flex-start;
  width: min(88%, 650px);
  padding-left: 42px;
  gap: 10px;
}

.message-row::before {
  position: absolute;
  top: 1px;
  left: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 11px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='6' width='18' height='12' rx='3'/%3E%3Cpath d='M9 3h6M8 12h8M12 8v8'/%3E%3C/svg%3E") center / 18px 18px no-repeat,
    linear-gradient(145deg, #3774ff, #1746d1);
  content: "";
  box-shadow: 0 7px 16px rgba(41, 98, 255, 0.2);
}

.message-row.user {
  align-self: flex-end;
  align-items: flex-end;
  width: min(78%, 560px);
  padding-left: 0;
}

.message-row.user::before { display: none; }

.message-bubble {
  border: 1px solid #e1e7ef;
  border-radius: 7px 20px 20px 20px;
  background: #fff;
  color: var(--text);
  padding: 13px 15px;
  font-size: 15px;
  line-height: 1.62;
  white-space: pre-line;
  box-shadow: 0 8px 22px rgba(31, 45, 72, 0.06);
}

.user .message-bubble {
  border-color: var(--blue);
  border-radius: 20px 7px 20px 20px;
  background: linear-gradient(145deg, #3774ff, var(--blue));
  color: #fff;
  box-shadow: 0 10px 24px rgba(41, 98, 255, 0.22);
}

.quick-replies,
.result-actions,
.result-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-reply,
.tool-button,
.result-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.quick-reply,
.tool-button {
  border: 1px solid #d9e4f6;
  background: rgba(255, 255, 255, 0.94);
  color: var(--blue-dark);
  padding: 9px 14px;
  box-shadow: 0 5px 14px rgba(31, 45, 72, 0.045);
}

.quick-reply:disabled {
  cursor: default;
  opacity: 0.48;
  box-shadow: none;
}

.quick-reply:focus-visible,
.tool-button:focus-visible,
.result-action:focus-visible,
.text-button:focus-visible,
.chat-form input:focus-visible,
.chat-form button:focus-visible,
a:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

.result-card {
  width: 100%;
  overflow: hidden;
  border: 1px solid #dce4ef;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(31, 45, 72, 0.1);
}

.result-card-head {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #173b93, #2962ff);
  color: #fff;
  padding: 20px;
}

.result-card-head::after {
  position: absolute;
  top: -44px;
  right: -34px;
  width: 125px;
  height: 125px;
  border: 24px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
}

.result-card-head small {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 750;
  opacity: 0.82;
}

.result-card-head strong {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 21px;
  line-height: 1.35;
}

.result-facts {
  display: grid;
  margin: 0;
  padding: 8px 20px;
}

.result-fact {
  display: grid;
  grid-template-columns: minmax(92px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
  border-bottom: 1px solid #edf0f4;
  padding: 12px 0;
}

.result-fact:last-child { border-bottom: 0; }

/* V5 summary only: keep the approved shell/composer unchanged. */
.consult-summary .result-card-head { padding: 12px 16px; }
.consult-summary .result-card-head strong { font-size: 16px; }
.consult-summary .result-facts { padding: 4px 16px; }
.consult-summary .result-fact { padding: 6px 0; }
.consult-summary .result-note { margin: 0; padding: 8px 16px 0; }
.consult-summary .result-actions { padding: 10px 16px 4px; }
.consult-summary > .text-button { margin: 2px 16px 8px; }

.result-fact dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-fact dd {
  margin: 0;
  color: var(--navy);
  font-size: 14px;
  font-weight: 850;
  text-align: right;
}

.result-note {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 14px 20px 0;
  font-size: 12px;
  line-height: 1.6;
}

.result-type-note {
  margin: 10px 20px 0;
  border-radius: 12px;
  background: #fff7ed;
  color: #9a3412;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
}

.result-actions { padding: 15px 20px 8px; }

.result-action {
  flex: 1 1 185px;
  padding: 10px 14px;
}

.result-action.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(41, 98, 255, 0.2);
}

.result-action.secondary {
  border: 1px solid #d6e2f8;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.result-action.neutral {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.result-tools { padding: 4px 20px 20px; }

.result-tools .tool-button { flex: 1 1 140px; }

.area-card {
  width: 100%;
  border: 1px solid #bfe9d2;
  border-radius: 18px;
  background: linear-gradient(145deg, #f2fcf7, #eaf9f1);
  padding: 16px;
  color: #155b3a;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 10px 24px rgba(25, 181, 107, 0.08);
}

.area-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
}

.area-card a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 6px;
  color: #0f6a42;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 14px 16px 8px;
}

.chat-form input {
  width: 100%;
  min-height: 54px;
  border: 1px solid #d7dfea;
  border-radius: 17px;
  background: #f7f9fc;
  padding: 0 16px;
  color: var(--navy);
  font-size: 16px;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.025);
}

.chat-form input::placeholder { color: #9aa6b5; }

.chat-form button {
  min-width: 80px;
  min-height: 54px;
  border: 0;
  border-radius: 17px;
  background: var(--navy);
  color: #fff;
  padding: 0 16px;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.17);
}

.chat-form button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.input-help,
.noscript-note {
  background: #fff;
  color: #8995a5;
  padding: 0 18px 13px;
  font-size: 11px;
  line-height: 1.5;
}

.site-footer {
  background: var(--navy);
  color: #b9c3d1;
}

.site-footer-inner {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 36px;
}

.site-footer strong {
  display: block;
  margin-bottom: 12px;
  color: #fff;
  font-size: 18px;
}

.site-footer p {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.55;
}

.site-footer a { color: #fff; }

.site-footer small {
  display: block;
  margin-top: 14px;
  color: #7e8a9b;
  font-size: 11px;
}

@media (hover: hover) {
  .quick-reply:hover,
  .tool-button:hover,
  .text-button:hover {
    border-color: #aec5f5;
    background: #f1f5ff;
    transform: translateY(-1px);
  }

  .result-action:hover,
  .header-call:hover {
    filter: brightness(0.97);
    transform: translateY(-1px);
  }
}

@media (max-width: 699px) {
  body { background: #f2f5f9; }

  .header-inner { min-height: 64px; }

  .consult-main {
    width: 100%;
    min-height: 0;
    padding: 0;
  }

  .chat-shell {
    height: 100%;
    min-height: 0;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .chat-heading {
    min-height: 74px;
    padding: 10px 14px;
  }

  .advisor-avatar {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 14px;
  }

  .advisor-copy h1 { font-size: 16px; }

  .chat-log { padding: 20px 14px 26px; }

  .message-row {
    width: 94%;
    padding-left: 38px;
  }

  .message-row::before {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .message-row.user { width: 84%; }

  .chat-form { padding: 12px 12px 7px; }

  .input-help,
  .noscript-note { padding: 0 14px calc(10px + env(safe-area-inset-bottom)); }
}

@media (max-width: 359px) {
  .header-inner {
    grid-template-columns: 48px auto 91px;
    width: calc(100% - 18px);
    gap: 5px;
  }

  .header-home { font-size: 12px; }

  .brand-logo img { width: 108px; }

  .header-call {
    padding-inline: 10px;
    font-size: 12px;
  }

  .chat-heading { padding-inline: 10px; }

  .advisor-profile { gap: 8px; }

  .advisor-avatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .advisor-avatar svg {
    width: 22px;
    height: 22px;
  }

  .advisor-copy h1 { font-size: 14px; }

  .advisor-copy p { font-size: 11px; }

  .text-button {
    padding-inline: 9px;
    font-size: 12px;
  }

  .chat-log { padding-inline: 10px; }

  .message-row {
    width: 98%;
    padding-left: 36px;
  }

  .message-row.user { width: 88%; }

  .message-bubble {
    padding: 12px 13px;
    font-size: 14px;
  }

  .chat-form {
    grid-template-columns: minmax(0, 1fr) 68px;
    gap: 7px;
    padding-inline: 9px;
  }

  .chat-form input { padding-inline: 12px; }

  .chat-form button {
    min-width: 68px;
    padding-inline: 8px;
  }

  .result-facts,
  .result-card-head { padding-inline: 16px; }

  .result-actions,
  .result-tools { padding-inline: 16px; }
}

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

/* Only this page loads these styles; the commercial-site footer is untouched. */
@media (max-width: 699px), (max-width: 1000px) and (max-height: 600px) {
  html.consult-page { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .consult-page body {
    position: fixed;
    top: var(--app-top, 0px);
    left: 0;
    width: 100%;
    height: 100vh;
    height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .consult-page .site-header { position: relative; flex: 0 0 auto; }
  .consult-page .header-inner { min-height: 56px; }
  .consult-page .consult-main { flex: 1; min-height: 0; width: 100%; margin: 0; padding: 0; overflow: hidden; }
  .consult-page .chat-shell { height: 100%; min-height: 0; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  .consult-page .chat-heading { min-height: 64px; padding: 8px 12px; gap: 8px; }
  .consult-page #chatHeaderTitle { font-size: 14px; }
  .consult-page .advisor-copy p { font-size: 10px; line-height: 1.4; }
  .consult-page .advisor-profile { gap: 8px; }
  .consult-page .advisor-avatar { width: 32px; height: 32px; flex-basis: 32px; border-radius: 11px; }
  .consult-page .chat-log { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .consult-page .chat-form { min-width: 0; padding: 8px 12px 6px; }
  .consult-page .chat-form input, .consult-page .chat-form button { min-height: 48px; }
  .consult-page .input-help { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .consult-page .site-footer { display: none; }
}
@media (max-width: 359px) {
  .consult-page .advisor-avatar { display: none; }
}
