.profile-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.profile-chat-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(23, 31, 40, 0.46);
  cursor: pointer;
}

.profile-chat-panel {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  height: min(780px, calc(100dvh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: 18px;
  background: rgba(248, 249, 247, 0.98);
  box-shadow: 0 32px 88px rgba(23, 31, 40, 0.26);
}

.profile-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid rgba(var(--primary-rgb), 0.1);
  background: rgba(255, 255, 255, 0.92);
}

.profile-chat-head strong {
  color: var(--text-deep);
  font-family: var(--font-heading);
  font-size: 1rem;
}

.profile-chat-head p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.4;
}

.profile-chat-close {
  width: auto;
  min-height: 38px;
  padding-inline: 13px;
  border: 1px solid rgba(var(--primary-rgb), 0.32);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 18px rgba(15, 43, 37, 0.08);
  white-space: nowrap;
}

.profile-chat-body {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.profile-chat-jump {
  position: absolute;
  right: 18px;
  bottom: 82px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(var(--primary-rgb), 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 28px rgba(15, 43, 37, 0.16);
  color: var(--text-deep);
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  cursor: pointer;
}

.profile-chat-jump.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.profile-chat-body .profile-thread-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.profile-chat-composer {
  padding: 10px 12px;
  border-top: 1px solid rgba(var(--primary-rgb), 0.1);
  background: rgba(255, 255, 255, 0.94);
}

.profile-chat-composer .profile-response-actions {
  margin: 0 0 9px;
}

.profile-chat-composer .profile-response-form {
  margin: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.profile-chat-composer .profile-response-form label {
  display: none;
}

.profile-chat-composer .profile-response-form textarea {
  height: 44px;
  min-height: 44px;
  max-height: 88px;
  padding: 11px 12px;
  resize: none;
}

.profile-chat-composer .profile-response-form button {
  width: auto;
  min-height: 44px;
  padding-inline: 16px;
  border: 1px solid rgba(var(--primary-rgb), 0.34);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 18px rgba(15, 43, 37, 0.08);
  white-space: nowrap;
}

.profile-chat-composer .profile-response-status {
  grid-column: 1 / -1;
}

.profile-response-actions,
.profile-response-form,
.profile-client-responses {
  margin-top: 14px;
}

.profile-response-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-response-actions p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.45;
}

.profile-response-actions .btn-main {
  flex: 0 0 auto;
  width: auto;
  min-height: 42px;
  padding-inline: 18px;
  white-space: nowrap;
}

.profile-response-composer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(var(--primary-rgb), 0.1);
}

.profile-response-form {
  display: grid;
  gap: 10px;
}

.profile-response-form label,
.profile-client-responses > strong {
  color: var(--text-deep);
  font-size: 0.82rem;
  font-weight: 800;
}

.profile-response-form textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px 13px;
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-main);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.profile-response-form textarea:focus {
  outline: 3px solid rgba(var(--accent-rgb), 0.18);
  border-color: rgba(var(--accent-rgb), 0.36);
}

.profile-response-status {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
}

.profile-response-status.is-success {
  color: rgb(28, 112, 86);
}

.profile-response-status.is-error,
.profile-response-save-state.is-error {
  color: rgb(162, 56, 56);
}

.profile-response-save-state {
  display: inline-flex;
  margin-top: 6px;
  color: rgba(36, 47, 60, 0.68);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 700;
}

@media (max-width: 640px) {
  .profile-chat-overlay {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .profile-chat-panel {
    position: fixed;
    inset: 0 0 var(--portal-chat-keyboard-offset, 0px) 0;
    width: 100%;
    height: auto;
    min-height: 0;
    border-radius: 0;
    border: 0;
  }

  .profile-chat-head {
    align-items: center;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  }

  .profile-chat-head p {
    display: none;
  }

  .profile-chat-close {
    min-height: 34px;
    padding-inline: 11px;
    font-size: 0.72rem;
  }

  .profile-chat-body {
    padding: 12px;
  }

  .profile-chat-jump {
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: 40px;
    height: 40px;
  }

  .profile-chat-composer {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .profile-chat-composer .profile-response-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .profile-thread-bubble--client {
    width: 100%;
  }

  .profile-response-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-response-actions .btn-main {
    white-space: normal;
  }
}
.profile-message-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 250, 0.9));
  box-shadow: 0 18px 42px rgba(43, 56, 70, 0.08), 0 0 22px rgba(var(--primary-rgb), 0.08);
  scroll-margin-top: 18px;
}

