/* Matter conversations and assistant use the same surfaces as the case drawer. */
#matterChat,
#matterAssistant {
  display: grid;
  gap: 14px;
  padding: clamp(12px, 3vw, 22px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

#matterChat > :first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#matterChat select,
#matterChat textarea,
#matterAssistant textarea,
.portal-compose input {
  min-width: 0;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

#matterChat select {
  flex: 1 1 220px;
  width: 100%;
  min-height: 42px;
}

#matterChat select:focus-visible,
#matterChat textarea:focus-visible,
#matterAssistant textarea:focus-visible,
.portal-compose input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

#matterChat [data-chat-thread] {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: min(420px, 48vh);
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

#matterChat [data-chat-thread] article {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 12px;
  overflow-wrap: anywhere;
}

#matterChat [data-chat-thread] article strong {
  color: var(--ink);
  text-transform: capitalize;
}

#matterChat [data-chat-thread] article p {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

#matterChat [data-chat-thread] > p,
#matterChat [data-chat-status] {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

#matterChat [data-chat-status]:empty,
#assistantAnswer:empty {
  display: none;
}

#matterChat form,
#matterChat form label,
#matterAssistant label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#matterChat textarea,
#matterAssistant textarea {
  width: 100%;
  resize: vertical;
}

#matterChat form button,
#matterAssistant button {
  justify-self: end;
}

#assistantAnswer:not(:empty) {
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.portal-msg .bubble {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.5;
}

.portal-compose input {
  flex: 1 1 0;
}

.portal-sign-receipt {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 9px;
  background: var(--brand-2);
  color: var(--ink);
}

.pick-head > :first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pick-head .dr-close { flex: none; }
.pick-opt .po-main { display: grid; gap: 4px; }
.pick-opt .po-t, .pick-opt .po-s { display: block; margin: 0; }
.pick-opt .po-s { line-height: 1.4; overflow-wrap: anywhere; }
.pick-opt:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.tc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: start;
  gap: 16px;
}
.tc-layout > .card { min-width: 0; }
.tc-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 10px; }
.tc-item {
  display: flex; align-items: center; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.tc-item:has(.tc-row[aria-pressed="true"]) { border-color: var(--brand); background: var(--brand-2); }
.tc-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex: 1; min-width: 0; align-self: stretch; padding: 12px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
}
.tc-row:hover { background: var(--surface-2); }
.tc-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.tc-row-identity, .tc-row-meta { display: grid; gap: 4px; }
.tc-row-identity { min-width: 0; overflow-wrap: anywhere; }
.tc-row-meta { justify-items: end; flex-shrink: 0; }
.tc-row .tc-kind, .tc-tags .tc-kind {
  justify-self: start;
  padding: 3px 8px;
  border: 1px solid var(--kind-border);
  border-radius: 999px;
  background: var(--kind-bg);
  color: var(--kind-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}
.tc-kind-prospect { --kind-bg: #e4edff; --kind-border: #b9cdff; --kind-ink: #153d92; }
.tc-kind-client { --kind-bg: #def5e9; --kind-border: #a7d8bb; --kind-ink: #145538; }
.tc-kind-voicemail { --kind-bg: #fff1d7; --kind-border: #e8c985; --kind-ink: #6b460b; }
.tc-kind-vendor { --kind-bg: #efe7ff; --kind-border: #d2bef6; --kind-ink: #58378c; }
.tc-kind-other { --kind-bg: #fae8ea; --kind-border: #e9bec4; --kind-ink: #872c3b; }
.tc-kind-unknown { --kind-bg: #edf0f4; --kind-border: #ced5df; --kind-ink: #3d4b5c; }
.tc-row span span, .tc-detail-head p { color: var(--ink-3); font-size: 12px; }
.tc-contact { margin-right: 8px; flex-shrink: 0; }
.tc-badge, .tc-tags span {
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--ink); font-size: 12px;
}
.tc-detail-head, .tc-contact-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.tc-detail-head, .tc-empty { padding: 18px; }
.tc-detail-head { border-bottom: 1px solid var(--line); }
.tc-detail-head h3, .tc-copy h4, .tc-empty h3 { margin: 0; }
.tc-detail-head p, .tc-empty p { margin: 5px 0 0; }
.tc-detail-body { display: grid; gap: 12px; padding: 16px; overflow-wrap: anywhere; }
.tc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tc-contact-panel, .tc-copy { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.tc-contact-panel { background: var(--brand-2); }
.tc-copy p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.55; }
.tc-transcript summary { cursor: pointer; font-weight: 700; }
@media (max-width: 900px) {
  .tc-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .tc-row { gap: 6px; padding: 9px; }
  .tc-contact { max-width: 90px; white-space: normal; }
}

@media (max-width: 480px) {
  #matterChat form button,
  #matterAssistant button {
    width: 100%;
  }

  .portal-compose {
    flex-wrap: wrap;
  }

  .portal-compose input {
    flex-basis: 100%;
  }
}
