* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #e9ebee;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.phone {
  width: 420px;
  max-width: 100vw;
  min-height: 100vh;
  background: #eef1f4;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.15);
}

.chat-header {
  background: #2b2b2f;
  color: #fff;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.chat-header-title {
  font-weight: 700;
  font-size: 17px;
}

.chat-header-sub {
  font-size: 12px;
  color: #b7b7bd;
  margin-top: 2px;
}

.chat-body {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.empty-hint {
  margin: auto;
  color: #8a8578;
  font-size: 13px;
  text-align: center;
  max-width: 220px;
  line-height: 1.6;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
}

.bubble-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sender-name {
  font-size: 11px;
  color: #6f6a5e;
  padding-left: 2px;
}

.bubble {
  background: #fff;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.bubble-row.mine .bubble {
  background: #ffe680;
}

.bubble.typing {
  color: #a39d8c;
  font-style: italic;
}

.bubble img.thumb {
  display: block;
  max-width: 160px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.composer {
  background: #fff;
  border-top: 1px solid #ddd;
  padding: 10px 12px 14px;
}

#setupPhase,
#chatPhase {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#setupPhase[hidden],
#chatPhase[hidden] {
  display: none;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-btn {
  display: inline-block;
  padding: 8px 12px;
  background: #f2f2f2;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: #333;
}

.preview {
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
}

.text-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.text-input:focus {
  border-color: #f0c419;
}

.persona-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #ddd;
}

.persona-chip {
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.persona-chip.selected {
  background: #333;
  color: #fff;
  border-color: #333;
}

.persona-chip.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.persona-chip.locked {
  background: #333;
  color: #fff;
  border-color: #333;
  cursor: default;
  opacity: 0.85;
}

.ask-btn {
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: #f0c419;
  color: #2b2b2f;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.ask-btn:disabled {
  background: #ddd;
  color: #999;
  cursor: not-allowed;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-input-row .text-input {
  flex: 1;
}

.attach-icon-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f2f2f2;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}

.followup-btn {
  padding: 0 16px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: #2b2b2f;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

#followupPreview {
  align-self: flex-start;
}

.invite-more-row {
  display: flex;
  gap: 6px;
}

.invite-more-btn {
  border: 1px dashed #bbb;
  background: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
}

.invite-more-btn.active {
  border-style: solid;
  border-color: #333;
  color: #333;
}

.session-divider {
  align-self: center;
  font-size: 11px;
  color: #a39d8c;
  margin: 6px 0;
  text-align: center;
}

.system-notice {
  align-self: center;
  font-size: 12px;
  color: #4a4a4a;
  background: #ffffff;
  padding: 8px 16px;
  border-radius: 14px;
  margin: 8px auto;
  text-align: center;
  max-width: 80%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chip-edit-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  padding: 0 0 0 2px;
  line-height: 1;
  opacity: 0.6;
}

.chip-edit-btn:hover {
  opacity: 1;
}

.edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.edit-modal-overlay[hidden] {
  display: none;
}

.edit-modal {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-modal h3 {
  margin: 0;
  font-size: 15px;
}

.edit-avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edit-avatar-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #eee;
}

.edit-modal-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}

.edit-modal-actions button {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.edit-reset-btn {
  background: #f2f2f2;
  color: #555;
  margin-right: auto;
}

.edit-cancel-btn {
  background: #f2f2f2;
  color: #333;
}

.edit-save-btn {
  background: #2b2b2f;
  color: #fff;
}
