:root {
  --primary: #ff9901;
  --primary-press: #fa8c00;
  --brand: #ef6e00;
  --sel-bg: #fff6e8;
  --sel-border: #fee0b2;
  --text: #222222;
  --text2: #616161;
  --muted: #9e9e9e;
  --line: #e0e0e0;
  --surface: #f5f5f5;
  --disabled-bg: #eeeeee;
  --disabled-text: #bdbdbd;
  --danger: #ef2b2a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: #ececec;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input { font-family: inherit; border: none; outline: none; background: transparent; }

/* ===== stage / phone frame ===== */
.stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}
.phone {
  position: relative;
  width: 375px;
  height: 812px;
  background: #fff;
  border-radius: 40px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22), 0 0 0 10px #1b1b1b;
  overflow: hidden;
}
@media (max-width: 480px), (max-height: 900px) and (max-width: 900px) {
  .stage { padding: 0; }
  .phone {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ===== screens ===== */
.screen {
  position: absolute;
  inset: 0;
  background: #fff;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen[data-active="true"] { display: flex; animation: screen-in .22s ease; }
@keyframes screen-in { from { opacity: .4; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ===== status bar / home indicator ===== */
.statusbar {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 28px;
  font-size: 15px;
  font-weight: 600;
}
.sb-icons { letter-spacing: 2px; font-size: 8px; opacity: .8; }
.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: #111;
  opacity: .9;
  pointer-events: none;
}
.home-indicator.in-bar { position: static; transform: none; margin: 10px auto 0; }

/* ===== splash / login ===== */
.splash-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mascot { width: 64px; height: 72px; object-fit: contain; }
.brand-word {
  font-size: 46px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -.5px;
}
.splash-art {
  position: absolute;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  opacity: .12;
  pointer-events: none;
}
.splash-art img { width: 100%; filter: grayscale(0); }
.login-actions {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 96px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-btn {
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}
.login-btn.google { background: #fff; border: 1px solid var(--line); color: var(--text); }
.login-btn.google:active { background: var(--surface); }
.login-btn.apple { background: #000; color: #fff; }
.login-btn.apple:active { opacity: .85; }

/* ===== onboarding ===== */
.progressbar {
  height: 4px;
  margin: 8px 20px 0;
  flex: none;
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 2px; background: var(--primary); transition: width .3s ease; }
.ob-body { flex: 1; overflow-y: auto; padding: 32px 20px 24px; }
.ob-title { font-size: 20px; font-weight: 700; line-height: 1.35; }
.ob-desc { margin-top: 12px; font-size: 16px; line-height: 1.45; color: var(--text2); }
.ob-options { display: flex; flex-direction: column; gap: 12px; margin-top: 40px; }
.ob-options.row { flex-direction: row; }
.ob-options.row .ob-option { flex: 1; }
.ob-group { margin-top: 40px; }
.ob-group .ob-options { margin-top: 12px; }
.ob-group + .ob-group { margin-top: 44px; }
.ob-label { font-size: 14px; font-weight: 600; }
.ob-option {
  height: 44px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid transparent;
  font-size: 16px;
  color: var(--text);
  text-align: left;
  padding: 0 12px;
  transition: background .15s, border-color .15s, color .15s;
}
.ob-option.selected {
  background: var(--sel-bg);
  border-color: var(--sel-border);
  color: var(--brand);
  font-weight: 600;
}

/* ===== bottom cta bar ===== */
.bottom-bar {
  flex: none;
  padding: 12px 20px 30px;
  background: #fff;
  display: flex;
  gap: 12px;
}
.cta {
  flex: 1;
  height: 48px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  transition: background .15s;
}
.cta:active:not(:disabled) { background: var(--primary-press); }
.cta:disabled { background: var(--disabled-bg); color: var(--disabled-text); cursor: default; }
.cta.line { background: #fff; border: 1px solid var(--line); color: var(--text); flex: 0 0 30%; }
.cta.line:active { background: var(--surface); }
.bottom-bar.double .cta:not(.line) { flex: 1; }

/* ===== top navigation ===== */
.topnav { flex: none; background: #fff; border-bottom: 1px solid var(--line); }
.topnav.noline { border-bottom: none; }
.topnav-row {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}
.topnav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 700;
}
.topnav-row { position: relative; }
.topnav-brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand);
  padding-left: 8px;
  letter-spacing: -.3px;
}
.topnav-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.icon-btn:active { background: var(--surface); }
.icon-btn.ghost { pointer-events: none; }

/* ===== main / map ===== */
.map-wrap { position: relative; flex: 1; overflow: hidden; background: #dfe8dc; }
.map-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pin { position: absolute; width: 50px; transform: translate(-50%, -100%); }
.pin-dot {
  display: block;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
  overflow: hidden;
}
.pin-dot img { width: 100%; height: 100%; object-fit: contain; padding: 6px; background: #fff; border-radius: 50%; }
.pin-tail {
  display: block;
  margin: -4px auto 0;
  width: 0; height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 16px solid var(--primary);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.2));
}
.pin.green .pin-dot { background: #00c400; }
.pin.green .pin-tail { border-top-color: #00c400; }
.pin-label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.map-locate {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.map-locate:active { background: var(--surface); }

/* ===== chat bar ===== */
.chatbar {
  flex: none;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 12px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chatbar .icon-btn.plus { flex: none; }
.chat-input {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: 22px;
  padding: 6px 6px 6px 16px;
  min-height: 40px;
}
.chat-input input { flex: 1; font-size: 14px; color: var(--text); }
.chat-input input::placeholder { color: var(--muted); }
.send-btn {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-btn:active { background: var(--primary-press); }
.chatbar .home-indicator.in-bar { flex-basis: 100%; }

/* ===== chat screen ===== */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.msg { display: flex; flex-direction: column; gap: 8px; }
.msg-head { display: flex; align-items: center; justify-content: space-between; }
.msg-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: contain; background: var(--sel-bg); padding: 3px; border: 1px solid var(--sel-border); }
.msg-audio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text2);
  background: #fff;
}
.msg-audio svg { flex: none; }
.msg-bubble-row { display: flex; flex-direction: column; gap: 6px; }
.msg-actions { display: flex; gap: 6px; }
.msg-action {
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.msg-action:active, .msg-action.on { background: var(--sel-bg); border-color: var(--sel-border); }
.msg-text { font-size: 14px; line-height: 1.55; white-space: pre-line; }
.msg.ai.active .msg-text { color: var(--brand); }
.msg-time { font-size: 12px; color: var(--muted); }
.msg.me { align-items: flex-end; }
.msg.me .msg-name { font-size: 14px; font-weight: 600; }
.msg.me .msg-bubble {
  background: var(--surface);
  border-radius: 16px 4px 16px 16px;
  padding: 10px 14px;
  max-width: 85%;
}
.msg.me { text-align: right; }
.msg-loading { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  animation: bounce 1s infinite;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ===== chat list ===== */
.search-wrap { flex: none; padding: 12px 20px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}
.search-field:focus-within { border-color: var(--muted); }
.search-field input { flex: 1; font-size: 14px; }
.search-field input::placeholder { color: var(--muted); }
.chatlist { flex: 1; overflow-y: auto; padding: 4px 20px 40px; display: flex; flex-direction: column; gap: 8px; }
.chatlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-radius: 8px;
  text-align: left;
}
.chatlist-item:active { background: var(--surface); }
.cl-thumb {
  flex: none;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  background: #ededed;
}
.cl-thumb.blank { display: inline-block; }
.cl-body { flex: 1; min-width: 0; }
.cl-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cl-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-time { flex: none; font-size: 12px; color: var(--muted); }
.cl-preview {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== settings ===== */
.settings-scroll { flex: 1; overflow-y: auto; padding-bottom: 48px; }
.set-section { padding: 16px 20px 8px; }
.set-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.set-account { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.set-provider {
  width: 24px; height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.set-account-text { display: flex; flex-direction: column; gap: 2px; }
.set-email { font-size: 14px; color: var(--text2); font-weight: 500; }
.set-joined { font-size: 12px; color: var(--muted); }
.set-divider { height: 6px; background: var(--surface); }
.set-row {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px;
  border-radius: 8px;
  text-align: left;
}
button.set-row:active { background: var(--surface); }
.set-texts { display: flex; flex-direction: column; gap: 2px; }
.set-title { font-size: 14px; font-weight: 500; }
.set-title.danger { color: var(--danger); }
.set-desc { font-size: 12px; color: var(--muted); }
.chev {
  width: 8px; height: 8px;
  border-top: 2px solid #bdbdbd;
  border-right: 2px solid #bdbdbd;
  transform: rotate(45deg);
  flex: none;
  margin-right: 6px;
}
.switch {
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--line);
  position: relative;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .2s;
}
.switch.on { background: var(--primary); }
.switch.on::after { left: 21px; }

/* toast */
.toast {
  position: absolute;
  left: 20px; right: 20px;
  bottom: 40px;
  background: #e6f9e6;
  border: 1px solid #8ae48a;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  animation: toast-in .25s ease;
  z-index: 30;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
