/* LIVX 챗봇 — 미니멀 모바일 우선 */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-sub: #6b6b6b;
  --ink-mute: #9a9a9a;
  --brand: #2f2a28;       /* 자사몰 톤 */
  --accent: #efe6df;      /* 살색 톤 (포인트) */
  --line: #ececec;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --radius: 16px;
  --radius-sm: 12px;
  --pad: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
          "Segoe UI", Roboto, "Pretendard", sans-serif;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── 헤더 ───────────────────── */
.head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.head-btn {
  background: transparent;
  border: 0;
  width: 32px; height: 32px;
  font-size: 20px;
  color: var(--ink-sub);
  border-radius: 50%;
}
.head-btn:hover { background: rgba(0,0,0,0.04); }
.head-btn[hidden] { display: none; }

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--line);
}
.brand-name { font-size: 17px; font-weight: 700; color: var(--ink); }

/* ── 화면 ──────────────────── */
.screen { display: none; padding: 0 16px 16px; flex: 1; }
.screen.active { display: block; }

#chat {
  display: none;
  padding: 0;
  flex: 1;
  flex-direction: column;
  min-height: calc(100vh - 64px); /* 헤더 제외 */
}
#chat.active { display: flex; }
.msgs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 120px; /* 하단 composer + 여유 공간 */
  overflow-y: auto;
}

/* ── 홈 카드 ────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.hero-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.hero-logo {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.hero-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.hero-greet {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}
.hero-block { margin-bottom: 20px; }
.hero-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.hero-list {
  list-style: none; padding: 0; margin: 0;
  color: var(--ink-sub);
  font-size: 13.5px;
  line-height: 1.6;
}
.hero-list li::before { content: "■ "; color: var(--brand); margin-right: 4px; }

.hero-features {
  list-style: none; padding: 0; margin: 0 0 14px;
  font-size: 14px; line-height: 1.7; color: var(--ink);
}
.hero-features li { margin: 6px 0; }
.hero-notice {
  margin: 0 0 14px; padding: 11px 13px;
  background: #FFF4E5; border: 1px solid #FFD8A8; border-radius: 10px;
  font-size: 13px; line-height: 1.65; color: #8A4B00; font-weight: 500;
}
.hero-notice strong { font-weight: 800; color: #C2410C; }
.hero-hint {
  margin: 0 0 18px; font-size: 13.5px; color: var(--ink-sub); font-weight: 500;
}

.cta {
  width: 100%;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .08s ease;
}
.cta:active { transform: scale(.98); }
.cta-icn { font-size: 14px; }
.cta-referral { margin-top: 10px; background: #fff; color: var(--brand); border: 1.5px solid #ff7f11; }
/* 10/2 — 플친 버튼(맨 위)·문의하기(맨 아래, 가장 진한 주 버튼) */
.cta-pf { background: #fee500; color: #191919; text-decoration: none; box-sizing: border-box; }
.cta-main { margin-top: 10px; }
.cta-referral[hidden] { display: none; }

/* ── 메시지 ────────────────── */
.msg-bot {
  align-self: flex-start;
  max-width: 85%;
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bot .bot-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-mute);
  margin-bottom: 4px;
}
.msg-bot .bot-head .bot-logo {
  width: 18px; height: 18px;
  border-radius: 50%;
  object-fit: cover;
}
.msg-bot .msg-body a {
  color: var(--brand);
  text-decoration: underline;
  word-break: break-all;
}

.msg-user {
  align-self: flex-end;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14px;
  max-width: 80%;
  box-shadow: var(--shadow-sm);
}

/* ── 양식 복사하기 큰 버튼 (배송팀 전달용) ── */
.form-cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}
.form-cta:active { transform: scale(.98); }
.form-cta-icn { font-size: 12px; }

