/* Portal colleague chat */

.portal-chat-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#portalChatBtn {
  position: relative;
}

.portal-chat-badge {
  position: absolute;
  top: -2px;
  inset-inline-start: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ui-accent);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
  pointer-events: none;
}

.portal-chat-contacts {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: min(480px, 75vh);
  display: flex;
  flex-direction: column;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  z-index: 5000;
  overflow: hidden;
}

.portal-chat-contacts[hidden] {
  display: none !important;
}

.portal-chat-inbox {
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface-muted);
  max-height: 46%;
  overflow: auto;
  flex: 0 1 auto;
}

.portal-chat-inbox[hidden] {
  display: none !important;
}

.portal-chat-inbox-head {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ui-text-muted);
}

.portal-chat-inbox-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 6px 8px;
}

.portal-chat-inbox-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  text-align: right;
  border: none;
  background: var(--ui-surface);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border: 1px solid transparent;
}

.portal-chat-inbox-item:hover {
  border-color: var(--ui-border-strong);
  background: var(--ui-row-hover);
}

.portal-chat-inbox-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.portal-chat-inbox-top strong {
  font-size: 13px;
  color: var(--ui-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-chat-inbox-count {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ui-accent);
  color: #fff;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}

.portal-chat-inbox-preview {
  font-size: 12px;
  color: var(--ui-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-chat-inbox-time {
  font-size: 10px;
  color: var(--ui-text-muted);
}

.portal-chat-contacts-head {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-chat-contacts-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.portal-chat-contacts-head strong {
  font-size: 14px;
  color: var(--ui-text);
}

.portal-chat-sound-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface-muted, rgba(15, 23, 42, 0.04));
  color: var(--ui-text);
  cursor: pointer;
  flex-shrink: 0;
}

.portal-chat-sound-btn:hover {
  border-color: var(--ui-border-strong, #94a3b8);
}

.portal-chat-sound-btn.is-muted {
  color: var(--ui-text-muted, #64748b);
  opacity: 0.85;
}

.portal-chat-contact-search {
  width: 100%;
  border: 1px solid var(--ui-border-strong);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}

.portal-chat-contact-search:focus {
  border-color: var(--ui-text-muted);
}

.portal-chat-contacts-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.portal-chat-contacts-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--ui-text-muted);
  font-size: 13px;
}

.portal-chat-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  text-align: right;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.portal-chat-contact:hover {
  background: var(--ui-surface-muted);
}

.portal-chat-contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ui-border);
  color: var(--ui-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}

.portal-chat-contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.portal-chat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ui-surface);
  position: absolute;
  bottom: -1px;
  inset-inline-start: -1px;
  background: var(--ui-text-muted);
}

.portal-chat-dot.is-online {
  background: #22c55e;
}

.portal-chat-dot.is-group {
  background: #6366f1;
}

.portal-chat-win-panel {
  max-height: 180px;
  overflow: auto;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface-muted);
}

.portal-chat-panel-head {
  padding: 8px 10px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ui-text);
}

.portal-chat-panel-empty {
  padding: 12px;
  text-align: center;
  color: var(--ui-text-muted);
  font-size: 12px;
}

.portal-chat-panel-list {
  display: flex;
  flex-direction: column;
  padding: 4px 0 8px;
}

.portal-chat-panel-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  text-align: right;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.portal-chat-panel-item.is-static {
  cursor: default;
}

.portal-chat-panel-item:not(.is-static):hover {
  background: var(--ui-border);
}

.portal-chat-panel-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ui-border);
  color: var(--ui-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.portal-chat-panel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portal-chat-panel-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}

.portal-chat-panel-meta span {
  font-size: 13px;
  font-weight: 600;
}

.portal-chat-panel-item small {
  font-size: 11px;
  color: var(--ui-text-muted);
}

.portal-chat-leave-btn {
  margin: 4px 12px 10px;
  width: calc(100% - 24px);
  color: #b91c1c !important;
  border-color: #fecaca !important;
}

