:root {
  color-scheme: light;
  --bg: #edf1f6;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --ink: #141b2d;
  --muted: #667085;
  --border: #d9e0ea;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e8f5f3;
  --sent: #0f766e;
  --received: #ffffff;
  --auth-bg: #f7f5f0;
  --auth-card: rgba(255, 255, 255, 0.84);
  --auth-card-solid: #ffffff;
  --auth-ink: #111827;
  --auth-muted: #6b7280;
  --auth-line: rgba(17, 24, 39, 0.1);
  --glass-surface: rgba(255, 255, 255, 0.64);
  --glass-panel: rgba(255, 255, 255, 0.48);
  --glass-control: rgba(255, 255, 255, 0.56);
  --glass-border: rgba(255, 255, 255, 0.58);
  --glass-highlight: rgba(255, 255, 255, 0.86);
  --app-background:
    linear-gradient(135deg, #eef7f4 0%, #f7fbff 48%, #f7f0ea 100%);
  --messages-glass: rgba(255, 255, 255, 0.24);
  --shadow: 0 18px 50px rgba(20, 27, 45, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1117;
  --surface: #151922;
  --surface-muted: #10141d;
  --ink: #eef2f7;
  --muted: #98a2b3;
  --border: #28303d;
  --accent: #14b8a6;
  --accent-strong: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.12);
  --sent: #0f766e;
  --received: #171c25;
  --auth-bg: #0c1017;
  --auth-card: rgba(20, 24, 32, 0.82);
  --auth-card-solid: #151922;
  --auth-ink: #f8fafc;
  --auth-muted: #98a2b3;
  --auth-line: rgba(248, 250, 252, 0.12);
  --glass-surface: rgba(16, 20, 28, 0.7);
  --glass-panel: rgba(18, 23, 32, 0.48);
  --glass-control: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-highlight: rgba(255, 255, 255, 0.18);
  --app-background:
    linear-gradient(135deg, #111827 0%, #0e1726 52%, #15151f 100%);
  --messages-glass: rgba(6, 9, 15, 0.16);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

html[data-background="lagoon"] {
  --app-background:
    linear-gradient(135deg, #e8f7f4 0%, #eaf3ff 44%, #edf8e7 100%);
}

html[data-background="dawn"] {
  --app-background:
    linear-gradient(135deg, #f8f2ec 0%, #f5f8ff 46%, #edf7f1 100%);
}

html[data-background="graphite"] {
  --app-background:
    linear-gradient(135deg, #1a2230 0%, #101722 48%, #24212c 100%);
}

html[data-theme="dark"][data-background="mist"] {
  --app-background:
    linear-gradient(135deg, #131d24 0%, #0f1720 52%, #1b1a22 100%);
}

html[data-theme="dark"][data-background="lagoon"] {
  --app-background:
    linear-gradient(135deg, #0d2021 0%, #101a2a 52%, #142216 100%);
}

html[data-theme="dark"][data-background="dawn"] {
  --app-background:
    linear-gradient(135deg, #251d1a 0%, #111827 52%, #182119 100%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--app-background);
  background-attachment: fixed;
  color: var(--ink);
  transition:
    background 520ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 420ms ease;
}

html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 420ms ease,
    background 420ms ease,
    border-color 420ms ease,
    box-shadow 420ms ease,
    color 420ms ease,
    fill 420ms ease,
    opacity 420ms ease;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 520ms;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: 2px;
}

.boot-status {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 9999;
  padding: 12px 14px;
  border: 1px solid #b7c7e8;
  border-radius: 12px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.12);
}

.boot-status-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
  width: min(1440px, calc(100vw - 24px));
  height: min(920px, calc(100vh - 24px));
  min-height: 620px;
  margin: 12px auto;
}

.sidebar,
.chat {
  border: 1px solid rgba(221, 227, 238, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 10px;
  overflow: hidden;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #141b2d;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

.brand-block h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand-block p,
.chat-header p,
.profile-row small,
.auth-dialog p,
.typing-line {
  color: var(--muted);
}

.brand-block p {
  margin-top: 4px;
  font-size: 13px;
}

.panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #394154;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: #344054;
}

.icon-button:hover,
.ghost-button:hover {
  background: #eef3ff;
}

.profile-row,
.user-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-row strong,
.user-list strong {
  display: block;
  overflow: hidden;
  max-width: 190px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.user-list small {
  color: var(--muted);
}

.network-panel {
  margin-top: auto;
}

.conversation-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
}

.conversation-button,
.contact-button {
  display: grid;
  grid-template-columns: 24px 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #172033;
  text-align: left;
}

.conversation-button {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

.conversation-button:hover,
.contact-button:hover,
.conversation-button.active,
.contact-button.active {
  border-color: #bfe3de;
  background: var(--accent-soft);
}

.conversation-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #172033;
  color: #ffffff;
  font-weight: 800;
}

.contact-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  max-height: 330px;
  overflow: auto;
}

.conversation-search {
  margin-bottom: 2px;
}

.conversation-search input {
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: var(--surface-muted);
  color: var(--ink);
}

.conversation-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}

.presence-dot.online {
  background: #16a34a;
}

.avatar.compact {
  width: 34px;
  height: 34px;
}

.group-avatar {
  background: #7c3aed;
}

.contact-copy {
  min-width: 0;
}

.contact-copy strong,
.contact-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-copy small {
  color: var(--muted);
  font-size: 12px;
}

.contact-security {
  margin-top: 2px;
  color: #8490a3;
}

.contact-empty {
  padding: 18px 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.request-list,
.search-results,
.member-picker,
.member-list,
.admin-user-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.request-item,
.search-row,
.member-row,
.admin-user-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.request-item button,
.search-row button,
.admin-user-row button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.request-item button:last-child {
  background: #e8edf5;
  color: #344054;
}

.search-row button:disabled {
  cursor: not-allowed;
  background: #e8edf5;
  color: #667085;
}

.unread-pill {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
}

.address {
  overflow-wrap: anywhere;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border-radius: 10px;
  overflow: hidden;
}

.chat-header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.mobile-menu-button {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #344054;
  font-size: 20px;
}

.header-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #141b2d;
  color: #ffffff;
  font-weight: 900;
}

.chat-heading {
  min-width: 0;
}

.chat-header h2 {
  font-size: 21px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header p {
  margin-top: 5px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #bfd8d5;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.privacy-badge.public {
  border-color: #d7deea;
  background: #f6f8fb;
  color: #475467;
}

.privacy-badge.secure {
  border-color: #bfd8d5;
  background: #e8f5f3;
  color: #0b5f59;
}

.ghost-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px;
  overflow: auto;
  background:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.72)),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.08), transparent 38%);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(420px, 100%);
  margin: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 17px;
}

.empty-state span {
  max-width: 340px;
  font-size: 13px;
  line-height: 1.5;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #141b2d;
  color: #ffffff;
  font-weight: 900;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: min(76%, 680px);
}

.message-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.system {
  align-self: center;
  max-width: 90%;
}

.message-avatar,
.user-avatar,
.header-avatar,
#profileAvatar {
  cursor: pointer;
}

