/* ── Design tokens — warm dark, IG-native (2026-07-01 polish) ── */
:root {
  --ink: #0f1012;
  --surface: #17181c;
  --surface-2: #202127;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text-primary: #f5f6f7;
  --text-secondary: rgba(255, 255, 255, 0.62);
  --text-tertiary: rgba(255, 255, 255, 0.42);
  --accent: #3b9bff;
  --success: #34c759;
  --charged-a: #6a5fd4;
  --charged-b: #b85a8a;
  --bubble-them: #25262c;
  --shadow-bubble: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.38);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--ink);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.demo-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: rgba(20, 20, 24, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 11px;
  text-align: center;
  padding: 6px 8px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--line);
}

.demo-banner::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.6);
}

.demo-banner[data-mode="live"]::before {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.6);
}

.demo-banner[data-mode="offline"]::before {
  background: #636366;
  box-shadow: none;
}

.demo-banner[data-mode="connecting"]::before {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.build-version {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0);
  left: 0;
  right: 0;
  z-index: 850;
  pointer-events: none;
  text-align: center;
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 4px 8px 6px;
  letter-spacing: 0.03em;
}

#app {
  padding-top: 26px;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.75) 100%), url("../avatars/lyndsy.jpg") center/cover no-repeat;
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.lock-screen.dismissed {
  display: none;
}

.lock-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: max(48px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
}

.lock-time {
  font-size: 72px;
  font-weight: 200;
  letter-spacing: -2px;
}

.lock-date {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 24px;
}

.notification-center {
  margin-top: auto;
}

.lock-notification {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 12px;
}

.notif-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

.notif-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
}

.notif-time {
  margin-left: auto;
  opacity: 0.7;
}

.notif-body {
  margin-top: 8px;
  font-size: 14px;
}

.notif-body p {
  margin: 4px 0 0;
  opacity: 0.9;
}

.lock-footer {
  text-align: center;
  padding-top: 24px;
  font-size: 14px;
  opacity: 0.75;
  animation: lockPulse 2.6s ease-in-out infinite;
}

.lock-screen {
  transition: opacity 0.28s ease;
}

.lock-screen.leaving {
  opacity: 0;
}

@keyframes lockPulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: var(--ink);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 20px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding-top: max(8px, env(safe-area-inset-top));
}

.status-icons {
  letter-spacing: 2px;
  color: var(--text-secondary);
  font-size: 11px;
}

.msg-row.burst {
  margin-top: -2px;
}

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

.view.active {
  display: flex;
  animation: viewIn 0.22s ease;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.header-badge {
  background: #ff3b30;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.18s ease;
}

.thread-item:active {
  background: var(--surface);
}

.thread-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

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

.thread-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.thread-name {
  font-weight: 600;
  font-size: 16px;
}

.thread-time {
  font-size: 13px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.thread-preview {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-preview.unread {
  color: var(--text-primary);
  font-weight: 500;
}

.unread-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(59, 155, 255, 0.5);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 16, 18, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-header-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.chat-header-text strong {
  font-size: 16px;
}

.chat-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-mood-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: transparent;
}

.chat-sub {
  font-size: 12px;
  color: var(--success);
}

.relationship-closer {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: 6px;
  font-weight: 400;
  opacity: 0.85;
}

.relationship-closer.hidden {
  display: none;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.9);
  opacity: 0.7;
}

.icon-btn.plus {
  font-size: 22px;
  color: var(--text-tertiary);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--ink);
}

.memory-banner {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 4px 12px 8px;
}

.msg-row {
  display: flex;
  max-width: 82%;
}

.msg-row.them {
  align-self: flex-start;
}

.msg-row.me {
  align-self: flex-end;
}