.portal-chat-msg.is-system {
  align-self: center;
  max-width: 92%;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 4px 8px;
  text-align: center;
}

.portal-chat-msg-system {
  font-size: 11px;
  color: var(--ui-text-muted);
  background: var(--ui-border);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

.portal-chat-msg-sender {
  font-size: 11px;
  font-weight: 700;
  color: var(--ui-brand-hover);
  margin-bottom: 2px;
}

.portal-chat-msg.is-system .portal-chat-msg-meta {
  justify-content: center;
}

.portal-chat-contact-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-chat-contact-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-contact-sub {
  font-size: 11px;
  color: var(--ui-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-windows {
  position: fixed;
  bottom: 0;
  inset-inline-end: 12px;
  inset-inline-start: 12px;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 10px;
  z-index: 4800;
  pointer-events: none;
  overflow-x: auto;
  padding-bottom: 0;
  max-width: calc(100vw - 24px);
}

.portal-chat-window {
  width: min(340px, 92vw);
  height: 440px;
  max-height: calc(100vh - 80px);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border-strong);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  flex: 0 0 auto;
}

.portal-chat-window.is-minimized {
  height: 44px;
}

.portal-chat-window.is-alerting {
  outline: 2px solid var(--ui-accent, #dc2626);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.25);
  animation: portal-chat-pulse 1s ease-in-out 2;
  z-index: 40;
}

.portal-chat-win-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--ui-text);
  color: var(--ui-surface-muted);
  cursor: pointer;
  user-select: none;
}

.portal-chat-win-avatar-host {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.portal-chat-win-avatars {
  display: inline-flex;
  align-items: center;
  flex-direction: row-reverse;
}

.portal-chat-win-avatars .portal-chat-win-avatar {
  margin-inline-start: -10px;
  border: 2px solid var(--ui-text);
}

.portal-chat-win-avatars .portal-chat-win-avatar:last-child {
  margin-inline-start: 0;
}

.portal-chat-win-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: var(--ui-surface-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.portal-chat-win-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portal-chat-win-avatar .portal-chat-dot {
  position: absolute;
  bottom: -1px;
  inset-inline-start: -1px;
  border-color: var(--ui-text);
}

.portal-chat-win-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-win-actions {
  display: inline-flex;
  gap: 4px;
}

.portal-chat-win-actions button {
  border: 0;
  background: transparent;
  color: var(--ui-border);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
}

.portal-chat-win-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.portal-chat-win-main {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.portal-chat-win-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--ui-surface-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.portal-chat-msg-spacer {
  flex: 0 0 auto;
  height: 0;
  min-height: 0;
  pointer-events: none;
}

.portal-chat-unread-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
  align-self: stretch;
  color: var(--ui-primary, #0b6e4f);
  font-size: 12px;
  font-weight: 600;
}

.portal-chat-unread-sep::before,
.portal-chat-unread-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--ui-primary, #0b6e4f) 35%, transparent);
}

.portal-chat-jump-latest {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.portal-chat-jump-latest[hidden] {
  display: none !important;
}

.portal-chat-jump-latest:hover {
  background: var(--ui-surface-muted);
}

.portal-chat-jump-latest-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ui-primary, #0b6e4f);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.portal-chat-jump-latest-badge[hidden] {
  display: none !important;
}

.portal-chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  align-self: flex-start;
}

.portal-chat-msg-row.is-mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.portal-chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ui-border);
  color: var(--ui-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.portal-chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portal-chat-msg {
  max-width: 88%;
  align-self: flex-start;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 10px;
  position: relative;
}

.portal-chat-msg-row .portal-chat-msg {
  max-width: min(88%, 100%);
  align-self: auto;
}

.portal-chat-msg-row.has-avatar .portal-chat-msg {
  max-width: calc(88% - 36px);
}

.portal-chat-msg.is-mine {
  align-self: flex-end;
  background: var(--ui-row-hover);
  border-color: var(--ui-border-strong);
  border-radius: 12px 12px 4px 12px;
}

.portal-chat-msg.is-deleted {
  opacity: 0.7;
  font-style: italic;
  color: var(--ui-text-muted);
}

.portal-chat-msg-reply {
  border-inline-start: 3px solid var(--ui-text-muted);
  background: rgba(15, 23, 42, 0.04);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--ui-text-muted);
}

.portal-chat-msg-reply strong {
  display: block;
  font-size: 11px;
  color: var(--ui-text);
}

.portal-chat-msg-body {
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ui-text);
}

