/* Messaging only. All paint and typography come from the audited native bridge. */
body.toma-chat { margin:0; min-height:100dvh; height:100dvh; display:flex; flex-direction:column; overflow:hidden; background:var(--background); color:var(--text-primary); font:var(--type-body); color-scheme:light; }
body.toma-chat.dark-mode { color-scheme:dark; }
.toma-chat * { box-sizing:border-box; }
.toma-chat h1,.toma-chat h2,.toma-chat p { margin:0; }
.toma-chat button,.toma-chat input,.toma-chat textarea { font:inherit; color:inherit; }
.toma-chat button,.toma-chat a,.toma-chat label { -webkit-tap-highlight-color:var(--transparent); }
.toma-chat button { cursor:pointer; }
.toma-chat button:disabled { cursor:not-allowed; }
.toma-chat :focus-visible { outline:3px solid var(--link); outline-offset:3px; }
.toma-chat svg { width:22px; height:22px; flex-shrink:0; vertical-align:middle; }
.toma-chat a { color:var(--link); }
.toma-chat .topbar { height:72px; flex-shrink:0; border-bottom:1px solid var(--border); background:var(--card); display:flex; align-items:center; justify-content:space-between; gap:12px; padding:0 max(24px,calc((100vw - 1240px)/2)); }
.toma-chat .top-start,.toma-chat .top-end { display:flex; align-items:center; gap:12px; min-width:0; }
.toma-chat .topbar a { text-decoration:none; color:var(--text-primary); }
.toma-chat .brand-link { font:var(--type-subheading); letter-spacing:2px; padding:8px 0; }
.toma-chat .title { font:var(--type-label); border-inline-start:1px solid var(--border); padding-inline-start:12px; }
.toma-chat .back-link,.toma-chat .icon-btn,.toma-chat .chrome-button { min-width:44px; min-height:44px; display:inline-flex; align-items:center; justify-content:center; gap:6px; border:1px solid var(--border); border-radius:var(--radius-button); background:var(--card); color:var(--text-primary); padding:8px; text-decoration:none; }
.toma-chat .back-link { border:0; font:var(--type-caption); }
.toma-chat .chrome-button { font:var(--type-caption); padding-inline:12px; }
.toma-chat .user-name { color:var(--text-secondary); font:var(--type-caption); max-width:160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.toma-chat .workspace { flex:1; min-height:0; width:100%; max-width:1240px; margin:auto; padding:24px; display:grid; grid-template-columns:360px minmax(0,1fr); gap:20px; }
.toma-chat .panel { background:var(--card); border:1px solid var(--border); border-radius:var(--radius-card); overflow:hidden; min-width:0; min-height:0; box-shadow:var(--shadow-card); }
.toma-chat .sidebar,.toma-chat .chat { display:flex; flex-direction:column; }
.toma-chat .side-head { padding:24px 20px 20px; border-bottom:1px solid var(--border); }
.toma-chat .side-title { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; }
.toma-chat h1 { font:var(--type-heading); }
.toma-chat .count { background:var(--subdued); border-radius:var(--radius-badge); color:var(--text-secondary); font:var(--type-caption); padding:3px 10px; }
.toma-chat .search { position:relative; }
.toma-chat .search svg { position:absolute; inset-inline-start:12px; top:12px; width:20px; height:20px; color:var(--text-secondary); pointer-events:none; }
.toma-chat .search input { min-width:0; width:100%; min-height:44px; border:1px solid var(--input-border); background:var(--input); border-radius:var(--radius-input); padding:10px 12px; padding-inline-start:40px; font:var(--type-label); }
.toma-chat input::placeholder,.toma-chat textarea::placeholder { color:var(--placeholder); opacity:1; }
.toma-chat .conversation-list { flex:1; overflow:auto; }
.toma-chat .conversation-item { width:100%; display:flex; gap:14px; align-items:center; padding:18px 20px; border:0; border-bottom:1px solid var(--border); background:var(--card); text-align:start; position:relative; }
.toma-chat .conversation-item:hover { background:var(--subdued); }
.toma-chat .conversation-item.active { background:var(--brand-tint-1); }
.toma-chat .conversation-item.active::before { content:""; position:absolute; inset-inline-start:0; top:0; bottom:0; width:3px; background:var(--link); }
.toma-chat .avatar { display:grid; place-items:center; width:44px; height:44px; flex-shrink:0; border-radius:var(--radius-full); background:var(--primary); color:var(--on-primary); font:var(--type-subheading); }
.toma-chat .conversation-item .avatar { width:52px; height:52px; }
.toma-chat .conv-copy { flex:1; min-width:0; }
.toma-chat .conv-top { display:flex; flex-direction:column; gap:2px; }
.toma-chat .conv-name { font:var(--type-label); font-weight:600; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.toma-chat .conv-time { font:var(--type-caption); color:var(--text-secondary); }
.toma-chat .conv-bottom { display:flex; align-items:center; gap:8px; margin-top:4px; }
.toma-chat .conv-preview { font:var(--type-caption); color:var(--text-secondary); white-space:nowrap; text-overflow:ellipsis; overflow:hidden; flex:1; }
.toma-chat .unread { display:grid; place-items:center; flex-shrink:0; min-width:22px; height:22px; padding:0 6px; border-radius:var(--radius-badge); background:var(--primary); color:var(--on-primary); font:var(--type-caption); }
.toma-chat .has-unread .conv-name,.toma-chat .has-unread .conv-preview { font-weight:700; color:var(--text-primary); }
.toma-chat #activeChat { display:none; flex:1; flex-direction:column; min-height:0; }
.toma-chat .chat-head { display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid var(--border); min-height:76px; background:var(--card); }
.toma-chat .partner-copy { flex:1; min-width:0; }
.toma-chat .partner-name { font:var(--type-button); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.toma-chat .partner-type { font:var(--type-caption); color:var(--text-secondary); }
.toma-chat .mobile-back { display:none; }
.toma-chat .messages { flex:1; min-height:0; overflow:auto; overscroll-behavior:contain; display:flex; flex-direction:column; gap:10px; padding:20px 24px; background:var(--background); }
.toma-chat .message { max-width:min(75%,520px); display:flex; flex-direction:column; gap:4px; min-width:0; }
.toma-chat .message.sent { align-self:flex-end; align-items:flex-end; }
.toma-chat .message.received { align-self:flex-start; align-items:flex-start; }
.toma-chat .bubble { padding:10px 12px; border-radius:var(--radius-card); font:var(--type-body); white-space:pre-wrap; overflow-wrap:anywhere; max-width:100%; text-align:start; }
.toma-chat .sent .bubble { background:var(--primary); color:var(--on-primary); border-end-end-radius:4px; }
.toma-chat .received .bubble { background:var(--card); color:var(--text-primary); border-end-start-radius:4px; box-shadow:var(--shadow-small); }
.toma-chat .message-time { font:var(--type-caption); font-size:10px; color:var(--text-secondary); padding:0 4px; }
.toma-chat .message a { max-width:100%; }
.toma-chat .message-image { display:block; max-width:100%; width:240px; max-height:210px; border-radius:var(--radius-input); object-fit:cover; background:var(--subdued); }
.toma-chat .composer { border-top:1px solid var(--border); padding:12px; background:var(--card); }
.toma-chat .compose-row,.toma-chat .compose-box { display:flex; align-items:flex-end; gap:8px; min-width:0; }
.toma-chat .compose-box { flex:1; }
.toma-chat textarea { flex:1; min-width:0; min-height:44px; max-height:110px; border:1px solid var(--input-border); border-radius:22px; background:var(--background); padding:10px 14px; resize:none; font:var(--type-body); }
.toma-chat .attach-label,.toma-chat .send { width:44px; height:44px; flex-shrink:0; display:grid; place-items:center; border:1px solid var(--border); border-radius:var(--radius-full); background:var(--background); color:var(--text-secondary); cursor:pointer; }
.toma-chat .send { border:0; background:var(--primary); color:var(--on-primary); }
.toma-chat .send:disabled { background:var(--disabled-action); color:var(--on-primary); }
.toma-chat textarea:disabled { background:var(--disabled-background); color:var(--disabled-text); }
.toma-chat .attach-label[aria-disabled="true"] { color:var(--disabled-text); background:var(--disabled-background); cursor:not-allowed; }
.toma-chat .file-input { position:absolute; width:1px; height:1px; clip-path:inset(50%); overflow:hidden; }
.toma-chat .compose-box:has(.file-input:focus-visible) .attach-label { outline:3px solid var(--link); outline-offset:3px; }
.toma-chat #chatLock { font:var(--type-caption); color:var(--text-secondary); padding:0 4px 12px; }
.toma-chat .attachment-preview { display:flex; align-items:center; gap:12px; background:var(--background); border-radius:var(--radius-input); padding:10px; margin-bottom:12px; }
.toma-chat .attachment-preview img { width:56px; height:56px; flex-shrink:0; object-fit:cover; border-radius:var(--radius-input); }
.toma-chat .attachment-preview span { min-width:0; overflow-wrap:anywhere; flex:1; font:var(--type-caption); color:var(--text-secondary); }
.toma-chat .attachment-preview button { margin-inline-start:auto; color:var(--error); }
.toma-chat .attachment-preview button:disabled { color:var(--disabled-text); background:var(--disabled-background); }
.toma-chat .state { flex:1; min-height:100%; display:grid; place-items:center; text-align:center; padding:32px 20px; color:var(--text-secondary); }
.toma-chat .state-icon { margin:0 auto 16px; width:72px; height:72px; border-radius:var(--radius-full); background:var(--brand-tint-1); color:var(--link); display:grid; place-items:center; }
.toma-chat .state-icon svg { width:32px; height:32px; }
.toma-chat .state h2 { font:var(--type-subheading); color:var(--text-primary); margin-bottom:8px; }
.toma-chat .state p { font:var(--type-caption); max-width:310px; margin:auto; }
.toma-chat .error-state button { min-height:44px; margin-top:16px; border:0; border-radius:var(--radius-button); background:var(--primary); color:var(--on-primary); font:var(--type-button); padding:10px 20px; }
.toma-chat .skeleton { height:72px; margin:12px 16px; border-radius:var(--radius-card); background:var(--subdued); }
.toma-chat .messages .skeleton { width:65%; min-height:52px; margin:0 0 12px; }
.toma-chat .messages .skeleton:nth-child(even) { align-self:flex-end; width:45%; }
.toma-chat .feedback { font:var(--type-caption); color:var(--text-secondary); padding:0 0 10px; }
.toma-chat .feedback:empty { display:none; }
.toma-chat .feedback.error { color:var(--error); }
.toma-chat .feedback.success { color:var(--success); }
.toma-chat .page-feedback:not(:empty) { flex-shrink:0; padding:10px 20px; background:var(--card); border-bottom:1px solid var(--border); }
.toma-chat .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.toma-chat [dir="auto"] { unicode-bidi:plaintext; }
html[dir="ltr"] .toma-chat .back-link svg,html[dir="ltr"] .toma-chat .mobile-back svg { transform:scaleX(-1); }
html[dir="rtl"] .toma-chat .send svg { transform:scaleX(-1); }
@media(max-width:1023px) { .toma-chat .workspace { grid-template-columns:310px minmax(0,1fr); padding:16px; gap:16px; } .toma-chat .back-link span,.toma-chat .user-name { display:none; } }
@media(max-width:767px) {
  .toma-chat .topbar { height:64px; padding:0 12px; gap:8px; }
  .toma-chat .top-start,.toma-chat .top-end { gap:6px; }
  .toma-chat .topbar .title { display:none; }
  .toma-chat .chrome-button { padding:8px; }
  .toma-chat .workspace { position:relative; padding:0; display:block; }
  .toma-chat .panel { position:absolute; inset:0; border:0; border-radius:0; box-shadow:none; }
  .toma-chat .chat { display:none; }
  .toma-chat .workspace.chat-open .sidebar { display:none; }
  .toma-chat .workspace.chat-open .chat { display:flex; }
  .toma-chat .mobile-back { display:inline-flex; border:0; }
  .toma-chat .side-head { padding:20px 20px 16px; }
  .toma-chat .messages { padding:12px; }
  .toma-chat .composer { padding:10px 12px max(10px,env(safe-area-inset-bottom)); }
  .toma-chat .message { max-width:75%; }
}
