* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
}
button,
a,
label,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top, #ffd2e3 0, #f7d8e5 24%, #f2e7ef 48%, #ebeef5 100%);
  color: #2c1532;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 0;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
button:focus,
button:focus-visible {
  outline: none;
}
.hidden { display: none !important; }
html.boot-loading .phone-shell {
  visibility: hidden;
}
html.boot-loading .boot-overlay {
  display: grid !important;
}
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  place-items: center;
  align-content: center;
  gap: 14px;
  background:
    radial-gradient(circle at top, #ffd2e3 0, #f7d8e5 24%, #f2e7ef 48%, #ebeef5 100%);
  color: #7d5066;
  font-size: 15px;
  font-weight: 700;
}
.boot-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(255, 111, 160, .22);
  border-top-color: #ff4f87;
  animation: bootSpin .8s linear infinite;
}
@keyframes bootSpin {
  to { transform: rotate(360deg); }
}
.phone-shell {
  width: min(100vw, 430px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  background: linear-gradient(180deg, #fff5f8 0%, #f7f1f6 45%, #f3f6fb 100%);
  overflow: hidden;
  box-shadow: 0 14px 48px rgba(126, 74, 106, .18);
}
h1, h2, p { margin: 0; }
.auth-view { padding: 42px 18px; min-height: 100vh; background: linear-gradient(180deg, #fff7fa 0%, #f8eff5 100%); }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff6fa0 0%, #ff4f86 100%);
  color: white;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(255, 95, 148, .28);
}
.brand h1 { font-size: 28px; }
.brand p { color: #9a7189; margin-top: 4px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tab, .ghost, .danger {
  border-radius: 12px;
  background: rgba(255, 255, 255, .9);
  color: #7d5066;
  padding: 11px 12px;
}
.ghost {
  border: 1px solid #f5bfd2;
}
.danger { background: #ffe1ea; color: #cc3f6d; }
.tab.active, .primary, .send {
  background: linear-gradient(135deg, #ff6d9e 0%, #ff4f87 100%);
  color: white;
}
.panel {
  background: rgba(255, 255, 255, .92);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: 0 14px 32px rgba(188, 119, 150, .12);
}
label { display: grid; gap: 6px; color: #4b5563; font-size: 13px; }
input, select {
  width: 100%;
  border: 1px solid #f1cad8;
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, .94);
  outline: none;
}
input:focus, select:focus { border-color: #ff5c90; }
.remember-row {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: #8d6277;
}
.remember-row input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: #ff4f87;
}
.grid-two { display: grid; grid-template-columns: 96px 1fr; gap: 10px; }
.city-grid { grid-template-columns: 1fr 96px; }
.form-spacer { display: block; }
.primary, .send {
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(255, 95, 148, .22);
}
.send {
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  box-shadow: none;
}
.app-view { height: 100%; min-height: 0; position: relative; background: linear-gradient(180deg, #fff5f8 0%, #f4f6fb 100%); overflow: hidden; }
.page {
  height: 100%;
  min-height: 0;
  padding-bottom: 86px;
  display: none;
}
.page.active { display: block; }
.chat-page {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  background: linear-gradient(180deg, #fff5f8 0%, #f4f6fb 100%);
  transform: translateX(100%);
  transition: transform .22s ease;
  will-change: transform;
  backface-visibility: hidden;
  contain: layout paint;
  z-index: 4;
  display: flex;
  flex-direction: column;
}
.chat-page.active { transform: translateX(0); }
.app-view.chat-open .bottom-nav { display: none; }
.topbar, .chat-topbar {
  height: 54px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .72);
  border-bottom: 1px solid rgba(247, 196, 217, .8);
  display: grid;
  align-items: center;
  backdrop-filter: blur(14px);
}
.topbar { grid-template-columns: 1fr 38px; }
.topbar h2, .chat-topbar h2 {
  font-size: 18px;
  font-weight: 700;
}
.chat-topbar {
  grid-template-columns: 42px 1fr 42px 42px;
  text-align: center;
}
.icon-btn, .plain-btn, .round-btn {
  display: grid;
  place-items: center;
  background: transparent;
  color: #5e3146;
}
.icon-btn {
  width: 38px;
  height: 38px;
  font-size: 28px;
  border-radius: 8px;
}
.plain-btn { height: 42px; font-size: 24px; border-radius: 10px; }
.round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #dedee4;
  font-size: 19px;
  background: rgba(255, 255, 255, .84);
}
.conversation-list { background: rgba(255, 255, 255, .68); }
.conversation {
  width: 100%;
  min-height: 70px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid #f7dce6;
  text-align: left;
}
.conversation img, .msg-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  object-fit: cover;
  background: #ffd7e4;
}
.conversation strong {
  display: block;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation p {
  margin-top: 4px;
  color: #9c7487;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation time { color: #b48aa0; font-size: 12px; align-self: start; padding-top: 4px; }
.empty-state { padding: 40px 16px; text-align: center; color: #a0778e; }
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100vw, 430px);
  height: 58px;
  background: rgba(255, 255, 255, .88);
  border-top: 1px solid rgba(247, 196, 217, .82);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 12;
  box-shadow: 0 -8px 28px rgba(209, 129, 164, .16);
  backdrop-filter: blur(14px);
}
.nav-item {
  display: grid;
  gap: 2px;
  place-items: center;
  background: transparent;
  color: #9b7185;
  font-size: 12px;
}
.nav-item span { font-size: 19px; }
.nav-item.active { color: #ff4f87; }
.me-hero {
  padding: 10px 14px 0;
  background: linear-gradient(180deg, rgba(255, 179, 209, .62) 0%, rgba(255, 244, 248, .2) 100%);
}
.me-profile-card,
.me-card,
.menu-group {
  background: rgba(255, 255, 255, .88);
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(196, 126, 158, .12);
}
.me-profile-card {
  padding: 12px;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.me-avatar-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
}
.me-avatar-wrap img {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  object-fit: cover;
  background: #ffd7e4;
  box-shadow: 0 12px 28px rgba(255, 126, 171, .22);
}
.me-profile-meta {
  min-width: 0;
  display: grid;
  gap: 5px;
}
.me-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.me-profile-meta strong {
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-profile-meta span {
  color: #8d6277;
  font-size: 13px;
}
.change-avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe2ed 0%, #ffd3e4 100%);
  color: #d74f80;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 117, 165, .16);
}
.change-avatar-btn input { display: none; }
.me-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff3f8;
  color: #8d6277;
}
.badge-pill em {
  font-style: normal;
  font-size: 12px;
  color: #be7d98;
}
.badge-pill strong {
  font-size: 13px;
}
.location-pill {
  max-width: 100%;
}
.location-pill strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-card {
  margin: 8px 14px 0;
  padding: 0;
  overflow: hidden;
}
.me-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 8px;
  margin-bottom: 0;
}
.me-card-head h3 {
  margin: 0;
  font-size: 16px;
}
.me-card-head span {
  color: #b5879b;
  font-size: 12px;
  text-align: right;
}
.me-form { display: grid; gap: 12px; }
.edit-profile-row {
  border-top: 1px solid #f8dbe6;
}
.profile-compact-grid {
  display: grid;
  grid-template-columns: 82px 1fr 1fr;
  gap: 10px;
}
.menu-group {
  margin: 8px 14px 0;
  overflow: hidden;
}
.menu-row {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f8dbe6;
  text-align: left;
}
.menu-row:last-child { border-bottom: 0; }
.menu-row span {
  color: #331a2a;
  font-size: 15px;
}
.menu-row strong {
  color: #b5879b;
  font-size: 13px;
  font-weight: 500;
}
.copy-row strong,
.clear-row strong { color: #ff4f87; }
.block { width: calc(100% - 28px); margin: 14px; }
.messages {
  flex: 1;
  min-height: 0;
  padding: 12px 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.time-divider {
  align-self: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 144, 187, .38);
  color: white;
  font-size: 12px;
}
.msg-row {
  display: grid;
  grid-template-columns: 38px minmax(0, max-content);
  gap: 8px;
  align-items: start;
  max-width: 88%;
}
.msg-row.audio-row {
  align-items: center;
  min-height: 38px;
  max-height: 38px;
}
.msg-row.call-row {
  align-items: center;
}
.msg-row.mine {
  align-self: flex-end;
  grid-template-columns: minmax(0, max-content) 38px;
}
.msg-avatar {
  width: 38px;
  height: 38px;
}
.bubble {
  position: relative;
  width: fit-content;
  max-width: min(240px, calc(100vw - 138px));
  padding: 9px 11px;
  border-radius: 16px;
  background: white;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.msg-row:not(.mine) .bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid white;
}
.mine .bubble {
  background: linear-gradient(135deg, #ff86b1 0%, #ff5f95 100%);
  color: white;
}
.mine .bubble::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 12px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid #ff679a;
}
.image-message {
  display: block;
  padding: 0;
  background: transparent;
  border-radius: 5px;
}
.bubble img, .bubble video {
  max-width: 210px;
  max-height: 280px;
  border-radius: 5px;
  display: block;
}
.image-preview {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 10, 14, .92);
}
.image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.image-preview-close {
  position: fixed;
  right: 14px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: white;
  font-size: 28px;
  line-height: 1;
}
.composer {
  flex: 0 0 auto;
  background: rgba(247, 247, 249, .96);
  border-top: 1px solid rgba(215, 215, 222, .9);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  margin-bottom: 0;
  backdrop-filter: blur(14px);
}
.emoji-bar {
  max-height: 172px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 0;
}
.emoji-bar button {
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 12px;
  background: white;
  font-size: 22px;
}
.tools { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px 38px 54px; gap: 7px; align-items: center; }
.tools input {
  border: 0;
  border-radius: 8px;
  min-width: 0;
  height: 38px;
  padding: 8px 11px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(220, 220, 226, .9);
}
.file-btn input { display: none; }
.composer.voice-mode .tools { grid-template-columns: 38px minmax(0, 1fr) 38px 38px; }
.composer.voice-mode #messageInput,
.composer.voice-mode #sendBtn { display: none; }
.composer.voice-mode #recordBtn { display: block !important; }
.record-btn {
  min-width: 0;
  height: 38px;
  border-radius: 8px;
  background: #fff;
  color: #222;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(220, 220, 226, .95);
}
.record-btn.recording {
  background: #e9f7ee;
  color: #10a64a;
  box-shadow: inset 0 0 0 1px #65c987;
}
.voice-bubble-wrap {
  display: flex;
  align-items: center;
  padding: 0;
  background: transparent;
  overflow: visible;
  line-height: 1;
  max-width: none;
  min-height: 38px;
  max-height: 38px;
  white-space: normal;
}
.voice-bubble-wrap::before,
.mine .voice-bubble-wrap::after {
  display: none;
}
.voice-message {
  position: relative;
  height: 38px;
  min-width: 96px;
  max-width: min(220px, calc(100vw - 156px));
  padding: 0 12px;
  border-radius: 17px;
  background: white;
  color: #331a2a;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(80, 46, 62, .04);
}
.mine .voice-message {
  flex-direction: row-reverse;
  background: linear-gradient(135deg, #ff86b1 0%, #ff5f95 100%);
  color: white;
}
.voice-message::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid white;
}
.mine .voice-message::before {
  left: auto;
  right: -6px;
  border-right: 0;
  border-left: 6px solid #ff679a;
}
.voice-title,
.voice-waves,
.voice-duration {
  pointer-events: none;
}
.voice-waves {
  font-family: Arial, sans-serif;
  letter-spacing: 1px;
  transform-origin: center;
}
.mine .voice-waves {
  transform: scaleX(-1);
}
.voice-duration {
  min-width: 18px;
  font-size: 13px;
  font-weight: 700;
  opacity: .82;
}
.voice-message.playing .voice-waves {
  animation: voicePulse .75s infinite ease-in-out;
}
@keyframes voicePulse {
  0%, 100% { opacity: .42; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.mine .voice-message.playing .voice-waves {
  animation-name: voicePulseMine;
}
@keyframes voicePulseMine {
  0%, 100% { opacity: .42; transform: scaleX(-1) scale(1); }
  50% { opacity: 1; transform: scaleX(-1) scale(1.08); }
}
.call-bubble-wrap {
  padding: 8px 10px;
  background: rgba(255, 255, 255, .92);
}
.mine .call-bubble-wrap {
  background: linear-gradient(135deg, #ff86b1 0%, #ff5f95 100%);
}
.call-record {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 2px 7px;
  align-items: center;
  min-width: 142px;
  line-height: 1.2;
  white-space: normal;
}
.call-record-icon {
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 95, 148, .14);
  color: #ff4f87;
  font-size: 13px;
}
.mine .call-record-icon {
  background: rgba(255, 255, 255, .22);
  color: white;
}
.call-record span:not(.call-record-icon) {
  font-size: 14px;
  font-weight: 700;
}
.call-record strong {
  font-size: 12px;
  font-weight: 600;
  opacity: .76;
}
.call-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: start center;
  padding-top: 86px;
  background: rgba(44, 21, 50, .32);
}
.call-card {
  width: min(360px, calc(100vw - 28px));
  padding: 22px 18px 18px;
  border-radius: 18px;
  background: rgba(255, 249, 251, .96);
  display: grid;
  gap: 12px;
  text-align: center;
  box-shadow: 0 18px 44px rgba(71, 35, 53, .22);
}
.call-card strong { font-size: 19px; }
.call-card span { color: #8d6277; }
.call-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.call-actions .primary,
.call-actions .danger { min-height: 42px; }
.call-actions button:only-child,
.call-actions #endCallBtn:not(.hidden) { grid-column: 1 / -1; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  max-width: min(380px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(71, 35, 53, .92);
  color: white;
  z-index: 20;
}
dialog { border: 0; border-radius: 20px; padding: 0; width: min(360px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-card {
  padding: 18px;
  display: grid;
  gap: 12px;
  position: relative;
  background: linear-gradient(180deg, #fff9fb 0%, #fff 100%);
}
.close {
  position: absolute;
  right: 10px;
  top: 8px;
  background: transparent;
  font-size: 24px;
  color: #6b7280;
}
.dialog-avatar { width: 76px; height: 76px; border-radius: 18px; object-fit: cover; justify-self: center; }
.dialog-card h2, .dialog-card p { text-align: center; }
.dialog-card p { color: #8d6277; }
.edit-fields { display: grid; gap: 10px; }
@media (min-width: 760px) {
  .phone-shell { height: 820px; margin-top: 24px; margin-bottom: 24px; border-radius: 18px; }
  .auth-view, .app-view, .page { min-height: 0; }
}
