/* GLOBAL CHAT MVP — Light & Warm UI (Phase 1) */
:root {
  --bg: #ffffff;
  --bg-soft: #f4faff;
  --bg-mint: #eefaf5;
  --sky: #4db8ff;
  --sky-deep: #2a9fe8;
  --mint: #5ee0b8;
  --mint-soft: #d8f8ee;
  --blue-soft: #e3f2ff;
  --yellow: #ffd166;
  --yellow-soft: #fff6dd;
  --text: #1c2b3a;
  --text-secondary: #6b7f94;
  --text-muted: #9aadc0;
  --card: #ffffff;
  --shadow: 0 8px 28px rgba(77, 184, 255, 0.1);
  --shadow-sm: 0 4px 16px rgba(77, 184, 255, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --nav-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Nunito", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 40%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

.app-shell {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 0 1px rgba(77, 184, 255, 0.06);
  overflow: hidden;
}

.screen {
  display: none;
  min-height: calc(100dvh - var(--nav-h) - var(--safe-bottom));
  padding: 20px 20px 24px;
  animation: fadeIn 0.28s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Home ── */
.home-header .brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--sky-deep);
  margin-bottom: 6px;
}

.home-header h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.home-header .sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.hero {
  position: relative;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--blue-soft) 0%, var(--mint-soft) 100%);
  padding: 22px 20px 18px;
  margin-bottom: 20px;
  overflow: hidden;
  min-height: 148px;
}

.hero::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  top: -30px;
  right: -20px;
}

.hero-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--sky-deep);
  margin-bottom: 4px;
}

.hero-copy {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 58%;
  line-height: 1.45;
  position: relative;
  z-index: 1;
}

.hero-globe {
  position: absolute;
  right: 12px;
  bottom: 8px;
  width: 130px;
  height: 110px;
  z-index: 1;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-label h2 {
  font-size: 17px;
  font-weight: 800;
}

.section-label span {
  font-size: 12px;
  color: var(--sky-deep);
  font-weight: 700;
}

.friend-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(77, 184, 255, 0.08);
}

.friend-card.featured {
  border: 2px solid rgba(77, 184, 255, 0.22);
  box-shadow: var(--shadow);
}

.friend-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: linear-gradient(135deg, var(--blue-soft), var(--mint-soft));
  flex-shrink: 0;
  position: relative;
}

.avatar.lg {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  font-size: 42px;
}

.avatar .flag {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 18px;
  background: var(--card);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.friend-meta h3 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 2px;
}

.friend-meta .loc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--sky-deep);
}

.chip.mint {
  background: var(--mint-soft);
  color: #1a9b72;
}

.chip.yellow {
  background: var(--yellow-soft);
  color: #c99200;
}

.presence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--mint);
  margin: 10px 0 8px;
}

.presence .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(94, 224, 184, 0.25);
}

.stars {
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--yellow);
  margin-bottom: 14px;
}

.stars-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  margin-right: 6px;
}

.btn-chat {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--sky) 0%, var(--sky-deep) 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(42, 159, 232, 0.28);
  transition: transform 0.15s ease;
}

.btn-chat:active {
  transform: scale(0.98);
}

.btn-secondary {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  color: var(--sky-deep);
  font-weight: 800;
  font-size: 14px;
}

/* ── AI Screen ── */
.ai-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky), var(--mint));
  margin: 8px auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 12px 32px rgba(77, 184, 255, 0.35);
}

.ai-header {
  text-align: center;
  margin-bottom: 22px;
}

.ai-header h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.ai-header p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ai-input-wrap {
  background: var(--bg-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(77, 184, 255, 0.12);
}

.ai-input-wrap label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--sky-deep);
  margin-bottom: 8px;
}

.ai-input-wrap textarea {
  width: 100%;
  min-height: 80px;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
}

.mode-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.mode-chip {
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: var(--card);
  color: var(--text-secondary);
  border: 1px solid rgba(77, 184, 255, 0.15);
}

.mode-chip.active {
  background: linear-gradient(135deg, var(--sky), var(--mint));
  color: #fff;
  border-color: transparent;
}

.ai-hint-card {
  background: var(--yellow-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #7a6520;
  margin-bottom: 14px;
}

.ai-result-list .friend-card {
  padding: 14px;
}

/* ── Chat ── */
.chat-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(77, 184, 255, 0.1);
  cursor: pointer;
}

.chat-list-item .avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 22px;
}

.chat-list-body {
  flex: 1;
  min-width: 0;
}

.chat-list-body h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 2px;
}

.chat-list-body p {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.chat-room {
  display: none;
  flex-direction: column;
  height: calc(100dvh - var(--nav-h) - var(--safe-bottom));
  padding: 0;
}

.chat-room.open {
  display: flex;
}

.chat-room-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(77, 184, 255, 0.1);
  background: var(--bg);
}

.chat-room-header .back {
  font-size: 22px;
  background: var(--blue-soft);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sky-deep);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--bg-soft);
}

.bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 10px;
}

