.support-chat { position: fixed; inset: auto 24px 24px auto; z-index: 90; }
/* 버튼의 우측 정렬은 유지하고, 스크롤 끝에서 런처 위로 올릴 여유를 둔다. */
body:has(> .support-chat) :is(.content-main, .standalone-main) {
  padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  scroll-padding-bottom: calc(6rem + env(safe-area-inset-bottom));
}
html:has(body > .support-chat) { scroll-padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
body:has(> .support-chat) .app-main { scroll-padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
.support-chat-launcher { position: relative; display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: var(--radius-full); background: var(--primary); color: var(--text-inverse); box-shadow: var(--shadow-overlay); cursor: pointer; }
.support-chat-launcher svg { width: 24px; height: 24px; }
.support-chat-unread { position: absolute; top: -4px; right: -4px; min-width: 24px; height: 24px; border-radius: var(--radius-full); background: var(--cta); color: var(--text-inverse); font-size: 12px; line-height: 24px; }
.support-chat-panel { position: fixed; inset: auto 24px 96px auto; margin: 0; padding: 0; width: 400px; max-width: calc(100vw - 32px); height: min(704px, calc(100dvh - 120px)); max-height: none; border: 0; border-radius: var(--radius-lg); background: var(--surface-0); color: var(--text-primary); box-shadow: var(--shadow-overlay); overflow: hidden; text-align: start; }
.support-chat-panel[open] { display: flex; flex-direction: column; }
.support-chat-panel::backdrop { background: transparent; }
.support-chat [hidden] { display: none !important; }
.support-chat-header { display: flex; align-items: center; gap: 0; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.support-chat-brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.support-chat-header h2 { margin: 0; font-size: 24px; font-weight: 400; white-space: nowrap; }
.support-chat-header p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.4; }
.support-chat-icon { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--text-secondary); border-radius: var(--radius-md); cursor: pointer; flex-shrink: 0; }
.support-chat-icon:hover { background: var(--surface-hover); }
.support-chat-body { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.support-chat-history { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.support-chat-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.support-chat-history-heading .support-chat-section-title { margin: 0; }
.support-chat-welcome { display: flex; flex-direction: column; gap: 8px; }
.support-chat-welcome h3 { margin: 0; font-size: 22px; line-height: 1.4; font-weight: 600; letter-spacing: -.4px; text-wrap: balance; }
.support-chat-welcome p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--text-secondary); }
.support-chat-section-title { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.support-chat-links { display: flex; flex-direction: column; border-block: 1px solid var(--border-subtle); }
.support-chat-link { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; min-height: 60px; padding: 16px 4px; text-align: start; border: 0; background: transparent; color: var(--text-primary); cursor: pointer; font: inherit; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.support-chat-link + .support-chat-link { border-top: 1px solid var(--border-subtle); }
.support-chat-link:hover { background: var(--surface-hover); }
.support-chat-link svg, .support-chat-citation svg { flex-shrink: 0; color: var(--text-secondary); }
.support-chat-citation svg { margin-right: 12px; }
.support-chat-thread { min-height: 100%; background: var(--surface-0); padding-bottom: 20px; }
.support-chat-messages { display: flex; flex-direction: column; gap: 24px; padding: 24px 20px 16px; }
.support-chat-messages:empty { display: none; }
.support-chat-greeting { display: flex; flex-direction: column; gap: 24px; padding: 40px 24px 24px; }
.support-chat-message { align-self: flex-start; width: 100%; min-width: 0; }
.support-chat-message--user { align-self: flex-end; width: auto; max-width: 90%; }
.support-chat-message-label { margin: 0 0 4px; font-size: 12px; color: var(--text-muted); }
.support-chat-message--user .support-chat-message-label { display: none; }
.support-chat-bubble { font-size: 16px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-chat-message--user .support-chat-bubble { padding: 10px 14px; background: var(--surface-1); color: var(--text-primary); border-radius: var(--radius-lg); }
.support-chat-message--system { align-self: center; max-width: 100%; }
.support-chat-message--system .support-chat-bubble { background: transparent; color: var(--text-secondary); font-size: 12px; text-align: center; }
.support-chat-citation { display: flex; align-items: center; min-height: 52px; padding: 12px 4px; border-block: 1px solid var(--border-subtle); font-size: 14px; color: var(--text-primary); text-decoration: none; margin-top: 16px; overflow-wrap: anywhere; line-height: 1.6; }
.support-chat-citation:hover { background: var(--surface-hover); }
.support-chat-compose { padding: 16px 20px 20px; background: var(--surface-0); flex-shrink: 0; max-height: 65%; overflow-y: auto; }
.support-chat-compose-hint { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.support-chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 6px; border: 1px solid var(--border-default); background: var(--surface-0); border-radius: var(--radius-md); }
.support-chat-form .form-field { width: 100%; margin: 0; min-width: 0; }
.support-chat-form textarea { display: block; width: 100%; min-height: 44px; max-height: 128px; resize: none; padding: 10px 8px; background: transparent; color: var(--text-primary); border: 0; box-shadow: none; font: inherit; font-size: 16px; line-height: 24px; }
.support-chat-input-actions { grid-column: 2; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.support-chat-image-tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.support-chat-image-tools span { font-size: 12px; color: var(--text-muted); }
.support-chat-attachments { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.support-chat-attachments:has([data-support-chat-target="images"]:empty):has([data-support-chat-target="imageTools"][hidden]) { display: none; }
.support-chat-image-previews { grid-column: 1 / -1; display: flex; gap: 8px; overflow-x: auto; max-width: 100%; }
.support-chat-image-previews:empty { display: none; }
.support-chat-image-draft { position: relative; flex-shrink: 0; padding-right: 32px; }
.support-chat-image-draft img { width: 96px; height: 80px; object-fit: contain; border: 1px solid var(--border-subtle); background: var(--surface-1); border-radius: var(--radius-md); }
.support-chat-image-remove { position: absolute; top: 0; right: 0; width: 32px; height: 44px; border: 0; border-radius: var(--radius-sm); background: var(--surface-0); color: var(--text-secondary); cursor: pointer; font-size: 20px; }
.support-chat-image { display: block; min-width: 44px; min-height: 44px; max-width: 240px; padding-top: 8px; }
.support-chat-image img { display: block; max-height: 240px; max-width: 100%; border-radius: var(--radius-md); object-fit: contain; }
.support-chat-handoff-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.support-chat-handoff-heading strong { font-size: 16px; font-weight: 600; }
.support-chat-text-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer; }
.support-chat-text-button:hover { background: var(--surface-hover); }
.support-chat-compose--handoff { border-top: 1px solid var(--border-subtle); }
.support-chat-compose--handoff .support-chat-form { display: flex; flex-direction: column; align-items: stretch; border: 0; border-radius: 0; padding: 12px 0 0; gap: 12px; }
.support-chat-compose--handoff textarea { min-height: 72px; border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.support-chat-compose--handoff .support-chat-input-actions { justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.support-chat-compose--handoff .support-chat-send { width: auto; min-width: 45%; padding: 10px 16px; background: var(--cta); font: inherit; font-size: 14px; font-weight: 600; }
.support-chat-compose--handoff .support-chat-send svg { display: none; }
.support-chat-compose--handoff .support-chat-attachments { flex-direction: row; align-items: stretch; }
.support-chat-compose--handoff .support-chat-image-previews { flex: 0 1 auto; }
.support-chat-compose--handoff .support-chat-image-tools { flex: 0 0 108px; flex-direction: column; justify-content: center; gap: 0; border-radius: var(--radius-md); background: var(--surface-1); padding: 6px; }
.support-chat-compose--handoff .support-chat-image-tools button { flex-direction: column; width: 100%; }
.support-chat-compose--handoff .support-chat-image-tools span { text-align: center; font-size: 11px; }
.support-chat-send { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: var(--radius-full); background: var(--primary); color: var(--text-inverse); cursor: pointer; }
.support-chat-compose--handoff .support-chat-send { border-radius: var(--radius-md); }
.support-chat-send:disabled { opacity: .4; cursor: default; }
.support-chat-thread-actions { margin: 0 20px; }
.support-chat-thread-actions button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: var(--radius-md); background: var(--surface-1); color: var(--text-secondary); padding: 10px 12px; min-height: 44px; font-size: 13px; cursor: pointer; }
.support-chat-thread-actions button:hover { background: var(--surface-hover); }
.support-chat-typing { display: inline-flex; gap: 4px; padding-right: 8px; vertical-align: middle; }
.support-chat-typing i { width: 4px; height: 4px; border-radius: var(--radius-full); background: var(--text-muted); animation: support-chat-pulse 1.2s ease-in-out infinite; }
.support-chat-typing i:nth-child(2) { animation-delay: .15s; }
.support-chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes support-chat-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .support-chat-typing i { animation: none; } }
.support-chat-error { margin: 0; padding: 12px 16px; background: var(--destructive-light); color: var(--destructive-dark); font-size: 14px; line-height: 1.5; }
.support-chat-empty { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; margin: 0; }
.support-chat-history-item { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px 0; background: transparent; border: 0; border-bottom: 1px solid var(--border-subtle); width: 100%; text-align: start; font: inherit; cursor: pointer; color: var(--text-primary); overflow-wrap: anywhere; }
.support-chat-history-item small { color: var(--text-muted); }
.support-chat-history-item[data-unread="true"] strong::before { content: "● "; color: var(--cta); }
.support-chat button:focus-visible, .support-chat textarea:focus-visible, .support-chat a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.support-chat-form:focus-within { border-color: var(--text-muted); box-shadow: 0 0 0 1px var(--border-subtle); }
.support-chat-form textarea:focus { outline: none; box-shadow: none; }
.support-chat-compose--handoff .support-chat-form:focus-within { box-shadow: none; }
.support-chat-compose--handoff textarea:focus-visible { border-color: var(--text-muted); box-shadow: 0 0 0 1px var(--border-subtle); }
@media (max-width: 640px) {
  .support-chat { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  /* 떠 있는 상담 버튼이 본문 끝(배지·안내문·버튼)을 가렸다 — 그만큼 본문 아래를 비운다. */
  /* 스크롤 컨테이너의 padding-bottom 은 넘침 영역에 들어가지 않아(실측) 끝에 빈 블록을 둔다. */
  body:has(.support-chat) .content-main::after { content: ""; display: block; height: calc(72px + env(safe-area-inset-bottom)); }
  .support-chat-panel { inset: 0; width: 100%; max-width: 100%; height: 100dvh; border-radius: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .support-chat-bubble, .support-chat-link { font-size: 16px; }
  .support-chat-header { padding-left: 12px; }
  .support-chat-header:has([data-support-chat-target="menu"]:not([hidden])) .support-chat-brand { gap: 6px; }
  .support-chat-header:has([data-support-chat-target="menu"]:not([hidden])) h2 { font-size: 20px; }
}
