/* Staff chat — aligns with admin.css tokens when loaded together */

.chat-screen-wrap {
  /* Match main.css / manager theme (teal #005983), not indigo */
  --chat-primary: var(--primary, #005983);
  --chat-primary-soft: var(--primary-50, #e0f4f8);
  /* Alias for components expecting --color-primary (maps from main.css --primary) */
  --color-primary: var(--primary, #005983);
  --color-primary-50: var(--primary-50, #e0f4f8);
  --chat-surface: var(--white, #fff);
  --chat-border: var(--gray-200, #e5e7eb);
  --chat-muted: var(--gray-500, #6b7280);
  --chat-text: var(--gray-900, #111827);
  --chat-radius: 12px;
  --chat-radius-lg: 16px;
  --chat-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --chat-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  /* Inter has no emoji glyphs — explicit stacks so color emoji render on all platforms */
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif,
    'Apple Color Emoji',
    'Segoe UI Emoji',
    'Segoe UI Symbol',
    'Noto Color Emoji';

  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Fit inside content area and reach near viewport bottom. */
  max-height: calc(100dvh - 60px - 48px);
  height: calc(100dvh - 60px - 48px);
  overflow: hidden;
}

.main-content:has(.chat-screen-wrap) {
  overflow: hidden;
  overflow-y: hidden;
  padding-bottom: 0 !important;
}

.chat-screen-wrap .page-header.page-header--chat {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--chat-border);
}

.chat-screen-wrap .page-header.page-header--chat h1 {
  font-size: var(--text-xl, 1.25rem);
  letter-spacing: -0.02em;
}

.chat-screen-wrap .chat-page {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.chat-page {
  display: flex;
  min-height: 0;
  background: var(--gray-50, #f9fafb);
  border-radius: var(--chat-radius-lg);
  overflow: hidden;
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
}

.chat-sidebar {
  width: 400px;
  min-width: 320px;
  max-width: 44%;
  max-height: 100%;
  min-height: 0;
  border-right: 1px solid var(--chat-border);
  background: var(--chat-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
}

.chat-sidebar-header {
  padding: 16px 18px 12px;
  background: linear-gradient(180deg, var(--gray-50, #fafafa) 0%, var(--chat-surface) 100%);
  border-bottom: 1px solid var(--chat-border);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--chat-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.chat-sidebar-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-sidebar-header-unread {
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--chat-primary);
  color: #fff;
  flex-shrink: 0;
}

.chat-live-pill {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #10b981;
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.35);
}

.chat-live-pill.off {
  background: var(--gray-200, #e5e7eb);
  color: var(--gray-600, #4b5563);
  box-shadow: none;
}

.chat-sidebar-search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100, #f3f4f6);
  flex-shrink: 0;
}

.chat-sidebar-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-sidebar-toolbar .chat-sidebar-search {
  flex: 1 1 120px;
  min-width: 0;
  width: auto;
}

.chat-sidebar-search {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  font-size: 0.875rem;
  background: var(--gray-50, #f9fafb) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E")
    12px 50% no-repeat;
  background-size: 16px 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.chat-sidebar-search::placeholder {
  color: var(--gray-400, #9ca3af);
}

.chat-sidebar-search:focus {
  outline: none;
  border-color: var(--chat-primary);
  background-color: var(--chat-surface);
  box-shadow: 0 0 0 3px var(--chat-primary-soft);
}

.chat-sidebar-new-group {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--color-primary);
  background: var(--chat-surface);
  cursor: pointer;
  color: var(--color-primary);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.chat-sidebar-new-group:hover {
  background: var(--color-primary-50);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.chat-section-label {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--chat-muted);
  padding: 14px 18px 8px;
  margin: 0;
  background: linear-gradient(180deg, var(--chat-surface) 70%, transparent);
}

.chat-team-empty {
  padding: 4px 18px 16px;
  font-size: 0.8125rem;
  color: var(--chat-muted);
  line-height: 1.5;
}

.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  margin: 0 8px 2px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.chat-row:hover {
  background: var(--gray-50, #f9fafb);
}

.chat-row.active {
  background: var(--chat-primary-soft);
  border-color: color-mix(in srgb, var(--chat-primary) 20%, transparent);
  box-shadow: var(--chat-shadow-sm);
}

.chat-row.active .chat-row-title {
  color: var(--chat-primary);
}

.chat-row--button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
}

.chat-row--button:hover {
  background: var(--gray-50, #f9fafb);
}

.chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gray-200, #e5e7eb), var(--gray-100, #f3f4f6));
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--gray-600, #4b5563);
  font-size: 1rem;
  border: 2px solid var(--chat-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chat-row.active .chat-avatar {
  border-color: color-mix(in srgb, var(--chat-primary) 25%, transparent);
}

.chat-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.chat-row-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.chat-row-title-wrap .chat-row-title {
  min-width: 0;
}

.chat-presence--dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
  flex-shrink: 0;
}

.chat-row-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--chat-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row-time {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-400, #9ca3af);
  flex-shrink: 0;
}

.chat-row-preview {
  display: block;
  max-width: 100%;
  font-size: 0.8125rem;
  color: var(--chat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
  line-height: 1.35;
}

.chat-row-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-600, #4b5563);
}

.chat-row-badge--admin {
  background: #fef3c7;
  color: #b45309;
}

.chat-row-badge--manager {
  background: #dbeafe;
  color: #1d4ed8;
}

.chat-row-badge--member {
  background: #ede9fe;
  color: #5b21b6;
}

.chat-unread {
  background: var(--chat-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--chat-primary) 35%, transparent);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--gray-50, #f3f4f6);
  background-image:
    radial-gradient(
      circle at 20% 20%,
      color-mix(in srgb, var(--primary, #005983) 4%, transparent) 0%,
      transparent 45%
    ),
    radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

.chat-main-header {
  padding: 14px 22px;
  border-bottom: 1px solid var(--chat-border);
  background: var(--chat-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.chat-main-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.chat-main-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--gray-700, #374151);
  background: linear-gradient(145deg, var(--gray-100, #f3f4f6), var(--gray-200, #e5e7eb));
  border: 1px solid var(--chat-border);
  overflow: hidden;
}

.chat-main-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-main-header-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-main-header-title {
  display: block;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--chat-text);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.chat-main-header-sub {
  display: block;
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--chat-muted);
  font-weight: 500;
}

.chat-header-online {
  color: #16a34a;
  font-weight: 600;
}

.chat-typing-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px 6px;
  min-height: 32px;
  background: var(--gray-100, #f3f4f6);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-typing-text {
  font-size: 0.8125rem;
  color: var(--gray-500, #6b7280);
  font-style: italic;
  font-weight: 500;
}

.chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.chat-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gray-400, #9ca3af);
  animation: chat-typing-bounce 1.2s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-typing-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.chat-main-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.chat-main-header-actions button {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--chat-border);
  background: var(--chat-surface);
  cursor: pointer;
  color: var(--gray-700, #374151);
  transition: background 0.15s, border-color 0.15s;
}

.chat-main-header-actions button:hover {
  background: var(--gray-50, #f9fafb);
  border-color: var(--gray-300, #d1d5db);
}

.chat-main-header-inner--btn {
  background: transparent;
  border: 0;
  padding: 4px;
  margin: -4px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  border-radius: 10px;
  transition: background 0.15s ease;
  flex: 1 1 auto;
}

.chat-main-header-inner--btn:hover {
  background: var(--gray-50, #f9fafb);
}

.chat-main-header-inner--btn:focus-visible {
  outline: 2px solid var(--primary-500, #3b82f6);
  outline-offset: 2px;
}

.chat-member-option--static {
  cursor: default;
}

.chat-member-option--static:hover {
  background: transparent;
}

.chat-member-row__remove {
  background: transparent;
  border: 1px solid var(--red-300, #fca5a5);
  color: var(--red-600, #dc2626);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.chat-member-row__remove:hover {
  background: var(--red-50, #fef2f2);
  border-color: var(--red-400, #f87171);
}

.chat-group-intro {
  align-self: center;
  max-width: 520px;
  width: 100%;
  margin: 24px auto 12px;
  padding: 24px 22px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  text-align: center;
}

.chat-group-intro__avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-700, #374151);
  background: linear-gradient(145deg, var(--gray-100, #f3f4f6), var(--gray-200, #e5e7eb));
  border: 1px solid var(--chat-border);
}

.chat-group-intro__title {
  margin: 0 0 4px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--chat-text);
  letter-spacing: -0.01em;
}

.chat-group-intro__desc {
  margin: 0 0 10px;
  font-size: 0.875rem;
  color: var(--chat-muted);
  line-height: 1.45;
}

.chat-group-intro__meta {
  margin: 0 0 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-500, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-group-intro__members {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  justify-content: center;
}

.chat-group-intro__member {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--gray-50, #f9fafb);
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--gray-700, #374151);
}

.chat-group-intro__member img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-group-intro__member-letter {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--gray-100, #f3f4f6), var(--gray-200, #e5e7eb));
  color: var(--gray-700, #374151);
  font-size: 0.6875rem;
  font-weight: 700;
}

.chat-group-intro__member-name {
  font-weight: 500;
}

.chat-group-intro__hint {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--chat-muted);
}

.chat-system-event {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}

.chat-system-event__pill {
  font-size: 0.75rem;
  color: var(--chat-muted);
  background: var(--gray-50, #f9fafb);
  border: 1px solid var(--chat-border);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 500;
  max-width: 80%;
  text-align: center;
  line-height: 1.4;
}

.chat-notif-enable {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--primary-300, #93c5fd);
  background: var(--primary-50, #eff6ff);
  color: var(--primary-700, #1d4ed8);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-notif-enable:hover {
  background: var(--primary-100, #dbeafe);
  border-color: var(--primary-400, #60a5fa);
}

.chat-composer { position: relative; }

.chat-mention-popup {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--chat-text);
}

.chat-mention-item--active,
.chat-mention-item:hover {
  background: var(--gray-50, #f9fafb);
}

.chat-mention-item__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-mention-item__avatar--letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--gray-100, #f3f4f6), var(--gray-200, #e5e7eb));
  color: var(--gray-700, #374151);
  font-size: 0.75rem;
  font-weight: 700;
}

.chat-mention-item__name {
  font-size: 0.875rem;
  font-weight: 500;
}

.chat-mention {
  background: var(--primary-50, #eff6ff);
  color: var(--primary-700, #1d4ed8);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 600;
}

.chat-bubble-row.mine .chat-mention {
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

/* Lock the viewport when the chat screen is mounted so the messages list scrolls inside the pane instead of the whole page. Replaces a post-mount useEffect that caused a brief layout flash on first paint. */
body:has(.chat-screen-wrap) {
  overflow: hidden;
}
body:has(.chat-screen-wrap) #__next {
  overflow: hidden;
  height: 100vh;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(78%, 560px);
  margin-bottom: 6px;
}

.chat-bubble-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-bubble-meta {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-500, #6b7280);
  margin-bottom: 4px;
  padding: 0 6px;
}

.chat-bubble-row.mine .chat-bubble-meta {
  text-align: right;
}

.chat-bubble {
  padding: 10px 14px 10px 14px;
  border-radius: 14px 14px 14px 6px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow-sm);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--chat-text);
}

.chat-bubble-row.mine .chat-bubble {
  background: linear-gradient(145deg, var(--primary-light, #4db8d4), var(--primary, #005983));
  color: #fff;
  border-color: transparent;
  border-radius: 14px 14px 6px 14px;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary, #005983) 28%, transparent);
}

.chat-bubble-row.mine .chat-bubble-meta {
  color: var(--gray-500, #6b7280);
}

/* Inline file attachments under bubble text */
.chat-msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.chat-msg-attachments--mine {
  border-top-color: rgba(255, 255, 255, 0.22);
}

.chat-msg-attachment {
  max-width: 100%;
}

.chat-msg-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--gray-50, #f9fafb);
  border: 1px solid var(--chat-border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary, #005983);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.chat-msg-attachment-chip:hover {
  background: var(--chat-primary-soft);
  border-color: color-mix(in srgb, var(--chat-primary) 25%, transparent);
}

.chat-msg-attachment-doc-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 4px;
  background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.chat-msg-attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chat-msg-attachment-thumb-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 220px;
  text-decoration: none;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--chat-border);
  background: var(--gray-50, #f9fafb);
}

.chat-msg-attachment-thumb {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  display: block;
  vertical-align: top;
}

.chat-msg-attachment-under {
  padding: 4px 8px 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-700, #374151);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-msg-attachments--mine .chat-msg-attachment-chip {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.chat-msg-attachments--mine .chat-msg-attachment-chip:hover {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.5);
}

.chat-msg-attachments--mine .chat-msg-attachment-doc-icon {
  background: rgba(255, 255, 255, 0.35);
  box-shadow: none;
}

.chat-msg-attachments--mine .chat-msg-attachment-thumb-wrap {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.12);
}

.chat-msg-attachments--mine .chat-msg-attachment-under {
  color: rgba(255, 255, 255, 0.92);
}

.chat-bubble-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: flex-start;
}

.chat-bubble-wrap--mine {
  width: fit-content;
  max-width: 100%;
  align-self: flex-end;
  align-items: flex-end;
}

/* Room for the pill above the bubble */
.chat-bubble-wrap--mine.chat-bubble-wrap--floating-actions {
  padding-top: 14px;
}

/* White capsule toolbar (similar to Google Chat) */
.chat-bubble-top-actions {
  position: absolute;
  top: 4px;
  right: 0;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: #fff;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 2px rgba(60, 64, 67, 0.24),
    0 2px 6px rgba(60, 64, 67, 0.12);
}

.chat-bubble-top-actions .chat-bubble-msg-action {
  padding: 5px;
  border-radius: 50%;
  color: var(--gray-600, #5f6368);
}

.chat-bubble-top-actions .chat-bubble-msg-action:hover {
  color: var(--primary, #005983);
  background: rgba(0, 89, 131, 0.08);
}

.chat-bubble-top-actions .chat-bubble-msg-action--danger:hover {
  color: var(--danger-600, #d93025);
  background: rgba(217, 48, 37, 0.08);
}

.chat-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  margin-top: 2px;
  padding: 0 4px 0 6px;
  box-sizing: border-box;
}

.chat-bubble-row.mine .chat-bubble-footer {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.chat-bubble-time {
  font-size: 0.65rem;
  color: var(--gray-500, #6b7280);
  font-weight: 500;
  display: inline;
  line-height: 1.35;
}

.chat-bubble-time-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  max-width: 100%;
  flex-shrink: 0;
}

.chat-bubble-time-sep {
  color: var(--gray-400, #9ca3af);
  font-weight: 500;
}

.chat-bubble-edited-badge {
  font-weight: 600;
  font-size: 0.625rem;
  letter-spacing: 0.01em;
  color: var(--gray-550, #5f6368);
}

.chat-bubble-edited-time {
  font-weight: 500;
  color: var(--gray-500, #6b7280);
}

.chat-bubble-footer-mine {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-bubble-msg-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin: 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: var(--gray-600, #4b5563);
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
}

.chat-bubble-msg-action:hover {
  color: var(--primary, #005983);
  background: rgba(0, 89, 131, 0.08);
}

.chat-bubble-msg-action--danger:hover {
  color: var(--danger-600, #dc2626);
  background: rgba(239, 68, 68, 0.1);
}

/* Footer sits below the bubble — SVGs use currentColor via .chat-bubble-action-icon. */
.chat-bubble-action-icon {
  width: 16px;
  height: 16px;
  display: block;
}

/* Edit/delete capsule appears on hover; ticks stay visible; touch keeps capsule visible */
@media (hover: hover) {
  .chat-bubble-row.mine .chat-bubble-top-actions {
    opacity: 0;
    transition: opacity 0.12s ease;
    pointer-events: none;
  }

  .chat-bubble-row.mine:hover .chat-bubble-top-actions,
  .chat-bubble-row.mine:focus-within .chat-bubble-top-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (hover: hover) and (prefers-reduced-motion: reduce) {
  .chat-bubble-row.mine .chat-bubble-top-actions {
    transition: none;
  }
}

.chat-msg-ticks {
  display: inline-flex;
  align-items: center;
  min-height: 12px;
  color: var(--gray-500, #6b7280);
  line-height: 0;
}

.chat-msg-ticks--sending,
.chat-msg-ticks--failed {
  color: var(--gray-400, #9ca3af);
}

.chat-msg-ticks--delivered {
  color: var(--gray-500, #6b7280);
}

.chat-msg-ticks--read {
  color: #005983;
}

.chat-tick-time {
  opacity: 0.85;
  flex-shrink: 0;
}

.chat-tick-group {
  position: relative;
  display: inline-flex;
  width: 18px;
  height: 10px;
}

.chat-tick-line--2 {
  position: absolute;
  left: 4px;
  top: 0;
  opacity: 0.9;
}

.chat-header-btn-danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.chat-header-btn-danger:hover {
  background: #fee2e2;
}

/* Composer — WhatsApp-style bar + rounded field + circular send */
.chat-composer {
  position: relative;
  padding: 8px 10px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e9edef;
  background: #f0f2f5;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-composer-field {
  flex: 1;
  min-width: 0;
  background: #fff;
  border-radius: 24px;
  padding: 8px 14px 9px 16px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.08);
  display: flex;
  align-items: flex-end;
}

.chat-composer-field textarea {
  flex: 1;
  width: 100%;
  min-height: 24px;
  max-height: 120px;
  overflow-y: auto;
  resize: none;
  border: none;
  border-radius: 0;
  padding: 4px 0 3px;
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.4;
  font-family: inherit;
  background: transparent;
  color: #111b21;
  vertical-align: bottom;
}

.chat-composer-field textarea::placeholder {
  color: #8696a0;
}

.chat-composer-field textarea:focus {
  outline: none;
}

.chat-composer-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Keeps attach + send vertically centered as a pair; row still aligns to input baseline via flex-end. */
.chat-composer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  align-self: flex-end;
}

.chat-composer-emoji-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-composer-emoji {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #54656f;
  cursor: pointer;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.08);
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-composer-emoji:hover:not(:disabled) {
  background: #f7f8fa;
  color: var(--primary, #005983);
}

.chat-composer-emoji:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-composer-emoji-icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.chat-emoji-picker-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: min(320px, calc(100vw - 24px));
  max-height: min(380px, 70dvh);
  border-radius: 12px;
  overflow: auto;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--chat-border);
  background: #fff;
}

.chat-composer-attach {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #54656f;
  cursor: pointer;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.08);
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-composer-attach-icon {
  width: 17px;
  height: 17px;
  display: block;
  flex-shrink: 0;
}

.chat-composer-attach:hover:not(:disabled) {
  background: #f7f8fa;
  color: var(--primary, #005983);
}

.chat-composer-attach:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-composer-stack {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.chat-pending-files {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-pending-files__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  background: rgba(0, 89, 131, 0.1);
  border: 1px solid rgba(0, 89, 131, 0.2);
  font-size: 0.75rem;
  font-weight: 600;
  color: #1f2937;
}

.chat-pending-files__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 200px;
}

.chat-pending-files__remove {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-size: 1.125rem;
  font-weight: 700;
  color: #64748b;
}

.chat-pending-files__remove:hover {
  color: var(--danger-600, #dc2626);
}

.chat-composer-hint--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-composer-send {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #25d366;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, filter 0.15s ease;
  box-shadow: 0 1px 2px rgba(11, 20, 26, 0.12);
}

.chat-composer-send:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: scale(1.03);
}

.chat-composer-send:active:not(:disabled) {
  transform: scale(0.97);
}

.chat-composer-send:disabled {
  background: #8696a0;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

.chat-composer-send-icon {
  width: 22px;
  height: 22px;
  transform: translate(2px, -1px);
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--chat-muted);
  font-size: 0.9375rem;
  padding: 32px 24px;
  text-align: center;
  gap: 12px;
}

/* CSS-only loading indicator (avoids SVG + tinted box looking like a stray image) */
.chat-empty-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--gray-200, #e5e7eb);
  border-top-color: var(--chat-primary);
  border-radius: 50%;
  margin-bottom: 4px;
  flex-shrink: 0;
  animation: chat-empty-spin 0.65s linear infinite;
}

@keyframes chat-empty-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-empty-spinner {
    animation: none;
    border-top-color: var(--gray-300, #d1d5db);
    opacity: 0.85;
  }
}

.chat-empty--welcome .chat-empty-title {
  margin-top: 0;
}

.chat-empty-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--chat-text);
  margin: 0;
}

.chat-empty p {
  margin: 0;
  max-width: 22rem;
  line-height: 1.55;
  font-size: 0.875rem;
}

.chat-empty--error .chat-empty-title {
  color: var(--gray-800, #1f2937);
}

.chat-empty-back {
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--chat-primary);
  text-decoration: none;
}

.chat-empty-back:hover {
  text-decoration: underline;
}

.chat-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif,
    'Apple Color Emoji',
    'Segoe UI Emoji',
    'Segoe UI Symbol',
    'Noto Color Emoji';
}

.chat-modal {
  background: var(--chat-surface);
  border-radius: var(--chat-radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--chat-border);
}

.chat-modal h3 {
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--chat-border);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--chat-text);
}

.chat-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.chat-modal-body input[type='text'],
.chat-modal-body textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
}

.chat-modal-body input:focus,
.chat-modal-body textarea:focus {
  outline: none;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px var(--chat-primary-soft);
}

.chat-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--gray-50, #f9fafb);
}

.chat-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: background 0.12s;
}

.chat-checkbox-row:hover {
  background: var(--gray-50, #f9fafb);
}

/* Create group modal — rendered outside .chat-screen-wrap, so define tokens on the modal root */
.chat-modal--group {
  --chat-primary: var(--primary, #005983);
  --chat-primary-soft: var(--primary-50, #e0f4f8);
  --chat-surface: #ffffff;
  --chat-border: #e5e7eb;
  --chat-muted: #6b7280;
  --chat-text: #111827;
  --chat-modal-inset: #f8fafc;

  max-width: 520px;
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.22);
  background: var(--chat-surface);
  color: var(--chat-text);
  font-size: 0.9375rem;
}

.chat-modal-header--group {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 20px 18px;
  flex-shrink: 0;
  background: var(--chat-surface);
}

.chat-modal-header-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--chat-primary-soft), var(--primary-100, #b3e5f0));
  border: 1px solid color-mix(in srgb, var(--chat-primary) 14%, transparent);
  color: var(--chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-modal-header-icon svg {
  width: 26px;
  height: 26px;
}

.chat-modal-header-copy {
  flex: 1;
  min-width: 0;
}

.chat-modal--group .chat-modal-eyebrow {
  margin: 0 0 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chat-muted);
}

.chat-modal--group .chat-modal-header-copy h3 {
  margin: 0 0 8px;
  padding: 0;
  border: none;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--chat-text);
  line-height: 1.2;
}

.chat-modal-lede {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--chat-muted);
}

.chat-modal-dismiss {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-600, #4b5563);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.chat-modal-dismiss:hover {
  background: var(--gray-200, #e5e7eb);
  color: var(--chat-text);
}

.chat-modal-dismiss svg {
  width: 20px;
  height: 20px;
}

/* Edit message modal (no title bar) */
.chat-modal--edit-msg {
  --chat-primary: var(--primary, #005983);
  --chat-primary-soft: var(--primary-50, #e0f4f8);
  --chat-surface: #ffffff;
  --chat-border: #e5e7eb;
  --chat-muted: #6b7280;
  --chat-text: #111827;

  max-width: 460px;
  border-radius: 16px;
  background: var(--chat-surface);
  color: var(--chat-text);
}

.chat-modal--edit-msg .chat-modal-body--edit-msg {
  padding: 18px 20px 14px;
  flex: 1;
}

.chat-modal--edit-msg .chat-field--textarea {
  margin: 0;
}

.chat-edit-msg-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 120px;
  resize: vertical;
  padding: 11px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.45;
  background: var(--chat-surface);
  color: var(--chat-text);
}

.chat-edit-msg-input:focus {
  outline: none;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px var(--chat-primary-soft);
}

.chat-modal-body--group {
  padding: 20px;
  display: flex;
  flex-direction: column;
  background: var(--chat-modal-inset);
  border-top: 1px solid var(--chat-border);
  min-height: 0;
}

.chat-group-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.chat-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.chat-field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700, #374151);
}

.chat-field-optional {
  font-weight: 500;
  color: var(--chat-muted);
}

.chat-group-fields input[type='text'],
.chat-group-fields textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--chat-surface);
  color: var(--chat-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-group-fields textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

.chat-group-fields input:focus,
.chat-group-fields textarea:focus {
  outline: none;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px var(--chat-primary-soft);
}

.chat-member-picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chat-member-picker-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--chat-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-member-picker-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--chat-primary);
  background: var(--chat-primary-soft);
  padding: 4px 11px;
  border-radius: 999px;
}

.chat-member-search {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--chat-surface);
  color: var(--chat-text);
}

.chat-member-search:focus {
  outline: none;
  border-color: var(--chat-primary);
  background: var(--chat-surface);
  box-shadow: 0 0 0 3px var(--chat-primary-soft);
}

.chat-member-search::placeholder {
  color: var(--gray-400, #9ca3af);
}

.chat-member-picker {
  max-height: min(36vh, 260px);
  overflow-y: auto;
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  background: var(--chat-surface);
  scrollbar-width: thin;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chat-member-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--chat-border);
  transition: background 0.12s ease;
}

.chat-member-option:last-child {
  border-bottom: none;
}

.chat-member-option:hover {
  background: var(--chat-modal-inset);
}

.chat-member-option--selected {
  background: var(--chat-primary-soft);
  box-shadow: inset 3px 0 0 var(--chat-primary);
}

.chat-member-option-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-member-option-avatar--letter {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #e5e7eb, #f3f4f6);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--gray-600, #4b5563);
  border: 1px solid var(--chat-border);
}

.chat-member-option-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-member-option-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-member-option-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--chat-text);
}

.chat-member-option-email {
  font-size: 0.8125rem;
  color: var(--chat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-member-option-check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--chat-primary);
}

.chat-member-picker-empty {
  margin: 0;
  padding: 28px 20px;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--chat-muted);
}

.chat-modal-footer--group {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  background: var(--chat-surface);
  border-top: 1px solid var(--chat-border);
}

.chat-modal-footer-hint {
  margin: 0;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--chat-muted);
}

.chat-modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.chat-modal-btn {
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s, background 0.15s;
}

.chat-modal-btn--ghost {
  background: var(--chat-surface);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
}

.chat-modal-btn--ghost:hover {
  background: var(--gray-50, #f9fafb);
}

.chat-modal-btn--primary {
  background: var(--chat-primary);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--chat-primary) 28%, transparent);
}

.chat-modal-btn--primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.chat-modal-btn--primary:disabled {
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
  background: #e5e7eb;
  color: #6b7280;
}

@media (max-width: 520px) {
  .chat-modal-footer--group {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-modal-footer-hint {
    max-width: none;
  }

  .chat-modal-footer-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 900px) {
  .chat-screen-wrap {
    max-height: none;
    height: auto;
    min-height: min(80vh, 640px);
  }
  .chat-page {
    flex-direction: column;
    min-height: min(70vh, 560px);
    max-height: none;
    overflow: visible;
  }
  .chat-sidebar {
    width: 100%;
    max-width: none;
    max-height: 42vh;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--chat-border);
  }
  .chat-main {
    min-height: min(50vh, 420px);
  }
}
