* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
  body { margin: 0; background: #0a0a0f; color: #fff; font-family: "TikTok Sans", "Proxima Nova", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; letter-spacing: -0.1px; min-height: 100vh; }
  .phone, .device { font-family: "TikTok Sans", "Proxima Nova", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; letter-spacing: -0.1px; }
  #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, #0f0f1a 0%, #000 80%); }
  .back-link { color: rgba(255,255,255,0.5); text-decoration: none; font-size: 13px; display: inline-flex; gap: 6px; margin-bottom: 16px; }
  .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: #FE2C55; }
  .btn { padding: 10px 16px; border-radius: 10px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 7px; }
  .btn-primary { background: linear-gradient(135deg, #FE2C55, #25F4EE); color: #fff; width: 100%; justify-content: center; padding: 12px; }
  .btn-secondary { background: rgba(255,255,255,0.07); color: #fff; border: 1px solid 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: #FE2C55; }
  .event-row .who.other { color: #25F4EE; }
  .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; }
  .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(254,44,85,0.15); border-color: #FE2C55; color: #FE2C55; }
  .scenarios-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
  .sc-btn { padding: 8px 10px; background: rgba(254,44,85,0.08); border: 1px solid rgba(254,44,85,0.25); border-radius: 8px; color: #FFA8BB; font-size: 11px; cursor: pointer; text-align: left; line-height: 1.3; font-family: inherit; }
  .sc-btn:hover { background: rgba(254,44,85,0.18); }

  /* iPhone */
  .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; background: #000; }
  .device.vertical .device-screen { border-radius: 24px; }

  /* ═════════ TIKTOK DM — pixel-accurate 2024/2025 ═════════ */
  .tt {
    font-family: "TikTok Sans", "Proxima Nova", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
    height: 100%; display: flex; flex-direction: column;
    letter-spacing: -0.1px;
  }
  /* TikTok DEFAULTS TO DARK */
  .tt-dark {
    --bg: #000000; --text: #FFFFFF; --muted: #8A8B8F; --sub: #A8A8AB; --border: rgba(255,255,255,0.08);
    --bubble-other: #2F2F2F; --bubble-other-text: #FFFFFF;
    --bubble-me: #FE2C55; --bubble-me-text: #FFFFFF;
    --header: #000000; --icon: #FFFFFF;
    --input-bg: #000000; --input-field-bg: #1C1C1D;
    --reaction-bg: #161616;
  }
  .tt-light {
    --bg: #FFFFFF; --text: #161823; --muted: #8A8B8F; --sub: #6B6C70; --border: rgba(22,24,35,0.08);
    --bubble-other: #F1F1F2; --bubble-other-text: #161823;
    --bubble-me: #FE2C55; --bubble-me-text: #FFFFFF;
    --header: #FFFFFF; --icon: #161823;
    --input-bg: #FFFFFF; --input-field-bg: #F1F1F2;
    --reaction-bg: #F1F1F2;
  }
  .tt-screen { height: 100%; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }

  /* Status bar iOS */
  .tt-statusbar { height: 47px; padding: 14px 30px 0; display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 600; color: var(--text); background: var(--header); position: relative; z-index: 15; font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif; }
  .tt-statusbar .right { display: flex; gap: 5px; align-items: center; }
  .tt-statusbar .signal { display: inline-flex; gap: 1px; align-items: flex-end; }
  .tt-statusbar .signal span { width: 3px; background: currentColor; border-radius: 0.5px; }
  .tt-statusbar .signal span:nth-child(1) { height: 4px; }
  .tt-statusbar .signal span:nth-child(2) { height: 6px; }
  .tt-statusbar .signal span:nth-child(3) { height: 8px; }
  .tt-statusbar .signal span:nth-child(4) { height: 10px; }
  .tt-statusbar .battery { width: 24px; height: 11px; border: 1.2px solid currentColor; border-radius: 3px; position: relative; padding: 1px; }
  .tt-statusbar .battery::after { content: ''; position: absolute; right: -3px; top: 3px; width: 2px; height: 4px; background: currentColor; border-radius: 0 1px 1px 0; }
  .tt-statusbar .battery::before { content: ''; display: block; width: 75%; height: 100%; background: currentColor; border-radius: 1px; }

  /* Header — TikTok 2024: back | [avatar + name + @handle centered] | flag/dots */
  .tt-header { display: grid; grid-template-columns: 40px 1fr 60px; align-items: center; padding: 4px 10px 10px; background: var(--header); position: relative; z-index: 10; }
  .tt-header .back { color: var(--icon); padding: 4px; display: flex; justify-self: start; cursor: pointer; }
  .tt-header .back svg { width: 24px; height: 24px; }
  .tt-header .center { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
  .tt-header .avatar-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
  .tt-header .avatar-wrap { position: relative; width: 28px; height: 28px; flex-shrink: 0; }
  .tt-header .avatar { width: 100%; height: 100%; border-radius: 50%; background: linear-gradient(135deg,#25F4EE,#FE2C55); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; overflow: hidden; }
  .tt-header .online-dot { position: absolute; bottom: -1px; right: -1px; width: 9px; height: 9px; background: #00F2A9; border: 2px solid var(--header); border-radius: 50%; display: none; }
  .tt-header .online-dot.active { display: block; }
  .tt-header .name { font-size: 15px; font-weight: 700; color: var(--text); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
  .tt-header .verified { width: 13px; height: 13px; flex-shrink: 0; }
  .tt-header .handle { font-size: 11px; color: var(--sub); margin-top: 0px; font-weight: 400; }
  .tt-header .actions { display: flex; gap: 16px; color: var(--icon); justify-self: end; align-items: center; }
  .tt-header .actions svg { width: 22px; height: 22px; cursor: pointer; }

  /* Chat */
  .tt-chat { flex: 1; overflow: hidden; padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }

  .time-divider { align-self: center; font-size: 11px; color: var(--muted); margin: 10px 0 8px; font-weight: 500; }

  .msg-row { display: flex; max-width: 78%; margin-bottom: 2px; align-items: flex-end; gap: 6px; position: relative; }
  .msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
  .msg-row.other { align-self: flex-start; }
  .msg-row .row-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg,#25F4EE,#FE2C55); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; overflow: hidden; }
  .msg-row.me .row-avatar { display: none; }
  .msg-row .row-avatar.hidden { visibility: hidden; }

  .bubble {
    padding: 9px 13px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.28;
    word-wrap: break-word;
    max-width: 100%;
    animation: ttIn .22s cubic-bezier(.34,1.56,.64,1) both;
    position: relative;
    font-weight: 400;
    letter-spacing: -0.1px;
  }
  @keyframes ttIn { from { opacity: 0; transform: translateY(5px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
  .msg-row.other .bubble { background: var(--bubble-other); color: var(--bubble-other-text); }
  .msg-row.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); }

  /* TikTok keeps bubbles flat & uniform — minimal squish between grouped */
  .msg-row.other.has-prev .bubble { border-top-left-radius: 6px; }
  .msg-row.other.has-next .bubble { border-bottom-left-radius: 6px; }
  .msg-row.me.has-prev .bubble { border-top-right-radius: 6px; }
  .msg-row.me.has-next .bubble { border-bottom-right-radius: 6px; }

  /* Seen indicator */
  .seen { align-self: flex-end; font-size: 11px; color: var(--muted); margin: 2px 4px 6px; font-weight: 400; }

  /* Reactions — inline pill inside bubble (gen pattern) */
  .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;
    margin-top: 6px;
  }
  .reaction-bubble img,
  .reaction-bubble .r-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.5);
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
  }
  .reaction-bubble .emoji { font-size: 12px; line-height: 1; }
  .msg-row.me .reaction-bubble { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.35); }
  .tt-dark .msg-row.other .reaction-bubble { background: rgba(56,151,240,0.18); border-color: rgba(56,151,240,0.35); }
  @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 */
  .tt-typing { align-self: flex-start; background: var(--bubble-other); padding: 11px 14px; border-radius: 20px; display: inline-flex; gap: 4px; margin: 2px 0 2px 34px; max-width: fit-content; }
  .tt-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ttDot 1.1s infinite; }
  .tt-typing span:nth-child(2) { animation-delay: .18s; }
  .tt-typing span:nth-child(3) { animation-delay: .36s; }
  @keyframes ttDot { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-5px);opacity:1} }

  /* Input — TikTok 2024: [+] [ field   stickers camera ] [mic/send] */
  .tt-input { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; background: var(--input-bg); }
  .tt-input .iconbtn { width: 34px; height: 34px; border-radius: 50%; background: var(--input-field-bg); color: var(--icon); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .tt-input .iconbtn svg { width: 20px; height: 20px; }
  .tt-input .field-wrap { flex: 1; background: var(--input-field-bg); border-radius: 22px; padding: 7px 6px 7px 14px; min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 15px; }
  .tt-input .field-wrap .placeholder { flex: 1; font-weight: 400; }
  .tt-input .field-wrap .ricons { display: flex; gap: 6px; color: var(--icon); align-items: center; }
  .tt-input .field-wrap .ricons .ric { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
  .tt-input .field-wrap .ricons svg { width: 20px; height: 20px; display: block; }

  .home-bar { width: 134px; height: 5px; background: rgba(255,255,255,0.85); border-radius: 3px; margin: 6px auto 8px; }
  .tt-light .home-bar { background: #000; }

  .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, #FE2C55, #25F4EE); }
  .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; }
