* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
  body { margin: 0; background: #0a0a0f; color: #fff; font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', 'Helvetica Neue', Roboto, sans-serif; min-height: 100vh; }
  #app { display: grid; grid-template-columns: 380px 1fr; min-height: 100vh; }
  #sidebar { background: rgba(255,255,255,0.03); border-right: 1px solid rgba(255,255,255,0.08); padding: 20px; overflow-y: auto; max-height: 100vh; }
  #stage { display: flex; align-items: center; justify-content: center; padding: 30px; background: radial-gradient(ellipse at center, #0d2f28 0%, #0a0a0f 80%); }
  .back-link { color: rgba(255,255,255,0.5); text-decoration: none; font-size: 13px; display: inline-flex; gap: 6px; margin-bottom: 16px; }
  .back-link:hover { color: #fff; }
  .title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
  .subtitle { font-size: 12px; color: rgba(255,255,255,0.4); margin-bottom: 20px; }
  .label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,0.4); font-weight: 600; margin-bottom: 6px; }
  .field { width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 9px 12px; color: #fff; font-size: 13px; margin-bottom: 12px; outline: none; font-family: inherit; }
  .field:focus { border-color: #25D366; }
  .btn { padding: 10px 16px; border-radius: 10px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: all .15s; }
  .btn-primary { background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; width: 100%; justify-content: center; padding: 12px; }
  .btn-primary:hover { box-shadow: 0 8px 20px -8px rgba(37,211,102,0.5); }
  .btn-secondary { background: rgba(255,255,255,0.07); color: #fff; border: 1px solid rgba(255,255,255,0.12); }
  .btn-secondary:hover { background: rgba(255,255,255,0.12); }
  .btn-ghost { background: transparent; color: rgba(255,255,255,0.6); padding: 6px 10px; font-size: 12px; }
  .btn-ghost:hover { color: #fff; background: rgba(255,255,255,0.05); }
  .divider { height: 1px; background: rgba(255,255,255,0.08); margin: 18px 0; }
  .event-row { display: flex; gap: 8px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 12px; align-items: center; }
  .event-row .who { font-weight: 600; font-size: 11px; min-width: 40px; }
  .event-row .who.me { color: #25D366; }
  .event-row .who.other { color: #4ade80; }
  .event-row .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,0.85); }
  .event-row button { background: transparent; border: none; color: rgba(255,255,255,0.4); cursor: pointer; padding: 0 4px; }
  .event-row button:hover { color: #fff; }
  .fmt-row { display: flex; gap: 6px; margin-bottom: 12px; }
  .fmt-btn { flex: 1; padding: 8px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; color: rgba(255,255,255,0.7); font-size: 12px; font-weight: 500; cursor: pointer; }
  .fmt-btn.active { background: rgba(37,211,102,0.15); border-color: #25D366; color: #25D366; }
  .scenarios-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
  .sc-btn { padding: 8px 10px; background: rgba(37,211,102,0.1); border: 1px solid rgba(37,211,102,0.25); border-radius: 8px; color: #8EE6B0; font-size: 11px; cursor: pointer; text-align: left; line-height: 1.3; font-family: inherit; }
  .sc-btn:hover { background: rgba(37,211,102,0.2); }

  /* ═════════ iPHONE FRAME ═════════ */
  .device { width: 393px; height: 852px; background: #000; border-radius: 55px; padding: 12px; position: relative; box-shadow: 0 35px 80px -20px rgba(0,0,0,0.7), 0 0 0 2px #1a1a1a, inset 0 0 0 2px #2a2a2a; }
  .device::before { content: ''; position: absolute; top: 19px; left: 50%; transform: translateX(-50%); width: 124px; height: 36px; background: #000; border-radius: 20px; z-index: 20; }
  .device.vertical { width: 461px; height: 820px; border-radius: 24px; padding: 0; box-shadow: 0 35px 80px -20px rgba(0,0,0,0.7); }
  .device.vertical::before { display: none; }
  .device-screen { width: 100%; height: 100%; border-radius: 44px; overflow: hidden; display: flex; flex-direction: column; position: relative; background: #fff; }
  .device.vertical .device-screen { border-radius: 24px; }

  /* ═════════ WHATSAPP iOS ═════════ */
  .wa {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', 'Helvetica Neue', Roboto, sans-serif;
    height: 100%; display: flex; flex-direction: column;
    letter-spacing: -0.24px;
  }
  .wa h1, .wa h2, .wa h3, .wa .name, .wa .title-strong { font-weight: 600; }
  .wa strong, .wa b { font-weight: 700; }

  .wa-light {
    --bg-chat: #EFEAE2;
    --divider: rgba(0,0,0,0.08);
    --bg: #EFEAE2;
    --text: #111B21;
    --muted: #667781;
    --border: rgba(0,0,0,0.08);
    --bubble-in: #FFFFFF;
    --bubble-in-text: #111B21;
    --bubble-out: #D9FDD3;
    --bubble-out-text: #111B21;
    --meta: #667781;
    --meta-out: #53805A;
    --tick-read: #53BDEB;
    --tick-sent: #8696A0;
    --header-bg: #008069;
    --header-text: #FFFFFF;
    --input-bg: #F0F2F5;
    --input-field-bg: #FFFFFF;
    --link: #027EB5;
    --chat-pattern: rgba(0,0,0,0.04);
    --divider-bg: rgba(225,245,254,0.92);
    --divider-text: #54656F;
    --security-bg: #FEF3C7;
    --security-text: #54656F;
  }
  .wa-dark {
    --bg-chat: #0B141A;
    --divider: rgba(255,255,255,0.12);
    --bg: #0B141A;
    --text: #E9EDEF;
    --muted: #8696A0;
    --border: rgba(255,255,255,0.06);
    --bubble-in: #202C33;
    --bubble-in-text: #E9EDEF;
    --bubble-out: #005C4B;
    --bubble-out-text: #E9EDEF;
    --meta: #8696A0;
    --meta-out: #A9C6BE;
    --tick-read: #53BDEB;
    --tick-sent: #8696A0;
    --header-bg: #1F2C34;
    --header-text: #E9EDEF;
    --input-bg: #1F2C34;
    --input-field-bg: #2A3942;
    --link: #53BDEB;
    --chat-pattern: rgba(255,255,255,0.03);
    --divider-bg: rgba(27,51,66,0.92);
    --divider-text: #8696A0;
    --security-bg: #182229;
    --security-text: #8696A0;
  }

  /* Status bar iOS */
  .wa-statusbar { height: 54px; padding: 18px 30px 0; display: flex; justify-content: space-between; align-items: flex-start; font-size: 16px; font-weight: 600; color: var(--header-text); background: var(--header-bg); position: relative; z-index: 15; font-family: -apple-system, 'SF Pro Text'; letter-spacing: -.2px; }
  .wa-statusbar .right { display: flex; gap: 5px; align-items: center; }
  .wa-statusbar .signal { display: inline-flex; gap: 1px; align-items: flex-end; }
  .wa-statusbar .signal span { width: 3px; background: currentColor; border-radius: 0.5px; }
  .wa-statusbar .signal span:nth-child(1) { height: 4px; }
  .wa-statusbar .signal span:nth-child(2) { height: 6px; }
  .wa-statusbar .signal span:nth-child(3) { height: 8px; }
  .wa-statusbar .signal span:nth-child(4) { height: 10px; }
  .wa-statusbar .battery { width: 24px; height: 11px; border: 1.2px solid currentColor; border-radius: 3px; position: relative; padding: 1px; }
  .wa-statusbar .battery::after { content: ''; position: absolute; right: -3px; top: 3px; width: 2px; height: 4px; background: currentColor; border-radius: 0 1px 1px 0; }
  .wa-statusbar .battery::before { content: ''; display: block; width: 75%; height: 100%; background: currentColor; border-radius: 1px; }

  /* Header */
  .wa-header {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px 8px 4px;
    background: var(--header-bg); color: var(--header-text);
    position: relative; z-index: 10;
    box-shadow: 0 1px 0 rgba(0,0,0,0.08);
  }
  .wa-header .back { display: flex; align-items: center; color: var(--header-text); padding: 4px 0 4px 6px; cursor: pointer; font-size: 13px; gap: 1px; }
  .wa-header .back svg { width: 12px; height: 20px; }
  .wa-header .avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; flex-shrink: 0; background-size: cover; background-position: center; margin-right: 2px; }
  .wa-header .info { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
  .wa-header .name { font-weight: 600; font-size: 17px; color: var(--header-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.3px; }
  .wa-header .status { font-size: 12px; color: rgba(255,255,255,0.82); line-height: 1.15; margin-top: 1px; }
  .wa-header .status.typing { font-style: normal; color: #fff; }
  .wa-header .actions { display: flex; gap: 20px; color: var(--header-text); padding: 0 4px 0 0; align-items: center; }
  .wa-header .actions svg { width: 22px; height: 22px; display: block; }

  /* Chat area */
  .wa-chat {
    flex: 1; overflow-y: auto; padding: 8px 0 6px;
    display: flex; flex-direction: column; gap: 2px;
    background: var(--bg);
    position: relative;
  }
  .wa-chat::-webkit-scrollbar { width: 0; }
  /* WhatsApp classic doodle pattern — leaves, phones, hearts, camera, chat bubbles */
  .wa-chat::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='330' height='330' viewBox='0 0 330 330'><g fill='none' stroke='%23000' stroke-opacity='0.055' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path d='M30 35 C40 20 60 20 66 35 C72 20 92 20 102 35 C90 55 66 68 66 68 C66 68 42 55 30 35 Z'/><path d='M175 48 Q190 30 210 42 L204 56 Q186 52 175 48 Z M175 48 L168 66'/><circle cx='270' cy='32' r='13'/><path d='M264 32 L268 36 L277 27'/><path d='M40 130 h22 a6 6 0 0 1 6 6 v30 a6 6 0 0 1 -6 6 h-12 l-6 8 v-8 h-4 a6 6 0 0 1 -6 -6 v-30 a6 6 0 0 1 6 -6 z'/><path d='M135 122 a10 10 0 0 1 20 0 a10 10 0 0 1 20 0 c0 14 -20 26 -20 26 s-20 -12 -20 -26 z'/><path d='M230 115 l10 -4 l30 12 l-6 14 l-30 -12 z M246 121 a4 4 0 1 1 0 8 a4 4 0 0 1 0 -8 z'/><path d='M280 175 q20 -20 40 0 M260 195 q30 -25 60 0'/><circle cx='55' cy='220' r='11'/><path d='M48 220 l5 5 l10 -10'/><path d='M125 210 h26 a4 4 0 0 1 4 4 v20 a4 4 0 0 1 -4 4 h-26 a4 4 0 0 1 -4 -4 v-20 a4 4 0 0 1 4 -4 z M135 216 h6 l2 -3 h-10 z M128 222 a10 8 0 1 0 20 0 a10 8 0 0 0 -20 0 z'/><path d='M205 215 C215 200 235 200 241 215 C247 200 267 200 277 215 C265 235 241 248 241 248 C241 248 217 235 205 215 Z'/><path d='M24 275 Q14 265 24 255 Q34 265 24 275 Z M50 275 Q40 265 50 255 Q60 265 50 275 Z'/><path d='M100 285 l-8 -4 l4 -10 l16 8 l-4 10 z M108 279 l12 -6 l-4 -8 l-12 6 z'/><path d='M180 285 q10 -15 30 -5 t30 -5'/><circle cx='285' cy='280' r='14'/><path d='M279 280 l4 4 l9 -9'/></g></svg>");
    background-size: 330px 330px;
    opacity: 1;
  }
  .wa-dark .wa-chat::before { filter: invert(1); opacity: .22; }

  .date-divider {
    align-self: center;
    background: var(--divider-bg);
    color: var(--divider-text);
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 8px;
    margin: 8px 0 10px;
    box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
    text-transform: uppercase;
    letter-spacing: .2px;
    backdrop-filter: blur(4px);
    position: relative; z-index: 1;
  }

  .security-note {
    align-self: center; max-width: 320px;
    background: var(--security-bg); color: var(--security-text);
    font-size: 12.5px; line-height: 1.4;
    padding: 7px 14px; border-radius: 7px; text-align: center;
    margin: 2px 6px 10px;
    box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
    position: relative; z-index: 1;
  }
  .security-note .lock { display: inline-block; margin-right: 3px; }

  /* Bubble groups */
  .wa-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; max-width: 78%; position: relative; z-index: 1; }
  .wa-group.in { align-self: flex-start; margin-left: 9px; }
  .wa-group.out { align-self: flex-end; margin-right: 9px; }

  .bubble {
    padding: 6px 9px 8px 9px;
    border-radius: 7.5px;
    font-size: 15px;
    line-height: 1.33;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
    word-wrap: break-word;
    animation: waIn .22s cubic-bezier(.34,1.56,.64,1) both;
    min-width: 74px;
    letter-spacing: -0.24px;
    margin-bottom: 0;
  }
  @keyframes waIn { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

  .wa-group.in .bubble { background: var(--bubble-in); color: var(--bubble-in-text); align-self: flex-start; }
  .wa-group.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); align-self: flex-end; }

  /* Realistic curved WA tail on first bubble only (SVG) */
  .wa-group.in .bubble:first-of-type { border-top-left-radius: 0; }
  .wa-group.out .bubble:first-of-type { border-top-right-radius: 0; }
  .wa-group.in .bubble:first-of-type::before {
    content: ''; position: absolute; top: 0; left: -7px;
    width: 8px; height: 13px;
    background: var(--bubble-in);
    clip-path: path('M8 0 L8 13 C8 13 7 13 5 11 C2 8 0 4 0 0 Z');
    filter: drop-shadow(0 1px 0.5px rgba(0,0,0,0.08));
  }
  .wa-group.out .bubble:first-of-type::before {
    content: ''; position: absolute; top: 0; right: -7px;
    width: 8px; height: 13px;
    background: var(--bubble-out);
    clip-path: path('M0 0 L0 13 C0 13 1 13 3 11 C6 8 8 4 8 0 Z');
    filter: drop-shadow(0 1px 0.5px rgba(0,0,0,0.08));
  }

  .bubble .text { padding-right: 58px; white-space: pre-wrap; }
  .bubble .meta {
    position: absolute; right: 7px; bottom: 3px;
    font-size: 10.5px;
    display: inline-flex; align-items: center; gap: 2px;
    color: var(--meta);
    line-height: 1;
  }
  .wa-group.out .bubble .meta { color: var(--meta-out); }
  .bubble .meta .tick svg { width: 15px; height: 10px; display: block; }
  .bubble .meta .tick.read { color: var(--tick-read); }
  .bubble .meta .tick.sent { color: var(--meta-out); }
  .wa-dark .wa-group.out .bubble .meta .tick.sent { color: #A9C6BE; }

  /* Reactions (inline pill inside bubble) */
  .reaction-bubble { display:inline-flex; align-items:center; gap:4px; background:#E0F2FE; border:1px solid #BAE6FD; border-radius:999px; padding:1px 6px 1px 1px; cursor:pointer; }
  .reaction-bubble img { width:16px; height:16px; border-radius:50%; border:1px solid rgba(255,255,255,0.5); object-fit:cover; flex-shrink:0; }
  .reaction-bubble .r-avatar { width:16px; height:16px; border-radius:50%; border:1px solid rgba(255,255,255,0.5); flex-shrink:0; display:flex; align-items:center; justify-content:center; color:#fff; font-size:9px; font-weight:600; background:linear-gradient(135deg,#25D366,#128C7E); }
  .reaction-bubble .emoji { font-size:12px; line-height:1; }
  .wa-dark .reaction-bubble { background:rgba(59,130,246,0.22); border-color:rgba(96,165,250,0.38); }
  .bubble.has-reaction { display:flex; flex-direction:column; padding-bottom:4px; }
  .bubble .footer-row { display:flex; justify-content:space-between; align-items:end; gap:10px; margin-top:4px; }
  .bubble .in-reaction-row { margin-top:6px; margin-bottom:4px; }
  @keyframes reaction-pop {0%{transform:scale(0.3);opacity:0}50%{transform:scale(1.1)}100%{transform:scale(1);opacity:1}}
  .animate-reaction { animation: reaction-pop 0.5s cubic-bezier(0.175,0.885,0.32,1.275) forwards; transform-origin:left center; }

  /* Typing bubble */
  .wa-typing {
    align-self: flex-start;
    background: var(--bubble-in);
    padding: 10px 14px;
    border-radius: 8px 8px 8px 0;
    display: inline-flex; gap: 4px;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    margin: 0 9px 4px 9px;
    max-width: fit-content;
    position: relative; z-index: 1;
  }
  .wa-typing::before {
    content: ''; position: absolute; top: 0; left: -8px;
    width: 8px; height: 13px;
    background: var(--bubble-in);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
  }
  .wa-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: waDot 1.2s infinite; }
  .wa-typing span:nth-child(2) { animation-delay: .2s; }
  .wa-typing span:nth-child(3) { animation-delay: .4s; }
  @keyframes waDot { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-5px);opacity:1} }

  /* Input bar */
  .wa-input {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px 6px;
    background: var(--input-bg);
    border-top: 1px solid var(--border);
  }
  .wa-input .plus {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); flex-shrink: 0;
  }
  .wa-input .plus svg { width: 26px; height: 26px; }
  .wa-input .field-wrap {
    flex: 1;
    background: var(--input-field-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 8px 6px 12px;
    min-height: 36px;
    display: flex; align-items: center; gap: 10px;
    color: var(--muted);
    font-size: 16px;
  }
  .wa-dark .wa-input .field-wrap { border-color: transparent; }
  .wa-input .field-wrap .placeholder { flex: 1; color: var(--muted); }
  .wa-input .field-wrap .emoji svg,
  .wa-input .field-wrap .sticker svg { width: 23px; height: 23px; display: block; color: var(--muted); }
  .wa-input .camera, .wa-input .mic {
    width: 30px; height: 30px; border-radius: 50%;
    color: var(--header-bg); display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .wa-input .camera svg, .wa-input .mic svg { width: 26px; height: 26px; display: block; color: var(--header-bg); }
  .wa-dark .wa-input .camera svg, .wa-dark .wa-input .mic svg { color: #00A884; }

  .home-bar-wrap { background: var(--input-bg); padding: 6px 0 8px; display: flex; justify-content: center; }
  .home-bar { width: 134px; height: 5px; background: #000; border-radius: 3px; }
  .wa-dark .home-bar { background: rgba(255,255,255,0.7); }

  .controls { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: rgba(15,15,25,0.9); border: 1px solid rgba(255,255,255,0.1); border-radius: 40px; padding: 7px 10px; display: flex; gap: 6px; z-index: 50; backdrop-filter: blur(14px); }
  .ctrl-btn { background: transparent; color: #fff; border: none; padding: 8px 14px; border-radius: 30px; font-size: 13px; font-weight: 600; cursor: pointer; }
  .ctrl-btn.play { background: linear-gradient(135deg, #25D366, #128C7E); }
  .ctrl-btn.stop { background: rgba(239,68,68,0.85); }
  .ctrl-btn.rec  { background: rgba(239,68,68,0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); }
  .ctrl-btn.rec.recording { background: rgba(239,68,68,0.95); color: #fff; }