.portal-chat-msg-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.portal-chat-msg-files a.portal-chat-file-link,
.portal-chat-media-download {
  font-size: 12px;
  color: var(--ui-brand-hover);
  text-decoration: none;
  word-break: break-all;
}

.portal-chat-msg-files a:hover,
.portal-chat-media-download:hover {
  text-decoration: underline;
}

.portal-chat-file-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.portal-chat-att-import {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: var(--ui-surface);
  color: var(--ui-text);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.portal-chat-att-import:hover {
  background: var(--ui-surface-muted);
}

.portal-chat-inq-pick-list {
  max-height: 240px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
}

.portal-chat-inq-pick-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: right;
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: var(--ui-surface);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.portal-chat-inq-pick-item.is-selected,
.portal-chat-inq-pick-item:hover {
  border-color: var(--ui-brand);
  background: var(--ui-row-hover);
}

.portal-chat-import-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.portal-chat-msg-system .portal-chat-inq-link {
  background: none;
  border: none;
  color: var(--ui-brand-hover);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.portal-chat-voice-player {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 280px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  direction: ltr;
}

.portal-chat-voice-player audio {
  display: none;
}

.portal-chat-voice-toggle {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--ui-text);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portal-chat-voice-seek {
  flex: 1;
  min-width: 0;
  accent-color: var(--ui-brand);
  cursor: pointer;
}

.portal-chat-voice-time {
  font-size: 10px;
  color: var(--ui-text-muted);
  white-space: nowrap;
  min-width: 4.5em;
  text-align: center;
  direction: ltr;
}

.portal-chat-voice-rates {
  display: inline-flex;
  gap: 2px;
}

.portal-chat-voice-rates button {
  border: 0;
  background: transparent;
  color: var(--ui-text-muted);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  width: auto;
  height: auto;
}

.portal-chat-voice-rates button.is-active {
  background: var(--ui-brand);
  color: #fff;
}

.portal-chat-media {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 260px;
}

.portal-chat-media-preview {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  background: #0f172a0a;
}

.portal-chat-media-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.portal-chat-video {
  display: block;
  width: 100%;
  max-height: 220px;
  border-radius: 10px;
  background: var(--ui-text);
}

.portal-chat-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--ui-text-muted);
}

.portal-chat-ticks {
  letter-spacing: -2px;
  font-size: 12px;
  color: var(--ui-text-muted);
}

.portal-chat-ticks.is-read {
  color: var(--ui-brand);
}

.portal-chat-msg-actions {
  position: absolute;
  top: -10px;
  inset-inline-end: 6px;
  display: none;
  gap: 2px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.portal-chat-msg:hover .portal-chat-msg-actions,
.portal-chat-msg-actions.is-react-open {
  display: inline-flex;
}

.portal-chat-msg-actions button {
  border: 0;
  background: transparent;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ui-text-muted);
  font-size: 12px;
}

.portal-chat-msg-actions button:hover {
  background: var(--ui-surface-muted);
  color: var(--ui-text);
}

.portal-chat-msg.has-reacts {
  margin-bottom: 12px;
  padding-bottom: 14px;
}

