/* 회원 화면 AI 도우미 (#2272) — 떠 있는 버튼·패널(next/shared/_assistant, next/assistant/show)과
 * 대화 말풍선 공용 부품(.hs-chat-msg*, .hs-chat-activity, .hs-bb-chip — AI로 봇 만들기 화면과 함께 쓴다).
 * layouts/next 만 싣는다. 색은 app_pages.css 의 --d-* 토큰만 쓴다. 그림자는 떠 있는 층(버튼·패널·최근 대화 목록) 한 겹만.
 * 레퍼런스: AI로 봇 만들기 대화 화면(/bot_builder/:id)의 말풍선·입력창·진행 표시. */

/* ───────── 대화 말풍선 (AI로 봇 만들기 next/bot_builder/_style 에서 옮김 — 값 그대로) ───────── */
.hs-chat-msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: 14px; line-height: 1.65; color: var(--d-body); white-space: pre-wrap; word-break: break-word; }
.hs-chat-msg.user { align-self: flex-end; background: var(--d-accent-fill); color: #fff; border-bottom-right-radius: 4px; }
.hs-chat-msg.assistant { align-self: flex-start; background: var(--d-wash); border: 1px solid var(--d-line-soft); border-bottom-left-radius: 4px; }
/* AI 답(마크다운) — 긴 코드·표는 말풍선 안에서 옆으로 밀어 보고, 목록 글머리표는 Tailwind 초기화가 지운 것을 되살린다 */
.hs-chat-msg.is-md { white-space: normal; min-width: 0; }
.hs-chat-msg.is-md p { margin: 0 0 8px; }
.hs-chat-msg.is-md p:last-child, .hs-chat-msg.is-md ul:last-child, .hs-chat-msg.is-md ol:last-child, .hs-chat-msg.is-md table:last-child, .hs-chat-msg.is-md pre:last-child { margin-bottom: 0; }
.hs-chat-msg.is-md ul, .hs-chat-msg.is-md ol { margin: 0 0 8px; padding-left: 20px; }
.hs-chat-msg.is-md ul { list-style: disc; }
.hs-chat-msg.is-md ol { list-style: decimal; }
.hs-chat-msg.is-md li + li { margin-top: 2px; }
.hs-chat-msg.is-md strong { color: var(--d-ink); font-weight: 700; }
.hs-chat-msg.is-md table { display: block; max-width: 100%; overflow-x: auto; margin: 4px 0 8px; border-collapse: collapse; font-size: 12.5px; }
.hs-chat-msg.is-md th, .hs-chat-msg.is-md td { padding: 5px 8px; border: 1px solid var(--d-line); text-align: left; vertical-align: top; }
.hs-chat-msg.is-md th { background: var(--d-card); font-weight: 600; color: var(--d-ink); white-space: nowrap; }
.hs-chat-msg.is-md code { padding: 1px 4px; border-radius: 4px; background: var(--d-card); color: var(--d-body); font-size: 12.5px; word-break: break-all; }
.hs-chat-msg.is-md pre { max-width: 100%; overflow-x: auto; margin: 4px 0 8px; padding: 10px 12px; border: 1px solid var(--d-line); border-radius: 8px; background: var(--d-card); white-space: pre; }
.hs-chat-msg.is-md pre code { padding: 0; background: none; word-break: normal; }
.hs-chat-msg.notice { align-self: center; max-width: 100%; background: var(--d-amber-pale); color: var(--d-amber); font-size: 13px; }
.hs-chat-activity { align-self: flex-start; font-size: 12.5px; color: var(--d-soft); }
.hs-chat-activity::before { content: '·'; margin-right: 6px; }
/* 예시 문장 칩 — 누르면 입력창에 채운다(바로 보내지 않는다) */
.hs-bb-chip { max-width: 100%; padding: 8px 12px; border: 1px solid var(--d-line); border-radius: 10px; background: var(--x-fff, #fff); font-size: 13px; line-height: 1.5; color: var(--d-body); text-align: left; cursor: pointer; transition: border-color .15s; }
.hs-bb-chip:hover { border-color: var(--d-hover-line); }
.hs-bb-chip:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 2px; }

/* ───────── 떠 있는 버튼 ───────── */
/* 레거시 픽셀 재현 전역 규칙(.theadmin-next a·button·input·p — 굵기 300·청록 링크)보다 앞서도록 패널 규칙은 모두 .hs-asst 아래에 둔다 */
.hs-asst { --asst-gap: 24px; font-family: var(--hsn-font, inherit); font-size: 14px; font-weight: 400; line-height: 1.5; color: var(--d-body); letter-spacing: -.01em; -webkit-font-smoothing: antialiased; }
.hs-asst button, .hs-asst input, .hs-asst textarea { font-family: inherit; font-weight: inherit; letter-spacing: inherit; }
.hs-asst p { margin: 0; }
.hs-asst a { color: var(--d-accent-deep); }
.hs-asst .hs-asst-launcher {
  position: fixed; right: var(--asst-gap); bottom: var(--asst-gap); z-index: 1030;
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px 0 15px;
  border: 1px solid var(--d-line); border-radius: 24px; background: var(--d-card); color: var(--d-ink);
  font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer;
  box-shadow: 0 8px 24px rgba(13, 33, 55, .14); transition: border-color .15s, transform .15s var(--d-ease);
}
.hs-asst .hs-asst-launcher:hover { border-color: var(--d-hover-line); }
.hs-asst .hs-asst-launcher:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 2px; }
.hs-asst .hs-asst-launcher-icon { flex: none; color: var(--d-accent-deep); }
.hs-asst.is-open .hs-asst-launcher { display: none; }

/* ───────── 패널 ───────── */
.hs-asst .hs-asst-panel {
  position: fixed; right: var(--asst-gap); bottom: var(--asst-gap); z-index: 1031;
  display: flex; flex-direction: column; width: 400px; max-width: calc(100vw - 2 * var(--asst-gap));
  height: min(640px, calc(100vh - 2 * var(--asst-gap))); height: min(640px, calc(100dvh - 2 * var(--asst-gap)));
  border: 1px solid var(--d-line); border-radius: var(--d-radius); background: var(--d-card); color: var(--d-body);
  box-shadow: 0 16px 40px rgba(13, 33, 55, .18); overflow: hidden;
}
.hs-asst .hs-asst-panel[hidden] { display: none; }
.hs-asst .hs-asst-panel:focus { outline: none; }
.hs-asst .hs-asst-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; padding: 6px 8px 6px 18px; border-bottom: 1px solid var(--d-line); }
.hs-asst .hs-asst-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; color: var(--d-ink); letter-spacing: -.02em; }
.hs-asst .hs-asst-beta { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; background: var(--d-neutral-pale); color: var(--d-soft); font-size: 12px; font-weight: 600; }
.hs-asst .hs-asst-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--d-soft); cursor: pointer; }
.hs-asst .hs-asst-icon-btn:hover { background: var(--d-wash); color: var(--d-ink); }
.hs-asst .hs-asst-icon-btn:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 2px; }