.message-highlight .bubble {
  animation: quotePulse 1200ms ease;
}

.bubble {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 5px;
  background: var(--received);
  line-height: 1.45;
  box-shadow: 0 7px 18px rgba(23, 32, 51, 0.06);
}

.mine .bubble {
  border-color: transparent;
  border-radius: 16px 16px 5px 16px;
  background: var(--sent);
  color: #ffffff;
}

.system .bubble {
  border: 0;
  border-radius: 999px;
  background: rgba(23, 32, 51, 0.08);
  color: #526071;
  font-size: 12px;
  box-shadow: none;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-quote,
.quote-preview {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-left: 3px solid rgba(20, 184, 166, 0.68);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--ink);
}

.mine .message-quote {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.message-quote {
  margin-bottom: 7px;
  cursor: pointer;
}

.message-quote strong,
.quote-preview strong {
  font-size: 12px;
}

.message-quote span,
.quote-preview span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mine .message-quote span {
  color: rgba(255, 255, 255, 0.78);
}

.quote-preview {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.quote-preview[hidden] {
  display: none;
}

.quote-preview > div {
  min-width: 0;
}

.quote-preview span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes quotePulse {
  0%,
  100% {
    box-shadow: 0 7px 18px rgba(23, 32, 51, 0.06);
  }

  35% {
    box-shadow:
      0 0 0 3px rgba(20, 184, 166, 0.3),
      0 18px 42px rgba(15, 118, 110, 0.2);
  }
}

.mine .message-meta {
  color: rgba(255, 255, 255, 0.78);
}

.secure-label {
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 11px;
  opacity: 0.8;
}

.message-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.revoked-text {
  color: var(--muted);
  font-style: italic;
}

.mine .revoked-text {
  color: rgba(255, 255, 255, 0.78);
}

.message-action {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.82;
}

.secure-failed {
  color: #b42318;
}

.mine .secure-failed {
  color: #ffe4e6;
}

.media-block {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.media-block img,
.media-block video {
  display: block;
  width: min(360px, 100%);
  max-height: 360px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(23, 32, 51, 0.08);
}

.media-block audio {
  width: min(320px, 100%);
}

.file-card {
  display: grid;
  gap: 3px;
  min-width: min(300px, 100%);
  padding: 10px;
  border-radius: 8px;
  background: rgba(23, 32, 51, 0.06);
  color: inherit;
  text-decoration: none;
}

button.file-card {
  border: 0;
  cursor: pointer;
  text-align: left;
}

.mine .file-card {
  background: rgba(255, 255, 255, 0.16);
}

.file-card strong,
.file-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card small {
  opacity: 0.72;
}

.typing-line {
  min-height: 24px;
  padding: 0 22px 4px;
  font-size: 13px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
}

.composer-row {
  display: grid;
  grid-template-columns: 44px 44px minmax(0, 1fr) 88px;
  gap: 10px;
}

.composer textarea {
  width: 100%;
  max-height: 136px;
  min-height: 44px;
  resize: none;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  line-height: 1.4;
}

.attach-button {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 24px;
  font-weight: 500;
}

.attach-button:hover {
  background: #eef3ff;
}

.attach-button:disabled,
.composer textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: #344054;
  font-size: 13px;
}

.attachment-preview[hidden] {
  display: none;
}

.voice-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass-panel);
  color: var(--ink);
  backdrop-filter: blur(18px) saturate(1.25);
}

