/* Keep release status clear of the composer and its send/attachment actions. */
:root {
  --vot-release-notice-top: calc(64px + var(--vot-spacing-md));
  --vot-release-notice-bottom: auto;
}

:root {
  color-scheme: light;
  font-family: var(--vot-font-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  color: var(--vot-text);
  background: var(--vot-surface);

  /* Semantic aliases mapping Votex local variables to shared design tokens */
  --surface: var(--vot-surface);
  --surface-soft: var(--vot-surface-container);
  --surface-strong: var(--vot-surface-container-high);

  --text: var(--vot-text);
  --muted: var(--vot-muted);
  --outline: var(--vot-outline);
  --outline-variant: var(--vot-outline-variant, color-mix(in srgb, var(--outline) 45%, transparent));
  --outline-subtle: var(--vot-outline-subtle, color-mix(in srgb, var(--outline) 22%, transparent));

  --primary: var(--vot-primary);
  --on-primary: var(--vot-on-primary);
  --primary-strong: var(--vot-primary-hover);
  --primary-soft: var(--vot-primary-container);
  --on-primary-soft: var(--vot-on-primary-container);

  --danger: var(--vot-error);
  --danger-soft: var(--vot-error-container);

  --shadow: 0 12px 32px var(--vot-shadow);
}

html[data-theme="light"],
html[data-vot-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"],
html[data-vot-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-width: 280px;
  overflow: hidden;
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 38%, transparent);
  outline-offset: 2px;
}

/* Inline SVG glyphs inherit the button's color and stay optically centered. */
.icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  transition: background 150ms ease;
}

.icon-button:hover {
  background: var(--surface-strong);
}

.brand-mark-art {
  display: block;
  width: 100%;
  height: 100%;
}

.application-bootstrap {
  display: grid;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
  background: var(--surface);
}

.application-landing {
  box-sizing: border-box;
  height: 100dvh;
  overflow-y: auto;
  min-height: 0;
  padding: var(--vot-spacing-lg);
  align-content: start;
  padding-block-start: clamp(24px, 10dvh, 96px);
}

.application-landing-title {
  max-width: 24ch;
  margin: 0;
  color: var(--text);
  text-align: center;
  font: var(--vot-type-headline-medium);
  overflow-wrap: anywhere;
}

.application-landing-actions {
  width: min(100%, 360px);
  flex-direction: column;
}

.application-landing-actions .application-bootstrap-action {
  width: 100%;
  min-height: 48px;
}

.application-bootstrap-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.application-bootstrap-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

#votex-startup-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#votex-app {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.application-mark {
  width: 56px;
  height: 56px;
}

.application-bootstrap-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: application-bootstrap-spin 800ms linear infinite;
}

@keyframes application-bootstrap-spin {
  to {
    transform: rotate(1turn);
  }
}

@media (prefers-reduced-motion: reduce) {
  .application-bootstrap-spinner {
    animation-duration: 1.6s;
  }
}

.application-bootstrap-message {
  max-width: min(320px, calc(100vw - 40px));
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
}

.application-bootstrap-error {
  max-width: min(360px, calc(100vw - 40px));
  margin: 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  color: var(--danger);
}

.application-bootstrap-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.application-bootstrap-action {
  min-height: 40px;
  padding: 8px 22px;
  border: 0;
  border-radius: var(--vot-radius-full, 9999px);
  color: var(--on-primary);
  background: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}

.application-bootstrap-action:hover {
  background: var(--primary-strong);
}

.application-bootstrap-action.secondary {
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--outline-subtle);
}

.application-bootstrap-action.secondary:hover {
  background: var(--surface-strong);
}

.votex-root {
  --rail: 72px;
  --sidebar: 360px;

  /* Chat-specific tokens mapped from shared Living Paper tokens */
  --surface-selected: var(--md-sys-color-secondary-container);
  --bubble: var(--surface-soft);
  --outgoing: var(--primary);
  --on-outgoing: var(--on-primary);
  --link-incoming: var(--primary-strong);
  --link-incoming-hover: var(--primary-strong);
  --link-outgoing: var(--on-primary);
  --link-outgoing-hover: var(--on-outgoing);
  --online: #3fba69;
  /* Avatar fallback palette: separate tokens keep identity colors stable
     while allowing dark mode to use brighter mid-tones. */
  --avatar-bg-0: #e9e0ff;
  --avatar-fg-0: #332541;
  --avatar-bg-1: #dbe7ff;
  --avatar-fg-1: #17315f;
  --avatar-bg-2: #d7f0e8;
  --avatar-fg-2: #164b3d;
  --avatar-bg-3: #f8e2cf;
  --avatar-fg-3: #5a2d10;
  --avatar-bg-4: #f3ddec;
  --avatar-fg-4: #5d214d;
  --avatar-bg-5: #e5e0ff;
  --avatar-fg-5: #342669;
  --avatar-bg-6: #f1eac9;
  --avatar-fg-6: #51400c;
  --avatar-bg-7: #d8ebdc;
  --avatar-fg-7: #1f4a2b;
  --avatar-group-bg: var(--primary);
  --avatar-group-fg: var(--on-primary);

  display: grid;
  position: fixed;
  top: var(--visual-viewport-top, 0px);
  right: 0;
  left: 0;
  grid-template-columns: var(--rail) minmax(0, var(--sidebar)) 12px minmax(0, 1fr);
  padding: 12px 12px 12px 0;
  /* Content belongs to the panes' scrollports, not the implicit grid row. */
  grid-template-rows: minmax(0, 1fr);
  height: var(--visual-viewport-height, 100dvh);
  /* The off-canvas mobile pane must never make the shell itself scrollable. */
  overflow: clip;
  color: var(--text);
  background: var(--surface-soft);
  transition:
    color 180ms ease,
    background 180ms ease;
}

[data-theme="dark"] .votex-root,
[data-vot-theme="dark"] .votex-root,
.votex-root.dark {
  --online: #57d67e;
  /* Dark-mode avatar colors are intentionally independent from light mode. */
  --avatar-bg-0: #5c4a7c;
  --avatar-fg-0: #fff;
  --avatar-bg-1: #405985;
  --avatar-fg-1: #fff;
  --avatar-bg-2: #3d6258;
  --avatar-fg-2: #fff;
  --avatar-bg-3: #806342;
  --avatar-fg-3: #fff;
  --avatar-bg-4: #76526d;
  --avatar-fg-4: #fff;
  --avatar-bg-5: #62578e;
  --avatar-fg-5: #fff;
  --avatar-bg-6: #766b3d;
  --avatar-fg-6: #fff;
  --avatar-bg-7: #4e7558;
  --avatar-fg-7: #fff;
  --avatar-group-bg: var(--primary);
  --avatar-group-fg: var(--on-primary);
}

