/* ============================================================
   HE.R.E — responsive UI
   ============================================================ */
:root {
  --bg: #0a0a0c;
  --bg-elevated: #121218;
  --bg-soft: #1a1a22;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #73e6be;
  --accent-2: #93c5fd;
  --danger: #f87171;
  --border: rgba(255,255,255,.08);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 56px;
  --footer-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  /* 메시지·입력창·헤더 공통 콘텐츠 폭 */
  --content-max: 720px;
  --page-pad: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scrollbar-gutter: stable;
  height: 100%;
  overflow: hidden; /* 문서 스크롤 금지 — 채팅 컨테이너만 스크롤 */
}
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body {
  /* 채팅 앱은 뷰포트 고정, 스크롤은 #chat-container 내부에서만 */
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }

/* ---------- INTRO ---------- */
.intro-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  overflow: hidden;
}
.intro-screen[aria-hidden="true"] { display: none; }
.intro-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, #1a1a2e 0%, #000 70%);
}
.intro-glow {
  position: absolute; width: 60vmin; height: 60vmin;
  left: 50%; top: 35%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(115,230,190,.12) 0%, transparent 70%);
  pointer-events: none; animation: glowPulse 6s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { opacity: .6; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

.intro-step {
  position: relative; z-index: 2;
  width: min(440px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 20px 24px;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: stepIn .45s ease;
}
.intro-step.active { display: flex; }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.intro-kicker {
  font-size: 11px; letter-spacing: .35em; color: var(--accent);
  margin-bottom: 20px; font-weight: 700;
}
.welcome-phrase {
  font-size: clamp(1.35rem, 4.5vw, 1.75rem);
  font-weight: 600; line-height: 1.45;
  min-height: 3.2em;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .7s ease;
  margin-bottom: 36px;
  padding: 0 8px;
}
.welcome-phrase.is-fading { opacity: 0; }

.language-picker-wrap { width: 100%; margin-bottom: 28px; }
.language-picker-label {
  display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 10px;
}
.language-select {
  width: 100%; max-width: 280px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%2394a3b8'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.intro-nav {
  display: flex; gap: 12px; width: 100%;
  justify-content: space-between; margin-top: 24px;
}
.intro-nav.center { justify-content: center; }
.intro-next, .intro-back {
  min-width: 110px; padding: 12px 22px;
  border-radius: 999px; font-weight: 600; font-size: 14px;
  transition: transform .15s, opacity .15s, background .15s;
}
.intro-next {
  background: linear-gradient(135deg, #73e6be, #93c5fd);
  color: #0a0a0c;
}
.intro-next:disabled { opacity: .35; cursor: not-allowed; }
.intro-next:not(:disabled):active { transform: scale(.97); }
.intro-back {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
}
.intro-back:active { background: var(--bg-soft); }

/* Avatar grid */
.avatar-preview-wrap {
  width: 120px; height: 120px; border-radius: 50%;
  overflow: hidden; margin: 12px auto 16px;
  border: 2px solid var(--border);
  background: var(--bg-soft);
  position: relative;
}
.avatar-preview-wrap img { width: 100%; height: 100%; object-fit: cover; }
.avatar-gender, .profile-gender {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.avatar-tile {
  aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer; padding: 0;
  transition: border-color .15s, transform .15s;
  background: var(--bg-soft);
}
.avatar-tile img { width: 100%; height: 100%; object-fit: cover; }
.avatar-tile.selected { border-color: var(--accent); transform: scale(1.04); }
.avatar-tile:active { transform: scale(.96); }

.profile-card {
  width: 100px; margin: 0 auto 16px;
}
.profile-card img {
  width: 100px; height: 100px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border);
}
.intro-step label {
  align-self: flex-start; font-size: 13px; color: var(--text-muted);
  margin: 12px 0 6px;
}
.intro-step input[type="text"],
.intro-step select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

/* Personality — mobile-simplified: no axis titles/hints, no accent fill */
.personality-grid { width: 100%; display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.personality-axis { text-align: left; }
.personality-axis-label,
.personality-axis-hint { display: none; }
.personality-options { display: flex; gap: 8px; flex-wrap: nowrap; }
.personality-opt {
  flex: 1; min-width: 0;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px; line-height: 1.35;
  transition: border-color .15s, color .15s, background .15s;
}
.personality-opt.selected {
  border-color: var(--text);
  background: transparent;
  color: var(--text);
  font-weight: 600;
}
.personality-preview {
  font-size: 12px; color: var(--text-muted);
  min-height: 1.6em; margin-top: 4px;
}

.ready-avatar-wrap {
  width: 110px; height: 110px; border-radius: 50%; overflow: hidden;
  margin-bottom: 16px; border: 2px solid var(--accent);
}
.ready-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.ready-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 8px; }
.ready-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.ready-loader { display: flex; gap: 6px; }
.ready-loader span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s ease-in-out infinite;
}
.ready-loader span:nth-child(2) { animation-delay: .15s; }
.ready-loader span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-8px); opacity: 1; }
}

