:root {
  --bg: #000;
  --elev: #1c1c1e;
  --elev-2: #2c2c2e;
  --line: rgba(84, 84, 88, 0.65);
  --text: #fff;
  --dim: #8e8e93;
  --pink: #ff2d95;
  --cyan: #00f0ff;
  --purple: #9b30ff;
  --blue: #ff2d95; /* remapped: no iOS/system blue anywhere */
  --bubble-in: #1a121c;
  --bubble-out: #ff2d95;
  --safe-top: env(safe-area-inset-top, 0px);
  --status-h: 54px;
  --nav-h: 52px;
  --phone-w: 390px;
  --phone-h: 844px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
html, body { margin: 0; background: #07050f; color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 70% 50% at 20% 15%, rgba(155, 48, 255, .22), transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(255, 45, 149, .16), transparent 60%),
    #05010a;
}

.phone {
  position: relative;
  width: min(100vw, var(--phone-w));
  height: min(100vh - 32px, var(--phone-h));
  background: #050208;
  border-radius: 54px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.16),
    0 0 0 2px #1a0a16,
    0 0 0 10px #0c070c,
    0 0 0 11px rgba(255, 45, 149, .55),
    0 0 0 14px #12080e,
    0 0 0 15px rgba(0, 240, 255, .22),
    0 40px 100px rgba(0, 0, 0, .7),
    0 0 80px rgba(255, 45, 149, .2);
}
.phone::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(118deg, rgba(255,255,255,.2) 0%, rgba(255,255,255,.05) 14%, transparent 30%, transparent 68%, rgba(0,240,255,.08) 100%);
  pointer-events: none;
  z-index: 50;
  mix-blend-mode: screen;
}

.island {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 40;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}

.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--status-h);
  padding: 16px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 30;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: .2px;
  pointer-events: none;
}
.sb-right { display: flex; align-items: center; gap: 6px; }
.sb-batt {
  width: 25px;
  height: 12px;
  border: 1.2px solid rgba(255,255,255,.55);
  border-radius: 3px;
  position: relative;
  display: inline-flex;
  padding: 1px;
}
.sb-batt::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 3px;
  width: 2px;
  height: 5px;
  background: rgba(255,255,255,.55);
  border-radius: 0 1px 1px 0;
}
.sb-batt i {
  display: block;
  width: 72%;
  height: 100%;
  background: #fff;
  border-radius: 1px;
}

.app {
  position: absolute;
  inset: 0;
  padding-top: var(--status-h);
  padding-bottom: 18px;
}

.view {
  position: absolute;
  inset: 0;
  padding-top: var(--status-h);
  padding-bottom: 18px;
  display: flex;
  flex-direction: column;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
  transition: opacity .22s ease, transform .28s cubic-bezier(.22,.8,.32,1);
}
.view.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  z-index: 2;
}

.nav {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: end;
  min-height: 56px;
  padding: 4px 14px 8px;
  flex: 0 0 auto;
}
.nav.compact { align-items: center; min-height: 44px; }
.nav-title {
  margin: 0;
  text-align: center;
  font-size: 34px;
  font-weight: 730;
  letter-spacing: .2px;
  grid-column: 1 / -1;
  grid-row: 1;
  padding-top: 18px;
}
.nav.compact .nav-title,
.nav-title.small {
  font-size: 17px;
  font-weight: 650;
  padding-top: 0;
  grid-column: 2;
}
#view-inbox .nav { grid-template-rows: auto auto; }
#view-inbox .nav-text,
#view-inbox .nav-icon {
  grid-row: 1;
  align-self: start;
  margin-top: 2px;
}
#view-inbox .nav-text { grid-column: 1; }
#view-inbox .compose { grid-column: 3; justify-self: end; }
#view-inbox .nav-title { grid-row: 2; text-align: left; padding: 6px 2px 0; }