.profile-message-card:focus,
.profile-message-timeline--primary:focus {
  outline: 3px solid rgba(var(--accent-rgb), 0.28);
  outline-offset: 3px;
}

.profile-message-preview.has-unread-trisma-message {
  border-color: rgba(var(--accent-rgb), 0.66);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.22), 0 0 28px rgba(var(--accent-rgb), 0.28);
  animation: trisma-message-pulse 1.9s ease-in-out infinite;
}

@keyframes trisma-message-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18), 0 0 18px rgba(var(--accent-rgb), 0.18); }
  50% { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.36), 0 0 34px rgba(var(--accent-rgb), 0.36); }
}

.profile-message-preview {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px;
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.profile-message-preview:hover,
.profile-message-preview:focus-visible {
  border-color: rgba(var(--accent-rgb), 0.36);
  box-shadow: 0 12px 28px rgba(43, 56, 70, 0.08);
  outline: none;
}

.profile-message-preview span { min-width: 0; display: grid; gap: 4px; }
.profile-message-preview small, .profile-message-meta { color: var(--text-soft); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.profile-message-preview strong { color: var(--text-deep); font-family: var(--font-heading); font-size: 0.98rem; line-height: 1.3; overflow-wrap: anywhere; }
.profile-message-preview em { color: var(--text-main); font-size: 0.88rem; font-style: normal; line-height: 1.45; overflow-wrap: anywhere; }
.profile-message-preview b { flex: 0 0 auto; border-radius: 999px; padding: 10px 14px; background: rgba(var(--accent-rgb), 0.16); color: var(--text-deep); font-size: 0.82rem; }

.profile-message-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-message-count { flex: 0 0 auto; margin: 0; padding: 7px 11px; border: 1px solid rgba(var(--accent-rgb), 0.24); border-radius: 999px; background: rgba(255, 255, 255, 0.82); color: var(--text-soft); font-size: 0.78rem; font-weight: 850; line-height: 1; }

.profile-message-timeline { margin-top: 14px; padding: 14px; border: 1px solid rgba(var(--primary-rgb), 0.12); border-radius: 14px; background: rgba(255, 255, 255, 0.68); }
.profile-message-timeline--primary { padding: 18px; border-color: rgba(var(--accent-rgb), 0.28); background: rgba(255, 255, 255, 0.88); box-shadow: 0 18px 42px rgba(43, 56, 70, 0.08); scroll-margin-top: 18px; }
.profile-message-head strong { color: var(--text-deep); font-family: var(--font-heading); font-size: 0.98rem; }
.profile-message-head p { margin: 5px 0 0; color: var(--text-soft); font-size: 0.88rem; }
.profile-latest-message-body, .profile-thread-list { margin-top: 14px; }
.profile-message-timeline .profile-thread-list, .profile-chat-body .profile-thread-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.profile-chat-body .profile-thread-list { margin: 0; }
.profile-thread-bubble { border: 1px solid rgba(var(--primary-rgb), 0.1); border-radius: 14px; padding: 14px; overflow-wrap: anywhere; }
.profile-thread-bubble--trisma { background: rgba(255, 255, 255, 0.84); }
.profile-message-event { display: inline-block; margin-bottom: 0.35rem; color: var(--primary); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.profile-thread-event--proposal { border-color: rgba(var(--primary-rgb), 0.32); }
.profile-thread-event--appointment { border-color: rgba(33, 113, 79, 0.32); }
.profile-thread-event--recommendation { border-color: rgba(189, 112, 37, 0.32); }
.profile-thread-bubble--client { width: min(86%, 720px); margin-left: auto; border-color: rgba(var(--accent-rgb), 0.2); background: rgba(var(--accent-rgb), 0.08); }
.profile-message-subject { display: block; margin-top: 5px; color: var(--text-deep); font-family: var(--font-heading); font-size: 1.06rem; line-height: 1.3; overflow-wrap: anywhere; }
.profile-latest-message-body em { display: block; margin-top: 4px; color: var(--text-soft); font-size: 0.86rem; font-style: normal; }
.profile-message-copy { margin: 12px 0 0; color: var(--text-main); font-size: 0.94rem; line-height: 1.62; overflow-wrap: anywhere; }
.profile-client-responses ol { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.profile-client-responses li { padding: 12px; }
.profile-client-responses li span, .profile-message-timeline li span { display: block; color: var(--text-soft); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.profile-client-responses li strong, .profile-message-timeline li strong { display: block; margin-top: 4px; color: var(--text-deep); font-size: 0.9rem; }
.profile-client-responses li p { margin: 6px 0 0; color: var(--text-main); font-size: 0.88rem; line-height: 1.52; }
.profile-message-history { margin-top: 14px; border-top: 1px solid rgba(var(--primary-rgb), 0.1); padding-top: 12px; }
.profile-message-history summary { cursor: pointer; color: var(--text-deep); font-size: 0.86rem; font-weight: 800; }
.profile-message-timeline ol { margin: 12px 0 0; padding-left: 18px; }
.profile-message-timeline li + li { margin-top: 10px; }
.profile-thread-list li + li { margin-top: 0; }
.profile-message-timeline li strong { margin-top: 2px; font-size: 0.92rem; line-height: 1.35; overflow-wrap: anywhere; }
.profile-message-timeline li em { display: block; margin-top: 2px; color: var(--text-soft); font-size: 0.82rem; font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  .profile-message-preview.has-unread-trisma-message { animation: none; }
}

@media (max-width: 640px) {
  .profile-message-preview { align-items: stretch; flex-direction: column; }
  .profile-message-preview b { width: fit-content; }
}
      .profile-message-title-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
      }

      .profile-message-count {
        flex: 0 0 auto;
        margin: 0;
        padding: 7px 11px;
        border: 1px solid rgba(var(--accent-rgb), 0.24);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.82);
        color: var(--text-soft);
        font-size: 0.78rem;
        font-weight: 850;
        line-height: 1;
      }

      .profile-message-timeline {
        margin-top: 14px;
        padding: 14px;
        border: 1px solid rgba(var(--primary-rgb), 0.12);
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.68);
      }

      .profile-message-timeline--primary {
        padding: 18px;
        border-color: rgba(var(--accent-rgb), 0.28);
        background: rgba(255, 255, 255, 0.88);
        box-shadow: 0 18px 42px rgba(43, 56, 70, 0.08);
        scroll-margin-top: 18px;
      }

      .profile-message-timeline--primary:focus {
        outline: 3px solid rgba(var(--accent-rgb), 0.28);
        outline-offset: 3px;
      }

      .profile-message-head strong {
        color: var(--text-deep);
        font-family: var(--font-heading);
        font-size: 0.98rem;
      }

      .profile-message-head p {
        margin: 5px 0 0;
        color: var(--text-soft);
        font-size: 0.88rem;
      }

      .profile-latest-message-body,
      .profile-thread-list {
        margin-top: 14px;
      }

      .profile-message-timeline .profile-thread-list {
        margin: 14px 0 0;
        padding: 0;
        list-style: none;
        display: grid;
        gap: 10px;
      }

      .profile-thread-bubble {
        border: 1px solid rgba(var(--primary-rgb), 0.1);
        border-radius: 14px;
        padding: 14px;
        overflow-wrap: anywhere;
      }

      .profile-thread-bubble--trisma {
        background: rgba(255, 255, 255, 0.84);
      }

      .profile-message-event {
        display: inline-block;
        margin-bottom: 0.35rem;
        color: var(--primary);
        font-size: 0.72rem;
        font-weight: 800;
        letter-spacing: 0.06em;
        text-transform: uppercase;
      }

      .profile-thread-event--proposal { border-color: rgba(var(--primary-rgb), 0.32); }
      .profile-thread-event--appointment { border-color: rgba(33, 113, 79, 0.32); }
      .profile-thread-event--recommendation { border-color: rgba(189, 112, 37, 0.32); }

      .profile-thread-bubble--client {
        width: min(86%, 720px);
        margin-left: auto;
        border-color: rgba(var(--accent-rgb), 0.2);
        background: rgba(var(--accent-rgb), 0.08);
      }

      .profile-message-meta {
        display: block;
        color: var(--text-soft);
        font-size: 0.74rem;
        font-weight: 800;
        letter-spacing: 0.5px;
        text-transform: uppercase;
      }

      .profile-message-subject {
        display: block;
        margin-top: 5px;
        color: var(--text-deep);
        font-family: var(--font-heading);
        font-size: 1.06rem;
        line-height: 1.3;
        overflow-wrap: anywhere;
      }

      .profile-latest-message-body em {
        display: block;
        margin-top: 4px;
        color: var(--text-soft);
        font-size: 0.86rem;
        font-style: normal;
      }

      .profile-message-copy {
        margin: 12px 0 0;
        color: var(--text-main);
        font-size: 0.94rem;
        line-height: 1.62;
        overflow-wrap: anywhere;
      }
