/* Session chat panel ------------------------------------------------------- */

.chat--card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
  max-height: 480px;
}

.chat--drawer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  min-height: 360px;
  max-height: min(70vh, 560px);
}

.chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chat__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat__title {
  margin: 0;
}

.chat__subtitle {
  margin: 4px 0 0;
}

.chat__messages {
  flex: 1 1 auto;
  min-height: 140px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.chat__system {
  align-self: center;
  max-width: 90%;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

.chat__bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  animation: bubble-in 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
}

.chat__bubble--mine {
  align-self: flex-end;
  background: rgba(94, 242, 176, 0.1);
  border-color: rgba(94, 242, 176, 0.28);
}

.chat__bubble--theirs {
  align-self: flex-start;
}

.chat__who {
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 4px;
}

.chat__text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.chat__text a {
  color: var(--accent-2);
  word-break: break-all;
}

.chat__file {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-3);
}

.chat__file-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ok-soft);
  font-size: 16px;
}

.chat__file-meta {
  min-width: 0;
  flex: 1 1 auto;
}

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

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

.chat__file-download {
  flex: 0 0 auto;
}

.chat__file-sent {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--faint);
}

.chat__transfer {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.chat__transfer[hidden] {
  display: none !important;
}

.chat__transfer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.chat__composer {
  display: grid;
  gap: 8px;
}

.chat__input {
  resize: vertical;
  min-height: 64px;
  max-height: 160px;
}

.chat__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.chat-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  animation: bubble-in 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.viewer-session--with-chat {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  align-items: start;
}

.viewer-session--with-chat .viewer-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.viewer-session--with-chat .chat--drawer {
  position: sticky;
  top: 12px;
}

@media (max-width: 991.98px) {
  .viewer-session--with-chat {
    grid-template-columns: minmax(0, 1fr);
  }

  .viewer-session--with-chat .chat--drawer {
    position: static;
  }
}
