:root {
  --device-w: 392px;
  --device-h: 768px;
  --bezel: 10px;
  --shell-radius: 46px;
  --screen-radius: 36px;
  --shell-color: #1c1c1e;
  --shell-edge: #3a3a3c;
  --shell-highlight: #48484a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1a1a1c 0%, #0a0a0a 55%);
  padding: 24px 16px;
}

body.embed {
  background: transparent;
  min-height: var(--device-h);
  height: var(--device-h);
  overflow: hidden;
  padding: 0;
}

/* ── Device frame ── */
.device {
  width: var(--device-w);
  height: var(--device-h);
  flex-shrink: 0;
  position: relative;
}

.device-shell {
  width: 100%;
  height: 100%;
  border-radius: var(--shell-radius);
  background:
    linear-gradient(145deg, var(--shell-highlight) 0%, var(--shell-color) 18%, #111113 82%, #09090b 100%);
  padding: var(--bezel);
  position: relative;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(0, 0, 0, 0.65),
    0 28px 70px rgba(0, 0, 0, 0.55),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

body.embed .device-shell {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 0 1px rgba(0, 0, 0, 0.5);
}

.device-screen {
  width: 100%;
  height: 100%;
  border-radius: var(--screen-radius);
  overflow: hidden;
  position: relative;
  background: #000;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9) inset;
}

.dynamic-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 108px;
  height: 30px;
  background: #000;
  border-radius: 20px;
  z-index: 20;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.dynamic-island::after {
  content: '';
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1f2937 0%, #020617 70%);
  opacity: 0.85;
}

.device-button {
  position: absolute;
  background: linear-gradient(90deg, #2c2c2e, #48484a, #2c2c2e);
  border-radius: 2px;
  z-index: 5;
}

.device-button-left {
  left: -3px;
  top: 128px;
  width: 3px;
  height: 34px;
}

.device-button-right {
  right: -3px;
  top: 108px;
  width: 3px;
  height: 56px;
}

.device-button-power {
  right: -3px;
  top: 174px;
  width: 3px;
  height: 56px;
}

.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 118px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  z-index: 20;
  pointer-events: none;
}

.device-screen:has(.phone.messenger) .home-indicator {
  background: rgba(0, 0, 0, 0.22);
}

.device-screen:has(.phone.ghl-webchat) .home-indicator {
  background: rgba(0, 0, 0, 0.22);
}

/* ── GHL live website chat (phone wrapper only) ── */
.phone.ghl-webchat {
  background: #fff;
  height: 100%;
}

.ghl-mount {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding-top: 38px;
  padding-bottom: 16px;
}

.ghl-mount > iframe,
.ghl-mount > div {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ── Screen content ── */
.phone {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
  color: inherit;
}

.status-icons svg { display: block; }

.messenger .status-bar { color: #000; }
.instagram .status-bar,
.imessage .status-bar { color: #fff; }

/* ── Messenger ── */
.phone.messenger {
  background: #fff;
  color: #050505;
}

.messenger .app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 12px;
  border-bottom: 1px solid #e4e6eb;
  flex-shrink: 0;
}

.messenger .back-btn {
  color: #0084ff;
  font-size: 22px;
  line-height: 1;
  width: 24px;
}

.messenger .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.messenger .header-meta strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.messenger .header-meta span {
  font-size: 12px;
  color: #65676b;
}

.messenger .thread {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.messenger .bubble-row.business { align-self: flex-start; }
.messenger .bubble-row.customer { align-self: flex-end; margin-left: auto; }

.messenger .bubble {
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
}

.messenger .bubble.business {
  background: #e4e6eb;
  color: #050505;
  border-bottom-left-radius: 4px;
}

.messenger .bubble.customer {
  background: #0084ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.messenger .composer {
  padding: 8px 10px 22px;
  border-top: 1px solid #e4e6eb;
  flex-shrink: 0;
}

.messenger .composer-fake {
  background: #f0f2f5;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  color: #65676b;
}

/* ── Instagram ── */
.phone.instagram {
  background: #000;
  color: #fff;
}

.instagram .app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 10px;
  border-bottom: 1px solid #262626;
  flex-shrink: 0;
}

.instagram .back-btn {
  font-size: 20px;
  line-height: 1;
}

.instagram .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  padding: 2px;
  flex-shrink: 0;
}

.instagram .avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #262626;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.instagram .header-meta strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.instagram .header-meta span {
  font-size: 12px;
  color: #a8a8a8;
}

.instagram .thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.instagram .bubble-row {
  display: flex;
  max-width: 78%;
}

.instagram .bubble-row.business { align-self: flex-start; }
.instagram .bubble-row.customer { align-self: flex-end; margin-left: auto; }

.instagram .bubble {
  padding: 10px 14px;
  border-radius: 22px;
  font-size: 14px;
  line-height: 1.4;
}

.instagram .bubble.business {
  background: #262626;
  color: #fff;
  border-bottom-left-radius: 4px;
}

.instagram .bubble.customer {
  background: #3797f0;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.instagram .composer {
  padding: 8px 12px 24px;
  border-top: 1px solid #262626;
  flex-shrink: 0;
}

.instagram .composer-fake {
  border: 1px solid #363636;
  border-radius: 22px;
  padding: 10px 14px;
  font-size: 14px;
  color: #737373;
}

/* ── iMessage ── */
.phone.imessage {
  background: #000;
  color: #fff;
}

.imessage .app-header.imessage-header {
  display: block;
  text-align: center;
  padding: 4px 14px 10px;
}

.imessage .app-header {
  border-bottom: 1px solid #1c1c1e;
  flex-shrink: 0;
}

.imessage .imessage-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin: 0 auto 4px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.imessage .header-meta strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.imessage .header-meta span {
  font-size: 11px;
  color: #8e8e93;
}

.imessage .thread {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 8px;
  background: #000;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.imessage .bubble-row {
  display: flex;
  max-width: 78%;
}

.imessage .bubble-row.business { align-self: flex-start; }
.imessage .bubble-row.customer { align-self: flex-end; margin-left: auto; }

.imessage .bubble {
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.35;
}

.imessage .bubble.business {
  background: #3a3a3c;
  color: #fff;
  border-bottom-left-radius: 4px;
}

.imessage .bubble.customer {
  background: #0a84ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.imessage .composer {
  padding: 8px 10px 24px;
  flex-shrink: 0;
}

.imessage .composer-fake {
  background: #1c1c1e;
  border: 1px solid #2c2c2e;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 15px;
  color: #636366;
}

/* ── Shared ── */
.typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: #e4e6eb;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.instagram .typing { background: #262626; }
.imessage .typing { background: #3a3a3c; }

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #90949c;
  animation: bounce 1.2s infinite ease-in-out;
}

.instagram .typing span,
.imessage .typing span { background: #8e8e93; }

.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; }
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 18px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
}

.messenger .choices {
  background: #f7f8fa;
  border-top-color: #e4e6eb;
}

.choice-btn {
  appearance: none;
  border: none;
  border-radius: 20px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
  font-family: inherit;
}

.choice-btn:active { transform: scale(0.98); }
.choice-btn:disabled { opacity: 0.45; cursor: default; }

.messenger .choice-btn {
  background: #fff;
  color: #0084ff;
  border: 1px solid #ccd0d5;
}

.instagram .choice-btn,
.imessage .choice-btn {
  background: #1c1c1e;
  color: #0a84ff;
  border: 1px solid #2c2c2e;
}

.restart-btn {
  margin-top: 4px;
  background: transparent !important;
  color: #8e8e93 !important;
  border: none !important;
  font-weight: 500 !important;
  font-size: 13px !important;
}

.demo-badge {
  position: fixed;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

body.embed .demo-badge { display: none; }

@media (max-width: 420px) {
  body:not(.embed) {
    padding: 0;
    align-items: stretch;
    background: #000;
  }

  body:not(.embed) .device {
    width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  body:not(.embed) .device-shell {
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: #000;
  }

  body:not(.embed) .device-screen {
    border-radius: 0;
  }

  body:not(.embed) .device-button { display: none; }
}
