:root {
  --blue: #0084ff;
  --purple: #a033ff;
  --bg: #ffffff;
  --bg-alt: #f5f6f7;
  --text: #050505;
  --text-dim: #65676b;
  --border: #e4e6eb;
  --online: #31a24c;
  --ai-badge: #6b4eff;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.phone {
  max-width: 420px;
  height: 100%;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ---------- Top bar (list page) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.topbar h1 {
  font-size: 26px;
  margin: 0;
  color: var(--blue);
  font-weight: 800;
}

.topbar .icons { display: flex; gap: 14px; font-size: 20px; }

.search {
  margin: 4px 16px 8px;
  background: var(--bg-alt);
  border-radius: 20px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
}

.disclosure-banner {
  margin: 0 16px 10px;
  background: #f0ebff;
  border: 1px solid #d9c9ff;
  color: #4b2fb3;
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 10px;
  line-height: 1.4;
}

/* ---------- Stories / online row ---------- */
.stories {
  display: flex;
  gap: 14px;
  padding: 4px 16px 14px;
  overflow-x: auto;
}

.story {
  flex: 0 0 auto;
  width: 64px;
  text-align: center;
  cursor: pointer;
}

.story .avatar-wrap {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(45deg, var(--purple), var(--blue));
  position: relative;
}

.story img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  display: block;
}

.story .dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: var(--online);
  border: 2px solid #fff;
  border-radius: 50%;
}

.story .ai-tag {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--ai-badge);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}

.story span {
  display: block;
  font-size: 11.5px;
  margin-top: 4px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Native ad card in feed ---------- */
.ad-card {
  margin: 6px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-alt);
}

.ad-card .ad-banner {
  height: 90px;
  background: linear-gradient(135deg, #ffd76a, #ff9a6a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5b3a00;
  font-weight: 700;
  font-size: 14px;
}

.ad-card .ad-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.ad-card .ad-meta .tag {
  background: #e4e6eb;
  border-radius: 6px;
  padding: 2px 6px;
  font-weight: 600;
}

/* ---------- Conversation list ---------- */
.convo-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.paywall-banner {
  margin: 12px 16px 20px;
  background: linear-gradient(135deg, #ff8ac2, #a033ff);
  color: #fff;
  text-align: center;
  font-size: 13.5px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
}

.convo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.convo:last-child { border-bottom: none; }

.convo:hover { background: var(--bg-alt); }

.convo .avatar-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.convo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.convo .dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 13px;
  height: 13px;
  background: var(--online);
  border: 2px solid #fff;
  border-radius: 50%;
}

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

.convo .name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 15px;
}

.ai-pill {
  background: var(--ai-badge);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  letter-spacing: 0.3px;
}