/* ---------- CHAT APP ---------- */
.app-chat {
  position: relative;
  display: block;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.app-chat[hidden] { display: none !important; }

/*
 * 스크롤 영역 = 화면 전체 높이 → 스크롤바가 화면 끝까지 이어짐
 * 푸터는 absolute 오버레이, 메시지 가림 방지는 padding-bottom
 */
.chat-scroll {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  /* 입력창과 마지막 대화 사이 여유 (약 한 줄 + α) */
  padding-bottom: calc(var(--composer-h, var(--footer-h)) + 28px);
  box-sizing: border-box;
}

.header {
  flex-shrink: 0;
  height: var(--header-h);
  padding: 0 max(var(--page-pad), calc(50% - var(--content-max) / 2));
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,12,.92);
  backdrop-filter: blur(12px);
  z-index: 10;
  /* position sticky 아님 — 스크롤 시 위로 사라짐 */
  position: relative;
}
.brand-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.brand-subtitle {
  margin-left: 4px; margin-top: -2px;
  font-size: 10px; color: #64748b; letter-spacing: .15px;
  white-space: nowrap;
}
.header-controls { display: flex; align-items: center; gap: 10px; }
.char-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  max-width: 140px;
}
.char-chip-avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
}
.char-chip span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.date { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.history-pager {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px max(var(--page-pad), calc(50% - var(--content-max) / 2)) 2px;
  color: var(--text-muted);
  font-size: 12px;
}
.history-pager[hidden] { display: none !important; }
.history-pager button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}
.history-pager button:disabled { opacity: .35; cursor: default; }

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  /* 메시지 적을 때 하단(푸터 쪽)으로 밀착 */
  margin-top: auto;
  overflow: visible;
  padding: 16px max(var(--page-pad), calc(50% - var(--content-max) / 2)) 16px;
  box-sizing: border-box;
}


/* Messages */
.msg {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  /* 부모 콘텐츠 트랙(max 720px) 안에서만 자람 → 입력창과 좌·우 가장자리 일치 */
  max-width: 100%;
  animation: msgIn .25s ease;
}
.msg:last-child {
  margin-bottom: 12px;
}
.msg.assistant {
  align-self: flex-start;
  flex-direction: column;
  align-items: flex-start;
  margin-left: 0;
  margin-right: auto;
  width: auto;
  max-width: 100%;
}
.msg.assistant .msg-avatar { margin-bottom: 0; }
.msg.assistant .msg-body { width: auto; max-width: 100%; }
.msg.user {
  align-self: flex-end;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: 0;
  flex-direction: column;
  align-items: stretch;
}
.msg.user .msg-body { width: auto; max-width: 100%; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  background: var(--bg-soft); border: 1px solid var(--border);
}
/* 보조 캐릭터: 파일이 없어도 주인공과 구분되도록 테두리·톤 유지 */
.msg-avatar.is-guest-avatar {
  border-color: #7c9cff;
  box-shadow: 0 0 0 1px rgba(124, 156, 255, 0.35);
  filter: saturate(1.08);
}
.msg-body { min-width: 0; }
.msg-meta {
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 4px;
  display: flex; gap: 8px; align-items: baseline;
}
.msg.user .msg-meta { justify-content: flex-end; }
.msg-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.55; font-size: 15px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.assistant .msg-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, rgba(115,230,190,.2), rgba(147,197,253,.18));
  border: 1px solid rgba(115,230,190,.25);
  border-top-right-radius: 4px;
}
.msg-time { font-size: 10px; color: #64748b; }
/* 캐릭터(assistant) 말풍선 아래 응답 시간 */
.msg-latency {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.2;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  min-height: 12px;
}
.msg-latency:empty { display: none; }
.msg-latency.is-pending {
  color: var(--accent);
}
.msg.user .msg-latency { display: none; }

/* Footer / Composer */
.footer-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  /* 좌우 위치·폭은 JS syncComposerAlignment 가 #chat-container 기준으로 맞춤 */
  padding: 8px 0 calc(8px + var(--safe-b));
  /* 입력창 주변은 투명 — 뒤 메시지가 비치도록 (입력 pill 자체는 .input-group 배경 유지) */
  background: transparent;
  pointer-events: none;
}
.footer-inner {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  box-sizing: border-box;
  pointer-events: auto;
  position: relative;
}
.input-group {
  width: 100%;
  min-height: 56px;
  height: 56px;
  margin: 0;
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: none;
  padding: 15px 14px 15px 14px;
  overflow: visible;
  transition: none;
  flex-shrink: 0;
  visibility: visible;
  opacity: 1;
}