/* ── 옵션 버튼 ────────────── */
.opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  margin: 4px 0 8px;
}
.opt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--ink);
  max-width: 90%;
  text-align: right;
  transition: background .08s ease;
}
.opt:hover { background: var(--accent); }
.opt:active { transform: scale(.98); }
.opt:disabled { opacity: .5; pointer-events: none; }
/* 강조 버튼 — 첫 메뉴 [플친 쿠폰이 안오셨다면?] (10/6 대표) */
.opt.opt-orange { border: 2px solid #f07c00; color: #c75f00; font-weight: 600; }
.opt.opt-orange:hover { background: #fff3e6; }
.msg-bot .msg-body strong.pf-alert { color: #f07c00; font-weight: 800; }

/* ── Composer (자유 입력) ──── */
.composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--line);
  z-index: 20;
}
.composer-wrap {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 8px;
}
.composer textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  background: var(--bg);
  min-height: 48px;
  max-height: 140px;
  resize: none;
  overflow-y: auto;
}
.composer textarea:focus { outline: 0; border-color: var(--brand); }
.composer button {
  width: 44px; height: 44px;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 14px;
  flex-shrink: 0;
  align-self: flex-end;
}

/* ── 시스템 버튼 (뒤로/처음으로) ── */
.sys-opts {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 4px 0 12px;
  flex-wrap: wrap;
}
.sys-opt {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--ink-sub);
}
.sys-opt:hover { background: var(--surface); color: var(--ink); }
.sys-opt:active { transform: scale(.97); }

/* ── 폼 카드 (자동 변경 등) ─── */
.form-card {
  align-self: stretch;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 4px 0 8px;
  box-shadow: var(--shadow-sm);
}
.form-card .form-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-card label {
  display: block;
  font-size: 12px;
  color: var(--ink-sub);
  margin: 10px 0 4px;
}
.form-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.form-card input:focus { outline: 0; border-color: var(--brand); }
.form-card .submit {
  width: 100%;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  cursor: pointer;
}
.form-card .submit:disabled { opacity: .5; cursor: wait; }
.form-card .skip {
  width: 100%;
  background: transparent;
  color: var(--ink-sub);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
  cursor: pointer;
}
.form-card .skip:hover { background: var(--bg); }
.form-card .skip:disabled { opacity: .4; cursor: wait; }
.form-card .form-note {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 8px;
  line-height: 1.5;
}

/* ── 자동화 CTA 버튼 ─── */
.auto-cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 4px;
  cursor: pointer;
}
.auto-cta:hover { background: var(--brand); color: #fff; }
.auto-cta:active { transform: scale(.98); }

/* ── 양식 fallback (작은 보조 버튼) ─── */
.form-cta-small {
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--ink-sub);
  margin: 2px 0 6px;
  cursor: pointer;
}
.form-cta-small:hover { background: var(--surface); color: var(--ink); }

/* form-card 안 textarea */
.form-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 70px;
}
.form-card textarea:focus { outline: 0; border-color: var(--brand); }

/* ── 타이핑 인디케이터 ─── */
.msg-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.msg-typing .bot-logo {
  width: 18px; height: 18px;
  border-radius: 50%;
  object-fit: cover;
}
.msg-typing .dots {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow-sm);
}
.msg-typing .dots span {
  width: 6px; height: 6px;
  background: var(--ink-mute);
  border-radius: 50%;
  animation: livx-typing 1.4s infinite ease-in-out;
}
.msg-typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes livx-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 굵은 글씨 (markdown ** → <strong>) */
.msg-bot .msg-body strong { font-weight: 700; color: var(--ink); }

/* 사용자 메시지를 viewport 상단 근처로 스크롤 시 약간 여백 */
.msg-user {
  scroll-margin-top: 80px;  /* 헤더 + 약간 여백 */
}

