* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
  body { margin: 0; background: #0a0a0f; color: #fff; font-family: "VK Sans Display", "VK Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; letter-spacing: -0.12px; 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, #0f2d5e 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: #0077FF; }
  .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; }
  .btn-primary { background: #0077FF; color: #fff; width: 100%; justify-content: center; padding: 12px; }
  .btn-primary:hover { background: #0066DD; }
  .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; color: #0077FF; }
  .event-row .who.other { color: #8b5cf6; }
  .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(0,119,255,0.15); border-color: #0077FF; color: #60a5fa; }
  .scenarios-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
  .sc-btn { padding: 8px 10px; background: rgba(0,119,255,0.08); border: 1px solid rgba(0,119,255,0.25); border-radius: 8px; color: #8CC0F5; font-size: 11px; cursor: pointer; text-align: left; line-height: 1.3; font-family: inherit; }
  .sc-btn:hover { background: rgba(0,119,255,0.18); }

  /* 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; background: #fff; }
  .device.vertical .device-screen { border-radius: 24px; }

  /* ═════════ VK MESSENGER 2024/2025 ═════════ */
  .vk, .phone {
    font-family: "VK Sans Display", "VK Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.12px;
    height: 100%; display: flex; flex-direction: column;
    --accent: #0077FF;
    --vk-blue: #0077FF;
    --vk-blue-grad-a: #3F8AE0;
    --vk-blue-grad-b: #447BBA;
  }
  .vk-light {
    --bg-rgb: 255 255 255;
    --bg: #EDEEF0;
    --text: #000000;
    --muted: #818C99;
    --border: rgba(0,0,0,0.08);
    --bubble-other: #F2F3F5;
    --bubble-other-text: #000000;
    --bubble-me-bg: linear-gradient(135deg, #3F8AE0 0%, #447BBA 100%);
    --bubble-me-text: #FFFFFF;
    --bubble-me-meta: rgba(255,255,255,0.75);
    --header-bg: #FFFFFF;
    --icon: #0077FF;
    --input-bg: #FFFFFF;
    --input-field-bg: #F2F3F5;
    --reaction-bg: rgba(255,255,255,0.92);
    --reaction-border: rgba(0,0,0,0.06);
    --tick-sent: #99A2AD;
    --tick-read: #3F8AE0;
    --stroke-subtle: rgba(0,0,0,0.08);
    --date-pill-bg: rgba(0,0,0,0.08);
    --date-pill-text: #55606E;
  }
  .vk-dark {
    --bg-rgb: 26 26 28;
    --bg: #0F0F10;
    --text: #E1E3E6;
    --muted: #76787A;
    --border: rgba(255,255,255,0.08);
    --bubble-other: #2A2A2B;
    --bubble-other-text: #E1E3E6;
    --bubble-me-bg: linear-gradient(135deg, #529EF4 0%, #3A7DC9 100%);
    --bubble-me-text: #FFFFFF;
    --bubble-me-meta: rgba(255,255,255,0.72);
    --header-bg: #161617;
    --icon: #71AAEB;
    --input-bg: #161617;
    --input-field-bg: #232324;
    --reaction-bg: rgba(255,255,255,0.08);
    --reaction-border: rgba(255,255,255,0.08);
    --tick-sent: #76787A;
    --tick-read: #71AAEB;
    --stroke-subtle: rgba(255,255,255,0.08);
    --date-pill-bg: rgba(255,255,255,0.10);
    --date-pill-text: #B8BCC2;
  }
  .vk-screen { height: 100%; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }

  /* Status bar iOS */
  .vk-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-bg); position: relative; z-index: 15; }
  .vk-statusbar .right { display: flex; gap: 5px; align-items: center; }
  .vk-statusbar .signal { display: inline-flex; gap: 1px; align-items: flex-end; }
  .vk-statusbar .signal span { width: 3px; background: currentColor; border-radius: 0.5px; }
  .vk-statusbar .signal span:nth-child(1) { height: 4px; }
  .vk-statusbar .signal span:nth-child(2) { height: 6px; }
  .vk-statusbar .signal span:nth-child(3) { height: 8px; }
  .vk-statusbar .signal span:nth-child(4) { height: 10px; }
  .vk-statusbar .battery { width: 24px; height: 11px; border: 1.2px solid currentColor; border-radius: 3px; position: relative; padding: 1px; }
  .vk-statusbar .battery::after { content: ''; position: absolute; right: -3px; top: 3px; width: 2px; height: 4px; background: currentColor; border-radius: 0 1px 1px 0; }
  .vk-statusbar .battery::before { content: ''; display: block; width: 75%; height: 100%; background: currentColor; border-radius: 1px; }

  /* Header */
  .vk-header { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; background: var(--header-bg); border-bottom: 0.5px solid var(--border); }
  .vk-header .back { color: var(--icon); padding: 4px; display: flex; align-items: center; }
  .vk-header .back svg { width: 11px; height: 20px; }
  .vk-header .avatar-wrap { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
  .vk-header .avatar { width: 100%; height: 100%; border-radius: 50%; background: linear-gradient(135deg, #5B88C5, #2787F5); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; overflow: hidden; }
  .vk-header .online-dot { position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; background: #4BB34B; border: 2px solid var(--header-bg); border-radius: 50%; display: none; }
  .vk-header .online-dot.active { display: block; }
  .vk-header .info { flex: 1; min-width: 0; }
  .vk-header .name { font-weight: 600; font-size: 16px; color: var(--text); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.1px; }
  .vk-header .status { font-size: 13px; color: var(--muted); line-height: 1.2; margin-top: 1px; }
  .vk-header .status.typing { color: var(--vk-blue); }
  .vk-header .actions { display: flex; gap: 16px; color: var(--icon); padding: 0 4px; }
  .vk-header .actions svg { width: 24px; height: 24px; }

  /* Chat */
  .vk-chat { flex: 1; overflow: hidden; padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }

  .date-divider { align-self: center; font-size: 12px; color: var(--date-pill-text); background: var(--date-pill-bg); padding: 3px 12px; border-radius: 12px; margin: 4px 0 10px; font-weight: 500; backdrop-filter: blur(6px); }

  .msg-row { display: flex; align-items: flex-end; gap: 6px; max-width: 82%; margin-bottom: 1px; }
  .msg-row.other { align-self: flex-start; }
  .msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
  .msg-row .row-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg,#5B88C5,#2787F5); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; overflow: hidden; }
  .msg-row.me .row-avatar { display: none; }
  .msg-row .row-avatar.hidden { visibility: hidden; }

  .bubble {
    padding: 7px 12px 6px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.33;
    word-wrap: break-word;
    max-width: 100%;
    animation: vkIn .24s cubic-bezier(.34,1.56,.64,1) both;
    position: relative;
    letter-spacing: -0.12px;
  }
  @keyframes vkIn { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

  .msg-row.other .bubble { background: var(--bubble-other); color: var(--bubble-other-text); border-bottom-left-radius: 6px; }
  .msg-row.me .bubble { background: var(--bubble-me-bg); color: var(--bubble-me-text); border-bottom-right-radius: 6px; box-shadow: 0 1px 1.5px rgba(63,138,224,0.18); }

  .msg-row.other.has-prev .bubble { border-top-left-radius: 6px; }
  .msg-row.me.has-prev .bubble { border-top-right-radius: 6px; }

  .bubble .text { display: inline; }
  .bubble .meta { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; font-size: 11px; color: var(--muted); float: right; margin-top: 5px; position: relative; top: 3px; }
  .msg-row.me .bubble .meta { color: var(--bubble-me-meta); }
  .bubble .meta .tick { display: inline-flex; color: var(--tick-sent); }
  .bubble .meta .tick.read { color: var(--tick-read); }
  .msg-row.me .bubble .meta .tick { color: rgba(255,255,255,0.85); }
  .msg-row.me .bubble .meta .tick.read { color: #FFFFFF; }
  .bubble .meta .tick svg { width: 14px; height: 10px; }

  /* Sticker-mode (large emoji without bubble) */
  .msg-row.sticker .bubble { background: transparent !important; box-shadow: none !important; padding: 2px 4px; font-size: 64px; line-height: 1; border-radius: 0 !important; }
  .msg-row.sticker .bubble .meta { font-size: 11px; position: static; margin-top: 2px; }

  /* Reactions — inline pill inside bubble footer */
  .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,
  .reaction-bubble .ra {
    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;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
  }
  .reaction-bubble .emoji { font-size: 12px; line-height: 1; }
  @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; }

  .msg-row.me .reaction-bubble { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.4); }
  .vk-dark .msg-row.other .reaction-bubble { background: rgba(63,138,224,0.2); border-color: rgba(113,170,235,0.35); }

  .bubble .footer-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
  .bubble .footer-row .meta { position: static; margin: 0; float: none; top: auto; }
  .bubble .reaction-line { margin-top: 6px; }

  /* Typing */
  .vk-typing { align-self: flex-start; background: var(--bubble-other); padding: 11px 14px; border-radius: 18px 18px 18px 6px; display: inline-flex; gap: 4px; margin: 2px 0; max-width: fit-content; }
  .vk-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: vkDot 1.1s infinite; }
  .vk-typing span:nth-child(2) { animation-delay: .18s; }
  .vk-typing span:nth-child(3) { animation-delay: .36s; }
  @keyframes vkDot { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-4px);opacity:1} }

  /* Input */
  .vk-input { display: flex; align-items: center; gap: 8px; padding: 7px 10px 9px; background: var(--input-bg); border-top: 0.5px solid var(--border); }
  .vk-input .attach { color: var(--icon); padding: 4px; display: flex; align-items: center; }
  .vk-input .attach svg { width: 26px; height: 26px; }
  .vk-input .field-wrap { flex: 1; background: var(--input-field-bg); border-radius: 18px; padding: 8px 10px 8px 14px; min-height: 36px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; }
  .vk-input .field-wrap .placeholder { flex: 1; letter-spacing: -0.1px; }
  .vk-input .field-wrap .sticker { color: var(--muted); display: flex; }
  .vk-input .field-wrap .sticker svg { width: 22px; height: 22px; display: block; }
  .vk-input .send { width: 36px; height: 36px; border-radius: 50%; background: var(--vk-blue); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,119,255,0.25); }
  .vk-input .send svg { width: 20px; height: 20px; }

  .home-bar { width: 134px; height: 5px; background: #000; border-radius: 3px; margin: 6px auto 8px; }
  .vk-dark .home-bar { background: rgba(255,255,255,0.8); }

  .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: #0077FF; }
  .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; }
