.rap-select,
.rap-input,
.rap-textarea,
.rap-file {
  width: 100%;
  max-width: 640px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 12px;
}

.rap-textarea { min-height: 160px; resize: vertical; }

.rap-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

.rap-hint {
  margin: 8px 0 0;
  color: var(--text-tertiary);
  font-size: 13px;
  max-width: 640px;
}

.rap-notice {
  margin: 20px 0 0;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.47;
  color: var(--text-secondary);
}

.rap-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 14px 0 0;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.rap-consent input {
  margin-top: 3px;
  flex: none;
}

.rap-error {
  color: var(--danger);
  margin: 12px 0;
}

.rap-list { margin-top: 18px; }

.rap-meta {
  color: var(--text-secondary);
  font-size: 13px;
}

.rap-thread {
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rap-chat-pane {
  max-width: 720px;
  height: min(46vh, 380px);
  min-height: 200px;
  margin: 16px 0 8px;
  padding: 14px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-sizing: border-box;
}

.rap-chat-pane:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 2px;
}

.rap-chat {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rap-chat-row {
  display: flex;
  flex-direction: column;
  max-width: min(86%, 520px);
}

.rap-chat-row.is-user {
  align-self: flex-end;
  align-items: flex-end;
}

.rap-chat-row.is-admin,
.rap-chat-row.is-internal {
  align-self: flex-start;
  align-items: flex-start;
}

.rap-chat-row.is-system {
  align-self: center;
  align-items: center;
  max-width: 100%;
}

.rap-chat-who {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-tertiary);
  margin: 0 4px 4px;
}

.rap-chat-bubble {
  border-radius: 18px;
  padding: 10px 14px;
  white-space: pre-wrap;
  line-height: 1.47;
  word-break: break-word;
}

.rap-chat-row.is-user .rap-chat-bubble {
  background: #0071e3;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.rap-chat-row.is-admin .rap-chat-bubble {
  background: var(--bg-page);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 6px;
}

.rap-chat-row.is-internal .rap-chat-bubble {
  background: var(--bg-page);
  border: 1px dashed var(--hairline);
  border-bottom-left-radius: 6px;
}

.rap-chat-row.is-system .rap-chat-bubble {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
  padding: 4px 8px;
}

.rap-chat-text + .rap-chat-files {
  margin-top: 8px;
}

.rap-chat-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.rap-chat-file {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--hairline);
}

.rap-chat-row.is-user .rap-chat-file {
  background: rgba(255, 255, 255, 0.16);
  border-color: transparent;
  color: #fff;
}

.rap-bubble {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
  white-space: pre-wrap;
}

.rap-bubble.is-internal { background: var(--bg-page); }

.rap-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 16px; }

.btn-primary:active { transform: scale(0.97); }

.rap-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0 8px;
}

.rap-filters label { font-size: 13px; color: var(--text-secondary); }

.rap-filters select { min-width: 160px; }