/* 주소 검색 버튼 */
.form-card .addr-search {
  width: 100%;
  background: var(--accent);
  border: 1px solid var(--brand);
  color: var(--brand);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  margin: 4px 0 8px;
  cursor: pointer;
}
.form-card .addr-search:hover { background: var(--brand); color: #fff; }
.form-card input[readonly] { background: var(--bg); color: var(--ink-sub); cursor: default; }

/* ── 통합 교환/반품 (자동) — stateful matrix 카드 (B-lite 1단계) ──── */
.ue-line {
  border-top: 1px solid var(--border, #e5e5e5);
  padding: 10px 0;
}
.ue-line:first-of-type { border-top: 0; }
.ue-line-label { margin-bottom: 6px; line-height: 1.4; }
.ue-line-label small { color: var(--ink-sub, #777); }
.ue-line-radios {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 4px 0;
}
.ue-line-radios label {
  flex: 1;
  min-width: 70px;
  text-align: center;
  padding: 8px 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  font-size: 13px;
  margin: 0;
  background: #fff;
}
.ue-line-radios label:has(input:checked) {
  background: var(--accent, #e8f4ff);
  border-color: var(--brand, #2589f5);
  color: var(--brand, #2589f5);
  font-weight: 600;
}
.ue-line-radios input { margin-right: 4px; }
/* 여러 개 산 줄의 교환·반품 수량 선택 (2026-09-28) */
.ue-line-qty { margin-top: 6px; font-size: 13px; }
.ue-line-qty select {
  margin-left: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border, #ddd);
  border-radius: var(--radius-sm, 8px);
  font-size: 13px;
  background: #fff;
}
.ue-expand {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border, #ccc);
  color: var(--ink-sub, #666);
  border-radius: var(--radius-sm, 8px);
  padding: 6px;
  font-size: 12px;
  margin-top: 4px;
  cursor: pointer;
}
.ue-expand:hover { background: var(--accent, #f5f5f5); }
.ue-subs {
  margin-left: 12px;
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--accent, #e8f4ff);
}
.ue-sub { padding: 6px 0; }
.ue-sub-label { margin-bottom: 4px; }

/* 📱 상담 연락처(선택) 카드 — 2026-10-02 */
.form-card label.cc-agree { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); margin-top: 12px; }
.form-card label.cc-agree input { width: auto; margin: 0; }
.contact-card .cc-title { align-items: flex-start; line-height: 1.45; }
.contact-card .cc-title strong { color: var(--brand); }
.contact-card .cc-desc { font-size: 12.5px; color: var(--ink-sub); line-height: 1.6; margin: 0 0 8px; }
.contact-card .cc-desc strong { color: var(--ink); }
.contact-card .cc-warn { font-size: 12px; color: var(--ink); background: var(--bg); border-radius: var(--radius-sm); padding: 8px 10px; line-height: 1.55; margin: 0 0 4px; }
.contact-card .cc-opt { white-space: nowrap; font-weight: 500; color: var(--ink-sub); }
.contact-card .cc-warn p { margin: 0; }
.contact-card .cc-warn p + p { margin-top: 4px; }
.contact-card .cc-red, .contact-card .cc-red strong { color: #d93025; }
.contact-card .cc-title, .contact-card .cc-desc, .contact-card .cc-warn { word-break: keep-all; }
.contact-card .cc-warn p { padding-left: 1.55em; text-indent: -1.55em; }
.contact-card .cc-blue { color: #2b5c9e; } /* 신뢰감 있는 차분한 파랑 — 빨강(#d93025)과 짝 (대표 10/2) */

/* ── 고정 프레임 (10/6) ──
   페이지 자체는 움직이지 않고 대화 목록(.msgs)·첫 화면만 프레임 안에서 스크롤한다.
   전엔 페이지 전체가 스크롤돼서, 대화가 많을 때 입력칸(하얀 부분)을 끌면 프레임째 밀렸다(아이폰 테스터 10/6).
   --app-h·--vv-top = 키보드를 뺀 '보이는 영역' (app.js keyboardLift가 넣음) → 키보드가 올라오면 프레임째 줄어든다. */
:root { --app-h: 100vh; }
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--app-h); min-height: 0; overflow: hidden; }
.head { flex: none; }
.screen { min-height: 0; }
.screen.active { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#chat, #chat.active { min-height: 0; overflow: hidden; }
.msgs { min-height: 0; padding-bottom: 16px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.composer { position: static; flex: none; }
html.kb-open .composer { padding-bottom: 10px; }