/* Embedded Plugin Surface Mode (PR4) */
.votex-embedded-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  transition:
    color 180ms ease,
    background 180ms ease;

  /* Inherit chat token variables mapped from shared tokens */
  --surface-selected: var(--md-sys-color-secondary-container);
  --bubble: var(--surface-soft);
  --outgoing: var(--primary);
  --on-outgoing: var(--on-primary);
  --link-incoming: var(--primary-strong);
  --link-incoming-hover: var(--primary-strong);
  --link-outgoing: var(--on-primary);
  --link-outgoing-hover: var(--on-outgoing);
  --online: #3fba69;
  --avatar-bg-0: #e9e0ff;
  --avatar-fg-0: #332541;
  --avatar-bg-1: #dbe7ff;
  --avatar-fg-1: #17315f;
  --avatar-bg-2: #d7f0e8;
  --avatar-fg-2: #164b3d;
  --avatar-bg-3: #f8e2cf;
  --avatar-fg-3: #5a2d10;
  --avatar-bg-4: #f3ddec;
  --avatar-fg-4: #5d214d;
  --avatar-bg-5: #e5e0ff;
  --avatar-fg-5: #342669;
  --avatar-bg-6: #f1eac9;
  --avatar-fg-6: #51400c;
  --avatar-bg-7: #d8ebdc;
  --avatar-fg-7: #1f4a2b;
  --avatar-group-bg: var(--primary);
  --avatar-group-fg: var(--on-primary);
}

[data-theme="dark"] .votex-embedded-root,
[data-vot-theme="dark"] .votex-embedded-root,
.votex-embedded-root.dark {
  --online: #57d67e;
  --avatar-bg-0: #5c4a7c;
  --avatar-fg-0: #fff;
  --avatar-bg-1: #405985;
  --avatar-fg-1: #fff;
  --avatar-bg-2: #3d6258;
  --avatar-fg-2: #fff;
  --avatar-bg-3: #806342;
  --avatar-fg-3: #fff;
  --avatar-bg-4: #76526d;
  --avatar-fg-4: #fff;
  --avatar-bg-5: #62578e;
  --avatar-fg-5: #fff;
  --avatar-bg-6: #766b3d;
  --avatar-fg-6: #fff;
  --avatar-bg-7: #4e7558;
  --avatar-fg-7: #fff;
  --avatar-group-bg: var(--primary);
  --avatar-group-fg: var(--on-primary);
}

.conversation-panel.embedded {
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.conversation-header.embedded {
  min-height: 60px;
  padding: 8px 16px;
}

.embedded-surface-state {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 24px;
}

.discussion-access-status {
  margin: 0;
  padding: 12px 16px;
  color: var(--vot-muted);
  background: var(--surface-soft);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.discussion-access-status .mobile-back { place-items: center; }

.embedded-state-card {
  max-width: 420px;
  width: 100%;
  padding: 20px;
  text-align: center;
  display: grid;
  gap: 8px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--outline);
}

.embedded-state-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.embedded-state-message {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.embedded-room-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
}

.embedded-room-container[hidden] {
  display: none;
}

.embedded-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 8px 16px 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 15%, var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--outline));
  color: var(--text);
  font-size: 13px;
  animation: banner-slide-in 150ms ease-out;
}

.embedded-error-banner .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--danger);
}

.embedded-error-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.embedded-error-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
}

.embedded-error-close:hover {
  color: var(--text);
  background: var(--surface-strong);
}

@keyframes banner-slide-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.navigation-rail {
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  background: transparent;
}

.nav-brand {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
}

.rail-button {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  color: var(--muted);
  background: transparent;
  transition:
    color 150ms ease,
    background 150ms ease;
}

.rail-button:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.rail-button.active {
  color: var(--on-primary-soft);
  background: var(--primary-soft);
}

.rail-spacer {
  flex: 1;
}

.rail-account {
  position: relative;
  display: flex;
}

.rail-avatar {
  display: grid;
  padding: 4px;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  transition: background 150ms ease;
}

.rail-avatar:hover,
.rail-avatar.active {
  background: var(--primary-soft);
}

/* Transparent, full-viewport click target that dismisses the popover. */
.account-menu-scrim {
  position: fixed;
  z-index: 18;
  inset: 0;
  cursor: default;
  background: transparent;
}

.account-menu {
  position: absolute;
  z-index: 19;
  bottom: 0;
  left: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  width: 260px;
  max-height: min(440px, calc(var(--visual-viewport-height, 100dvh) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--outline-subtle);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  animation: menu-in 140ms ease-out;
}

.account-menu > * {
  flex-shrink: 0;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.account-identity {
  display: flex;
  width: 100%;
  min-width: 0;
  margin-bottom: 6px;
  padding: 6px 8px 12px;
  gap: 11px;
  align-items: center;
  border-bottom: 1px solid var(--outline-subtle);
  color: var(--text);
  background: transparent;
  text-align: left;
  border-radius: 12px;
}

.account-identity:hover {
  background: var(--surface-soft);
}

.account-identity-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.account-identity-copy strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-identity-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu-item {
  display: flex;
  width: 100%;
  gap: 11px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: background 150ms ease;
}

.account-menu-item:hover {
  background: var(--surface-soft);
}

.account-menu-item.destructive {
  color: var(--danger);
}

.account-menu-item.destructive:hover {
  background: var(--danger-soft);
}

.account-language-setting {
  display: grid;
  gap: 7px;
  padding: 9px 10px 10px;
  margin-top: 2px;
  border-top: 1px solid var(--outline-subtle);
}

.account-language-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.account-language-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.account-language-option {
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--outline-subtle);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 650;
}

.account-language-option:hover,
.account-language-option.active {
  border-color: var(--primary);
  color: var(--on-primary-soft);
  background: var(--primary-soft);
}

.account-language-option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.chat-list-panel {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-radius: var(--vot-radius-xl);
  overflow: hidden;
  background: var(--surface);
}

.chat-search-row,
.chat-search-scope,
.filter-chips {
  flex-shrink: 0;
}

.chat-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 12px;
}

/* Keep search scope secondary to conversation content. */
.chat-search-scope {
  margin: 0;
  padding: 0 18px 12px;
  color: var(--muted);
  font-size: 12px;
}

.search-field {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 22px;
  background: var(--primary-soft);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.search-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.search-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--primary-strong);
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 15px;
}

.search-field input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.avatar {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  overflow: visible;
  aspect-ratio: 1;
  border-radius: 50%;
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  background: var(--surface-strong);
}

.avatar-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: inherit;
  color: var(--avatar-fg-0);
  background: var(--avatar-bg-0);
  font-size: 0.9em;
  font-weight: 750;
}

.avatar-small {
  width: 40px;
  height: 40px;
}

.avatar-medium {
  width: 50px;
  height: 50px;
}

.avatar-profile {
  width: 88px;
  height: 88px;
  font-size: 1.45rem;
}