.hs-asst .hs-asst-frame { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hs-asst .hs-asst-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hs-asst .hs-asst-loading { display: flex; flex-direction: column; gap: 12px; padding: 20px 18px; }
.hs-asst .hs-asst-skel { display: block; height: 64px; border-radius: 12px; background: var(--d-wash); }
.hs-asst .hs-asst-skel.is-short { width: 62%; height: 40px; align-self: flex-end; }
.hs-asst .hs-asst-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hs-asst .hs-asst-load-failed { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; font-size: 13.5px; color: var(--d-red); }
.hs-asst .hs-asst-load-failed[hidden] { display: none; }
.hs-asst .hs-asst-alert { flex: none; margin: 12px 16px 0; padding: 9px 12px; border-radius: 10px; background: var(--d-red-pale); color: var(--d-red); font-size: 13px; line-height: 1.55; }
.hs-asst .hs-asst-admin-note { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 12px 16px 0; padding: 8px 12px; border-radius: 10px; background: var(--d-neutral-pale); color: var(--d-soft); font-size: 12.5px; line-height: 1.5; } /* 관리자만 보는 공개 상태(_admin_visibility) — 공개면 무채색, 비공개면 주황 */
.hs-asst .hs-asst-admin-note.is-private { background: var(--d-amber-pale); color: var(--d-amber); }
.hs-asst .hs-asst-admin-tag { font-weight: 700; }
.hs-asst .hs-asst-admin-link { margin-left: auto; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }

/* 버튼 — 패널 안 주 버튼(네이비)은 한 번에 하나만 보인다(동의하고 시작하기 / 보내기) */
.hs-asst .hs-asst-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--d-line); border-radius: 10px; background: var(--d-card); color: var(--d-ink); font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; transition: border-color .15s, background-color .15s; }
.hs-asst .hs-asst-btn:hover { border-color: var(--d-hover-line); }
.hs-asst .hs-asst-btn:focus-visible, .hs-asst .hs-asst-link-btn:focus-visible, .hs-asst .hs-asst-action:focus-visible, .hs-asst .hs-asst-send:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 2px; }
.hs-asst .hs-asst-btn.is-ghost { border-color: transparent; background: transparent; color: var(--d-accent-deep); }
.hs-asst .hs-asst-btn.is-ghost:hover { background: var(--d-wash); }
.hs-asst .hs-asst-btn.is-primary { height: 44px; border-color: var(--d-accent-fill); background: var(--d-accent-fill); color: #fff; font-size: 14px; }
.hs-asst .hs-asst-btn.is-primary:hover { border-color: var(--d-accent-fill-hover); background: var(--d-accent-fill-hover); }
.hs-asst .hs-asst-btn.is-block { width: 100%; }
.hs-asst .hs-asst-link-btn { padding: 0; border: 0; background: none; color: var(--d-accent-deep); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* 이용 안내 동의 */
.hs-asst .hs-asst-consent { flex: 1; overflow-y: auto; padding: 18px 18px 20px; }
.hs-asst .hs-asst-consent h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--d-ink); }
.hs-asst .hs-asst-consent ul { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; padding-left: 18px; list-style: disc; font-size: 13.5px; line-height: 1.65; color: var(--d-body); word-break: keep-all; }
.hs-asst .hs-asst-check { display: flex; align-items: center; line-height: 1.5; gap: 10px; min-height: 44px; margin-bottom: 10px; font-size: 13.5px; color: var(--d-ink); cursor: pointer; }
.hs-asst .hs-asst-check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--d-accent-deep); }