.bubble.in {
  background: var(--card);
  border: 1px solid rgba(77, 184, 255, 0.1);
  border-bottom-left-radius: 6px;
}

.bubble.out {
  background: linear-gradient(135deg, var(--sky), var(--sky-deep));
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 6px;
}

.chat-compose {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid rgba(77, 184, 255, 0.1);
}

.chat-compose input {
  flex: 1;
  border: 1px solid rgba(77, 184, 255, 0.2);
  border-radius: 999px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: var(--bg-soft);
}

.chat-compose button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky), var(--sky-deep));
  color: #fff;
  font-size: 18px;
}

/* ── Profile ── */
.profile-hero {
  text-align: center;
  padding: 12px 0 24px;
}

.profile-hero .avatar {
  margin: 0 auto 14px;
}

.profile-hero h1 {
  font-size: 24px;
  font-weight: 800;
}

.profile-hero .loc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-stat {
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid rgba(77, 184, 255, 0.08);
}

.profile-stat label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-stat span {
  font-size: 14px;
  font-weight: 800;
}

.profile-section {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.profile-section h3 {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--sky-deep);
}

.match-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--yellow-soft), var(--mint-soft));
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.match-score strong {
  font-size: 15px;
}

/* ── Settings ── */
.settings-group {
  margin-bottom: 18px;
}

.settings-group h3 {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 4px;
  letter-spacing: 0.06em;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 15px;
}

.settings-item span:last-child {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(77, 184, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
}

.nav-item .icon {
  font-size: 24px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.nav-item.active {
  color: var(--sky-deep);
}

.nav-item.active .icon {
  transform: scale(1.08);
}

.screen-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

/* ── Friend Detail (Phase 1.1) ── */
.screen-detail {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  z-index: 200;
  background: var(--bg);
  padding: 0;
  min-height: 100dvh;
  display: none;
  flex-direction: column;
}

.screen-detail.open {
  display: flex;
  animation: fadeIn 0.28s ease;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg);
  border-bottom: 1px solid rgba(77, 184, 255, 0.1);
  flex-shrink: 0;
}

.detail-header .back {
  font-size: 22px;
  background: var(--blue-soft);
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sky-deep);
  flex-shrink: 0;
}

.detail-header-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-secondary);
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 160px;
  -webkit-overflow-scrolling: touch;
}

.detail-hero {
  text-align: center;
  margin-bottom: 20px;
}

.detail-hero .avatar.xl {
  width: 112px;
  height: 112px;
  border-radius: 32px;
  font-size: 52px;
  margin: 0 auto 14px;
  box-shadow: var(--shadow);
}

.detail-hero h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 4px;
}

.detail-hero .loc {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.detail-match-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--yellow-soft), var(--mint-soft));
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.detail-match-banner strong {
  font-size: 15px;
}

.detail-match-banner .score {
  font-size: 22px;
  font-weight: 800;
  color: var(--sky-deep);
}

.detail-why {
  background: linear-gradient(145deg, var(--blue-soft), var(--mint-soft));
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(77, 184, 255, 0.15);
}

.detail-why h3 {
  font-size: 14px;
  font-weight: 800;
  color: var(--sky-deep);
  margin-bottom: 8px;
}

.detail-why p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.detail-common {
  margin-bottom: 16px;
}

.detail-common h3 {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-safety {
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  border: 1px solid rgba(94, 224, 184, 0.25);
}

.detail-safety strong {
  display: block;
  font-size: 13px;
  color: var(--mint);
  margin-bottom: 6px;
}

.detail-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(77, 184, 255, 0.12);
  z-index: 210;
}

.detail-cta-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.detail-cta-row .btn-chat {
  flex: 1;
}

.btn-save {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--yellow-soft);
  color: #b8860b;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid rgba(255, 209, 102, 0.5);
}

.btn-save.saved {
  background: var(--mint-soft);
  color: #1a9b72;
  border-color: rgba(94, 224, 184, 0.4);
}

.detail-safety-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
}

.detail-safety-links button {
  background: none;
  color: var(--text-muted);
  font-weight: 700;
  text-decoration: underline;
  padding: 4px;
}

.friend-card {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.friend-card:active {
  transform: scale(0.99);
}

.friend-card .btn-chat {
  position: relative;
  z-index: 2;
}

.match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 6px;
}

.match-pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--sky-deep);
}

.match-pct strong {
  font-size: 16px;
}

.stars-inline {
  font-size: 12px;
  color: var(--yellow);
  letter-spacing: 1px;
}

.match-reasons {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.match-reasons li {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 2px 0;
}

.purpose-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purpose-chip {
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid rgba(77, 184, 255, 0.15);
}

.purpose-chip.active {
  background: linear-gradient(135deg, var(--sky), var(--mint));
  color: #fff;
  border-color: transparent;
}

.section-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.guide-role-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-role-btn {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid rgba(77, 184, 255, 0.12);
}

.guide-role-btn.active {
  background: var(--blue-soft);
  color: var(--sky-deep);
  border-color: rgba(77, 184, 255, 0.35);
}

.guide-section {
  border-left: 4px solid var(--mint);
}