.voice-panel[hidden] {
  display: none;
}

.voice-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 900;
}

.voice-transcript-live {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-transcript {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.1);
}

.voice-button {
  font-size: 18px;
}

.avatar-editor {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.avatar-preview {
  width: 64px;
  height: 64px;
  font-size: 20px;
}

.avatar-editor input {
  min-height: 38px;
  padding-top: 8px;
}

.avatar-editor .ghost-button {
  margin-top: 8px;
}

.user-profile-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.user-profile-avatar {
  width: 68px;
  height: 68px;
  font-size: 22px;
}

.user-profile-card h2 {
  margin-bottom: 2px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-meta span {
  padding: 5px 8px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass-control);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.profile-bio {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--ink);
  line-height: 1.45;
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-choice {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 800;
}

.attachment-preview button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #ffffff;
  color: #344054;
}

.composer textarea:focus,
.auth-dialog input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.composer button[type="submit"],
.auth-dialog button[type="submit"] {
  min-height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.composer button[type="submit"]:hover,
.auth-dialog button[type="submit"]:hover {
  background: var(--accent-strong);
}

.composer button[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow);
}

.wide-dialog {
  width: min(680px, calc(100vw - 32px));
}

.auth-dialog.is-open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 10;
  height: fit-content;
  margin: auto;
  background: #ffffff;
}

.auth-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(4px);
}

#authDialog.auth-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border-radius: 0;
  background:
    linear-gradient(115deg, transparent 0 54%, rgba(15, 118, 110, 0.045) 54% 100%),
    var(--auth-bg);
  box-shadow: none;
  overflow: hidden;
}

#authDialog.auth-dialog[open],
#authDialog.auth-dialog.is-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: center;
  padding: clamp(18px, 4vw, 64px);
}

#authDialog.auth-dialog::backdrop {
  background: transparent;
  backdrop-filter: none;
}

.auth-art {
  position: relative;
  min-height: min(560px, 72vh);
}