/* + 와 전송 버튼은 하단에 고정. 한 줄에서는 입력 영역 양쪽에 여백을 확보하고,
   두 줄 이상이 되면 textarea가 박스 전체 폭을 사용한다. */
.composer-icon {
  position: absolute;
  z-index: 3;
  bottom: 9px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
}
#more-btn { left: 4px; }
#send-btn { right: 8px; bottom: 9px; }
.composer-icon svg { width: 20px; height: 20px; }
.composer-icon:active { background: var(--bg-soft); }

/* 이미지·음성 아이콘 (텍스트 입력 시 JS로 숨김) */
.media-actions {
  position: absolute;
  right: 48px;
  bottom: 9px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
}
.media-actions[hidden] { display: none !important; }
.media-icon {
  position: static;
  width: 34px;
  height: 34px;
  color: var(--text-muted);
}
.media-icon.recording {
  color: #ff4d6d;
  background: rgba(255, 77, 109, 0.15);
  animation: pulse-rec 1.2s ease-in-out infinite;
}
@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.attach-preview {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 0 8px;
  padding: 8px;
  box-sizing: border-box;
  border-radius: 14px;
  background: var(--bg-soft, #1a1b22);
  border: 1px solid rgba(255,255,255,0.08);
}
.attach-preview[hidden] { display: none !important; }
.attach-preview img {
  display: block;
  max-width: 100%;
  max-height: 160px;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
  object-fit: contain;
}
.attach-preview-clear {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.msg-bubble .msg-image {
  display: block;
  max-width: min(100%, 280px);
  max-height: 240px;
  width: auto;
  height: auto;
  margin: 0 0 8px;
  border-radius: 12px;
  object-fit: contain;
}
.msg-bubble .msg-caption { white-space: pre-wrap; }
.msg-bubble .msg-voice-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 미디어 아이콘 있을 때 입력 우측 여백 */
#message-input.has-media-icons {
  padding-right: 120px;
}
#more-btn[aria-expanded="true"] {
  background: var(--bg-soft);
  color: var(--accent);
}

#message-input {
  display: block;
  white-space: pre-wrap;
  width: 100%;
  min-width: 0;
  height: 24px;
  min-height: 24px;
  max-height: 72px;
  margin: 0;
  padding: 0 120px 0 30px;
  box-sizing: border-box;
  border: 0;
  outline: none;
  resize: none;
  overflow-x: hidden;
  overflow-y: hidden;
  background: transparent;
  box-shadow: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 24px;
  color: var(--text);
  vertical-align: top;
}
#message-input:focus { border: 0; outline: none; box-shadow: none; background: transparent; }
#message-input::placeholder { color: var(--text-muted); }
#message-input::-webkit-scrollbar { width: 5px; }
#message-input::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 8px; }

#send-btn {
  background: var(--accent);
  color: #0a0a0c;
  border-radius: 50%;
}
#send-btn:disabled { opacity: .4; }

.composer-meta {
  width: 100%;
  height: 14px;
  margin: 4px 0 0;
  padding: 0 4px;
  box-sizing: border-box;
  font-size: 10px;
  line-height: 14px;
  color: var(--text-muted);
  letter-spacing: 0;
  white-space: nowrap;
  user-select: none;
  text-align: center;
  background: transparent;
}

.input-group.is-multiline {
  padding: 12px 14px 48px 14px;
  min-height: 104px;
}
.input-group.is-multiline #message-input {
  max-height: 72px;
  overflow-y: auto;
  padding-right: 0 !important;
  padding-left: 0 !important;
  text-indent: 0 !important;
}

.composer-status {
  position: absolute;
  left: 52px;
  right: 124px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 20px;
  pointer-events: none;
}
.composer-status[aria-hidden="false"] { display: flex; }
.composer-status-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}
.composer-status-bars span {
  display: block;
  width: 3px;
  height: 40%;
  min-height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transform-origin: bottom center;
  animation: barPulse 0.9s ease-in-out infinite;
}
.composer-status-bars span:nth-child(1) { animation-delay: 0s; }
.composer-status-bars span:nth-child(2) { animation-delay: 0.12s; }
.composer-status-bars span:nth-child(3) { animation-delay: 0.24s; }
.composer-status-bars span:nth-child(4) { animation-delay: 0.36s; }
.composer-status-bars span:nth-child(5) { animation-delay: 0.48s; }
@keyframes barPulse {
  0%, 100% { height: 25%; opacity: 0.55; }
  50% { height: 100%; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .composer-status-bars span { animation: none; height: 60%; opacity: 0.8; }
}

@media screen and (max-width: 768px) {
  .input-group {
    width: 100%;
    min-height: 58px;
    height: 58px;
    padding: 16px 14px 16px 14px;
    border-radius: 29px;
  }
  .input-group.is-multiline {
    min-height: 108px;
    height: 108px;
    padding: 12px 14px 48px 14px;
    border-radius: 22px;
  }
  #message-input {
    height: 24px;
    min-height: 24px;
    line-height: 24px;
    white-space: pre-wrap;
    padding-left: 30px;
  }
  .composer-icon { bottom: 10px; width: 36px; height: 36px; }
  #more-btn { left: 8px; }
  #send-btn { right: 8px; bottom: 10px; }
  .composer-meta { margin-top: 4px; height: 14px; line-height: 14px; font-size: 9px; }
}