.group-avatar-fallback {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--avatar-group-fg);
  background: var(--avatar-group-bg);
}

.group-avatar-fallback-medium {
  width: 50px;
  height: 50px;
}

.group-avatar-fallback-profile {
  width: 88px;
  height: 88px;
}

.group-avatar-fallback .icon {
  width: 56%;
  height: 56%;
}

.avatar-tone-0 .avatar-fallback { background: var(--avatar-bg-0); color: var(--avatar-fg-0); }
.avatar-tone-1 .avatar-fallback { background: var(--avatar-bg-1); color: var(--avatar-fg-1); }
.avatar-tone-2 .avatar-fallback { background: var(--avatar-bg-2); color: var(--avatar-fg-2); }
.avatar-tone-3 .avatar-fallback { background: var(--avatar-bg-3); color: var(--avatar-fg-3); }
.avatar-tone-4 .avatar-fallback { background: var(--avatar-bg-4); color: var(--avatar-fg-4); }
.avatar-tone-5 .avatar-fallback { background: var(--avatar-bg-5); color: var(--avatar-fg-5); }
.avatar-tone-6 .avatar-fallback { background: var(--avatar-bg-6); color: var(--avatar-fg-6); }
.avatar-tone-7 .avatar-fallback { background: var(--avatar-bg-7); color: var(--avatar-fg-7); }

.presence {
  position: absolute;
  right: -1px;
  bottom: 1px;
  width: 13px;
  height: 13px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--outline) 35%, transparent);
  transition: background-color 160ms ease, opacity 160ms ease;
}

.presence.online {
  background: var(--online);
}

.filter-chips {
  display: flex;
  gap: 8px;
  padding: 4px 18px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-invitations {
  display: grid;
  gap: 8px;
  padding: 0 16px 12px;
}

.chat-invitations h2 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-invitation-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.chat-invitation-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.chat-invitation-copy strong,
.chat-invitation-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chat-invitation-card .secondary-button {
  min-height: 36px;
  padding-inline: 12px;
  font-size: 12px;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 99px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  transition:
    color 150ms ease,
    background 150ms ease;
}

.filter-chip:hover {
  color: var(--text);
}

.filter-chip.active {
  color: var(--on-primary-soft);
  background: var(--primary-soft);
}

.chat-list {
  min-height: 0;
  flex: 1;
  /* Invitations and joined rooms share the remaining height. A separate
     invitation pane can starve the list and compress filters on short screens. */
  padding: 2px 0 96px;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  scrollbar-color: var(--surface-strong) transparent;
}

.chat-list-items {
  padding-inline: 10px;
}

.chat-list-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  width: 100%;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--vot-radius-lg);
  color: var(--text);
  background: transparent;
  transition: background 150ms ease;
}

.chat-list-select {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  color: inherit;
  background: transparent;
  text-align: left;
}

.chat-profile-button {
  padding: 0;
  border-radius: 50%;
  background: transparent;
}