/* 머리 줄 — 최근 대화 · 새 대화 */
.hs-asst .hs-asst-bar { position: relative; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 6px 10px 6px 12px; border-bottom: 1px solid var(--d-line-soft); }
.hs-asst .hs-asst-new-form { margin-left: auto; }
.hs-asst .hs-asst-history > summary { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border-radius: 10px; list-style: none; font-size: 13px; font-weight: 600; color: var(--d-soft); cursor: pointer; }
.hs-asst .hs-asst-history > summary::-webkit-details-marker { display: none; }
.hs-asst .hs-asst-history > summary::after { content: ''; width: 6px; height: 6px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.hs-asst .hs-asst-history[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.hs-asst .hs-asst-history > summary:hover { background: var(--d-wash); color: var(--d-ink); }
.hs-asst .hs-asst-history > summary:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 2px; }
.hs-asst .hs-asst-count { font-weight: 600; color: var(--d-placeholder); }
.hs-asst .hs-asst-history nav { position: absolute; left: 10px; right: 10px; top: calc(100% + 4px); z-index: 2; display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; padding: 6px; border: 1px solid var(--d-line); border-radius: 10px; background: var(--d-card); box-shadow: 0 12px 28px rgba(13, 33, 55, .14); }
.hs-asst .hs-asst-history nav a { display: block; padding: 10px 10px; border-radius: 8px; font-size: 13.5px; color: var(--d-body); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-asst .hs-asst-history nav a:hover { background: var(--d-wash); color: var(--d-ink); }
.hs-asst .hs-asst-history nav a.is-current { background: var(--d-pale); color: var(--d-accent-deep); font-weight: 600; }
.hs-asst .hs-asst-history nav a:focus-visible { outline: 2px solid var(--d-accent); outline-offset: -2px; }

/* 대화 목록 */
.hs-asst .hs-asst-log { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding: 16px; overscroll-behavior: contain; }
.hs-asst .hs-asst-item { display: flex; flex-direction: column; gap: 8px; }
.hs-asst .hs-asst-log .hs-chat-msg { max-width: 92%; word-break: keep-all; overflow-wrap: break-word; }
.hs-asst .hs-asst-empty { margin: auto 0; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
.hs-asst .hs-asst-empty > b { font-size: 16px; font-weight: 700; color: var(--d-ink); }
.hs-asst .hs-asst-empty > p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.65; color: var(--d-soft); word-break: keep-all; }
.hs-asst .hs-asst-examples { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.hs-asst .hs-asst-hint { font-size: 12.5px; line-height: 1.55; color: var(--d-soft); word-break: keep-all; }
/* 이동 버튼 — 답 아래 칩 모양. 이동만 한다 */
.hs-asst .hs-asst-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.hs-asst .hs-asst-action { display: inline-flex; align-items: center; min-height: 36px; padding: 7px 12px; border: 1px solid var(--d-pale-line); border-radius: 10px; background: var(--d-pale); color: var(--d-accent-deep); font-size: 13px; font-weight: 600; line-height: 1.4; text-decoration: none; cursor: pointer; transition: border-color .15s; }
.hs-asst .hs-asst-action:hover { border-color: var(--d-accent); color: var(--d-accent-deep); }
.hs-asst .hs-asst-thinking { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--d-soft); }
.hs-asst .hs-asst-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: hs-asst-spin .7s linear infinite; }
@keyframes hs-asst-spin { to { transform: rotate(360deg); } }
.hs-asst .hs-asst-error { align-self: stretch; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--d-red-pale); color: var(--d-red); font-size: 13px; line-height: 1.55; }
.hs-asst .hs-asst-error p { margin: 0; }
.hs-asst .hs-asst-error .hs-asst-link-btn { color: var(--d-red); }