.auth-art::before,
.auth-art::after {
  content: "";
  position: absolute;
  inset: 16% auto auto 16%;
  width: min(44vw, 620px);
  aspect-ratio: 1;
  border: 1px solid var(--auth-line);
  border-radius: 50%;
  animation: authDrift 12s ease-in-out infinite alternate;
}

.auth-art::after {
  inset: 28% auto auto 27%;
  width: min(25vw, 340px);
  border-color: rgba(15, 118, 110, 0.18);
  animation-duration: 9s;
}

.auth-line-mark {
  position: absolute;
  left: min(16vw, 220px);
  top: 50%;
  width: 142px;
  height: 142px;
  transform: translateY(-50%);
}

.auth-line-mark span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--auth-line);
  border-radius: 50%;
  animation: authPulse 4.5s ease-in-out infinite;
}

.auth-line-mark span:nth-child(2) {
  inset: 22px;
  animation-delay: 600ms;
}

.auth-line-mark span:nth-child(3) {
  inset: 52px;
  border-radius: 8px;
  transform: rotate(45deg);
  animation-delay: 1200ms;
}

#authDialog .auth-card {
  position: relative;
  z-index: 1;
  justify-self: end;
  display: grid;
  gap: 11px;
  width: min(340px, calc(100vw - 42px));
  margin-right: clamp(0px, 5vw, 82px);
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 10px;
  background: var(--auth-card);
  color: var(--auth-ink);
  box-shadow:
    0 24px 70px rgba(17, 24, 39, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(22px);
  animation: authCardIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.auth-card-top,
.auth-brand {
  display: flex;
  align-items: center;
}

.auth-card-top {
  justify-content: space-between;
  gap: 12px;
}

.auth-brand {
  gap: 9px;
  color: var(--auth-ink);
  font-size: 15px;
}

.auth-welcome {
  margin: 4px 0 1px;
  color: var(--auth-ink);
  font-size: 24px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: 0;
}

.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

html[data-theme="dark"] .auth-brand-mark {
  background: #f8fafc;
  color: #111827;
}

.theme-toggle-button {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.36);
  color: var(--auth-ink);
  font-size: 15px;
}

html[data-theme="dark"] .theme-toggle-button {
  background: rgba(255, 255, 255, 0.06);
}

#authDialog .auth-switch {
  margin: 2px 0 4px;
}

#authDialog .auth-mode {
  min-height: 32px;
}

#authDialog .auth-notice {
  min-height: 18px;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.35;
}

#authDialog .auth-notice.error {
  color: #b42318;
}

html[data-theme="dark"] #authDialog .auth-notice.error {
  color: #fecaca;
}

#authDialog.auth-dialog label {
  color: var(--auth-ink);
  font-size: 12px;
}

#authDialog.auth-dialog input {
  min-height: 39px;
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.58);
  color: var(--auth-ink);
}

html[data-theme="dark"] #authDialog.auth-dialog input {
  background: rgba(255, 255, 255, 0.055);
}