.bubble {
  padding: 10px 15px;
  border-radius: 20px;
  font-size: 16px;
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: var(--shadow-bubble);
  animation: msgIn 0.24s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.them .bubble {
  background: var(--bubble-them);
  color: var(--text-primary);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.msg-row.me .bubble {
  background: linear-gradient(135deg, var(--charged-a) 0%, var(--charged-b) 100%);
  color: rgba(255, 255, 255, 0.96);
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-bubble), 0 2px 8px rgba(106, 95, 212, 0.18);
}

.bubble.image-bubble {
  padding: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.bubble.image-bubble img {
  display: block;
  max-width: 220px;
  border-radius: 14px;
}

.image-bubble-container {
  position: relative;
  display: inline-block;
}

.bubble.image-bubble .caption {
  padding: 6px 10px 8px;
  font-size: 15px;
}

.typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  display: flex;
  gap: 4px;
  box-shadow: var(--shadow-bubble);
}

.typing span {
  width: 7px;
  height: 7px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  background: rgba(15, 16, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.quick-replies {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 8px;
  scrollbar-width: none;
}

.quick-replies::-webkit-scrollbar { display: none; }

.quick-replies button {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--accent);
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease;
}

.quick-replies button:active {
  transform: scale(0.96);
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#composer-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease;
}

#composer-input:focus {
  border-color: rgba(59, 155, 255, 0.45);
}

#composer-input::placeholder {
  color: var(--text-tertiary);
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}

.send-btn:active {
  transform: scale(0.92);
}

.send-btn:disabled {
  opacity: 0.4;
}

.story-ring {
  padding: 2px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  flex-shrink: 0;
}

.story-ring.seen {
  background: rgba(255, 255, 255, 0.18);
}

.story-ring.stub {
  background: rgba(255, 255, 255, 0.12);
}

.story-ring.user {
  background: linear-gradient(135deg, #0095f6, #5856d6, #af52de);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
}

.stories-row {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  list-style: none;
}

.stories-row button {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
}

.story-label {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-avatar-plain,
#chat-avatar-wrap {
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

#chat-avatar-wrap.story-ring,
#chat-avatar-wrap.story-ring.seen {
  padding: 2px;
}

#chat-avatar-wrap .chat-avatar {
  border: 2px solid var(--ink);
}

.story-gradient-slide {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6rem;
}

.story-gradient-slide p {
  color: #fff;
  font-size: 1.125rem;
  font-weight: 500;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  padding: 0 1.5rem;
  text-align: center;
}

.story-ring .thread-avatar {
  border: 2px solid var(--ink);
}

.thread-handle {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.msg-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  max-width: 88%;
}

.msg-row.them {
  align-self: flex-start;
}

.msg-row.me {
  align-self: flex-end;
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  align-self: flex-end;
  flex-shrink: 0;
}

.msg-avatar-spacer {
  width: 28px;
  flex-shrink: 0;
}

.msg-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.typing-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.typing-row.ghost-typing {
  opacity: 0.85;
  animation: ghost-fade 0.6s ease-in;
}

@keyframes ghost-fade {
  from { opacity: 0.3; }
  to { opacity: 0.85; }
}

.voice-bubble.playing .voice-waveform span {
  animation: voice-bar 0.55s ease-in-out infinite alternate;
}

.voice-bubble.playing .voice-waveform span:nth-child(odd) {
  animation-delay: 0.08s;
}

@keyframes voice-bar {
  from { transform: scaleY(0.35); opacity: 0.5; }
  to { transform: scaleY(1); opacity: 1; }
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.95);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.lightbox.open {
  display: flex;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  pointer-events: auto;
  cursor: zoom-out;
}

.lightbox .lb-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.lightbox .lb-close:active {
  background: rgba(255, 255, 255, 0.15);
}

.thread-presence {
  margin: 0;
  font-size: 11px;
  color: #30d158;
}