/* + 메뉴: 입력창 바로 위 */
.composer-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: none;
  z-index: 40;
}
.composer-menu[aria-hidden="false"] { display: block; animation: menuIn .15s ease; }
@keyframes menuIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.composer-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left; padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
}
.composer-menu-item .menu-icon { width: 20px; text-align: center; opacity: .85; }
.composer-menu-item:hover, .composer-menu-item:active { background: var(--bg-soft); }
.composer-menu-item.danger { color: var(--danger); }

/* 언어 모달 */
.language-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.55);
  display: none; /* [hidden] 이 display:flex 에 덮이지 않도록 */
  align-items: flex-end; justify-content: center;
}
.language-modal:not([hidden]) {
  display: flex;
}
@media (min-width: 640px) {
  .language-modal { align-items: center; }
  .language-modal:not([hidden]) { display: flex; }
}
.language-dialog {
  width: min(400px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-b));
}
@media (min-width: 640px) {
  .language-dialog { border-radius: 16px; }
}
.language-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.language-modal-header h2 { margin: 0; font-size: 1.1rem; }
.language-close {
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; color: var(--text-muted);
}
.language-options { display: flex; flex-direction: column; gap: 6px; }
.language-option {
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  text-align: left; font-size: 15px;
}
.language-option.active {
  border-color: var(--accent);
  background: rgba(115,230,190,.12);
}

/* Status modal — 기본 숨김, .is-open 일 때만 표시 */
.status-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55);
  display: none !important;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}
.status-modal.is-open {
  display: flex !important;
  pointer-events: auto;
}
@media (min-width: 640px) {
  .status-modal.is-open { align-items: center; padding: 24px; }
}
.status-dialog {
  width: min(400px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(20px + var(--safe-b));
  animation: sheetUp .28s ease;
}
@media (min-width: 640px) {
  .status-dialog { border-radius: var(--radius); padding-bottom: 20px; }
}
@keyframes sheetUp {
  from { transform: translateY(100%); opacity: .5; }
  to { transform: none; opacity: 1; }
}
.status-dialog h2 {
  margin: 0 0 16px; font-size: 1.1rem;
}
#character-status-content {
  font-size: 14px; line-height: 1.7;
  color: var(--text);
}
#character-status-content .status-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
#character-status-content .status-avatar {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: block;
}
#character-status-content .status-avatar-placeholder {
  background: var(--bg-soft);
}
#character-status-content .status-name {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}
#character-status-content .status-row {
  display: flex; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
#character-status-content .status-label {
  flex: 0 0 88px; color: var(--text-muted); font-size: 13px;
}
#character-status-content .status-section-title {
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
#character-status-content .status-facts {
  flex: 1;
  min-width: 0;
}
#character-status-content .status-fact {
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 4px;
}
#character-status-content .status-muted {
  color: var(--text-muted);
}
#character-status-content .status-row-body {
  align-items: flex-start;
}
#character-status-content .status-body-text {
  flex: 1;
  min-width: 0;
  white-space: normal;
  line-height: 1.5;
  word-break: keep-all;
}
.status-close-btn {
  width: 100%; margin-top: 18px;
  padding: 12px; border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-weight: 600;
}

/* Empty state */
.chat-empty {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted); font-size: 14px;
}

/* Desktop: 패딩 공식은 위에서 CSS 변수로 이미 통일됨 (추가 override 불필요) */


/* 이미지 출처 선택 (카메라 / 앨범) */
.image-source-sheet {
  position: absolute;
  right: 48px;
  bottom: 52px;
  z-index: 40;
  min-width: 160px;
  padding: 6px;
  border-radius: 14px;
  background: var(--bg-elevated, #1c1d26);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.image-source-sheet[hidden] { display: none !important; }
.image-source-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text, #eee);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.image-source-item:active,
.image-source-item:hover { background: var(--bg-soft, #2a2b36); }
.image-source-item.cancel { color: var(--text-muted, #999); }
