:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --border: #e2e6f0;
  --text: #14161c;
  --text-muted: #5b6172;
  --accent: #4c6fff;
  --accent-contrast: #ffffff;
  --bubble-user: #4c6fff;
  --bubble-user-text: #ffffff;
  --bubble-ai: #ffffff;
  --bubble-ai-text: #1b1e27;
  --ok: #1faa59;
  --warn: #e0a800;
  --danger: #e23d5b;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.06), 0 8px 24px rgba(20, 22, 28, 0.05);
  --radius: 18px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --border: #e2e6f0;
  --text: #14161c;
  --text-muted: #5b6172;
  --accent: #4c6fff;
  --accent-contrast: #ffffff;
  --bubble-user: #4c6fff;
  --bubble-user-text: #ffffff;
  --bubble-ai: #ffffff;
  --bubble-ai-text: #1b1e27;
  --ok: #1faa59;
  --warn: #b77900;
  --danger: #d72f50;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.06), 0 8px 24px rgba(20, 22, 28, 0.05);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1016;
  --surface: #171a22;
  --surface-2: #1e222c;
  --border: #2d3341;
  --text: #eef1f8;
  --text-muted: #aab1c3;
  --accent: #7b93ff;
  --accent-contrast: #ffffff;
  --bubble-user: #526fe8;
  --bubble-user-text: #ffffff;
  --bubble-ai: #1e222c;
  --bubble-ai-text: #eef1f8;
  --ok: #42cb79;
  --warn: #f0c04a;
  --danger: #ff6680;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #171a22;
    --surface-2: #1e222c;
    --border: #262b37;
    --text: #eef1f8;
    --text-muted: #9aa1b4;
    --accent: #6b86ff;
    --accent-contrast: #0e1016;
    --bubble-user: #4c6fff;
    --bubble-user-text: #ffffff;
    --bubble-ai: #1e222c;
    --bubble-ai-text: #eef1f8;
    --ok: #35c46f;
    --warn: #f0c04a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Naskh Arabic", Tahoma, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; }
button, .secondary-button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}
button:hover, .secondary-button:hover { filter: brightness(1.04); }
button:active, .secondary-button:active { transform: scale(0.97); }
button:focus-visible, .secondary-button:focus-visible,
input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(76, 111, 255, 0.22);
  outline-offset: 2px;
}
button:disabled, .secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}
button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

input, textarea {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 111, 255, 0.18);
}
textarea { resize: none; max-height: 140px; }

.wrap {
  width: min(100%, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* The same compact brand header used by the Android WebView. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark, .nova-orb {
  display: grid;
  place-items: center;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, var(--accent), #7a5cff);
  box-shadow: var(--shadow);
}
.brand__mark { width: 40px; height: 40px; border-radius: 12px; }
.brand__text { display: flex; flex-direction: column; }
.brand__title { font-size: 1.15rem; line-height: 1.25; letter-spacing: 0.3px; }
.brand__subtitle { color: var(--text-muted); font-size: 0.78rem; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.topbar-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.15rem;
}
.topbar-icon:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--accent)); filter: none; }
.mobile-only { display: none; }

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}
.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}
.connection.online .status__dot { background: var(--ok); }

/* Pairing and unlock use the app's centered security-sheet language. */
.gate {
  width: min(100%, 460px);
  margin: auto;
  padding: 28px 22px;
}
.hero { text-align: center; margin-bottom: 18px; }
.hero h1 { margin: 4px 0; font-size: 1.45rem; }
.hero p { margin: 0; color: var(--text-muted); }
.hero .eyebrow {
  margin-top: 14px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.nova-orb { width: 66px; height: 66px; margin: 0 auto; border-radius: 20px; }
.nova-orb.small { width: 42px; height: 42px; margin: 0; border-radius: 13px; }
.login-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.login-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}
.login-field input {
  width: 100%;
  direction: ltr;
  text-align: left;
}
.login-form button { margin-top: 4px; }
.login-form .warn { margin: 0; }
.first-login {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.first-login summary {
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}
.first-login[open] summary { margin-bottom: 10px; }
.first-login > .muted { margin: 0; }

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 1.15rem; }
.card button { width: 100%; margin-top: 14px; }
.muted { color: var(--text-muted); }
.warn { color: var(--warn); font-weight: 600; }
.mono {
  direction: ltr;
  text-align: left;
  color: var(--text-muted);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
}