.convo .preview {
  color: var(--text-dim);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo .time {
  font-size: 11px;
  color: var(--text-dim);
  align-self: flex-start;
  margin-top: 2px;
}

/* ---------- Chat page ---------- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.chat-header .back {
  font-size: 22px;
  color: var(--blue);
  text-decoration: none;
  padding: 4px;
}

.chat-header img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-header .info { flex: 1; min-width: 0; }

.chat-header .name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 15px;
}

.chat-header .status {
  font-size: 12px;
  color: var(--text-dim);
}

.chat-disclosure {
  margin: 10px 16px;
  background: #f0ebff;
  border: 1px solid #d9c9ff;
  color: #4b2fb3;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: center;
  line-height: 1.4;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: #ffd9e2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='620' height='620' viewBox='0 0 620 620'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='45%25' r='65%25'%3E%3Cstop offset='0%25' stop-color='%23fff5f7'/%3E%3Cstop offset='55%25' stop-color='%23ffd6e0'/%3E%3Cstop offset='100%25' stop-color='%23ffb3c6'/%3E%3C/radialGradient%3E%3Cfilter id='b1' x='-50%25' y='-50%25' width='200%25' height='200%25'%3E%3CfeGaussianBlur stdDeviation='9'/%3E%3C/filter%3E%3Cfilter id='b2' x='-50%25' y='-50%25' width='200%25' height='200%25'%3E%3CfeGaussianBlur stdDeviation='3'/%3E%3C/filter%3E%3Cpath id='h' d='M50 88C10 60-8 34 4 14 16-6 42-2 50 20 58-2 84-6 96 14c12 20-6 46-46 74z'/%3E%3C/defs%3E%3Crect width='620' height='620' fill='url(%23g)'/%3E%3Cg filter='url(%23b1)' opacity='0.5'%3E%3Cuse href='%23h' x='10' y='0' fill='%23ff7d9c' transform='scale(0.9)'/%3E%3Cuse href='%23h' x='480' y='30' fill='%23ff9db3' transform='scale(1.1)'/%3E%3Cuse href='%23h' x='40' y='300' fill='%23ffc2d1' transform='scale(1.3)'/%3E%3Cuse href='%23h' x='430' y='420' fill='%23ff6f92' transform='scale(1.2)'/%3E%3Cuse href='%23h' x='240' y='200' fill='%23ffffff' transform='scale(1.4)'/%3E%3Cuse href='%23h' x='150' y='470' fill='%23ff9db3' transform='scale(1.0)'/%3E%3C/g%3E%3Cg filter='url(%23b2)'%3E%3Cuse href='%23h' x='60' y='40' fill='%23ff4d6d' opacity='0.85' transform='scale(0.35)'/%3E%3Cuse href='%23h' x='500' y='10' fill='%23ff8aa6' opacity='0.8' transform='scale(0.3)'/%3E%3Cuse href='%23h' x='20' y='230' fill='%23ff4d6d' opacity='0.75' transform='scale(0.4)'/%3E%3Cuse href='%23h' x='300' y='120' fill='%23ffffff' opacity='0.9' transform='scale(0.3)'/%3E%3Cuse href='%23h' x='420' y='260' fill='%23ff6f92' opacity='0.8' transform='scale(0.45)'/%3E%3Cuse href='%23h' x='120' y='400' fill='%23ff4d6d' opacity='0.85' transform='scale(0.32)'/%3E%3Cuse href='%23h' x='350' y='460' fill='%23ffffff' opacity='0.85' transform='scale(0.38)'/%3E%3Cuse href='%23h' x='520' y='500' fill='%23ff8aa6' opacity='0.8' transform='scale(0.3)'/%3E%3Cuse href='%23h' x='200' y='30' fill='%23ff6f92' opacity='0.8' transform='scale(0.28)'/%3E%3Cuse href='%23h' x='80' y='150' fill='%23ffffff' opacity='0.75' transform='scale(0.25)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 78%;
}

.msg-row.them { align-self: flex-start; }
.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }

.msg-row img.mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.bubble {
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.35;
}

.msg-row.them .bubble {
  background: var(--bg-alt);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-row.me .bubble {
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* in-stream ad bubble */
.ad-inline {
  align-self: center;
  width: 100%;
  max-width: 100%;
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-alt);
}

.ad-inline .ad-banner {
  height: 74px;
  background: linear-gradient(135deg, #6ae3ff, #6a8fff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #06305b;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  padding: 0 10px;
}

.ad-inline .ad-meta {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-dim);
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
  background: var(--bg);
}

.composer input {
  flex: 1;
  border: none;
  background: var(--bg-alt);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14.5px;
  outline: none;
}

.composer button {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
}

.composer button:disabled {
  color: var(--text-dim);
  cursor: default;
}

.icon-btn {
  font-size: 19px;
  flex: 0 0 auto;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--bg-alt); }

.icon-btn.recording {
  background: #ffe0e0;
  color: #e0245e;
  animation: pulse-rec 1s infinite;
}

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 36, 94, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(224, 36, 94, 0); }
}

.send-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple)) !important;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  box-shadow: 0 2px 6px rgba(160, 51, 255, 0.35);
  transition: transform 0.12s ease;
}

.send-btn:hover { transform: scale(1.06); }
.send-btn:active { transform: scale(0.94); }

.bubble-media {
  padding: 4px !important;
  background: transparent !important;
  overflow: hidden;
}

.bubble-image {
  display: block;
  max-width: 220px;
  max-height: 260px;
  border-radius: 14px;
  object-fit: cover;
}

.bubble-audio {
  height: 36px;
  max-width: 230px;
}

/* fixed bottom banner ad */
.fixed-ad {
  flex: 0 0 auto;
  background: #fffbe6;
  border-top: 1px solid #f0e2a3;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #6b5900;
}

.fixed-ad .label {
  font-weight: 700;
  background: #f0e2a3;
  border-radius: 5px;
  padding: 1px 5px;
  margin-right: 6px;
}

/* ---------- Ad modal (interstitial) ---------- */
.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.ad-overlay.show { display: flex; }

.ad-modal {
  width: min(340px, 88vw);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  text-align: center;
}

.ad-modal .ad-banner-big {
  height: 220px;
  background: linear-gradient(135deg, #ff8ac2, #a033ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  padding: 16px;
}

.ad-modal .ad-body {
  padding: 14px 16px 18px;
}

.ad-modal .ad-body p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 14px;
}

.ad-modal button {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.ad-modal .countdown {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}
