:root {
  --bg-deep: #1a1230;
  --violet: #7C5CFF;
  --violet-dark: #B9A6FF;
  --pink: #FF6FA5;
  --cream: #121016;
  --ink: #F3F1F8;
  --ink-soft: #9B94B0;
  --card: #1D1A24;
  --line: rgba(255,255,255,0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

/* First screen (welcome) keeps its original light look regardless of the app's dark theme */
.ob-step[data-step="welcome"] {
  --cream: #FFF8F0;
  --ink: #241C3A;
  --ink-soft: #6b6483;
  --card: #ffffff;
  --line: #EDE7FB;
  --violet-dark: #6244E0;
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #2b1e52 0%, #150f28 60%, #0d0a1a 100%);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 12px;
}

.phone {
  width: 100%;
  max-width: 420px;
  height: 860px;
  max-height: 92vh;
  background: var(--cream);
  border-radius: 40px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 10px #0e0a1c, 0 0 0 12px #322753;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------------- Onboarding ---------------- */

.ob-step {
  height: 100%;
  width: 100%;
  padding: 28px 24px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ob-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.btn-back {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 6px;
}

.progress {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--pink));
  border-radius: 4px;
  transition: width .3s ease;
}

.ob-step h2 {
  font-size: 22px;
  margin: 14px 0 4px;
}
.ob-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 18px;
}

.welcome-wrap {
  margin: auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.logo-orb {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #C9B6FF, var(--violet) 55%, var(--pink) 100%);
  box-shadow: 0 0 60px rgba(124,92,255,0.6);
  margin-bottom: 8px;
}
.brand {
  font-size: 32px;
  margin: 0;
  letter-spacing: -0.5px;
}
.tagline {
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 18px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
  display: block;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 15px;
  margin-bottom: 18px;
  font-family: inherit;
  color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--violet); }
.textarea { min-height: 84px; resize: vertical; }

.chip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.chip-grid.wrap {
  display: flex;
  flex-wrap: wrap;
  grid-template-columns: none;
}
.chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-soft);
  user-select: none;
  transition: all .15s ease;
}
.chip.mbti { border-radius: var(--radius-sm); padding: 10px 4px; font-weight: 600; }
.chip.selected {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  border-color: transparent;
  color: #fff;
}

.avatar-preview {
  width: 168px;
  height: 168px;
  flex-shrink: 0;
  margin: 0 auto 18px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(124,92,255,0.25);
  border: 4px solid #fff;
}
.avatar-preview svg, .room-avatar svg, .mini-avatar svg { width: 100%; height: 100%; display: block; }
.avatar-preview img, .room-avatar img, .mini-avatar img {
  width: 100%; height: 100%; display: block; object-fit: cover;
}

.selfie-preview-thumb {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  margin: 0 auto 10px;
  display: block;
}

.looking-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.looking-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--card);
  cursor: pointer;
}
.looking-card .lc-emoji { font-size: 22px; margin-bottom: 4px; }
.looking-card .lc-title { font-weight: 700; font-size: 15px; }
.looking-card .lc-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.looking-card.selected {
  border-color: var(--violet);
  background: linear-gradient(135deg, rgba(124,92,255,0.18), rgba(255,111,165,0.14));
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  color: #fff;
  box-shadow: 0 10px 24px rgba(124,92,255,0.35);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-fixed { margin-top: auto; width: 100%; }
.btn-ghost {
  background: var(--card);
  color: var(--violet-dark);
  border: 1.5px solid var(--line);
}
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; color: var(--ink-soft); }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 999px; }
.btn-reset-all {
  display: block;
  margin: 6px auto 0;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}
.btn-reset-all:active { opacity: 0.6; }

.creating-wrap {
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.spinner {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--violet);
  margin: 0 auto 16px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Main App ---------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.app-header-left { display: flex; align-items: center; gap: 10px; }
.mini-avatar {
  width: 40px; height: 40px;
  min-width: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--line);
  flex-shrink: 0;
}
.mini-name { font-weight: 700; font-size: 14px; }
.header-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--line);
  color: var(--violet-dark);
  padding: 5px 10px;
  border-radius: 999px;
}