/* The private area is one conversation surface with its people list beside it. */
.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  justify-content: center;
  min-height: 0;
  gap: 0;
  padding: 18px;
}
.people-pane {
  min-width: 0;
  min-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-inline-end: 0;
  border-radius: 0 20px 20px 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.people-pane__head {
  min-height: 65px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.people-pane__head h2 { margin: 0; font-size: 1.08rem; }
.people-pane__head p { margin: 2px 0 0; color: var(--text-muted); font-size: 0.78rem; }
.chat-panel { border-radius: 20px 0 0 20px; }

.panel {
  min-height: calc(100dvh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  box-shadow: var(--shadow);
  animation: rise 0.18s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 65px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.panel-head h2 { margin: 0; font-size: 1.08rem; }
.panel-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 0.78rem; }
.panel-head__actions { display: flex; align-items: center; gap: 8px; }
.panel-head__identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.panel-head__identity > div { min-width: 0; }
.panel-head__identity h2, .panel-head__identity p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.privacy-blur-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}
.privacy-blur-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}
#app-shell.privacy-obscured::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 12, 18, 0.56);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
#app-shell.privacy-obscured #privacy-blur-toggle {
  position: fixed;
  inset-block-start: calc(env(safe-area-inset-top, 0px) + 14px);
  inset-inline-end: 14px;
  z-index: 81;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
#ai-panel .panel-head { display: none; }

/* Message list and bubbles mirror Android exactly. */
.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 18px 16px 10px;
  list-style: none;
  scroll-behavior: smooth;
}
.ai-messages, .chat-messages { min-height: 360px; }
.message {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: var(--radius);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
  animation: rise 0.18s ease-out;
}
.message.ai, .message.in {
  align-self: flex-start;
  border: 1px solid var(--border);
  border-bottom-right-radius: 6px;
  background: var(--bubble-ai);
  color: var(--bubble-ai-text);
}
.message.user, .message.out {
  align-self: flex-end;
  border-bottom-left-radius: 6px;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
}
.message-body { margin: 0; }
.message-quote {
  display: block;
  margin-bottom: 7px;
  padding: 6px 9px;
  border-inline-start: 3px solid currentColor;
  border-radius: 7px;
  background: rgba(128, 128, 128, 0.13);
  font-size: 0.76rem;
  opacity: 0.82;
}
.message-sticker {
  display: grid;
  place-items: center;
  min-width: 118px;
  min-height: 92px;
  padding: 10px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(76, 111, 255, 0.18), rgba(139, 92, 246, 0.2));
  text-align: center;
}
.message-sticker b { display: block; font-size: 2.2rem; }
.message-sticker span { font-weight: 800; }
.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 5px;
  font-size: 0.66rem;
  opacity: 0.76;
}
.message-state.read { color: #67a4ff; opacity: 1; }
.message.failed { outline: 1px solid var(--danger); }
.message-actions { display: flex; gap: 5px; margin-top: 7px; }
.message-actions button, .message-retry {
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(128, 128, 128, 0.16);
  color: inherit;
  font-size: 0.67rem;
}
.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent);
  background: var(--surface-2);
}
.reply-preview div { min-width: 0; }
.reply-preview strong { display: block; color: var(--accent); font-size: 0.72rem; }
.reply-preview span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 0.76rem; }
.reply-preview button { padding: 3px 9px; border-radius: 999px; background: transparent; color: var(--text); font-size: 1.2rem; }

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer textarea {
  flex: 1;
  min-height: 46px;
  max-height: 132px;
  overflow-y: auto;
  line-height: 1.45;
}
.send-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  padding: 0;
  border-radius: 14px;
}
.send-button svg { transform: scaleX(-1); }
.composer-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 46px;
  flex: 0 0 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  touch-action: none;
}
.composer-icon:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--accent)); filter: none; }
.emoji-toggle { color: var(--accent); font-size: 1.55rem; font-weight: 400; }
.voice-record.recording { border-color: var(--danger); background: rgba(226, 61, 91, 0.12); color: var(--danger); }
.attachment-control { position: relative; flex: 0 0 auto; }
.attachment-menu {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 9px);
  z-index: 12;
  width: 190px;
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.attachment-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: start;
}
.attachment-menu button:hover { background: var(--surface-2); filter: none; }
.permission-onboarding {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 16, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.permission-card {
  width: min(100%, 560px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}
.permission-card h2 { margin: 0 0 5px; }
.permission-card > p { margin: 0 0 15px; }
.permission-list { display: grid; gap: 9px; }
.permission-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-align: start;
}
.permission-list button span { min-width: 0; }
.permission-list strong, .permission-list small { display: block; }
.permission-list small { margin-top: 2px; color: var(--text-muted); font-weight: 400; }
.permission-list b { flex: 0 0 auto; color: var(--accent); font-size: 0.78rem; }
.permission-list button[data-state="granted"] b { color: var(--ok); }
.permission-list button[data-state="declined"] b { color: var(--danger); }
.permission-finish { width: 100%; margin-top: 16px; }
.document-viewer {
  display: grid;
  gap: 6px;
  margin-top: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
}
.document-viewer__icon { font-size: 2rem; }
.pdf-viewer {
  width: min(82vw, 760px);
  height: min(68vh, 680px);
  margin-top: 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.emoji-picker {
  max-height: 250px;
  overflow-y: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.emoji-section + .emoji-section { margin-top: 9px; }
.emoji-section strong { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 0.75rem; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(32px, 1fr));
  gap: 3px;
}
.emoji-grid button {
  min-width: 0;
  padding: 5px 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 1.35rem;
}
.emoji-grid button:hover { background: var(--surface-2); filter: none; }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 6px;
}
.sticker-grid button {
  min-width: 0;
  padding: 8px 5px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(76, 111, 255, 0.12), rgba(139, 92, 246, 0.13));
  color: var(--text);
}
.sticker-grid b { display: block; font-size: 1.55rem; }
.sticker-grid span { display: block; margin-top: 2px; font-size: 0.68rem; }
.voice-recorder {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.voice-recorder > span { color: var(--text-muted); font-size: 0.78rem; }
.voice-recorder button { padding: 7px 10px; font-size: 0.76rem; }
.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: recording-pulse 1s ease-in-out infinite;
}
@keyframes recording-pulse { 50% { opacity: 0.35; } }

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 16px 14px;
  list-style: none;
}
.conversation-search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 12px 14px 0;
  padding-inline: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.conversation-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76, 111, 255, 0.14); }