.portal-chat-react-palette {
  display: none;
  position: absolute;
  top: 100%;
  inset-inline-end: 0;
  z-index: 20;
  gap: 2px;
  padding: 8px 3px 3px;
  margin-top: -2px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.portal-chat-msg-actions.is-react-open .portal-chat-react-palette {
  display: inline-flex;
}

.portal-chat-react-palette button {
  width: 28px;
  height: 28px;
  font-size: 16px;
  line-height: 1;
}

.portal-chat-react-bar {
  position: absolute;
  bottom: -10px;
  inset-inline-start: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  z-index: 2;
}

.portal-chat-msg.is-mine .portal-chat-react-bar {
  inset-inline-start: auto;
  inset-inline-end: 8px;
}

.portal-chat-react-chip {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

.portal-chat-react-chip span {
  margin-inline-start: 2px;
  font-size: 11px;
  color: var(--ui-text-muted);
}

.portal-chat-react-chip.is-mine {
  background: transparent;
}

.portal-chat-window.is-drop-over,
.portal-chat-mobile-thread.is-drop-over {
  outline: 2px dashed var(--ui-brand);
  outline-offset: -4px;
}

.portal-chat-file-confirm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
  max-height: 280px;
  overflow: auto;
}

.portal-chat-file-confirm-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-chat-file-confirm-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.portal-chat-file-confirm-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ui-surface-muted);
  color: var(--ui-text-muted);
  flex-shrink: 0;
}

.portal-chat-file-confirm-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-chat-file-confirm-meta strong {
  overflow-wrap: anywhere;
}

.portal-chat-win-reply {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--ui-row-selected);
  border-top: 1px solid var(--ui-border);
  font-size: 12px;
  color: var(--ui-text);
}

.portal-chat-win-reply.is-open {
  display: flex;
}

.portal-chat-win-reply-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-win-reply button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ui-text-muted);
}

.portal-chat-win-foot {
  border-top: 1px solid var(--ui-border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--ui-surface);
}