.chat-profile-button:hover .avatar-fallback,
.chat-profile-button:hover .avatar img {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

.chat-list-item:hover {
  background: var(--surface-soft);
}

.chat-list-item.selected {
  color: var(--md-sys-color-on-secondary-container);
  background: var(--surface-selected);
}

.chat-list-item.unread .chat-item-copy strong,
.chat-list-item.unread .chat-item-copy small,
.chat-list-item.unread .chat-item-meta time {
  color: var(--text);
  font-weight: 750;
}

.chat-item-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.chat-item-copy strong {
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-item.selected .chat-group-summary {
  color: var(--md-sys-color-on-secondary-container);
}

.chat-group-summary {
  overflow: hidden;
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-meta {
  display: grid;
  gap: 7px;
  justify-items: end;
}

.chat-item-meta time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.unread-indicator {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 99px;
}

.unread-indicator > span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.empty-list {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 48px 24px;
  margin: auto 0;
  color: var(--muted);
  text-align: center;
}

.empty-list strong {
  color: var(--text);
  font-size: 16px;
}

.empty-list small {
  max-width: 34ch;
  line-height: 1.5;
}

.new-chat-fab {
  position: absolute;
  right: 20px;
  bottom: 20px;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 18px;
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: var(--shadow);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

.new-chat-fab .icon {
  width: 26px;
  height: 26px;
}

.new-chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px color-mix(in srgb, var(--primary) 28%, transparent);
}

.conversation-panel {
  display: flex;
  min-height: 0;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

@media (min-width: 901px) {
  .votex-root > .conversation-panel {
    border-radius: var(--vot-radius-xl);
  }
}

.sidebar-resize-handle {
  position: relative;
  align-self: stretch;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.sidebar-resize-handle::after {
  content: "";
  position: absolute;
  top: calc(50% - 24px);
  left: calc(50% - 1.5px);
  width: 3px;
  height: 48px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0;
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.dragging::after,
.sidebar-resize-handle:focus-visible::after {
  opacity: 1;
}

.sidebar-resize-handle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 6px;
}

.managed-project-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vot-spacing-sm);
  padding: var(--vot-spacing-sm) var(--vot-spacing-md);
  background: var(--vot-surface-container-low);
  color: var(--vot-on-surface-variant);
  font: var(--md-sys-typescale-body-small);
}
.managed-project-title { flex: 1 1 8rem; overflow-wrap: anywhere; }
.managed-project-context .secondary-button {
  display: inline-flex;
  align-items: center;
  white-space: normal;
  height: auto;
  min-height: 44px;
  max-width: 100%;
  text-align: start;
}

.conversation-empty-state {
  display: grid;
  flex: 1;
  place-items: center;
  padding: 24px;
  color: var(--text);
  text-align: center;
}

.conversation-empty-state span {
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 16px;
  font-weight: 650;
}

.conversation-header {
  position: relative;
  z-index: 4;
  display: flex;
  min-height: 74px;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
}

.mobile-back {
  display: none;
  margin-left: -6px;
}

.conversation-title {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.conversation-title strong {
  overflow: hidden;
  font-size: 17px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.conversation-title small.pending {
  color: var(--primary-strong);
}

.conversation-title small:not(.pending),
.profile-presence {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-presence {
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .presence {
    transition: none;
  }
}

.message-feed {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  padding: 20px clamp(14px, 4vw, 52px) 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: var(--surface-strong) transparent;
}

.message-feed-content {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 16px;
  min-width: 0;
}

.jump-to-latest {
  align-self: center;
  flex-shrink: 0;
  margin: 4px 12px;
  min-height: 44px;
  max-width: calc(100% - 24px);
  white-space: normal;
}

.history-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 4px 0 12px;
}

.group-intro {
  display: grid;
  max-width: 620px;
  gap: 10px;
  align-items: center;
  justify-items: center;
  padding: 10px 8px 24px;
  margin: 0 auto;
  border-bottom: 1px solid var(--outline);
  animation: group-intro-enter 200ms ease-out;
}

@keyframes group-intro-enter {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.group-intro-copy {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.group-intro-copy strong,
.group-intro-copy small,
.group-intro-copy p {
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-intro-copy strong {
  font-size: 18px;
  font-weight: 700;
}

.group-intro-copy small {
  color: var(--muted);
  font-size: 13px;
}

.group-intro-copy p {
  display: -webkit-box;
  max-width: 44ch;
  margin: 3px 0 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.45;
}

.group-intro-action {
  min-height: 40px;
  padding-inline: 14px;
  white-space: nowrap;
}

.message-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 42px 24px;
  margin: auto 0;
  color: var(--muted);
  text-align: center;
}

.message-state > .icon {
  width: 24px;
  height: 24px;
  color: var(--primary-strong);
}

.message-state strong {
  color: var(--text);
  font-size: 16px;
}

.message-state small {
  max-width: 34ch;
  line-height: 1.5;
}

.message-loading-line {
  display: block;
  width: min(360px, 72vw);
  height: 13px;
  border-radius: 999px;
  background: var(--surface-strong);
  animation: message-loading-pulse 1.2s ease-in-out infinite alternate;
}

.message-loading-line-wide {
  width: min(480px, 82vw);
}

.message-loading-line-short {
  width: min(220px, 52vw);
}

@keyframes message-loading-pulse {
  from { opacity: 0.45; }
  to { opacity: 0.9; }
}

.history-inline-error {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--error, var(--primary-strong));
  font-size: 12px;
  font-weight: 650;
}

.history-inline-error .icon {
  width: 16px;
  height: 16px;
}

.history-loading {
  color: var(--muted);
  font-size: 12px;
}

.history-button {
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  transition:
    color 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.history-button:hover:not(:disabled) {
  border-color: var(--primary-soft);
  color: var(--primary-strong);
  background: var(--surface-soft);
}

.history-button:disabled {
  cursor: default;
  opacity: 0.68;
}

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-divider::before,
.day-divider::after {
  height: 1px;
  flex: 1;
  background: var(--outline-subtle);
  content: "";
}

.message-row {
  display: flex;
  min-width: 0;
  max-width: min(78%, 650px);
  gap: 10px;
  align-self: flex-start;
  align-items: flex-start;
}

.message-profile-button {
  padding: 0;
  border-radius: 50%;
  background: transparent;
}

.message-profile-button:hover .avatar-fallback,
.message-profile-button:hover .avatar img {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

.message-row.outgoing {
  align-self: flex-end;
}

.message-stack {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 5px;
}

.message-sender {
  padding-left: 9px;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 750;
}

.bubble {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 9px 24px 24px;
  color: var(--text);
  background: var(--bubble);
}

.outgoing .bubble {
  border-radius: 24px 9px 24px 24px;
  color: var(--on-outgoing);
  background: var(--outgoing);
}

.text-bubble {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  padding: 12px 15px 9px;
}

.text-bubble p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(15px, 1.6vw, 17px);
  line-height: 1.45;
}

.bubble .message-link {
  color: var(--link-incoming);
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.16em;
  text-decoration-skip-ink: auto;
  border-radius: 3px;
  transition: color 120ms ease, text-decoration-thickness 120ms ease;
}

.outgoing .bubble .message-link {
  color: var(--link-outgoing);
}

.bubble .message-link:visited {
  color: var(--link-incoming);
}

.outgoing .bubble .message-link:visited {
  color: var(--link-outgoing);
}

.bubble .message-link:hover {
  color: var(--link-incoming-hover);
  text-decoration-thickness: 2px;
}

.outgoing .bubble .message-link:hover {
  color: var(--link-outgoing-hover);
}

.bubble .message-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.image-bubble {
  display: grid;
  width: min(100%, 460px);
}

.image-preview-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: inherit;
  background: color-mix(in srgb, currentColor 12%, transparent);
  cursor: zoom-in;
}

.image-preview-placeholder {
  display: grid;
  width: min(100%, 460px);
  min-height: 72px;
  max-height: min(56vh, 420px);
  place-items: center;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
}

.image-preview-placeholder img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(56vh, 420px);
  object-fit: contain;
  background: var(--surface-strong);
}

.image-bubble-meta {
  display: flex;
  justify-content: flex-end;
  padding: 4px 8px 6px;
  font: var(--vot-type-label-small);
  color: var(--muted);
}

.outgoing .image-bubble-meta {
  color: var(--on-outgoing);
}

.file-bubble {
  display: grid;
  gap: var(--vot-spacing-sm);
  align-items: start;
  min-width: min(100%, 280px);
  padding: 12px 14px;
}

.file-download {
  display: grid;
  min-width: 0;
  gap: 3px;
  color: inherit;
  text-decoration: none;
}

.file-download:hover .file-name { text-decoration: underline; }
.file-download[aria-disabled="true"] { pointer-events: none; opacity: .6; }
.file-name { overflow-wrap: anywhere; font-weight: 650; }
.file-meta { color: var(--muted); font: var(--vot-type-body-small); }
.outgoing .file-meta { color: var(--on-outgoing); }

.image-viewer-scrim {
  position: fixed;
  z-index: 24;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.image-viewer {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  width: min(100%, 1180px);
  height: min(100%, 860px);
  place-items: center;
}

.image-viewer > img {
  display: block;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-viewer:has(.gallery-viewer-controls) {
  padding-bottom: calc(var(--vot-spacing-2xl) + var(--vot-spacing-md));
}

.image-viewer-close {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 12px;
  color: var(--text);
  background: var(--surface);
}

.bubble time {
  flex: 0 0 auto;
  color: var(--muted);
  font: var(--vot-type-label-small);
  white-space: nowrap;
}

.outgoing .bubble time {
  color: var(--on-outgoing);
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin: 0 24px max(16px, env(safe-area-inset-bottom));
  padding: 8px;
  border-radius: var(--vot-radius-xl);
  background: var(--surface-strong);
}

.composer:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.composer-send-failed {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 18px;
  color: var(--text);
  background: var(--surface-strong);
  font: var(--vot-type-body-medium);
}

.composer-send-failed > span {
  flex: 1 1 180px;
}

.composer-send-failed button {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 20px;
  color: var(--on-primary-soft);
  background: var(--primary-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.composer-send-failed button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.composer-attachments {
  display: grid;
  max-height: 176px;
  grid-template-columns: repeat(auto-fill, minmax(72px, 84px));
  grid-auto-rows: 84px;
  gap: 8px;
  min-width: 0;
  padding: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.composer-attachment {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--outline) 78%, transparent);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 8%, transparent);
}

.composer-attachment img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer-file-attachment {
  grid-column: span 2;
}

.composer-image-placeholder {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(110deg, transparent 25%, color-mix(in srgb, var(--surface) 34%, transparent) 46%, transparent 67%),
    var(--surface-strong);
  background-size: 220% 100%;
  animation: composer-preview-shimmer 1.3s ease-in-out infinite;
}

.composer-image-placeholder-mark {
  width: 28px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--muted) 34%, transparent);
  border-radius: 9px;
  opacity: .64;
}

.composer-image-placeholder-mark::before,
.composer-image-placeholder-mark::after {
  display: block;
  content: "";
}

.composer-image-placeholder-mark::before {
  width: 7px;
  height: 7px;
  margin: 5px 0 0 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 62%, transparent);
}

.composer-image-placeholder-mark::after {
  width: 18px;
  height: 8px;
  margin: 3px 0 0 4px;
  border-radius: 7px 7px 3px 3px;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  transform: skewY(-24deg);
}

@keyframes composer-preview-shimmer {
  to { background-position: -120% 0; }
}

.composer-file-summary {
  display: flex;
  min-width: 0;
  gap: 9px;
  align-items: center;
  padding: 10px 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 58%, var(--surface-strong));
}

.composer-file-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--on-primary-soft);
  background: var(--primary-soft);
}

.composer-file-icon .icon { width: 18px; height: 18px; }

.composer-file-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

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

.composer-file-copy strong {
  font-size: 12px;
  font-weight: 650;
}

.composer-file-copy small {
  color: var(--muted);
  font-size: 11px;
}

.composer-attachment-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 56%, transparent);
}