.missed-call {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.missed-call button {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.story-tease {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(123, 91, 255, 0.14), rgba(224, 85, 156, 0.12));
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.story-tease button {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.quick-replies.ig-choice-mode {
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding-bottom: 4px;
}

.quick-replies.ig-choice-mode .ig-choice-reply {
  font-size: 14px;
  padding: 10px 15px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, var(--charged-a), var(--charged-b));
  color: #fff;
  max-width: 88%;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.quick-replies.ig-choice-mode .ig-choice-reply:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.plot-choice-bubble {
  padding: 10px 12px;
  max-width: 260px;
}

.plot-choice-prompt {
  font-size: 13px;
  margin: 0 0 8px;
  color: #f5f5f5;
}

.plot-choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plot-chip {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 155, 255, 0.45);
  background: var(--surface-2);
  color: var(--accent);
  cursor: pointer;
}

.voice-waveform {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  margin: 0 4px;
}

.voice-waveform span {
  display: block;
  width: 3px;
  height: 35%;
  background: var(--accent);
  border-radius: 2px;
}

.voice-bubble.playing .voice-waveform span {
  animation: voiceBar 0.55s ease-in-out infinite alternate;
}

.voice-bubble.playing .voice-waveform span:nth-child(odd) {
  animation-delay: 0.1s;
}

@keyframes voiceBar {
  0%, 100% { transform: scaleY(0.35); opacity: 0.55; }
  50% { transform: scaleY(1); opacity: 1; }
}

.receipt {
  font-size: 11px;
  color: var(--text-tertiary);
  align-self: flex-end;
  padding-top: 2px;
}

.voice-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
}

.voice-bubble.playing .voice-play {
  opacity: 0.7;
}

.msg-reaction {
  font-size: 18px;
  margin-left: 4px;
}

.image-bubble.hearted::after {
  content: "❤️";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  pointer-events: none;
  animation: heartPop 0.6s ease-out;
}

.bubble.image-bubble {
  position: relative;
}

@keyframes heartPop {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.story-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  flex-direction: column;
}

.story-viewer.open {
  display: flex;
}

.story-bars {
  display: flex;
  gap: 4px;
  padding: 12px 8px 0;
  padding-top: max(12px, env(safe-area-inset-top));
}

.story-bar {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.story-bar div {
  height: 100%;
  background: #fff;
  transition: width 0.1s linear;
}

.story-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}

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

.story-header span {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.story-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.story-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.story-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.story-reply {
  margin: 12px;
  margin-bottom: max(12px, env(safe-area-inset-bottom));
  padding: 14px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

/* ── Call screen (Gemma voice / video) ── */
.call-view {
  position: relative;
  background: linear-gradient(180deg, #1a1025 0%, var(--ink) 100%);
  z-index: 200;
}

.call-view.video-mode {
  background: var(--ink);
}

.call-video-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.call-view.video-mode .call-video-bg {
  opacity: 0.55;
}

.call-view.video-mode .call-video-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.75) 100%);
}

.call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  position: relative;
  z-index: 2;
}

.call-header-btn {
  background: none;
  border: none;
  color: #0095f6;
  font-size: 22px;
  padding: 6px 10px;
  cursor: pointer;
}

#call-header-status {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.call-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  position: relative;
  z-index: 2;
  gap: 10px;
}

.call-avatar-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 8px;
}

.call-view.video-mode .call-avatar-wrap {
  width: 140px;
  height: 180px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.call-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.call-view.video-mode .call-avatar {
  border-radius: 16px;
}

@keyframes presenceListen {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.008); opacity: 0.96; }
}

@keyframes presenceSpeak {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.015) translateY(-1px); }
}

.call-view.video-mode .call-avatar.presence-listening {
  animation: presenceListen 2.4s ease-in-out infinite;
}

.call-view.video-mode .call-avatar.presence-speaking {
  animation: presenceSpeak 0.42s ease-in-out infinite;
}

.call-portrait-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  z-index: 1;
}

.call-portrait-video.hidden {
  display: none;
}

.call-speaking-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.call-view.video-mode .call-speaking-ring {
  border-radius: 20px;
}

.call-speaking-ring.active {
  border-color: rgba(0, 149, 246, 0.6);
  animation: callRingPulse 1.2s ease-in-out infinite;
}

@keyframes callRingPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.06); opacity: 1; }
}

#call-name {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.call-status {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
}

.call-timer {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
}

.call-waveform {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 48px;
  margin: 12px 0;
}

.call-waveform span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: #0095f6;
  height: 20%;
  transition: height 0.08s ease;
}

.call-waveform.active span {
  animation: callWave 0.55s ease-in-out infinite alternate;
}

.call-waveform.active span:nth-child(odd) {
  animation-delay: 0.1s;
}

@keyframes callWave {
  from { transform: scaleY(0.3); opacity: 0.5; }
  to { transform: scaleY(1); opacity: 1; }
}

.call-caption {
  margin: 0;
  font-size: 14px;
  color: #0095f6;
  text-align: center;
  max-width: 280px;
  min-height: 40px;
  line-height: 1.4;
}

