:root {
    --bg:        #f5f7fa;
    --surface:   #ffffff;
    --panel:     #ffffff;
    --border:    rgba(0,0,0,0.08);
    --primary:   #01A982;
    --primary-dim:#00875A;
    --primary-glow:rgba(1,169,130,0.1);
    --accent:    #00875A;
    --accent-dim:rgba(1,169,130,0.06);
    --text:      #1a1a2e;
    --text-light:#ffffff;
    --muted:     #6b7280;
    --bot-bg:    rgba(1,169,130,0.06);
    --user-bg:   #01A982;
    --green:     #01A982;
    --red:       #ef4444;
  }

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

  body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    position: relative;
    overflow: hidden;
  }

  /* Chat window */
  .chat-window {
    position: relative; z-index: 10;
    width: 100%; max-width: 520px;
    height: 70vh;
    max-height: 620px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
    background: var(--surface);
  }

  /* When loaded inside an iframe (embedded on another site) */
  .iframe-mode body {
    padding: 0;
    justify-content: flex-start;
    overflow: hidden;
  }

  .iframe-mode .chat-window {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  /* Header */
  .header {
    background: var(--primary);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    position: relative;
  }

  .logo-mark {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
  }

  .header-text h2 {
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
  }

  .header-text p {
    font-size: 11px;
    color: rgba(255,255,255,0.75);
    margin-top: 2px;
  }

  .status-row {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    transition: all 0.3s;
  }

  .status-dot.online {
    background: #ffffff;
    box-shadow: 0 0 8px rgba(255,255,255,0.6);
    animation: pulse 2s infinite;
  }

  @keyframes pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
    50%      { box-shadow: 0 0 0 5px rgba(255,255,255,0); }
  }

  .status-label {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
  }

  /* Messages */
  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
  }

  .messages::-webkit-scrollbar { width: 3px; }
  .messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

  .msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: fadeUp 0.3s ease forwards;
    opacity: 0;
  }

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

  .msg.user { flex-direction: row-reverse; }

  .msg-avatar {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    border: 1px solid var(--border);
  }

  .msg.bot .msg-avatar { background: var(--primary-glow); }
  .msg.user .msg-avatar { background: var(--primary); }

  .bubble {
    max-width: 80%;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.65;
  }

  .msg.bot .bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
  }

  .msg.user .bubble {
    background: var(--user-bg);
    border: none;
    border-bottom-right-radius: 4px;
    color: #ffffff;
  }

  .bubble strong { color: var(--primary); }
  .bubble em { color: var(--accent); font-style: normal; font-weight: 500; }

  /* Typing indicator */
  .typing .bubble { padding: 14px 16px; }
  .dots { display:flex; gap:5px; align-items:center; height:14px; }
  .dots span {
    width:5px; height:5px; border-radius:50%;
    background: var(--primary);
    animation: dotBounce 1.2s infinite;
  }
  .dots span:nth-child(2) { animation-delay:.2s; }
  .dots span:nth-child(3) { animation-delay:.4s; }

  @keyframes dotBounce {
    0%,60%,100% { transform:translateY(0); opacity:0.4; }
    30%          { transform:translateY(-5px); opacity:1; }
  }

  /* Quick replies */
  .quick-wrap {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
  }

  .qr {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11.5px;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 500;
    transition: all 0.2s;
  }

  .qr:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
  }

  .qr-loading {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    padding: 4px 0;
  }

  .trending-wrap {
    border-top: none;
    padding-top: 2px;
  }

  .trending-label {
    font-size: 10px;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    padding-bottom: 2px;
  }

  .qr.trending {
    border-color: rgba(1,169,130,0.3);
    color: var(--primary);
    background: var(--primary-glow);
  }

  .qr.trending:hover {
    background: rgba(1,169,130,0.15);
    border-color: var(--primary);
  }

  /* Input */
  .input-row {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
  }

  #userInput {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 13.5px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    outline: none;
    resize: none;
    max-height: 90px;
    min-height: 40px;
    transition: border-color 0.2s;
    line-height: 1.5;
  }

  #userInput:focus { border-color: var(--primary); }
  #userInput::placeholder { color: rgba(107,114,128,0.5); }

  .send {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary-dim), var(--primary));
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(1,169,130,0.25);
  }

  .send:hover { transform:scale(1.06); }
  .send:active { transform:scale(0.96); }
  .send:disabled { opacity:0.4; cursor:not-allowed; transform:none; box-shadow:none; }

  @media (max-width: 540px) {
    body { padding:0; justify-content:flex-start; }
    .chat-window { max-height:100vh; height:100vh; border-radius:0; border:none; box-shadow:none; }
  }