/* Mobile conversation authority. Loaded last; desktop remains untouched. */
html:root.native-mobile {
  --chat-paper: #f4f1e9;
  --chat-bar: #f8f7f2;
  --chat-incoming: #ffffff;
  --chat-outgoing: #dcf8ce;
  --chat-ink: #161818;
  --chat-secondary: #616765;
  --chat-link: #176847;
  --chat-menu: #ffffff;
}
html:root.native-mobile[data-theme="dark"] {
  --chat-paper: #0b141a;
  --chat-bar: #18242b;
  --chat-incoming: #202d34;
  --chat-outgoing: #145c49;
  --chat-ink: #f1f5f3;
  --chat-secondary: #b6c6c1;
  --chat-link: #8ce6bf;
  --chat-menu: #26333a;
}
html:root.native-mobile body .conversation,
html:root.native-mobile body #overlay.message-actions-popover {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 760px) {
  html:root.native-mobile body .conversation {
    height: 100dvh !important;
    max-height: 100dvh !important;
    background: var(--chat-paper);
  }
  html:root.native-mobile body #app:has(#sidebar:not(.open)) #native-mobile-nav { display: none !important; }
  html:root.native-mobile body:has(#overlay.navigation-view:not(.hidden)) #native-mobile-nav { display: grid !important; }
}
html:root.native-mobile body .conversation > header {
  min-height: 64px;
  padding: 6px 12px 6px 6px;
  gap: 4px;
  border: 0;
  color: var(--chat-ink);
  background: var(--chat-bar);
}
html:root.native-mobile body .conversation > header #menu {
  width: 44px; height: 44px; flex: 0 0 44px;
  border: 0; background: transparent; color: var(--chat-ink);
}
html:root.native-mobile body #conversation-info-trigger { gap: 10px; min-width: 0; }
html:root.native-mobile body #active-avatar { width: 36px; height: 36px; min-width: 36px; font-size: 16px; }
html:root.native-mobile body #active-name { font-size: 17px; font-weight: 650 !important; letter-spacing: -.25px; color: var(--chat-ink); }
html:root.native-mobile body #active-subtitle { font-size: 12px; color: var(--chat-secondary); }
html:root.native-mobile body .conversation.direct-chat #active-subtitle { display: none; }
html:root.native-mobile body .conversation > header .actions {
  display: flex; align-items: center; flex: 0 0 auto; gap: 0; padding: 0 2px;
  border: 1px solid color-mix(in srgb, var(--chat-secondary) 22%, transparent);
  border-radius: 26px; background: var(--chat-incoming);
}
html:root.native-mobile body .conversation > header .actions button {
  display: grid; place-items: center; flex: 0 0 44px;
  width: 44px; height: 44px; padding: 0; margin: 0;
  border: 0; line-height: 1; background: transparent; color: var(--chat-ink);
}
html:root.native-mobile body .conversation > header .actions button .lucide,
html:root.native-mobile body #composer > button .lucide {
  display: block; width: 22px; height: 22px; margin: 0; padding: 0;
}
html:root.native-mobile body #inside-search { display: none; }
/* Search remains in conversation information and the chat list. */
html:root.native-mobile body .conversation .encryption {
  margin: 0; padding: 0 14px; min-height: 30px; font-size: 11px; line-height: 1.4;
  border: 0; border-bottom: 1px solid color-mix(in srgb, var(--chat-secondary) 12%, transparent);
  background: var(--chat-bar); color: var(--chat-secondary);
}
html:root.native-mobile body .conversation details.encryption summary { padding: 8px 0; cursor: pointer; }
html:root.native-mobile body .conversation details.encryption p { margin: 0; padding: 0 0 10px; font-size: 12px; }
html:root.native-mobile body #messages {
  padding: 12px 12px 16px; gap: 4px;
  background-color: var(--chat-paper);
  background-image: url("/assets/chat-pattern.svg");
  background-repeat: repeat; background-size: 280px 280px;
}
html:root.native-mobile body #messages .message {
  display: block; width: fit-content; max-width: 86%; min-width: 58px;
  margin: 0; padding: 7px 10px 6px;
  border: 0; border-radius: 17px 17px 17px 5px;
  background: var(--chat-incoming); color: var(--chat-ink);
  box-shadow: 0 1px 1px #0000000d;
  font-size: 17px; line-height: 1.32;
  overflow: visible; overflow-wrap: anywhere;
}
html:root.native-mobile body #messages .message::after { content: ""; display: table; clear: both; }
html:root.native-mobile body #messages .message.mine {
  background: var(--chat-outgoing); border-radius: 17px 17px 5px 17px;
}
html:root.native-mobile body #messages .message > p {
  display: inline; margin: 0; padding: 0; color: inherit;
  font-size: 17px; line-height: 1.32; white-space: pre-wrap;
}
html:root.native-mobile body #messages .message > strong { display: block; margin: 0 0 3px; font-size: 12px; color: var(--chat-link); }
html:root.native-mobile body .conversation.direct-chat #messages .message > strong { display: none; }
html:root.native-mobile body #messages .message-meta {
  display: inline-flex; float: right; width: auto; min-height: 18px; height: auto;
  margin: 5px 0 -1px 8px; padding: 0; gap: 3px;
  border: 0; background: transparent; color: var(--chat-secondary);
  font-size: 11px; line-height: 16px; font-weight: 400; white-space: nowrap;
}
html:root.native-mobile body #messages .receipt.read { color: #087daa; }
html:root.native-mobile[data-theme="dark"] body #messages .receipt.read { color: #72d5ff; }
html:root.native-mobile body #messages .message a { color: var(--chat-link); }
html:root.native-mobile body #messages .message-reaction-trigger { display: none; }
html:root.native-mobile body #messages .message-menu {
  opacity: 0; pointer-events: none; width: 32px; min-width: 32px; min-height: 32px;
}
html:root.native-mobile body #messages .message-menu:focus-visible { opacity: 1; pointer-events: auto; background: var(--chat-incoming); }
html:root.native-mobile body #messages .message .mobile-reaction-chips { clear: both; margin: 4px 0 -5px; }
html:root.native-mobile body #messages .message-day {
  align-self: center; margin: 12px 0 8px; padding: 3px 11px;
  border-radius: 10px; background: var(--chat-incoming); color: var(--chat-ink);
  font-size: 12px; line-height: 18px; font-weight: 600;
}
html:root.native-mobile body #messages .message.selected { outline: 2px solid var(--ui-accent); }
html:root.native-mobile body #messages .message .message-quoted-reply { display: block; width: 100%; margin: 0 0 5px; }
html:root.native-mobile body #messages .message :is(.message-news-card,.message-contact-card,.message-poll,.message-media) { max-width: 100%; }
html:root.native-mobile body #messages .message-scroll-controls { bottom: 150px; }
html:root.native-mobile body #messages-to-top { display: none; }
html:root.native-mobile body #composer {
  position: relative; display: grid; grid-template-columns: 44px 44px 44px minmax(0,1fr) 44px 44px;
  grid-template-rows: auto 44px; gap: 4px 2px; min-height: 100px;
  margin: 6px 10px calc(8px + env(safe-area-inset-bottom)); padding: 10px 8px 6px;
  border: 0; border-radius: 26px; background: var(--chat-incoming); color: var(--chat-ink);
}
html:root.native-mobile body #composer #message-input {
  grid-column: 1 / -1; grid-row: 1; width: 100%; min-height: 38px; max-height: 132px;
  margin: 0; padding: 4px 10px 8px; border: 0; border-radius: 0;
  background: transparent; color: var(--chat-ink); font-size: 17px; line-height: 1.4;
  box-shadow: none;
}
html:root.native-mobile body #composer #message-input::placeholder { color: var(--chat-secondary); }
html:root.native-mobile body #composer #message-input:focus-visible { outline: none; }
html:root.native-mobile body #composer > button {
  display: grid; place-items: center; grid-row: 2;
  width: 44px; height: 44px; margin: 0; padding: 0; line-height: 1;
  color: var(--chat-ink); background: transparent;
}
html:root.native-mobile body #composer #attach { grid-column: 1; }
html:root.native-mobile body #composer #emoji { grid-column: 2; }
html:root.native-mobile body #composer #composer-tools-toggle { grid-column: 3; }
html:root.native-mobile body #composer #composer-camera { grid-column: 5; }
html:root.native-mobile body #composer #composer-action,
html:root.native-mobile body #composer:not(.recording) #composer-action[aria-label="Send message"] {
  grid-column: 6; grid-row: 2; width: 44px; height: 44px;
  margin: 0; border: 0; border-radius: 50%; background: var(--chat-ink); color: var(--chat-incoming);
}
html:root.native-mobile body #composer #message-reply-preview {
  grid-column: 1 / -1; grid-row: 1; margin-bottom: 4px; padding: 6px 10px;
  background: color-mix(in srgb,var(--chat-outgoing) 45%,var(--chat-incoming));
  border-left: 3px solid var(--chat-link); border-radius: 10px; color: var(--chat-ink);
}
html:root.native-mobile body #composer #message-reply-preview strong { color: var(--chat-link); }
html:root.native-mobile body #composer #message-reply-preview button { background: transparent; color: var(--chat-secondary); }
html:root.native-mobile body #composer:has(#message-reply-preview:not(.hidden)) { grid-template-rows: auto auto 44px; }
html:root.native-mobile body #composer:has(#message-reply-preview:not(.hidden)) #message-input { grid-row: 2; }
html:root.native-mobile body #composer:has(#message-reply-preview:not(.hidden)) > button { grid-row: 3; }
html:root.native-mobile body #composer:has(#message-reply-preview:not(.hidden)) #composer-action { grid-row: 3; }
html:root.native-mobile body #composer #ai-write { display: none; }
html:root.native-mobile body #composer.recording #voice-recording { grid-row: 1 / 3; grid-column: 1 / 6; width: auto; }
html:root.native-mobile body #composer.recording > :is(#attach,#emoji,#composer-tools-toggle,#composer-camera,#message-input) { display: none; }
/* Compact long-press stack: reactions, selected message, then actions. */
html:root.native-mobile body #overlay.message-actions-popover {
  background: #11182030; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