.view-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.view { display: flex; flex-direction: column; height: 100%; }

.room-avatar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}
.room-avatar {
  width: 150px; height: 150px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid #fff;
  box-shadow: 0 12px 30px rgba(124,92,255,0.2);
  margin-bottom: 10px;
}

.persona-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 4px;
}
.persona-card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.persona-card-title { font-weight: 700; font-size: 13.5px; margin-bottom: 0; }
.persona-row { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip-row span {
  background: var(--line);
  color: var(--violet-dark);
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
}
.persona-quote {
  font-size: 13px;
  font-style: italic;
  color: var(--ink);
  border-left: 3px solid var(--violet);
  padding-left: 10px;
}

/* Live scene — avatar wandering & meeting another avatar */
.scene {
  position: relative;
  height: 260px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
  background: #17141d;
  transition: height 0.3s ease;
}
.scene.expanded {
  flex: 1;
  height: auto;
  margin-bottom: 0;
}
.scene-decor { position: absolute; inset: 0; }
.scene-decor svg { display: block; }

.zone-label {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(255,255,255,0.9);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--ink-soft);
  z-index: 5;
  transition: opacity 0.4s ease;
}
.walker {
  position: absolute;
  width: 42px; height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 6px 14px rgba(0,0,0,0.2);
  transition: left 2.6s ease-in-out, top 2.6s ease-in-out, opacity 0.6s ease;
  z-index: 3;
  transform: translate(-50%, -50%);
}
.walker svg, .walker img { width: 100%; height: 100%; display: block; object-fit: cover; }
.walker.partner { z-index: 2; }

/* Conversation screen — KakaoTalk-style chat thread while two matched avatars talk */
.conversation-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--cream);
  display: flex;
  flex-direction: column;
}
.convo-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 16px;
}
.convo-msg { display: flex; align-items: flex-end; gap: 6px; max-width: 80%; }
.convo-msg.them { align-self: flex-start; }
.convo-msg.me { align-self: flex-end; }
.convo-msg-avatar {
  width: 26px; height: 26px;
  min-width: 26px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.convo-msg-avatar svg, .convo-msg-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.convo-msg-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.convo-msg.them .convo-msg-bubble {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  color: var(--ink);
}
.convo-msg.me .convo-msg-bubble {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  border-radius: 16px 16px 4px 16px;
  color: #fff;
}

/* 사주카페 점쟁이 (fortune teller) intro lines — a distinct third "speaker" */
.convo-msg.npc { align-self: center; max-width: 92%; }
.convo-msg.npc .convo-msg-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: linear-gradient(135deg, #FFD166, #FF9F6C);
}
.convo-msg.npc .convo-msg-bubble {
  background: linear-gradient(135deg, rgba(255,209,102,0.22), rgba(124,92,255,0.14));
  border: 1.5px dashed #C9A24B;
  border-radius: 16px;
  color: var(--ink);
  font-style: italic;
}

.meet-counter {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.9);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--ink-soft);
  z-index: 5;
}

.live-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.live-pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #FF6FA5;
  box-shadow: 0 0 0 0 rgba(255,111,165,0.6);
  animation: pulse 1.6s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,111,165,0.5); }
  70% { box-shadow: 0 0 0 10px rgba(255,111,165,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,111,165,0); }
}
.live-status-title { font-size: 13.5px; font-weight: 700; }
.live-status-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.live-log { display: flex; flex-direction: column; gap: 8px; }
.live-log-item {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.live-log-item b { color: var(--ink); }
.log-view-btn {
  margin-top: 6px;
  border: none;
  background: none;
  padding: 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--violet-dark);
  cursor: pointer;
}
.log-dialogue {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  background: #15131a;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.log-dialogue .dlg-line {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.6;
  padding: 2px 0;
}