.conversation-search input {
  width: 100%;
  min-height: 40px;
  padding: 7px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
}
.conversation-search-empty { margin: auto 14px; color: var(--text-muted); text-align: center; font-size: 0.82rem; }
.contact {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
}
.contact:hover { background: var(--surface-2); filter: none; }
.contact.active {
  border-color: rgba(76, 111, 255, 0.34);
  background: rgba(76, 111, 255, 0.12);
  box-shadow: inset -3px 0 0 var(--accent);
}
.contact.self { grid-template-columns: 28px minmax(0, 1fr); }
.contact.self .presence-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--accent-contrast);
  background: var(--accent);
  box-shadow: none;
  font-size: 0.76rem;
  font-weight: 800;
}
.presence-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(226, 61, 91, 0.12);
}
.presence-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(31, 170, 89, 0.14);
}
.contact-name { font-size: 0.92rem; font-weight: 700; }
.contact-meta { color: var(--text-muted); font-size: 0.78rem; }
.contact-name, .contact-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.private-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.private-actions button { min-width: 0; padding: 8px 10px; font-size: 0.78rem; }
.lock-mark {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ok);
  font-size: 0.72rem;
  white-space: nowrap;
}
.typing { margin: 10px 16px 0; color: var(--accent); font-size: 0.8rem; }
#conversation-line { margin: 10px 16px -4px; }

.secondary-button {
  min-width: 0;
  padding: 8px 11px;
  border-color: var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
}
.attachment-status {
  padding: 0 14px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: var(--surface);
  font-size: 0.72rem;
}
.attachment-card { min-width: min(320px, 70vw); display: grid; gap: 9px; }
.message-body + .attachment-card { margin-top: 9px; }
.attachment-details { display: grid; gap: 2px; }
.attachment-details strong { overflow-wrap: anywhere; }
.attachment-details small { color: inherit; font-size: 0.75rem; opacity: 0.75; }
.attachment-open, .attachment-download {
  display: block;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 28%, transparent);
  color: inherit;
  text-align: center;
  text-decoration: none;
}
.attachment-content:empty { display: none; }
.attachment-media {
  display: block;
  width: 100%;
  max-width: 440px;
  max-height: 360px;
  border-radius: 12px;
  background: #05070b;
}
.attachment-image { object-fit: contain; }