.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 20px 24px max(28px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 2;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.call-btn.call-end {
  background: #ff3b30;
  width: 64px;
  height: 64px;
}

.call-btn.call-speak.active {
  background: #0095f6;
  animation: callSpeakPulse 1s ease-in-out infinite;
}

@keyframes callSpeakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 149, 246, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(0, 149, 246, 0); }
}

.call-btn.muted {
  background: rgba(255, 59, 48, 0.25);
}

.call-controls.hidden {
  display: none;
}

.call-ended-panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.92);
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.call-ended-panel.hidden {
  display: none;
}

.call-back-btn {
  background: #0095f6;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.icon-btn.call-action {
  font-size: 20px;
}

.icon-btn.call-action.hidden {
  display: none;
}

/* ── Inbound call overlay ── */
.inbound-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.inbound-call-overlay.hidden {
  display: none;
}

.inbound-call-card {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.inbound-call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  animation: inboundPulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(0, 149, 246, 0.35);
}

@keyframes inboundPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(0, 149, 246, 0.35); }
  50% { box-shadow: 0 0 0 14px rgba(0, 149, 246, 0.08); }
}

.inbound-call-label {
  margin: 20px 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.inbound-call-sub {
  margin: 0 0 32px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
}

.inbound-call-actions {
  display: flex;
  justify-content: center;
  gap: 48px;
}

.inbound-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.inbound-btn::before {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 26px;
}

.inbound-btn.decline::before {
  content: "📵";
  background: #ff3b30;
}

.inbound-btn.accept::before {
  content: "📞";
  background: #30d158;
}

/* ── Push notification tease ── */
.push-tease-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(0, 149, 246, 0.18), rgba(139, 61, 255, 0.14));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.push-tease-banner.hidden {
  display: none;
}

.push-tease-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.push-tease-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.push-tease-copy strong {
  font-size: 13px;
  color: #fff;
}

.push-tease-copy span {
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.35;
}

.push-tease-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.push-tease-actions button {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  white-space: nowrap;
}

#push-tease-enable {
  color: #0095f6;
  font-weight: 600;
}

#push-tease-dismiss {
  color: rgba(255, 255, 255, 0.45);
}

.bubble.imperfect {
  opacity: 0.95;
}

/* Voice call screen (Gemma demo) */
.call-view {
  background: radial-gradient(circle at 50% 30%, #2a1b3d 0%, #0f1012 80%);
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.call-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.call-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 40px rgba(123, 91, 255, 0.25);
}

.call-avatar.speaking {
  border-color: var(--success);
  animation: call-pulse 1.2s ease-in-out infinite;
}

@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(48, 209, 88, 0); }
}

.call-status {
  margin: 12px 0 4px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

.call-timer {
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
  min-height: 16px;
}

.call-waveform {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
  margin-top: 20px;
}

.call-waveform span {
  width: 4px;
  background: #30d158;
  border-radius: 2px;
  animation: voice-bar 0.8s ease-in-out infinite alternate;
}

.call-caption {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  max-width: 280px;
  min-height: 40px;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 16px;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.call-btn.call-end {
  background: #ff3b30;
}

.call-btn.hidden {
  display: none;
}

/* ── First-run onboarding (P0) ── */
#onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 16, 18, 0.94);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

#onboarding-overlay.leaving {
  opacity: 0;
  transition: opacity 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.onboarding-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-pop);
}

.onboarding-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.onboarding-card > p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0 16px;
}

.character-option {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  color: inherit;
  font: inherit;
}

.character-option:active {
  transform: scale(0.98);
  border-color: rgba(59, 155, 255, 0.45);
}

.character-option img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

.character-option span {
  display: block;
  font-weight: 600;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-primary);
}

.character-option small {
  display: block;
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.25;
}

.onboarding-skip {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
}

.onboarding-skip:active {
  color: var(--text-secondary);
}

/* ── Easter egg toast (Tier 1) ── */
.character-secret-toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  max-width: min(320px, calc(100vw - 32px));
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
  text-align: center;
  box-shadow: var(--shadow-pop);
  z-index: 1800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.character-secret-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.character-secret-toast.flagship {
  font-style: italic;
  color: var(--text-primary);
}