html:root.native-mobile body #overlay.message-actions-popover .panel {
  position: fixed; display: block;
  left: var(--message-menu-left,12px) !important; right: auto !important;
  top: var(--message-menu-top,12px) !important; bottom: auto !important;
  width: var(--message-menu-width,320px); max-width: calc(100vw - 24px);
  max-height: var(--message-menu-height,calc(100dvh - 24px));
  margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  box-shadow: none; overflow: auto; scrollbar-width: none;
}
html:root.native-mobile body #overlay.message-actions-popover .panel > header { display: none !important; }
html:root.native-mobile body #overlay.message-actions-popover #panel-body {
  display: block; overflow: visible; max-height: none; padding: 0; background: transparent;
}
html:root.native-mobile body #overlay.message-actions-popover .message-actions-panel { padding: 0; background: transparent; }
html:root.native-mobile body #overlay.message-actions-popover .quick-reactions {
  display: flex; position: static;
  gap: 0; width: 100%; padding: 6px; margin: 0 0 10px;
  border: 0; border-radius: 30px; background: var(--chat-menu);
  box-shadow: 0 4px 20px #0000000a; overflow-x: auto; scrollbar-width: none;
}
html:root.native-mobile body #overlay.message-actions-popover .quick-reactions button {
  flex: 1 0 44px; width: auto; min-width: 44px; height: 44px; padding: 0; font-size: 27px; color: var(--chat-ink);
}
html:root.native-mobile body #overlay.message-actions-popover .mobile-message-preview {
  width: fit-content; max-width: 100%; max-height: 84px; overflow: auto;
  margin: 0 0 12px; padding: 8px 12px; border-radius: 18px;
  background: var(--chat-incoming); color: var(--chat-ink); font-size: 17px; line-height: 1.32;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