.portal-chat-win-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.portal-chat-win-input-row textarea {
  flex: 1;
  min-height: 38px;
  max-height: 90px;
  resize: none;
  border: 1px solid var(--ui-border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.portal-chat-win-input-row textarea:focus {
  border-color: var(--ui-text-muted);
}

.portal-chat-win-input-row button,
.portal-chat-quote-btn {
  border: 0;
  background: var(--ui-text);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.portal-chat-win-input-row button.portal-chat-attach,
.portal-chat-win-input-row button.portal-chat-voice {
  background: var(--ui-border);
  color: var(--ui-text);
}

.portal-chat-win-input-row button.portal-chat-voice.is-recording {
  background: var(--ui-accent);
  color: #fff;
  animation: portal-chat-pulse 1.2s ease-in-out infinite;
}

.portal-chat-voice-timer {
  font-size: 12px;
  color: var(--ui-accent);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
}

@keyframes portal-chat-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
  }
}

.portal-chat-inq-link {
  border: 0;
  background: transparent;
  color: var(--ui-brand);
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.portal-chat-inq-link:hover {
  color: var(--ui-brand-hover);
}

.portal-chat-inq-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.portal-chat-inq-preview-dialog {
  position: relative;
  width: min(380px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: transparent;
}

.portal-chat-inq-preview-close {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.portal-chat-inq-preview-body .inq-slide-card {
  width: 100%;
  max-width: none;
  cursor: default;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

.portal-chat-win-input-row button:hover {
  filter: brightness(1.08);
}

.portal-chat-quote-btn {
  display: none;
  position: fixed;
  z-index: 5100;
  width: auto;
  height: auto;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--ui-text);
}

.portal-chat-quote-btn.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 640px) {
  .portal-chat-window {
    width: min(100vw - 16px, 360px);
    height: min(70vh, 480px);
  }

  .portal-chat-windows {
    inset-inline-end: 8px;
    inset-inline-start: 8px;
  }
}

/* Voice call — floating non-blocking panel */
.portal-chat-call-overlay {
  position: fixed;
  bottom: 16px;
  inset-inline-start: 16px;
  z-index: 5200;
  display: block;
  width: auto;
  max-width: min(340px, calc(100vw - 32px));
  pointer-events: none;
  padding: 0;
  background: transparent;
}

.portal-chat-call-overlay[hidden] {
  display: none !important;
}

.portal-chat-call-card {
  pointer-events: auto;
  width: min(320px, calc(100vw - 32px));
  background: var(--ui-surface, #fff);
  border: 1px solid var(--ui-border, #e2e8f0);
  border-radius: 16px;
  padding: 20px 18px 16px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  position: relative;
}

.portal-chat-call-toolbar {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  display: flex;
  gap: 4px;
}

.portal-chat-call-toolbar button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--ui-text-muted, #64748b);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.portal-chat-call-toolbar button:hover {
  background: rgba(15, 23, 42, 0.12);
  color: var(--ui-text, #0f172a);
}

.portal-chat-call-mini {
  display: none;
  pointer-events: auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  background: var(--ui-surface, #fff);
  border: 1px solid var(--ui-border, #e2e8f0);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  max-width: min(340px, calc(100vw - 32px));
  cursor: pointer;
}

.portal-chat-call-overlay.is-minimized .portal-chat-call-card {
  display: none;
}

.portal-chat-call-overlay.is-minimized .portal-chat-call-mini {
  display: inline-flex;
}

.portal-chat-call-mini-peer {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ui-text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.portal-chat-call-mini-timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ui-brand, #0f766e);
  min-width: 3.2em;
}

.portal-chat-call-mini-timer[hidden] {
  display: none !important;
}

.portal-chat-call-mini-end {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.portal-chat-call-mini-expand {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.06);
  color: var(--ui-text, #334155);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.portal-chat-call-direction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 auto 14px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(15, 23, 42, 0.06);
  color: var(--ui-text-muted, #64748b);
}

.portal-chat-call-direction[data-mode='incoming'] {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.portal-chat-call-direction[data-mode='outgoing'] {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.portal-chat-call-direction[data-mode='connecting'] {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.portal-chat-call-direction[data-mode='active'] {
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
}

.portal-chat-call-avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--ui-surface-muted, #e2e8f0);
  color: var(--ui-text, #0f172a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  overflow: hidden;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.portal-chat-call-avatar.has-photo {
  background: transparent;
}

.portal-chat-call-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portal-chat-call-overlay[data-call-mode='incoming'] .portal-chat-call-avatar,
.portal-chat-call-card:has(.portal-chat-call-direction[data-mode='incoming']) .portal-chat-call-avatar {
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2);
  animation: portal-chat-call-pulse 1.6s ease-in-out infinite;
}

.portal-chat-call-overlay[data-call-mode='outgoing'] .portal-chat-call-avatar {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
  animation: portal-chat-call-pulse 1.6s ease-in-out infinite;
}

@keyframes portal-chat-call-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.portal-chat-call-peer {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ui-text, #0f172a);
  margin-bottom: 6px;
}

.portal-chat-call-status {
  font-size: 0.9rem;
  color: var(--ui-text-muted, #64748b);
  margin-bottom: 8px;
}

.portal-chat-call-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ui-brand, #0f766e);
  margin-bottom: 16px;
}

.portal-chat-call-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.portal-chat-call-actions button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
}

.portal-chat-call-accept {
  background: #16a34a;
}

.portal-chat-call-end,
.portal-chat-call-reject,
.portal-chat-call-hangup {
  background: #dc2626;
}

.portal-chat-call-mute {
  background: var(--ui-text, #334155);
}

.portal-chat-call-mute.is-muted {
  background: #64748b;
}

.portal-chat-win-actions [data-win='call'] {
  color: #16a34a;
}

.portal-chat-win-actions [data-win='call'][hidden] {
  display: none !important;
}

.portal-chat-win-actions [data-win='call']:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

