:root {
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --surface-2: #F3F1EC;
  --surface-3: #E8E5DD;
  --ink: #1A1A17;
  --ink-2: #44443F;
  --ink-3: #75736B;
  --ink-4: #A8A59B;
  --border: rgba(26, 26, 23, 0.08);
  --border-strong: rgba(26, 26, 23, 0.16);
  --accent: #2D4A2B;
  --accent-ink: #1F3320;
  --accent-bg: #E8EDDF;
  --green-bg: #E3ECC8;
  --green-ink: #2F4519;
  --amber: #B5651D;
  --amber-bg: #F5E9D4;
  --amber-ink: #6B3D11;
  --ai-purple: #3D2D6B;
  --ai-purple-bg: #EAE4F5;
  --ai-purple-ink: #2A1F4A;
  --buyer-bubble: var(--accent);
  --buyer-bubble-ink: #FFFFFF;
  --seller-bubble: #FFFFFF;
  --seller-bubble-ink: var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Page wrapper - mobile-ish chat with desktop framing */
.page {
  max-width: 520px;
  margin: 0 auto;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  border-left: 0.5px solid var(--border);
  border-right: 0.5px solid var(--border);
}

/* Header */
.chat-header {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.back-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--ink-2);
  cursor: pointer;
}
.back-btn:hover { background: var(--surface-2); }
.partner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.partner-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.partner-avatar::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 10px; height: 10px;
  background: #4CAF50;
  border: 2px solid var(--surface);
  border-radius: 50%;
}
.partner-info { flex: 1; min-width: 0; }
.partner-name {
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
  flex-wrap: nowrap; min-width: 0;
}
/* 이름 텍스트는 좁아지면 말줄임(글자단위 세로 줄바꿈 방지) */
.partner-name > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.partner-name .verified { color: var(--accent); font-size: 14px; flex-shrink: 0; }
.partner-role {
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 2px 7px; border-radius: 100px; flex-shrink: 0;
  background: var(--accent-bg, #eef3ff); color: var(--accent-ink, #1f5aa8);
  border: 0.5px solid var(--accent, #1f5aa8);
}
.partner-meta {
  font-size: 11px;
  color: var(--ink-3);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-icons { flex-shrink: 0; }
/* 모바일: 헤더 버튼은 아이콘만(텍스트 라벨 숨김) — 이름 칸 확보 */
@media (max-width: 560px) {
  .header-icons .hd-label { display: none; }
  .header-icons button { padding: 7px !important; }
}
.header-icons {
  display: flex; gap: 4px;
  color: var(--ink-2);
}
.header-icons i {
  font-size: 20px; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.header-icons i:hover { background: var(--surface-2); }

/* Pinned product card */
.product-pin {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.product-pin-img {
  width: 56px; height: 56px;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 20%, #4A4843 0%, #1A1A17 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.product-pin-img svg { width: 90%; height: auto; }
.product-pin-info { flex: 1; min-width: 0; }
.product-pin-tags {
  display: flex; gap: 4px;
  margin-bottom: 4px;
}
.pin-tag {
  font-size: 9px; padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.pin-tag-brand { background: var(--ink); color: var(--bg); }
.pin-tag-condition { background: var(--green-bg); color: var(--green-ink); }
.product-pin-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-pin-price {
  font-size: 14px;
  font-weight: 500;
  font-family: 'Instrument Serif', serif;
  font-size: 17px;
  letter-spacing: -0.01em;
  margin-top: 1px;
}
.product-pin-arrow {
  color: var(--ink-4);
  font-size: 16px;
}

/* Message thread */
.thread {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
}

.date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
  margin: 12px 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.date-divider::before, .date-divider::after {
  content: '';
  flex: 1;
  height: 0.5px;
  background: var(--border-strong);
}

.msg-row { display: flex; gap: 8px; max-width: 100%; }
.msg-row.them { justify-content: flex-start; }
.msg-row.me { justify-content: flex-end; }

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 11px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
}
.msg-stack { display: flex; flex-direction: column; gap: 3px; max-width: 78%; }

.msg-sender {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 1px;
  padding: 0 4px;
}
.me .msg-sender {
  text-align: right;
  color: var(--accent);
}

.bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.me .bubble {
  background: var(--buyer-bubble);
  color: var(--buyer-bubble-ink);
  border-bottom-right-radius: 4px;
}
.them .bubble {
  background: var(--seller-bubble);
  color: var(--seller-bubble-ink);
  border-bottom-left-radius: 4px;
  border: 0.5px solid var(--border);
}

.msg-time {
  font-size: 10px;
  color: var(--ink-3);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
  padding: 0 8px;
}
.me .msg-time { text-align: right; }

/* Special bubbles */
.bubble.offer-bubble {
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  border: 0.5px solid var(--border);
}
.me .bubble.offer-bubble {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-ink);
}
.offer-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  padding: 8px 14px 4px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}
.me .offer-header { color: var(--accent-ink); opacity: 0.7; }
.offer-header i { font-size: 12px; }
.offer-amount {
  font-family: 'Instrument Serif', serif;
  font-size: 24px;
  letter-spacing: -0.01em;
  padding: 0 14px 8px;
}
.offer-amount-strike {
  font-size: 12px;
  color: var(--ink-3);
  text-decoration: line-through;
  margin-left: 6px;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
}
.me .offer-amount-strike { color: var(--accent-ink); opacity: 0.55; }

/* AI inline hint */
.ai-hint {
  background: var(--ai-purple-bg);
  border-top: 0.5px solid rgba(61, 45, 107, 0.15);
  padding: 8px 14px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  color: var(--ai-purple-ink);
  line-height: 1.5;
}
.ai-hint i { font-size: 13px; color: var(--ai-purple); margin-top: 1px; flex-shrink: 0; }
.ai-hint strong { font-weight: 500; }

.offer-actions {
  display: flex;
  border-top: 0.5px solid var(--border);
}
.offer-actions button {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
}
.offer-actions button + button {
  border-left: 0.5px solid var(--border);
}
.offer-actions .accept {
  color: var(--accent);
}
.offer-actions .decline {
  color: var(--ink-3);
}

/* Meetup card */
.bubble.meetup-bubble {
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  border: 0.5px solid var(--border);
  width: 280px;
}
.meetup-header {
  padding: 12px 14px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}
.meetup-header i { font-size: 14px; color: var(--accent); }
.meetup-title {
  padding: 0 14px;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
}
.meetup-detail {
  padding: 0 14px 12px;
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meetup-detail-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.meetup-detail-row i {
  font-size: 13px;
  color: var(--ink-3);
}
.meetup-map {
  height: 110px;
  background: linear-gradient(135deg, #E8E5DD 0%, #DCD8CC 100%);
  position: relative;
  overflow: hidden;
}
.meetup-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.meetup-actions {
  display: flex;
  border-top: 0.5px solid var(--border);
}
.meetup-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.meetup-actions button + button {
  border-left: 0.5px solid var(--border);
  color: var(--ink-3);
}

/* System message (deal completed) */
.system-msg {
  align-self: center;
  background: var(--surface);
  border: 0.5px solid var(--border);
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 8px 0;
}
.system-msg i { font-size: 13px; color: var(--accent); }

/* Quick reply chips area */
.quick-replies {
  background: var(--surface);
  border-top: 0.5px solid var(--border);
  padding: 10px 16px 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.quick-chip {
  font-size: 12px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 100px;
  color: var(--ink-2);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}
.quick-chip:hover {
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.quick-chip i { font-size: 12px; vertical-align: -1px; margin-right: 2px; }

/* Input bar */
.input-bar {
  background: var(--surface);
  border-top: 0.5px solid var(--border);
  padding: 10px 16px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-action {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.input-action.primary {
  background: var(--accent);
  color: var(--bg);
}
.input-box {
  flex: 1;
  background: var(--surface-2);
  border: none;
  outline: none;
  padding: 10px 16px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
.input-box::placeholder { color: var(--ink-4); }

/* Annotation labels for prototype */
.note-bubble {
  position: absolute;
  background: var(--ai-purple);
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
  letter-spacing: 0.02em;
  z-index: 10;
}
.note-bubble::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border-style: solid;
}