/* Reports */
.reports-header { margin-bottom: 14px; }
.reports-title { font-size: 19px; font-weight: 800; }
.reports-sub { font-size: 12.5px; color: var(--ink-soft); }

.reports-list { display: flex; flex-direction: column; gap: 14px; }
.report-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
}
.report-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.report-avatar { width: 46px; height: 46px; min-width: 46px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 2px solid var(--line); }
.report-avatar svg, .report-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.report-name { font-weight: 700; font-size: 14px; }
.report-place { font-size: 11.5px; color: var(--ink-soft); }
.report-score-wrap { margin-left: auto; text-align: right; }
.report-score { font-size: 20px; font-weight: 800; color: var(--violet-dark); }
.report-relation {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--violet), var(--pink));
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.report-summary { font-size: 13px; color: var(--ink); line-height: 1.5; margin-bottom: 8px; }
.report-common { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.report-common span {
  font-size: 11px;
  background: rgba(124,92,255,0.16);
  color: var(--violet-dark);
  padding: 4px 9px;
  border-radius: 999px;
}
.report-actions { display: flex; gap: 8px; }
.report-actions .btn { flex: 1; padding: 10px; font-size: 13px; }
.report-actions .btn-secondary { background: var(--line); color: var(--ink-soft); box-shadow: none; }
.report-actions .btn-secondary:disabled { opacity: 0.5; }
.report-approved-tag {
  font-size: 12px;
  font-weight: 700;
  color: #00B894;
  text-align: center;
  padding: 8px;
}

/* Chat */
.chat-list { display: flex; flex-direction: column; gap: 10px; }
.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
}
.chat-list-avatar { width: 44px; height: 44px; min-width: 44px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.chat-list-avatar svg, .chat-list-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.chat-list-name { font-weight: 700; font-size: 14px; }
.chat-list-preview { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.chat-empty { text-align: center; color: var(--ink-soft); font-size: 13px; margin-top: 40px; line-height: 1.6; }

.chat-thread { display: flex; flex-direction: column; height: 100%; }
.chat-thread-header { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 12px; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; margin-bottom: 10px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.4; }
.msg.them { align-self: flex-start; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px 16px 16px 4px; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--violet), var(--pink)); color: #fff; border-radius: 16px 16px 4px 16px; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row .text-input { margin-bottom: 0; }
.chat-input-row .btn { white-space: nowrap; flex-shrink: 0; }

/* Tabbar */
.tabbar {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px 14px;
  font-size: 10.5px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: inherit;
}
.tab-btn span { font-size: 19px; }
.tab-btn.active { color: var(--violet-dark); font-weight: 700; }
.tabbar.locked .tab-btn { opacity: 0.4; cursor: not-allowed; }

/* Toast — brief message (e.g. blocked tab navigation during a conversation) */
.toast {
  position: absolute;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  background: rgba(20, 16, 30, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 80;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: toast-fade 2s ease forwards;
}
@keyframes toast-fade {
  0% { opacity: 0; transform: translateX(-50%) translateY(6px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* Outing planner overlay — pick today's 5 stops before going out */
.outing-planner {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 28px 24px 24px;
  overflow-y: auto;
}
.outing-planner h2 { font-size: 22px; margin: 0 0 4px; }
.outing-slots {
  display: flex;
  gap: 8px;
  margin: 18px 0 22px;
}
.outing-slot {
  flex: 1;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--card);
  position: relative;
  cursor: pointer;
}
.outing-slot.filled {
  border-style: solid;
  border-color: var(--violet);
  background: linear-gradient(135deg, rgba(124,92,255,0.18), rgba(255,111,165,0.14));
}
.outing-slot .slot-num {
  position: absolute;
  top: 3px; left: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-soft);
}
.outing-zone-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: auto;
}
.outing-zone-btn {
  padding: 18px 10px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.outing-zone-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.saju-time-unknown {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