details { margin-block: 16px; color: var(--text-muted); }

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: calc(100% - 28px);
  margin: 0 auto 12px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.74rem;
}
.status-bar > span::before { content: "●"; margin-inline-end: 6px; color: var(--accent); }
.status { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacts-backdrop { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .wrap { width: 100%; }
  .connection { padding: 8px; }
  .connection__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .gate { padding: 24px 18px 96px; }
  .app-shell {
    display: block;
    min-height: calc(100dvh - 65px);
    padding: 0;
  }
  .people-pane {
    position: fixed;
    inset-block: 65px 0;
    inset-inline-start: 0;
    z-index: 60;
    width: min(88vw, 350px);
    min-height: 0;
    border-block-end: 0;
    border-inline-start: 0;
    border-radius: 0;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    transform: translateX(110%);
    transition: transform 0.2s ease;
  }
  .app-shell.conversations-open .people-pane { transform: translateX(0); }
  .contacts-backdrop {
    position: fixed;
    inset: 65px 0 0;
    z-index: 55;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(7, 9, 14, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .mobile-only { display: inline-grid; }
  .people-pane__head { min-height: 61px; padding: 10px 12px; }
  .people-pane__head h2 { font-size: 1rem; }
  .people-pane__head p { font-size: 0.72rem; }
  .conversation-search { margin: 10px 12px 0; }
  .contact-list { gap: 7px; padding: 10px 12px; }
  .contact { padding: 11px 12px; border-radius: 12px; }
  .private-actions { padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px); }
  .panel {
    min-height: calc(100dvh - 65px);
    border-block: 0;
    border-inline-end: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .panel-head { min-height: 61px; }
  .message { max-width: 88%; }
  .ai-messages, .chat-messages { min-height: 280px; }
  .status-bar { display: none; }
}

@media (max-width: 520px) {
  .composer { gap: 6px; padding: 8px; }
  .composer-icon { width: 39px; flex-basis: 39px; }
  .send-button { width: 43px; height: 43px; flex-basis: 43px; }
  .emoji-grid { grid-template-columns: repeat(6, minmax(30px, 1fr)); }
  .sticker-grid { grid-template-columns: repeat(2, minmax(72px, 1fr)); }
  .voice-recorder { grid-template-columns: auto auto minmax(0, 1fr); }
  .voice-recorder button { grid-row: 2; }
  #voice-stop { grid-column: 2; }
  #voice-delete { grid-column: 3; justify-self: end; }
}

@media (max-width: 420px) {
  .brand__title { font-size: 1rem; }
  .brand__subtitle { font-size: 0.72rem; }
  .panel-head { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}


/* Public NOVA assistant: the private product is absent from this surface. */
body.public-mode { background: var(--surface); }
body.public-mode .wrap { width: 100%; }
body.public-mode .topbar {
  position: fixed;
  inset: 0 0 auto;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 0;
  box-shadow: none;
}
body.public-mode .brand__subtitle { display: none; }
.ai-landing { flex: 1; width: 100%; min-height: 100dvh; }
.public-ai {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100dvh;
  background: var(--surface);
}
.public-ai__heading {
  min-height: 68px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 22px 12px;
  text-align: center;
  font-size: 1rem;
}
.public-ai__conversation {
  position: relative;
  width: min(100%, 800px);
  min-height: 0;
  margin: 0 auto;
}
.public-ai__empty {
  position: absolute;
  inset: 12% 20px auto;
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}
.public-ai__empty h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 600;
}
.public-ai .ai-messages {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 24px 20px 32px;
}
.public-ai .message {
  width: 100%;
  max-width: 100%;
  padding: 12px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.public-ai .message.user {
  width: fit-content;
  max-width: 82%;
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--text);
}
.public-ai .message.ai { align-self: stretch; color: var(--text); }
.public-ai__composer-wrap {
  position: sticky;
  bottom: 0;
  z-index: 5;
  width: min(calc(100% - 28px), 800px);
  margin: 0 auto;
  padding: 10px 0 calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: linear-gradient(transparent, var(--surface) 18%);
}
.public-ai__composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 9px 10px 9px 16px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 4px 24px rgba(20, 22, 28, 0.1);
}
.public-ai__composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 180px;
  padding: 10px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.public-ai__composer .send-button {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
}
.public-ai__note {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
}
@media (max-width: 760px) {
  body.public-mode .topbar { padding-inline: 12px; }
  body.public-mode .brand__mark { width: 36px; height: 36px; }
  .public-ai__heading { min-height: 62px; }
  .public-ai__conversation { width: 100%; }
  .public-ai .ai-messages { padding-inline: 16px; }
  .public-ai__empty { inset-block-start: 18%; }
}

.message-played { color: #53bdeb; display: inline-flex; }
.message-played svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

.archive-dialog { width:min(620px,calc(100vw - 32px)); max-height:85dvh; overflow:auto; border-radius:16px; border:1px solid #adb5bd; padding:24px; background:var(--surface,#fff); color:var(--text,#18212d); line-height:1.8; }
.archive-dialog::backdrop {background:#0009;}
.archive-actions {display:flex;gap:10px;flex-wrap:wrap;}
.archive-dialog button {min-height:42px;padding:8px 14px;cursor:pointer;}
#conversation-archive {font-size:12px;white-space:nowrap;}
