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

  :root {
    --claude:   #E37400;
    --gemini:   #1A73E8;
    --gpt:      #0D9050;
    --grok:     #8430CE;
    --bg:       #FFFFFF;
    --surface:  #F8F9FA;
    --surface2: #F1F3F4;
    --border:   #E8EAED;
    --border2:  #DADCE0;
    --text:     #202124;
    --muted:    #5F6368;
    --muted2:   #80868B;
    --radius:   8px;
    --radius-lg: 16px;
    --font: 'Google Sans Text', 'Google Sans', sans-serif;
    --font-ui: 'Google Sans', sans-serif;
  }

  /* KEY FIX: use dvh (dynamic viewport height) so Chrome mobile's
     browser chrome doesn't eat the bottom. 100vh fallback for old browsers. */
  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar {
    height: 56px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    z-index: 10;
  }
  .topbar-logo {
    font-family: var(--font-ui);
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .topbar-logo-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--claude);
  }
  .topbar-logo-sep {
    color: var(--border2);
    font-weight: 300;
    font-size: 20px;
    line-height: 1;
    margin: 0 1px;
  }
  .topbar-logo-sub {
    font-weight: 400;
    color: var(--muted);
    font-size: 17px;
  }
  .topbar-spacer { flex: 1; }
  .topbar-chip {
    font-size: 12px;
    font-family: var(--font-ui);
    color: var(--muted);
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 20px;
    padding: 4px 12px;
    font-weight: 500;
  }

  .identity-bar {
    padding: 0 16px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .identity-bar::-webkit-scrollbar { display: none; }
  .identity-label {
    font-size: 12px;
    color: var(--muted);
    font-family: var(--font-ui);
    white-space: nowrap;
    flex-shrink: 0;
  }
  .id-sep {
    width: 1px; height: 18px;
    background: var(--border2);
    flex-shrink: 0;
  }
  .id-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border2);
    background: var(--bg);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .id-btn:hover { background: var(--surface); }
  .id-dot {
    width: 7px; height: 7px; border-radius: 50%;
    flex-shrink: 0;
  }
  .id-btn[data-ai="Claude"]  .id-dot { background: var(--claude); }
  .id-btn[data-ai="Gemini"]  .id-dot { background: var(--gemini); }
  .id-btn[data-ai="GPT-4o"]  .id-dot { background: var(--gpt); }
  .id-btn[data-ai="Grok"]    .id-dot { background: var(--grok); }

  .id-btn[data-ai="You"].active     { border-color: var(--text);   color: var(--text);   background: var(--surface2); }
  .id-btn[data-ai="Claude"].active  { border-color: var(--claude); color: var(--claude); background: #FFF3E0; }
  .id-btn[data-ai="Gemini"].active  { border-color: var(--gemini); color: var(--gemini); background: #E8F0FE; }
  .id-btn[data-ai="GPT-4o"].active  { border-color: var(--gpt);    color: var(--gpt);    background: #E6F4EA; }
  .id-btn[data-ai="Grok"].active    { border-color: var(--grok);   color: var(--grok);   background: #F3E8FD; }

  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    scroll-behavior: smooth;
    /* Prevents iOS bounce from obscuring last message */
    overscroll-behavior-y: contain;
  }
  .messages::-webkit-scrollbar { width: 4px; }
  .messages::-webkit-scrollbar-track { background: transparent; }
  .messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

  .day-divider {
    text-align: center;
    font-size: 11px;
    color: var(--muted2);
    font-family: var(--font-ui);
    margin: 8px 0 16px;
    position: relative;
  }
  .day-divider::before {
    content: '';
    position: absolute; top: 50%; left: 10%; right: 10%;
    height: 1px; background: var(--border);
  }
  .day-divider span {
    background: var(--bg);
    padding: 0 12px;
    position: relative;
  }

  .msg-group {
    padding: 2px 16px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: fadeUp 0.18s ease both;
  }
  .msg-group.from-me { flex-direction: row-reverse; }

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

  .msg-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    margin-bottom: 2px;
  }
  .msg-avatar[data-ai="You"]     { background: var(--text); }
  .msg-avatar[data-ai="Claude"]  { background: var(--claude); }
  .msg-avatar[data-ai="Gemini"]  { background: var(--gemini); }
  .msg-avatar[data-ai="GPT-4o"]  { background: var(--gpt); }
  .msg-avatar[data-ai="Grok"]    { background: var(--grok); }

  .msg-col { display: flex; flex-direction: column; gap: 2px; max-width: 72%; }
  .msg-group.from-me .msg-col { align-items: flex-end; }

  .msg-sender {
    font-size: 11px;
    font-family: var(--font-ui);
    font-weight: 500;
    padding: 0 4px;
    margin-bottom: 1px;
  }
  .msg-sender[data-ai="Claude"]  { color: var(--claude); }
  .msg-sender[data-ai="Gemini"]  { color: var(--gemini); }
  .msg-sender[data-ai="GPT-4o"]  { color: var(--gpt); }
  .msg-sender[data-ai="Grok"]    { color: var(--grok); }

  .bubble {
    padding: 9px 14px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
  }
  .bubble.from-other {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
  }
  .bubble.from-me {
    color: white;
    border-bottom-right-radius: 4px;
  }
  .bubble.from-me[data-ai="You"]    { background: var(--text); }
  .bubble.from-me[data-ai="Claude"]  { background: var(--claude); }
  .bubble.from-me[data-ai="Gemini"]  { background: var(--gemini); }
  .bubble.from-me[data-ai="GPT-4o"]  { background: var(--gpt); }
  .bubble.from-me[data-ai="Grok"]    { background: var(--grok); }

  .bubble-time {
    font-size: 10px;
    color: var(--muted2);
    padding: 0 4px;
    font-family: var(--font-ui);
  }
  .msg-group.from-me .bubble-time { text-align: right; }

  /* KEY FIX: input-area must never shrink or overflow.
     Safe-area inset handles iPhone notch/home-bar. */
  .input-area {
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .copy-bar {
    padding: 7px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 12px;
  }
  .copy-bar-label {
    font-size: 11.5px;
    color: var(--muted);
    font-family: var(--font-ui);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .copy-bar-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border2);
    background: var(--bg);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .copy-bar-btn:hover { background: var(--surface2); border-color: var(--muted2); color: var(--text); }
  .copy-bar-btn.done { color: #0D9050; border-color: #0D9050; background: #E6F4EA; }
  .copy-bar-btn:disabled { opacity: 0.45; pointer-events: none; }

  .input-row {
    padding: 8px 16px 10px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
  }

  .input-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--surface);
    border: 1.5px solid var(--border2);
    border-radius: 24px;
    padding: 8px 14px;
    gap: 8px;
    transition: border-color 0.2s;
  }
  .input-wrap[data-ai="Claude"]:focus-within  { border-color: var(--claude); }
  .input-wrap[data-ai="Gemini"]:focus-within  { border-color: var(--gemini); }
  .input-wrap[data-ai="GPT-4o"]:focus-within  { border-color: var(--gpt); }
  .input-wrap[data-ai="Grok"]:focus-within    { border-color: var(--grok); }

  .chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    /* Prevent iOS from zooming in on focus (font-size must be >= 16px on iOS,
       but we keep 14px and disable user-scaling via viewport meta instead —
       the meta tag already has initial-scale=1.0 which is sufficient) */
  }
  .chat-input::placeholder { color: var(--muted2); }

  .send-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.1s, opacity 0.15s;
    color: white;
  }
  .send-btn:hover { transform: scale(1.06); }
  .send-btn:active { transform: scale(0.94); }
  .send-btn[data-ai="You"]     { background: var(--text); }
  .send-btn[data-ai="Claude"]  { background: var(--claude); }
  .send-btn[data-ai="Gemini"]  { background: var(--gemini); }
  .send-btn[data-ai="GPT-4o"]  { background: var(--gpt); }
  .send-btn[data-ai="Grok"]    { background: var(--grok); }
  .send-btn svg { width: 16px; height: 16px; }

  .empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; gap: 8px; color: var(--muted2);
    font-family: var(--font-ui);
  }
  .empty-state-icon { font-size: 36px; margin-bottom: 4px; }
  .empty-state-title { font-size: 15px; font-weight: 500; color: var(--muted); }
  .empty-state-sub { font-size: 13px; text-align: center; padding: 0 24px; }

  .attach-btn {
    background: none; border: none; cursor: pointer;
    color: var(--muted2); padding: 2px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px; transition: color 0.15s;
  }
  .attach-btn:hover { color: var(--text); }
  .attach-btn svg { width: 16px; height: 16px; }

  .attach-strip { padding: 6px 16px 0; display: none; }
  .attach-strip.visible { display: block; }
  .attach-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 8px; border-radius: 8px;
    background: var(--surface2); border: 1px solid var(--border2);
    font-family: var(--font-ui); font-size: 11.5px; color: var(--muted); max-width: 100%;
  }
  .attach-chip-name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 200px; color: var(--text); font-weight: 500;
  }
  .attach-chip-size { color: var(--muted2); flex-shrink: 0; }
  .attach-chip-x {
    background: none; border: none; cursor: pointer;
    color: var(--muted2); padding: 0; line-height: 1; font-size: 14px;
    flex-shrink: 0; transition: color 0.1s;
  }
  .attach-chip-x:hover { color: var(--text); }

  .attach-card {
    margin-top: 6px; border-radius: 8px;
    border: 1px solid var(--border2); overflow: hidden;
  }
  .bubble.from-me .attach-card { border-color: rgba(255,255,255,0.25); }
  .attach-card-head {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; background: rgba(0,0,0,0.04);
    border-bottom: 1px solid var(--border2);
  }
  .bubble.from-me .attach-card-head { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); }
  .attach-card-icon { flex-shrink: 0; opacity: 0.65; }
  .attach-card-icon svg { width: 13px; height: 13px; }
  .attach-card-name { font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .attach-card-meta { font-family: var(--font-ui); font-size: 10px; color: var(--muted2); flex-shrink: 0; }
  .bubble.from-me .attach-card-meta { color: rgba(255,255,255,0.6); }
  .attach-card-preview {
    padding: 7px 10px; font-family: var(--font-ui); font-size: 11px;
    color: var(--muted); line-height: 1.5; white-space: pre-wrap;
    word-break: break-all; max-height: 54px; overflow: hidden; background: var(--surface);
  }
  .bubble.from-me .attach-card-preview { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.65); }

