:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) {
  --chat-text: var(--ink, #172a33);
  --chat-muted: var(--sub, #506572);
  --chat-line: var(--line, #d9e4e6);
  --chat-paper: var(--paper, #fff);
  --chat-accent: var(--blue, #123a4b);
  --chat-mint: var(--mint, #e4f0ef);
  --chat-sand: var(--sand, #f4ead3);
  --chat-gold: var(--gold, #775516);
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) :is(h1, h2, p) { margin: 0; }

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) [hidden] { display: none !important; }

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) .bt-title h1 {
  font-size: clamp(25px, 5vw, 34px);
  letter-spacing: -.035em;
  line-height: 1.15;
}

:is(.bt-chat-index, .bt-card-screen) .bt-title p {
  color: var(--chat-muted);
  margin-top: 5px;
}

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) :is(.bt-primary, .bt-secondary, .bt-inline) {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  padding: 7px 12px;
  width: fit-content;
  border: 1px solid var(--chat-line);
  border-radius: 10px;
  background: var(--chat-paper);
  color: var(--chat-accent);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) .bt-primary {
  background: var(--chat-accent);
  border-color: var(--chat-accent);
  color: var(--on-blue, #fff);
}

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) .bt-inline {
  border: 0;
  background: transparent;
  justify-content: start;
  padding-inline: 0;
}

:is(.bt-chat-index, .bt-chat-thread, .bt-card-screen) button:disabled { cursor: wait; opacity: .62; }

.bt-chat-heading, .bt-chat-controls, .bt-chat-request-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bt-chat-heading { justify-content: space-between; }

.bt-chat-list, .bt-chat-requests { display: grid; gap: 8px; }
.bt-chat-requests h2 { font-size: 15px; }

.bt-chat-entry, .bt-chat-request, .bt-chat-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bt-chat-entry, .bt-chat-request {
  min-height: 61px;
  padding: 11px;
  background: var(--chat-paper);
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  color: var(--chat-text);
  text-decoration: none;
}

.bt-chat-entry:hover { border-color: var(--chat-accent); }
.bt-chat-request { flex-wrap: wrap; }
.bt-chat-request-actions { margin-inline-start: auto; }
.bt-chat-entry .bt-chat-chevron { margin-inline-start: auto; color: var(--chat-muted); font-size: 23px; }

.bt-chat-list-label, .bt-chat-person-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bt-chat-list-label p, .bt-chat-person-name p, .bt-chat-meta, .bt-chat-translation-status {
  color: var(--chat-muted);
  font-size: .8rem;
}

.bt-chat-person h1 { font-size: clamp(19px, 4.5vw, 26px); letter-spacing: -.025em; }

.bt-chat-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  color: var(--chat-accent);
  background: var(--chat-mint);
  font-weight: 700;
}

.bt-chat-avatar-gold { color: var(--chat-gold); background: var(--chat-sand); }

.bt-chat-empty, .bt-chat-notice {
  color: var(--chat-muted);
  padding: 9px 10px;
  font-size: .9rem;
}

.bt-chat-notice {
  border-radius: 8px;
  background: var(--chat-mint);
  color: var(--chat-accent);
}

.bt-chat-error { background: var(--chat-sand); color: var(--chat-gold); }

.bt-chat-messages {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 8px;
  min-height: min(34dvh, 270px);
  max-height: min(51dvh, 560px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 7px 2px 7px 1px;
}

.bt-chat-bubble {
  max-width: min(92%, 42rem);
  padding: 9px 11px;
  border: 1px solid var(--chat-line);
  border-radius: 3px 13px 13px 13px;
  background: var(--chat-paper);
  overflow-wrap: anywhere;
}

.bt-chat-out { align-self: end; border-radius: 13px 3px 13px 13px; background: var(--chat-mint); }
.bt-chat-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.bt-chat-message-text, .bt-chat-original { white-space: pre-wrap; }
.bt-chat-original { border-top: 1px solid var(--chat-line); padding-top: 7px; color: var(--chat-muted); }
.bt-chat-thread .bt-chat-bubble .bt-inline { min-height: 44px; font-size: .82rem; }
.bt-chat-thread .bt-chat-translation-status { margin-top: 4px; }

.bt-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 6px;
}

.bt-chat-compose :is(textarea, select), .bt-card-form input:not([type="checkbox"]), .bt-card-preview > input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: var(--chat-paper);
  color: var(--chat-text);
  font: inherit;
  font-size: max(16px, 1rem);
}

.bt-chat-compose textarea { resize: vertical; }
.bt-chat-compose select { width: auto; padding-inline: 5px; }

.bt-card-view, .bt-card-preview, .bt-card-form { display: grid; gap: 12px; }

.bt-card-visual {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  padding: 18px 12px;
  background: var(--chat-paper);
  border: 1px solid var(--chat-line);
  border-radius: 15px;
  text-align: center;
  overflow-wrap: anywhere;
}

.bt-card-visual > .bt-chat-avatar { width: 52px; height: 52px; font-size: 1.1rem; }
.bt-card-visual > p { color: var(--chat-muted); }
.bt-card-visual > h2 { font-size: clamp(23px, 5vw, 30px); }

.bt-card-qr {
  display: block;
  width: min(176px, 100%);
  height: auto;
  margin: 8px 0;
  border: 8px solid #fff;
  border-radius: 9px;
  background: #fff;
}

.bt-card-face { display: grid; gap: 2px; }
.bt-card-face span { font-size: .86rem; }
.bt-card-editor summary { padding: 11px 0; cursor: pointer; font-weight: 650; }

.bt-card-fields {
  display: grid;
  gap: 8px;
  min-inline-size: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--chat-line);
  border-radius: 10px;
}

.bt-card-fields legend { padding-inline: 5px; color: var(--chat-muted); }
.bt-card-fields label { display: grid; gap: 4px; }
.bt-card-checkbox { display: flex; align-items: start; gap: 8px; min-height: 44px; padding-block: 8px; }
.bt-card-checkbox input { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--chat-accent); }

@media (min-width: 720px) {
  .bt-card-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bt-card-checkbox, .bt-card-form > button { grid-column: 1 / -1; }
}