.nav-text {
  background: none;
  border: 0;
  color: var(--cyan);
  font: inherit;
  font-size: 17px;
  padding: 4px 0;
  cursor: pointer;
}
.nav-icon {
  width: 34px;
  height: 34px;
  border: 0;
  background: none;
  color: var(--cyan);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.nav-spacer { display: block; }
.compose svg { display: block; }

.search-wrap { padding: 4px 16px 10px; flex: 0 0 auto; }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--elev);
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--dim);
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
  outline: none;
}
.search input::placeholder { color: var(--dim); }

.thread-list { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.row {
  width: 100%;
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 10px;
  padding: 10px 16px 10px 10px;
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  align-items: center;
}
.row + .row::before {
  content: "";
  position: absolute;
  left: 88px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--line);
}
.avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--elev-2);
  display: block;
}
.avatar.fallback {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}
.row-main { min-width: 0; padding-top: 4px; }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.row-name { font-size: 16px; font-weight: 610; }
.row-time { color: var(--dim); font-size: 14px; flex: 0 0 auto; }
.row-preview {
  margin-top: 2px;
  color: var(--dim);
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-del {
  align-self: center;
  background: #ff453a;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  display: none;
}
.editing .row-del { display: block; }

.empty-inbox {
  display: none;
  padding: 48px 36px;
  text-align: center;
  color: var(--dim);
}
.empty-inbox.show { display: block; }
.empty-kicker { color: #fff; font-size: 22px; font-weight: 680; margin: 0 0 8px; }
.empty-inbox p { margin: 0; line-height: 1.4; font-size: 15px; }

.to-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.to-label { color: var(--dim); font-size: 16px; }
#to-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
  outline: none;
}
.section-label {
  padding: 18px 16px 8px;
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.contact-list { flex: 1; overflow: auto; }
.contact-row {
  width: 100%;
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 12px;
  padding: 12px 16px;
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  align-items: center;
}
.contact-row .avatar { width: 92px; height: 92px; }
.contact-name { font-size: 16px; font-weight: 600; }
.contact-sub { color: var(--dim); font-size: 13px; margin-top: 1px; }
.contact-status {
  padding: 10px 16px 20px;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}

.thread-nav {
  grid-template-columns: 78px 1fr 56px;
  align-items: center;
  border-bottom: 1px solid rgba(84,84,88,.35);
  min-height: 78px;
}
.back {
  display: flex;
  align-items: center;
  gap: 0;
  background: none;
  border: 0;
  color: var(--cyan);
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 17px;
}
.peer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.peer img, .peer .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
.peer-text { display: flex; align-items: center; gap: 2px; }
.peer-name { font-size: 12.5px; font-weight: 620; }
.peer-sub { display: none; }
.peer-name::after {
  content: " ›";
  color: var(--dim);
  font-weight: 500;
}
.call-actions { display: flex; justify-content: end; }
.call-btn { color: var(--cyan); display: grid; place-items: center; opacity: .85; }

.thread {
  flex: 1;
  overflow: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.daystamp {
  align-self: center;
  color: var(--dim);
  font-size: 12px;
  font-weight: 560;
  margin: 10px 0 8px;
  text-align: center;
}
.msg {
  max-width: 78%;
  padding: 8px 12px;
  font-size: 16.5px;
  line-height: 1.28;
  border-radius: 18px;
  margin: 1px 0;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg.in {
  align-self: flex-start;
  background: var(--bubble-in);
  color: #fff;
  border-bottom-left-radius: 6px;
}
.msg.out {
  align-self: flex-end;
  background: linear-gradient(180deg, #ff4aad, #ff2d95);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 0 16px rgba(255, 45, 149, .28);
}
.msg.in.first { border-top-left-radius: 18px; }
.msg.in.last { border-bottom-left-radius: 18px; margin-bottom: 6px; }
.msg.out.first { border-top-right-radius: 18px; }
.msg.out.last { border-bottom-right-radius: 18px; margin-bottom: 6px; }
.msg.pending { opacity: .7; }
.msg.has-img { padding: 4px; overflow: hidden; }
.msg.has-img img {
  display: block;
  max-width: 220px;
  max-height: 280px;
  border-radius: 14px;
  object-fit: cover;
}
.msg.has-img .caption {
  padding: 6px 8px 8px;
  white-space: pre-wrap;
}
.meta {
  align-self: flex-end;
  color: var(--dim);
  font-size: 11px;
  padding: 0 6px 8px;
}

.typing {
  align-self: flex-start;
  background: var(--bubble-in);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  gap: 5px;
  margin: 2px 0 8px;
}
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8e8e93;
  animation: bounce 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: .45; }
  35% { transform: translateY(-3px); opacity: 1; }
}

.composer-wrap { flex: 0 0 auto; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 10px 8px;
}
.photo {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #ff2d95, #9b30ff);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255,45,149,0.45);
}
.photo[hidden] { display: none; }
.thread-cap {
  margin: 8px 12px 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,45,149,0.28), rgba(155,48,255,0.2));
  border: 1px solid rgba(255,45,149,0.45);
  font-size: 13px;
  line-height: 1.4;
  color: #fff5fb;
}
.thread-cap em { color: #00f0ff; font-style: normal; }
.msg a {
  color: #00f0ff;
  text-decoration: underline;
  word-break: break-all;
}
.os-menu {
  display: grid;
  gap: 8px;
  padding: 8px 16px 88px;
}
.os-menu a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(90deg, #ff2d95, #9b30ff);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}
.os-menu a small { color: rgba(255,255,255,0.75); font-size: 11px; letter-spacing: 0.08em; }
.ios-face.menu-face {
  background: linear-gradient(180deg, #ff2d95, #9b30ff);
  color: #fff;
  font-size: 22px;
}
.attach-preview {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 0 48px;
}
.attach-preview[hidden] { display: none; }
.attach-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
}
.attach-clear {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #3a3a3c;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.field {
  flex: 1;
  background: #000;
  border: 1.4px solid #3a3a3c;
  border-radius: 20px;
  padding: 6px 12px;
  min-height: 34px;
}
#composer {
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16.5px;
  line-height: 1.25;
  outline: none;
  max-height: 120px;
}
.send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--pink);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0 0 1px;
  box-shadow: 0 0 14px rgba(255, 45, 149, .55);
}
.send:disabled { opacity: 0; pointer-events: none; }