.composer-attachment-progress::after {
  width: 24px;
  height: 24px;
  border: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  content: "";
  animation: composer-attachment-spin 800ms linear infinite;
}

@keyframes composer-attachment-spin {
  to {
    transform: rotate(1turn);
  }
}

.composer-attachment-failed {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 2px;
  align-content: center;
  justify-items: center;
  padding: 6px;
  color: var(--text);
  background: color-mix(in srgb, var(--danger) 75%, var(--surface));
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
}

.composer-attachment-failed > span:first-child {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  color: var(--danger);
  background: var(--surface);
  font-weight: 700;
}

.composer-attachment-retry {
  min-height: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-size: 11px;
}

.composer-attachment-remove {
  position: absolute;
  z-index: 3;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  border: 1px solid color-mix(in srgb, var(--surface) 68%, transparent);
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 2px 7px color-mix(in srgb, var(--text) 20%, transparent);
}

.composer-attachment-remove:hover:not(:disabled) {
  color: var(--on-primary);
  background: var(--primary);
}

.composer-attachment-remove:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.composer-attachment-preparing {
  min-width: 72px;
  background:
    linear-gradient(110deg, transparent 25%, color-mix(in srgb, var(--surface) 34%, transparent) 46%, transparent 67%),
    var(--surface-strong);
  background-size: 220% 100%;
  animation: composer-preview-shimmer 1.3s ease-in-out infinite;
}

.image-button {
  position: relative;
}

.image-button.disabled {
  cursor: default;
  opacity: 0.48;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.composer-button,
.send-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary-strong);
  background: transparent;
  transition:
    transform 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

.composer-button:hover:not(:disabled) {
  background: var(--surface-strong);
}

.composer textarea {
  width: 100%;
  max-height: min(160px, 28dvh);
  min-height: 44px;
  resize: none;
  padding: 10px 8px 7px;
  overflow-y: auto;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
  line-height: 1.4;
}

.composer-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
}

.composer-toolbar-spacer {
  flex: 1;
}

.composer-send-progress {
  width: 20px;
  height: 20px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: composer-attachment-spin 800ms linear infinite;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.emoji-picker {
  position: absolute;
  z-index: 12;
  bottom: calc(100% + 10px);
  left: 0;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  max-height: min(360px, calc(var(--visual-viewport-height, 100dvh) - 128px));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--outline);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.emoji-picker-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.emoji-picker-tabs::-webkit-scrollbar {
  display: none;
}

.emoji-category-button,
.emoji-picker-close,
.emoji-option {
  display: grid;
  border-radius: 12px;
  background: transparent;
}

.emoji-category-button,
.emoji-picker-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 17px;
}

.emoji-category-button:hover,
.emoji-category-button.active,
.emoji-picker-close:hover {
  background: var(--surface-strong);
}

.emoji-picker-close {
  margin-left: auto;
  color: var(--muted);
  font-family: inherit;
  font-size: 22px;
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  min-height: 0;
  max-height: min(248px, calc(var(--visual-viewport-height, 100dvh) - 210px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.emoji-option {
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 23px;
}

.emoji-option:hover {
  background: var(--primary-soft);
}

.send-button {
  color: var(--on-primary);
  background: var(--primary);
}

.send-button:not(:disabled):hover {
  transform: scale(1.05);
}

.send-button:disabled[aria-busy="true"] {
  opacity: 1;
}

.send-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.votex-toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  display: flex;
  max-width: min(390px, calc(100vw - 48px));
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--outline);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
}

.notice-shell {
  display: grid;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
  color: var(--text);
  background: var(--surface-soft);
}

.notice-card {
  display: grid;
  width: min(100%, 420px);
  gap: 18px;
  padding: 32px;
  border: 1px solid var(--outline);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.notice-copy h1 {
  margin: 0;
  font-size: 24px;
}

.room-action-card h2 {
  margin: 0;
  font: var(--vot-type-headline-small);
}

.notice-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.room-action-card label {
  display: grid;
  gap: var(--vot-spacing-sm);
  color: var(--vot-text);
  font: var(--vot-type-label-large);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 750;
}

.primary-button {
  color: var(--on-primary);
  background: var(--primary);
}

.secondary-button {
  color: var(--on-primary-soft);
  background: var(--primary-soft);
}

.danger-button {
  color: var(--danger);
  background: var(--danger-soft);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.composer-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.room-action-card {
  display: grid;
  width: min(500px, calc(100vw - 32px));

  gap: var(--vot-spacing-md);

  overflow-y: auto;
}

.room-action-card header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

/* One field contract for all three tasks; label sits outside the input surface. */
.room-action-panel {
  display: grid;
  gap: var(--vot-spacing-sm);
  align-content: start;
}

.room-action-panel small {
  color: var(--vot-muted);
  font: var(--vot-type-body-small);
}

.user-search-field {
  display: grid;
  min-width: 0;
  gap: var(--vot-spacing-sm);
  color: var(--vot-text);
  font: var(--vot-type-label-large);
}

.room-action-tabs.m3-segmented-tabs [role="tab"] {
  flex: 1 1 0;
  min-width: 0;
  white-space: normal;
}

.room-action-tabs.m3-segmented-tabs [role="tab"][aria-selected="true"] {
  color: var(--vot-on-primary);
  background: var(--vot-primary);
}

.room-action-submit {
  display: flex;
  justify-content: flex-end;
}

.room-action-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.room-action-submit button {
  min-width: 112px;
}

.room-details-card {
  display: grid;
  width: min(100%, 480px);

  gap: var(--vot-spacing-lg);

  overflow-y: auto;

  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 46%, transparent) transparent;
}

.room-details-card::-webkit-scrollbar {
  width: 7px;
}

.room-details-card::-webkit-scrollbar-track {
  background: transparent;
}

.room-details-card::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 46%, transparent);
  background-clip: padding-box;
}