/* 입력 */
.hs-asst .hs-asst-form { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 12px 12px 10px; border-top: 1px solid var(--d-line); background: var(--d-card); }
.hs-asst .hs-asst-input-row { display: flex; align-items: flex-end; gap: 8px; }
.hs-asst .hs-asst-input { flex: 1; min-width: 0; min-height: 44px; max-height: 140px; padding: 11px 13px; border: 1px solid var(--d-line); border-radius: 10px; background: var(--d-card); color: var(--d-ink); font: inherit; font-size: 14px; line-height: 1.5; resize: none; }
.hs-asst .hs-asst-input::placeholder { color: var(--d-placeholder); }
.hs-asst .hs-asst-input:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 1px; border-color: var(--d-accent); }
.hs-asst .hs-asst-send { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: var(--d-accent-fill); color: #fff; cursor: pointer; transition: background-color .15s; }
.hs-asst .hs-asst-send:hover { background: var(--d-accent-fill-hover); }
.hs-asst .hs-asst-send:disabled { background: var(--d-gray-300); cursor: not-allowed; }
.hs-asst .hs-asst-send.is-sending .hs-asst-spin { width: 16px; height: 16px; }
.hs-asst .hs-asst-form .hs-asst-hint { padding: 0 2px; font-size: 12px; }

/* 랜딩 도우미 전용 화면(/ask, #2302) — 패널이 화면 전체를 채운다(넓은 화면은 랜딩 패널의 iframe 안, 좁은 화면은 화면 그대로) */
.hs-asst.is-page .hs-asst-panel { position: static; inset: auto; width: 100%; max-width: none; height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
.hs-asst.is-page .hs-asst-head h1 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; color: var(--d-ink); letter-spacing: -.02em; }

/* 회원 단독 화면(/assistant 를 frame 밖에서 열 때, next/assistant/page, #2369) — 다른 회원 화면처럼 .hs-page 머리말 아래 본문 자리에
   패널을 카드로 펼친다. 높이는 화면에 맞춰(상단바 64 + 머리말·여백) 입력창이 늘 보이게 하고, 대화만 안에서 스크롤한다. 떠 있는 층이 아니라 그림자는 없다 */
.hs-asst.is-standalone .hs-page-head h1 { display: flex; align-items: center; gap: 10px; }
.hs-asst.is-standalone .hs-asst-panel {
  position: static; inset: auto; z-index: auto; width: 100%; max-width: 920px;
  height: calc(100vh - 196px); height: calc(100dvh - 196px); min-height: 440px;
  box-shadow: none;
}

/* 모바일 — 패널은 화면 전체 시트, 버튼은 아이콘만 */
@media (max-width: 639px) {
  .hs-asst { --asst-gap: 16px; }
  .hs-asst .hs-asst-launcher { width: 52px; height: 52px; padding: 0; justify-content: center; border-radius: 26px; }
  .hs-asst .hs-asst-launcher-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .hs-asst .hs-asst-panel { inset: 0; width: 100%; max-width: none; height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .hs-asst .hs-asst-icon-btn { width: 44px; height: 44px; }
  .hs-asst .hs-asst-btn { height: 44px; }
  .hs-asst .hs-asst-action { min-height: 44px; }
  .hs-asst .hs-asst-input { font-size: 16px; } /* iOS 가 16px 아래 입력칸에 초점을 주면 화면을 확대한다 */
  /* 단독 화면은 시트가 아니라 본문 카드 — 테두리·모서리를 지키고, 좁은 머리말(.hs-page 20px 여백·24px 제목)에 맞춰 높이를 잡는다 (#2369) */
  .hs-asst.is-standalone .hs-asst-panel { height: calc(100vh - 160px); height: calc(100dvh - 160px); min-height: 400px; border: 1px solid var(--d-line); border-radius: var(--d-radius); }
}

@media (prefers-reduced-motion: reduce) {
  .hs-asst .hs-asst-spin { animation-duration: 2.4s; }
  .hs-asst .hs-asst-launcher, .hs-asst .hs-asst-history > summary::after { transition: none; }
}