.contact-sheet {
  padding: 18px 20px 40px;
  overflow: auto;
  text-align: center;
}
.sheet-avatar {
  width: 176px;
  height: 176px;
  border-radius: 50%;
  object-fit: cover;
  margin: 12px auto 16px;
  display: block;
}
.sheet-name { font-size: 28px; font-weight: 700; margin: 0; }
.sheet-handle { color: var(--dim); margin: 4px 0 18px; }
.sheet-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 22px;
}
.sheet-chip {
  background: var(--elev);
  border-radius: 14px;
  padding: 10px 18px;
  min-width: 86px;
  color: var(--cyan);
  font-size: 13px;
}
.sheet-bio {
  text-align: left;
  background: var(--elev);
  border-radius: 14px;
  padding: 14px 16px;
  color: #ddd;
  font-size: 15px;
  line-height: 1.4;
}

.home-bar {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: #fff;
  border-radius: 99px;
  z-index: 60;
  opacity: .9;
  border: 0;
  padding: 0;
  cursor: pointer;
}

@media (max-width: 860px) {
  .stage { padding: 0; background: #000; min-height: 100dvh; display: block; }
  .phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  body.gl-has-nav .phone {
    height: calc(100dvh - var(--gl-nav-h, 3.35rem));
  }
  .island { display: none; }
  .status-bar { padding-top: calc(var(--safe-top) + 8px); height: calc(var(--status-h) + var(--safe-top)); }
  .view, .app { padding-top: calc(var(--status-h) + var(--safe-top)); }
  .screen.home .home-body,
  .crush-map, .crush-play { padding-top: calc(var(--status-h) + var(--safe-top)); }
}

.row:active, .contact-row:active, .peer:active { opacity: .65; }