.room-details-card::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 68%, transparent);
  background-clip: padding-box;
}

.delete-conversation-card {
  display: grid;
  width: min(100%, 440px);
  gap: var(--vot-spacing-md);
}

.delete-conversation-card header {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.delete-conversation-card h2,
.delete-conversation-card p {
  margin: 0;
}

.delete-conversation-card h2 {
  font: var(--vot-type-headline-small);
}

.delete-conversation-card > p {
  color: var(--vot-muted);
  font: var(--vot-type-body-medium);
}

.delete-conversation-cancel {
  color: var(--vot-text);
  background: transparent;
  font: var(--vot-type-label-large);
}

.delete-conversation-cancel:hover:not(:disabled) {
  background: var(--vot-surface-container);
}

.dialog-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 10px;
}

.room-details-delete {
  margin-top: 4px;
}

.user-search-card {
  display: grid;
  width: min(100%, 520px);

  gap: 16px;

  overflow-y: auto;
}

.user-profile-card {
  display: grid;
  width: min(100%, 420px);
  gap: 22px;
}

.user-profile-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile-card h2,
.user-profile-card p {
  margin: 0;
}

.profile-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-avatar-actions label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.user-profile-card h2 {
  font-size: 24px;
}

.user-profile-identity {
  display: flex;
  gap: 18px;
  align-items: center;
}