.captcha-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.captcha-code-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-height: 39px;
  padding: 0 9px 0 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.08), transparent 42%),
    rgba(255, 255, 255, 0.46);
  color: var(--auth-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.captcha-code-card::after {
  content: "";
  position: absolute;
  inset: -60% auto -60% -42%;
  width: 36px;
  transform: rotate(18deg);
  background: rgba(255, 255, 255, 0.35);
  animation: captchaSweep 3.2s ease-in-out infinite;
}

.captcha-code-card span {
  position: relative;
  z-index: 1;
}

html[data-theme="dark"] .captcha-code-card {
  background:
    linear-gradient(120deg, rgba(20, 184, 166, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.055);
}

#authDialog .dialog-actions {
  margin-top: 4px;
}

#authDialog #authSubmitButton {
  width: 100%;
  min-height: 40px;
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateX(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes authDrift {
  from {
    transform: translate3d(-8px, 4px, 0) scale(0.98);
  }
  to {
    transform: translate3d(12px, -8px, 0) scale(1.02);
  }
}

@keyframes authPulse {
  0%,
  100% {
    opacity: 0.48;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.03);
  }
}

@keyframes captchaSweep {
  0%,
  48% {
    transform: translateX(0) rotate(18deg);
    opacity: 0;
  }
  62% {
    opacity: 1;
  }
  100% {
    transform: translateX(190px) rotate(18deg);
    opacity: 0;
  }
}

.auth-dialog form {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.auth-dialog h2 {
  font-size: 22px;
}

.auth-dialog label {
  font-size: 13px;
  font-weight: 800;
  color: #344054;
}

.auth-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.auth-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.auth-mode {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: #475467;
  font-weight: 800;
}

.auth-mode.active {
  background: #ffffff;
  color: #172033;
  box-shadow: 0 1px 5px rgba(23, 32, 51, 0.12);
}

.auth-field {
  display: grid;
  gap: 12px;
}

.dialog-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.settings-list {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--ink);
  text-align: left;
}

.settings-row strong,
.settings-row small {
  display: block;
}

.settings-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.field-title {
  font-size: 13px;
  font-weight: 800;
  color: #344054;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.member-option {
  display: grid;
  grid-template-columns: auto 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  font-weight: 700;
}

.member-option input {
  min-height: auto;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-grid div {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.stat-grid strong {
  font-size: 22px;
}

.stat-grid span {
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.split-actions {
  align-items: center;
  justify-content: flex-start;
}

.dialog-spacer {
  flex: 1 1 auto;
}

.danger-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b42318;
  font-size: 13px;
  font-weight: 800;
}

.danger-button:hover {
  background: #fee2e2;
}

.auth-dialog button[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.sidebar-overlay {
  display: none;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .chat {
  border-color: rgba(40, 48, 61, 0.94);
  background: rgba(21, 25, 34, 0.94);
}

html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .conversation-mark,
html[data-theme="dark"] .header-avatar,
html[data-theme="dark"] .empty-mark {
  background: #f8fafc;
  color: #111827;
}

html[data-theme="dark"] .panel-title,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .ghost-button,
html[data-theme="dark"] .mobile-menu-button,
html[data-theme="dark"] .attach-button,
html[data-theme="dark"] .address,
html[data-theme="dark"] .contact-button,
html[data-theme="dark"] .conversation-button {
  color: var(--ink);
}

html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .ghost-button,
html[data-theme="dark"] .mobile-menu-button,
html[data-theme="dark"] .attach-button,
html[data-theme="dark"] .attachment-preview button {
  background: var(--surface-muted);
}

html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .ghost-button:hover,
html[data-theme="dark"] .attach-button:hover {
  background: rgba(20, 184, 166, 0.14);
}

html[data-theme="dark"] .conversation-button:hover,
html[data-theme="dark"] .contact-button:hover,
html[data-theme="dark"] .conversation-button.active,
html[data-theme="dark"] .contact-button.active {
  border-color: rgba(20, 184, 166, 0.32);
  background: rgba(20, 184, 166, 0.12);
}

html[data-theme="dark"] .presence-dot {
  background: #475467;
}

html[data-theme="dark"] .contact-security {
  color: #7f8ea3;
}

html[data-theme="dark"] .request-item,
html[data-theme="dark"] .search-row,
html[data-theme="dark"] .member-row,
html[data-theme="dark"] .admin-user-row,
html[data-theme="dark"] .member-option,
html[data-theme="dark"] .stat-grid div,
html[data-theme="dark"] .address {
  background: var(--surface-muted);
}

html[data-theme="dark"] .request-item button:last-child,
html[data-theme="dark"] .search-row button:disabled {
  background: #202734;
  color: var(--muted);
}

html[data-theme="dark"] .chat-header {
  background: rgba(21, 25, 34, 0.78);
}

html[data-theme="dark"] .privacy-badge.public {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--muted);
}

html[data-theme="dark"] .privacy-badge.secure {
  border-color: rgba(20, 184, 166, 0.32);
  background: rgba(20, 184, 166, 0.12);
  color: var(--accent-strong);
}

html[data-theme="dark"] .messages {
  background:
    linear-gradient(rgba(14, 17, 23, 0.72), rgba(14, 17, 23, 0.72)),
    radial-gradient(circle at top right, rgba(20, 184, 166, 0.1), transparent 38%);
}

html[data-theme="dark"] .empty-state {
  background: rgba(21, 25, 34, 0.78);
}

html[data-theme="dark"] .bubble {
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .system .bubble,
html[data-theme="dark"] .media-block img,
html[data-theme="dark"] .media-block video,
html[data-theme="dark"] .file-card {
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .composer {
  background: rgba(21, 25, 34, 0.92);
}

html[data-theme="dark"] .composer textarea,
html[data-theme="dark"] .auth-dialog:not(#authDialog) input {
  background: var(--surface-muted);
  color: var(--ink);
}

html[data-theme="dark"] .attachment-preview {
  background: var(--surface-muted);
  color: var(--ink);
}

html[data-theme="dark"] .auth-dialog:not(#authDialog),
html[data-theme="dark"] .auth-dialog.is-open:not(#authDialog) {
  background: var(--surface);
  color: var(--ink);
}

html[data-theme="dark"] .auth-dialog:not(#authDialog)::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

html[data-theme="dark"] .auth-dialog:not(#authDialog) label,
html[data-theme="dark"] .field-title,
html[data-theme="dark"] .auth-mode,
html[data-theme="dark"] .dialog-hint {
  color: var(--ink);
}

html[data-theme="dark"] .auth-mode.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .danger-button {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.28);
  color: #fecaca;
}

/* Liquid glass app shell */
.shell {
  transition:
    grid-template-columns 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    gap 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sidebar,
.chat,
.panel,
.auth-dialog:not(#authDialog),
.empty-state,
.composer {
  border-color: var(--glass-border);
  background: var(--glass-surface);
  box-shadow:
    0 22px 70px rgba(15, 23, 42, 0.14),
    inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(28px) saturate(1.35);
}

.sidebar {
  min-width: 0;
  transition:
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 220ms ease,
    padding 260ms ease,
    border-width 260ms ease;
}

body.sidebar-collapsed .shell {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
}

body.sidebar-collapsed .sidebar {
  padding-inline: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-28px) scale(0.98);
}

.panel,
.conversation-search input,
.request-item,
.search-row,
.member-row,
.member-option,
.admin-user-row,
.settings-row,
.stat-grid div,
.attachment-preview,
.auth-switch {
  background: var(--glass-panel);
  border-color: var(--glass-border);
}

.chat {
  min-width: 0;
  background: rgba(255, 255, 255, 0.42);
}

html[data-theme="dark"] .chat {
  background: rgba(14, 17, 23, 0.52);
}

.chat-header,
.composer {
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(24px) saturate(1.35);
}

html[data-theme="dark"] .chat-header,
html[data-theme="dark"] .composer {
  background: rgba(15, 20, 28, 0.38);
}

.messages {
  background:
    linear-gradient(180deg, var(--messages-glass), transparent 48%),
    transparent;
}

.mobile-menu-button {
  display: grid;
}

.icon-button,
.ghost-button,
.mobile-menu-button,
.attach-button,
.conversation-button,
.contact-button,
.request-item button,
.search-row button,
.admin-user-row button,
.danger-button,
.composer button[type="submit"],
.auth-dialog button[type="submit"],
.auth-mode,
.background-choice,
.theme-choice,
.captcha-code-card {
  border: 1px solid var(--glass-border);
  background: var(--glass-control);
  color: var(--ink);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition:
    transform 170ms ease,
    background 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    color 220ms ease;
}

.icon-button:hover,
.ghost-button:hover,
.mobile-menu-button:hover,
.attach-button:hover,
.conversation-button:hover,
.contact-button:hover,
.background-choice:hover,
.theme-choice:hover,
.captcha-code-card:hover {
  background: color-mix(in srgb, var(--glass-control) 62%, var(--accent-soft));
  transform: translateY(-1px);
}

button:active {
  transform: scale(0.985);
}

.conversation-button.active,
.contact-button.active,
.auth-mode.active,
.theme-choice.active,
.background-choice.active {
  border-color: rgba(20, 184, 166, 0.34);
  background: color-mix(in srgb, var(--glass-control) 58%, var(--accent-soft));
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 10px 24px rgba(15, 118, 110, 0.12);
}

.bubble {
  border-color: var(--glass-border);
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    0 14px 34px rgba(15, 23, 42, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(22px) saturate(1.35);
}

html[data-theme="dark"] .bubble {
  background: rgba(19, 24, 34, 0.66);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mine .bubble {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.92), rgba(37, 99, 235, 0.82));
  box-shadow:
    0 16px 38px rgba(15, 118, 110, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.system .bubble {
  background: rgba(255, 255, 255, 0.36);
}

html[data-theme="dark"] .system .bubble {
  background: rgba(255, 255, 255, 0.08);
}

.composer textarea,
.auth-dialog:not(#authDialog) input {
  background: rgba(255, 255, 255, 0.52);
  border-color: var(--glass-border);
  color: var(--ink);
}

html[data-theme="dark"] .composer textarea,
html[data-theme="dark"] .auth-dialog:not(#authDialog) input {
  background: rgba(255, 255, 255, 0.08);
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.background-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.background-choice {
  display: grid;
  gap: 8px;
  justify-items: start;
  min-height: 116px;
  padding: 10px;
  border-radius: 8px;
  text-align: left;
}

.background-choice strong {
  font-size: 13px;
}

.background-swatch {
  display: block;
  width: 100%;
  aspect-ratio: 1.4;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.swatch-mist {
  background: linear-gradient(135deg, #eef7f4, #f7fbff 50%, #f7f0ea);
}

.swatch-lagoon {
  background: linear-gradient(135deg, #e8f7f4, #eaf3ff 48%, #edf8e7);
}

.swatch-dawn {
  background: linear-gradient(135deg, #f8f2ec, #f5f8ff 46%, #edf7f1);
}

.swatch-graphite {
  background: linear-gradient(135deg, #1a2230, #101722 48%, #24212c);
}

.context-menu {
  position: fixed;
  z-index: 80;
  display: grid;
  gap: 4px;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow:
    0 18px 44px rgba(15, 23, 42, 0.2),
    inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(26px) saturate(1.4);
}

.context-menu button {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  font-weight: 750;
}

.context-menu button:hover {
  background: var(--accent-soft);
}

.context-menu button.danger {
  color: #b42318;
}

html[data-theme="dark"] .context-menu button.danger {
  color: #fecaca;
}

.composer button[type="submit"],
.auth-dialog button[type="submit"] {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.96), rgba(37, 99, 235, 0.86));
  color: #ffffff;
}

@media (max-width: 820px) {
  body {
    background: var(--app-background);
  }

  .shell {
    grid-template-columns: 1fr;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    gap: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: min(340px, calc(100vw - 48px));
    border-radius: 0;
    transform: translateX(-104%);
    transition: transform 180ms ease;
  }

  body.sidebar-collapsed .shell {
    grid-template-columns: 1fr;
    gap: 0;
  }

  body.sidebar-collapsed .sidebar {
    padding: 16px;
    border-width: 1px;
    opacity: 1;
    transform: translateX(-104%);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(3px);
  }

  .sidebar-overlay[hidden] {
    display: none;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .chat {
    border: 0;
    border-radius: 0;
  }

  .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr);
    padding: 12px;
  }

  .mobile-menu-button {
    display: grid;
  }

  .header-avatar {
    width: 38px;
    height: 38px;
  }

  .chat-header h2 {
    font-size: 18px;
  }

  .header-actions {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .background-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ghost-button {
    min-height: 34px;
    max-width: 116px;
    white-space: normal;
  }

  .messages {
    padding: 16px;
  }

  .message-row {
    max-width: 88%;
  }

  .composer {
    padding: 10px;
  }

  .composer-row {
    grid-template-columns: 40px 40px minmax(0, 1fr) 72px;
    gap: 8px;
  }

  .attach-button {
    width: 40px;
    min-height: 42px;
  }

  .voice-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .voice-transcript-live {
    font-size: 12px;
  }

  .voice-panel button {
    min-height: 36px;
    padding-inline: 10px;
    white-space: nowrap;
  }

  #authDialog.auth-dialog[open],
  #authDialog.auth-dialog.is-open {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 22px;
  }

  .auth-art {
    position: absolute;
    inset: 0;
    min-height: 0;
    opacity: 0.62;
  }

  .auth-line-mark {
    left: 42px;
    top: 22%;
  }

  #authDialog .auth-card {
    justify-self: center;
    margin-right: 0;
  }
}

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