:root {
  --bg: #0b0d11;
  --bg-2: #12161f;
  --surface: #181d29;
  --surface-2: #1f2636;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: #9aa3b5;
  --accent: #ff3b6b;
  --accent-2: #ff6b8b;
  --green: #22c55e;
  --user-bubble: #d92659;
  --mia-bubble: #1b2130;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

.app-shell {
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 520px; margin: 0 auto;
  background: var(--bg); position: relative;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}

/* Header */
.topbar {
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(15, 18, 26, 0.94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 11px; }
.avatar-wrap { position: relative; width: 42px; height: 42px; flex-shrink: 0; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--accent);
}
.online-dot {
  position: absolute; right: 0; bottom: 0; width: 12px; height: 12px;
  border-radius: 50%; background: var(--green); border: 2px solid var(--bg);
}
.peer-name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.verified-dot { color: var(--accent); font-size: 13px; }
.peer-status { font-size: 12px; color: var(--green); font-weight: 500; }
.peer-status.typing { color: var(--accent-2); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.pill-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.vip-chip {
  background: linear-gradient(135deg, var(--accent), #c81d4e);
  color: #fff; border: none; border-radius: 999px;
  padding: 7px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 59, 107, 0.35);
}
.vip-chip.is-vip {
  background: rgba(34, 197, 94, 0.16); color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4); box-shadow: none;
}

/* Install banner */
.install-bar {
  background: linear-gradient(90deg, #1b1420, #231524);
  border-bottom: 1px solid rgba(255, 59, 107, 0.25);
  padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.install-bar-text { display: flex; flex-direction: column; font-size: 12px; line-height: 1.3; }
.install-bar-text span { color: var(--muted); font-size: 11px; }
.install-bar-btns { display: flex; align-items: center; gap: 6px; }
.btn-mini {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.btn-close-mini {
  background: transparent; color: var(--muted); border: none; font-size: 15px; padding: 4px 6px; cursor: pointer;
}

/* Views */
.view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

/* Chat */
.chat-scroll {
  flex: 1; overflow-y: auto; padding: 14px 12px 18px;
  background: radial-gradient(circle at 80% 10%, rgba(255, 59, 107, 0.08), transparent 45%), var(--bg);
  -webkit-overflow-scrolling: touch;
}
.enc-notice {
  text-align: center; font-size: 11px; color: var(--muted);
  background: rgba(255,255,255,0.04); padding: 6px 12px; border-radius: 999px;
  width: fit-content; margin: 0 auto 14px; border: 1px solid var(--border);
}
.msg-list { display: flex; flex-direction: column; gap: 9px; }
.msg-row { display: flex; flex-direction: column; max-width: 82%; }
.msg-row.assistant { align-self: flex-start; }
.msg-row.user { align-self: flex-end; }

.bubble {
  padding: 10px 13px; border-radius: 18px; font-size: 15px; line-height: 1.4;
  word-wrap: break-word; position: relative;
}
.msg-row.assistant .bubble {
  background: var(--mia-bubble); color: var(--text);
  border-bottom-left-radius: 5px; border: 1px solid var(--border);
}
.msg-row.user .bubble {
  background: linear-gradient(135deg, var(--accent), #b81d4a);
  color: #fff; border-bottom-right-radius: 5px;
}
.bubble.media-bubble { padding: 6px; overflow: hidden; }
.bubble-media-wrap {
  position: relative; border-radius: 13px; overflow: hidden;
  background: #0d1017; cursor: pointer;
}
.bubble-media-wrap img, .bubble-media-wrap video {
  display: block; width: 100%; max-width: 260px; max-height: 330px;
  object-fit: cover; border-radius: 12px;
}
.bubble-caption { padding: 7px 6px 3px; font-size: 14px; }

.lock-overlay {
  position: absolute; inset: 0;
  background: rgba(9, 11, 16, 0.48);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 14px; text-align: center;
}
.lock-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 59, 107, 0.9); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  box-shadow: 0 6px 24px rgba(255, 59, 107, 0.45);
}
.lock-pill {
  background: #fff; color: #0b0d11; border: none; border-radius: 999px;
  padding: 7px 14px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.msg-time { font-size: 10px; color: var(--muted); margin-top: 3px; padding: 0 4px; }
.msg-row.user .msg-time { text-align: right; }

/* Typing */
.typing-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.typing-ava { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.typing-bubble {
  background: var(--mia-bubble); border: 1px solid var(--border);
  border-radius: 16px; padding: 11px 14px; display: flex; gap: 5px;
}
.typing-bubble span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Free strip & composer */
.free-strip {
  padding: 7px 12px; background: #141824; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted);
}
.strip-cta {
  background: rgba(255, 59, 107, 0.16); color: var(--accent-2);
  border: 1px solid rgba(255, 59, 107, 0.4); border-radius: 999px;
  padding: 4px 10px; font-size: 11px; font-weight: 700; cursor: pointer;
}

.composer-wrap {
  padding: 8px 10px; background: var(--bg-2); border-top: 1px solid var(--border);
}
.composer {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 6px 5px 15px;
}
.composer input {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 16px; outline: none; padding: 6px 0;
}
.composer input::placeholder { color: var(--muted); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), #c81d4e);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.45; }

.locked-composer {
  padding: 12px 14px; background: linear-gradient(180deg, #17121d, #110e16);
  border-top: 1px solid rgba(255, 59, 107, 0.35);
  display: flex; flex-direction: column; gap: 9px; text-align: center;
}
.locked-composer-info strong { display: block; font-size: 14px; }
.locked-composer-info span { font-size: 12px; color: var(--muted); }

/* Paywall button */
.paywall-btn {
  width: 100%; border: none; border-radius: 14px; padding: 13px 16px;
  background: linear-gradient(135deg, #ff3b6b, #d91c52);
  color: #fff; font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 26px rgba(255, 59, 107, 0.4);
}
.paywall-btn.big { padding: 15px; font-size: 16px; }
.pulse { animation: pulseGlow 2.1s infinite; }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 8px 24px rgba(255, 59, 107, 0.38); }
  50% { box-shadow: 0 8px 34px rgba(255, 59, 107, 0.72); }
}

/* Feed & Stories */
.feed-scroll, .vault-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.stories-strip {
  display: flex; gap: 12px; padding: 14px 14px 10px;
  overflow-x: auto; border-bottom: 1px solid var(--border);
}
.story-item { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; cursor: pointer; }
.story-ring {
  width: 66px; height: 66px; border-radius: 50%; padding: 2.5px;
  background: linear-gradient(135deg, #ff3b6b, #ff9966);
  position: relative;
}
.story-ring img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg);
}
.story-lock {
  position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 10px;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg);
}
.story-label { font-size: 11px; color: var(--muted); }

.feed-list { padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.feed-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden;
}
.feed-card-head {
  padding: 11px 13px; display: flex; align-items: center; justify-content: space-between;
}
.feed-author { display: flex; align-items: center; gap: 9px; }
.feed-author img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.feed-author strong { font-size: 14px; display: block; }
.feed-author span { font-size: 11px; color: var(--muted); }
.tier-tag {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: rgba(255, 59, 107, 0.16); color: var(--accent-2);
}
.tier-tag.open { background: rgba(34, 197, 94, 0.16); color: #4ade80; }
.feed-media { position: relative; aspect-ratio: 4/5; background: #0d1017; overflow: hidden; cursor: pointer; }
.feed-media img, .feed-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vid-badge {
  position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.68);
  color: #fff; padding: 4px 8px; border-radius: 8px; font-size: 11px; font-weight: 700;
}
.feed-body { padding: 12px 13px 14px; }
.feed-caption { font-size: 14px; line-height: 1.4; margin: 0 0 8px; }
.feed-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

/* Vault */
.vault-hero {
  padding: 20px 16px 14px;
  background: linear-gradient(180deg, rgba(255, 59, 107, 0.16), transparent);
  border-bottom: 1px solid var(--border);
}
.vault-badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  color: var(--accent-2); background: rgba(255, 59, 107, 0.14);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 8px;
}
.vault-hero h2 { margin: 0 0 6px; font-size: 22px; }
.vault-hero p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

.vault-list { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.vault-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px;
  padding: 14px; display: flex; flex-direction: column; gap: 11px;
}
.vault-card.unlocked { border-color: rgba(34, 197, 94, 0.45); }
.vault-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.vault-top h3 { margin: 0 0 4px; font-size: 16px; }
.vault-top p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.vault-price {
  background: rgba(255, 59, 107, 0.16); color: var(--accent-2);
  padding: 5px 10px; border-radius: 10px; font-size: 14px; font-weight: 800; flex-shrink: 0;
}
.vault-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vault-thumb {
  position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden;
  background: #0d1017; cursor: pointer;
}
.vault-thumb img, .vault-thumb video { width: 100%; height: 100%; object-fit: cover; }

/* Tabbar */
.tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(15, 18, 26, 0.96); border-top: 1px solid var(--border);
  padding: 7px 6px calc(7px + var(--safe-bottom));
}
.tab {
  background: transparent; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; cursor: pointer; position: relative;
}
.tab.active { color: var(--accent); }
.tab-dot {
  position: absolute; top: 1px; right: calc(50% - 14px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}

/* Modals */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px); }
.modal-sheet {
  position: relative; width: 100%; max-width: 500px;
  background: #141824; border-top-left-radius: 24px; border-top-right-radius: 24px;
  border: 1px solid rgba(255, 59, 107, 0.28);
  padding: 18px 18px calc(22px + var(--safe-bottom));
  animation: slideUp 0.24s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px;
  border-radius: 50%; border: none; background: rgba(255,255,255,0.08);
  color: var(--text); font-size: 15px; cursor: pointer; z-index: 2;
}
.pw-head { position: relative; height: 170px; border-radius: 16px; overflow: hidden; margin-bottom: 14px; }
.pw-img { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; }
.pw-pill {
  position: absolute; bottom: 10px; left: 10px; background: rgba(0,0,0,0.74);
  color: #4ade80; font-size: 11px; font-weight: 800; padding: 5px 10px; border-radius: 999px;
}
.modal-sheet h3 { margin: 0 0 6px; font-size: 20px; }
.pw-sub { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.pw-perks { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.pw-foot { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 9px; }
.ios-steps { padding-left: 18px; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
.lb-close {
  position: absolute; top: calc(16px + var(--safe-top)); right: 16px;
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.14); color: #fff; font-size: 18px; cursor: pointer;
}
.lb-content img, .lb-content video {
  max-width: 94vw; max-height: 76dvh; border-radius: 14px; object-fit: contain;
}
.lb-caption { margin-top: 12px; color: #e2e8f0; font-size: 14px; text-align: center; max-width: 420px; }

.toast {
  position: fixed; top: calc(16px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  z-index: 70; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.step-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.step-sec { width: 100%; padding: 12px 14px; font-size: 14px; border-radius: 14px; }