.user-profile-identity > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.user-profile-identity .eyebrow {
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-profile-identity strong {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-identity small,
.user-profile-note {
  color: var(--muted);
  line-height: 1.5;
}

.user-search-card header {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.user-search-card h2 {
  margin: 0;
  font-size: 24px;
}

.user-search-input:not(.user-search-field) {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--outline);
  border-radius: 18px;
  background: var(--surface-soft);
}

.user-search-input:not(.user-search-field):focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.user-search-input:not(.user-search-field) input {
  width: 100%;
  min-height: 48px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.user-search-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.user-search-status:empty { display: none; }

.user-search-results {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.user-search-results li {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.user-search-result-copy {
  display: grid;
  flex: 1 1 8rem;
  min-width: 0;
  gap: 3px;
}

.user-search-result-copy strong,
.user-search-result-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.user-search-results .secondary-button {
  min-height: 38px;
  flex: 0 0 auto;
  font-size: 13px;
}

/* Connected actions wrap in narrow sheets without clipping their labels. */
.connected-chat-action {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.connected-chat-action small {
  color: var(--muted);
}

.connected-chat-action .secondary-button {
  min-height: 44px;
  white-space: normal;
}

.room-details-card header {
  display: flex;
  min-width: 0;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.room-details-toolbar {
  align-items: center !important;
}

.room-profile-header {
  display: grid;
  justify-items: center;
  gap: var(--vot-spacing-sm);
  text-align: center;
}

.room-profile-header h2,
.room-profile-header p {
  margin: 0;
}

.room-profile-header h2 {
  max-width: 100%;
  overflow: hidden;
  font-size: 25px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-profile-header p {
  color: var(--muted);
  font-size: 14px;
}

.room-quick-actions {
  display: grid;
  grid-template-columns: minmax(140px, 1fr);
  gap: 8px;
  padding: 2px 0;
}

.room-quick-actions-direct {
  grid-template-columns: 1fr;
}

.room-action-button {
  display: grid;
  min-height: 48px;
  gap: 5px;
  place-items: center;
  padding: 7px 4px;
  border-radius: 16px;
  color: var(--on-primary-soft);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 750;
}

.room-action-button:not(:disabled):hover {
  filter: brightness(1.08);
}

.room-action-button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.room-action-button .icon,
.room-action-icon {
  width: 20px;
  height: 20px;
  font-size: 18px;
}

.room-details-section {
  display: grid;
  gap: 11px;
  padding: 4px 0;
}

.room-details-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.room-details-section > p {
  margin: 0;
  line-height: 1.5;
}

.room-muted {
  color: var(--muted) !important;
}

.room-info-row {
  display: grid;
  gap: 3px;
  padding: 10px 0;
}

.room-info-row:last-child {
  border-bottom: 0;
}

.room-info-row dt {
  color: var(--muted);
  font-size: 12px;
}

.room-info-row dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.room-members-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.room-members-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.room-members-row > span {
  color: var(--muted);
  font-size: 24px;
}

.room-edit-section label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.room-edit-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 10px;
  padding-top: 4px;
}

.room-edit-section input,
.room-edit-section textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--outline);
  border-radius: 13px;
  outline: 0;
  color: var(--text);
  background: var(--surface-soft);
  font: inherit;
}

.room-edit-section textarea {
  min-height: 82px;
  resize: vertical;
}

.room-edit-section input:focus,
.room-edit-section textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.room-danger-section {
  margin: 0;
  padding: 0;
}

.room-danger-row {
  display: flex;
  width: 100%;
  min-height: 48px;
  gap: var(--vot-spacing-sm);
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--vot-radius-lg);
  color: var(--vot-error);
  background: var(--vot-surface-container);
  font: var(--vot-type-label-large);
  text-align: left;
}

.room-danger-row:hover:not(:disabled) {
  background: var(--vot-error-container);
  color: var(--vot-on-error-container);
}

.room-details-card h2,
.room-details-card .eyebrow {
  margin: 0;
}

.room-details-card h2 {
  overflow: hidden;
  font-size: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
.room-details-list dt,
.room-details-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.room-details-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.room-details-list > div {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.room-details-list dt,
.room-details-list dd {
  margin: 0;
}

.room-details-editable input,
.room-details-editable textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--outline);
  border-radius: 11px;
  outline: 0;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  line-height: 1.4;
}

.room-details-editable textarea {
  min-height: 72px;
  resize: vertical;
}

.room-details-editable input:focus,
.room-details-editable textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.room-details-list dd {
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.45;
}

.room-details-list dd.muted,
.room-details-help {
  color: var(--muted);
}

.room-details-help {
  margin: -10px 0 0;
  font-weight: 500;
  line-height: 1.45;
}

.room-link-copy {
  display: grid;
  gap: 10px;
}

.room-link-copy input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--outline);
  border-radius: 13px;
  outline: 0;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
}

.room-link-copy .primary-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.room-link-copy .primary-button .icon {
  width: 18px;
  height: 18px;
}

/* Room details: a compact expressive sheet with hierarchy carried by type and
 * tonal surfaces instead of a card around every field. */
.room-details-card {
  width: min(100%, 520px);
  gap: 14px;
}

.room-details-card .eyebrow {
  font-weight: 500;
}

.room-details-card .room-details-section h3 {
  font-weight: 600;
}

.room-details-card .room-edit-section label {
  font-weight: 500;
}

.room-profile-header .avatar-profile {
  width: 80px;
  height: 80px;
}

.room-profile-avatar-wrap {
  position: relative;
  display: grid;
}

.room-avatar-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.room-avatar-edit {
  position: absolute;
  right: -3px;
  bottom: -2px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 3px solid var(--surface);
  border-radius: 50%;
  color: var(--on-primary);
  background: var(--primary);
}

.room-avatar-edit .icon {
  width: 15px;
  height: 15px;
}

.room-profile-header h2 {
  font-size: 23px;
  font-weight: 600;
}

.room-quick-actions {
  display: flex;
  gap: 8px;
  padding: 0;
}

.room-action-button {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  flex: 1 1 0;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
}

.room-action-button-primary {
  color: var(--on-primary);
  background: var(--primary);
}

.room-action-button-primary:not(:disabled):hover {
  filter: brightness(1.06);
}

.room-action-button .icon {
  width: 18px;
  height: 18px;
}

.room-section-heading {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.room-view-all-members {
  display: inline-flex;
  min-height: 32px;
  gap: 2px;
  align-items: center;
  padding: 3px 0 3px 8px;
  color: var(--primary-strong);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.room-view-all-members .icon {
  width: 16px;
  height: 16px;
}

.room-inline-action {
  width: 30px;
  height: 30px;
  margin: -5px -7px -5px 0;
}

.room-description-section > p {
  min-height: 1.45em;
}

.room-member-preview {
  display: grid;
  gap: 6px;
}

.room-member-preview-row {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-radius: 15px;
  background: transparent;
}

.room-member-preview-row > span {
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-add-member-row {
  display: inline-flex;
  min-height: 38px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  color: var(--primary-strong);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.room-add-member-row .icon {
  width: 18px;
  height: 18px;
}

.room-advanced-details {
  border-top: 1px solid var(--outline);
  border-bottom: 1px solid var(--outline);
}

.room-advanced-details summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  list-style: none;
}

.room-advanced-details summary::-webkit-details-marker {
  display: none;
}

.room-advanced-details[open] summary .icon {
  transform: rotate(90deg);
}

.room-advanced-details summary .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 150ms ease;
}

.room-advanced-content {
  padding-bottom: 6px;
}

.room-info-row {
  position: relative;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 7px 0;
}

.room-info-row:last-child {
  border-bottom: 0;
}

.room-info-row dt {
  font-size: 12px;
}

.room-info-row dd {
  text-align: right;
}

.room-info-monospace {
  font-family: var(--vot-font-mono);
  font-size: 12px;
}

.room-copy-action {
  width: 30px;
  height: 30px;
}

.room-copy-action .icon {
  width: 16px;
  height: 16px;
}

.room-link-copy-compact {
  display: flex;
  gap: 8px;
  align-items: center;
}

.room-link-copy-compact input {
  min-width: 0;
  flex: 1;
}

.room-link-copy-compact button {
  min-height: 40px;
  flex: 0 0 auto;
}

.room-danger-row > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: var(--vot-spacing-sm);
  color: inherit;
}

.room-danger-row .icon {
  width: 18px;
  height: 18px;
}

.room-invite-title {
  margin: 4px 0 0;
  font-size: 22px;
}

.room-invite-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.user-search-empty {
  min-height: 1.5em;
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.room-member-search-result {
  display: flex;
  width: 100%;
  min-width: 0;
  gap: 10px;
  align-items: center;
  padding: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.user-search-results li.selected {
  outline: 2px solid color-mix(in srgb, var(--primary) 48%, transparent);
  background: var(--primary-soft);
}

.room-member-search-result:disabled {
  cursor: default;
  opacity: .62;
}

.room-member-selection-mark {
  max-width: 92px;
  margin-left: auto;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.room-invite-footer {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.room-invite-footer > span {
  color: var(--muted);
  font-size: 12px;
}

.delete-conversation-warning {
  padding: 10px 12px;
  margin: -6px 0 0;
  border-radius: 14px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  font-size: 13px;
  line-height: 1.45;
}

/* Narrow desktop: keep all three panes, just tighter. */
@media (max-width: 1120px) {
  .navigation-rail {
    padding-inline: 8px;
  }

  .rail-button {
    width: 44px;
    height: 44px;
  }

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

/*
 * One pane at a time, the way Telegram behaves once the window can no longer
 * hold a list and a conversation side by side: the chat list owns the window
 * and the conversation slides in over it. The list stays mounted underneath so
 * going back does not reset its scroll position.
 */
@media (max-width: 900px) {
  .votex-root {
    padding: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .sidebar-resize-handle {
    display: none;
  }

  .navigation-rail {
    grid-row: 2;
    flex-direction: row;
    gap: 8px;
    padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: var(--surface-soft);
  }

  .nav-brand {
    width: 34px;
    height: 34px;
    margin-bottom: 0;
    margin-right: 4px;
  }

  .chat-list-panel,
  .conversation-panel {
    grid-column: 1;
    grid-row: 1;
    border-radius: 0;
  }

  .votex-root .conversation-panel {
    z-index: 6;
    transform: translateX(100%);
    visibility: hidden;
    background: var(--surface);
    transition:
      transform 240ms cubic-bezier(0.32, 0.72, 0, 1),
      visibility 240ms;
  }

  .mobile-conversation .conversation-panel {
    transform: none;
    visibility: visible;
  }

  /* A conversation takes the whole window, including the rail's row. */
  .mobile-conversation .navigation-rail {
    display: none;
  }

  .mobile-back {
    display: grid;
  }

  .conversation-header {
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
    padding-top: max(12px, env(safe-area-inset-top));
  }

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

  .group-intro-action {
    width: 100%;
  }

  .votex-toast {
    right: 12px;
    left: 12px;
    bottom: 90px;
    max-width: none;
  }

  /* No bottom rail to clear while a conversation is open. */
  .mobile-conversation .votex-toast {
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .account-menu {
    right: 0;
    bottom: calc(100% + 8px);
    left: auto;
    max-height: min(420px, calc(var(--visual-viewport-height, 100dvh) - 72px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  }
}

@media (max-width: 520px) {
  .chat-search-row {
    padding: 14px 14px 10px;
  }

  .filter-chips {
    padding-inline: 14px;
  }

  .chat-list-items {
    padding-inline: 8px;
  }

  .message-feed {
    gap: 14px;
    padding: 16px max(12px, env(safe-area-inset-right)) 20px max(12px, env(safe-area-inset-left));
  }

  .conversation-header {
    min-height: 66px;
    gap: 10px;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .conversation-header .avatar-medium {
    width: 42px;
    height: 42px;
  }

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

  .text-bubble p {
    font-size: 15px;
  }

  .composer {
    margin: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .composer-button,
  .send-button {
    width: 42px;
    height: 42px;
  }

  .new-chat-fab {
    right: 14px;
    bottom: 14px;
  }

  .account-menu {
    width: min(250px, calc(100vw - 28px));
  }

  .room-details-card {
    width: 100%;

  }

  .user-search-card {
    width: 100%;

  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    /* Do not introduce an implicit `all` transition on descendants: inherited
       mobile-pane visibility can otherwise remain hidden after navigation. */
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}

/* A gallery is one message unit: close cells, one outer silhouette and one
 * metadata line. Each thumbnail can crop; the viewer always uses contain. */
.gallery-bubble {
  width: min(100%, 560px);
}

.message-row:has(.gallery-bubble) {
  width: min(88%, 640px);
}

.message-row:has(.gallery-bubble) .message-stack,
.message-row:has(.gallery-bubble) .gallery-bubble {
  width: 100%;
}

.media-gallery {
  display: grid;
  width: 100%;
  height: min(52vh, 420px);
  min-height: 156px;
  gap: 3px;
  overflow: hidden;
  background: var(--surface-strong);
}

.media-gallery-2,
.media-gallery-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.media-gallery-2 { height: min(42vh, 340px); }
.media-gallery-3 { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.media-gallery-3 .gallery-item:first-child { grid-row: span 2; }

.gallery-item {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: var(--surface-strong);
  cursor: zoom-in;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-overflow {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(18, 14, 24, .58);
  font-size: 28px;
  font-weight: 650;
}

.gallery-viewer-controls {
  position: absolute;
  right: 50%;
  bottom: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  transform: translateX(50%);
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-radius: 999px;
  padding: 4px;
}

.gallery-viewer-controls button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  font-size: 28px;
  line-height: 1;
}

.gallery-viewer-controls button:hover { background: var(--surface-strong); }

@media (max-width: 520px) {
  .media-gallery { height: min(46vh, 340px); min-height: 128px; }
}

/* Recovery stays inside the editor's low-emphasis, tonal surface. */
.room-edit-hint {
  color: var(--muted);
  font-size: 0.875rem;
}

.room-edit-error {
  color: var(--vot-on-error-container);
  background: var(--vot-error-container);
  padding: 12px;
  border-radius: var(--vot-radius-md);
  overflow-wrap: anywhere;
}

.room-edit-actions > button {
  min-width: 0;
  white-space: normal;
}

.room-details-editing .room-profile-avatar-wrap,
.room-details-editing .room-profile-header > p {
  display: none;
}

.room-details-editing .room-details-toolbar {
  position: sticky;
  top: -18px;
  z-index: 1;
  padding-block: 8px;
  background: var(--vot-surface-container-high);
}

/* Timeline actions preserve inline wrapping and the existing semantic link palette. */
button.message-link { display: inline; padding: 0; border: 0; background: transparent; font: inherit; text-align: inherit; cursor: pointer; }
button.message-link:disabled { cursor: default; text-decoration: none; }
button.file-download { width: 100%; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
button.file-download:disabled { cursor: default; }

.file-bubble > small { overflow-wrap: anywhere; }
.file-bubble > time { justify-self: end; }
.bubble .message-link:disabled { color: inherit; text-decoration: none; }

/* Dialog composition only; shell, controls and surface treatment live in vot-ui. */
.room-details-card h2 {
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  font: var(--vot-type-title-large);
}
.room-details-editing .room-profile-header { justify-items: start; text-align: start; }
.room-details-editing .room-profile-header h2 { font: var(--vot-type-title-medium); color: var(--vot-muted); }
.room-details-toolbar .eyebrow { font: var(--vot-type-title-large); color: var(--vot-text); }
.room-details-toolbar > button,
.m3-dialog-surface .icon-button { min-width: 44px; min-height: 44px; flex-shrink: 0; }
.room-details-editing .room-details-toolbar { top: -16px; }
.room-edit-section label { font: var(--vot-type-label-large); color: var(--vot-text); }
.room-edit-section .room-edit-hint { font: var(--vot-type-body-small); }
.room-edit-section .room-edit-error:focus { outline: 2px solid var(--vot-primary); outline-offset: 3px; }

.m3-dialog-surface .user-search-input:not(.user-search-field) { border: 0; border-radius: var(--vot-radius-md); background: var(--vot-surface); }
.m3-dialog-surface .user-search-input:not(.user-search-field):focus-within { box-shadow: none; }
.m3-dialog-surface .user-search-input:not(.user-search-field) input:focus-visible { outline-offset: -2px; border-radius: var(--vot-radius-sm); }

/* Group information and invitation tasks share the dialog's bounded scrollport. */
.room-action-panel[hidden] { display: none; }
.room-action-panels, .room-action-panel, .group-join-form { min-width: 0; }
.group-join-form { display: grid; gap: var(--vot-spacing-sm); }
.room-action-panel .m3-dialog-actions { margin-top: var(--vot-spacing-md); }
.room-action-panel .m3-dialog-actions button { padding-inline: var(--vot-spacing-lg); }
.room-action-panel label, .group-join-form label, .group-copy-field label {
  display: grid; gap: var(--vot-spacing-sm); min-width: 0;
}
.group-access, .group-invite-management { display: grid; gap: var(--vot-spacing-md); }
.group-access h4 { margin: 0; font: var(--vot-type-title-small); }
.group-access p, .group-join-form p { margin: 0; overflow-wrap: anywhere; }
.group-copy-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--vot-spacing-sm); align-items: end; }
.group-copy-field input { min-width: 0; width: 100%; text-overflow: ellipsis; }
.group-copy-button { display: inline-flex; gap: var(--vot-spacing-sm); white-space: nowrap; min-width: 168px; min-height: 44px; }
.group-copy-button .icon { width: 20px; height: 20px; }
.group-copy-feedback { grid-column: 1 / -1; min-height: 2.5em; font: var(--vot-type-body-small); color: var(--vot-muted); }
.group-invite-preview { display: grid; gap: var(--vot-spacing-md); padding: var(--vot-spacing-md); border-radius: var(--vot-radius-lg); background: var(--vot-surface-container); }
.room-member-preview { max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 420px) {
  .room-action-tabs.m3-segmented-tabs [role="tab"] { gap: var(--vot-spacing-xs); padding-inline: var(--vot-spacing-xs); }
  .group-copy-field { grid-template-columns: minmax(0, 1fr); }
  .group-copy-button { justify-self: end; }
}

.user-search-input:not(.user-search-field) { flex-wrap: wrap; }
.user-search-visible-label { font: var(--vot-type-label-large); color: var(--vot-text); }

.room-danger-row:disabled { color: var(--vot-muted); cursor: not-allowed; }