html:root.native-mobile body #overlay.message-actions-popover .mobile-message-preview.mine { margin-left: auto; background: var(--chat-outgoing); }
html:root.native-mobile body #overlay.message-actions-popover .mobile-message-preview small { float: right; margin: 6px 0 0 8px; color: var(--chat-secondary); font-size: 11px; }
html:root.native-mobile body #overlay.message-actions-popover .action-list {
  display: block; width: min(250px,100%); max-height: none;
  border: 0; border-radius: 24px; padding: 8px 0; overflow: hidden;
  background: var(--chat-menu); box-shadow: 0 8px 32px #00000012;
}
html:root.native-mobile body #overlay.message-actions-popover .message-actions-panel.mine .action-list { margin-left: auto; }
html:root.native-mobile body #overlay.message-actions-popover .action-list button {
  width: 100%; min-height: 44px; padding: 10px 20px; gap: 14px;
  border: 0; background: transparent; color: var(--chat-ink); font-size: 17px; line-height: 24px;
}
html:root.native-mobile body #overlay.message-actions-popover .action-list button strong { font-weight: 400; }
html:root.native-mobile body #overlay.message-actions-popover .action-list button .lucide { width: 21px; height: 21px; }
html:root.native-mobile body #overlay.message-actions-popover .action-list .action-divider { border-top: 0; }
html:root.native-mobile body #overlay.message-actions-popover .action-list [data-more-message-actions] {
  margin-top: 6px; padding-top: 14px; border-top: 1px solid color-mix(in srgb,var(--chat-secondary) 18%,transparent);
}
html:root.native-mobile body #overlay.message-actions-popover .mobile-more-actions[hidden] { display: none; }
html:root.native-mobile body #overlay.message-actions-popover .action-list .danger { color: #ba1735 !important; }
html:root.native-mobile[data-theme="dark"] body #overlay.message-actions-popover .action-list .danger { color: #ff9eb2 !important; }
@media (prefers-reduced-motion: reduce) {
  html:root.native-mobile body #messages .message { transition: none; }
}
