.ai-pa,
.ai-pa * {
  box-sizing: border-box;
}

.ai-pa {
  --ai-pa-accent: #175cd3;
  --ai-pa-accent-hover: #1849a9;
  --ai-pa-border: #d0d5dd;
  --ai-pa-bg: #ffffff;
  --ai-pa-muted: #475467;
  --ai-pa-text: #101828;
  color: var(--ai-pa-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.38;
}

.ai-pa button,
.ai-pa input,
.ai-pa textarea,
.ai-pa a {
  font: inherit;
}

.ai-pa button:focus-visible,
.ai-pa input:focus-visible,
.ai-pa textarea:focus-visible,
.ai-pa a:focus-visible {
  outline: 3px solid #84adff;
  outline-offset: 2px;
}

.ai-pa__launcher {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ai-pa-accent);
  box-shadow: 0 8px 24px rgb(16 24 40 / 22%);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.ai-pa__launcher:hover {
  background: var(--ai-pa-accent-hover);
}

.ai-pa__panel {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 64px));
  z-index: 2147483000;
  display: grid;
  width: min(400px, calc(100vw - 32px));
  max-height: min(680px, calc(100dvh - 112px));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(120px, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--ai-pa-border);
  border-radius: 16px;
  background: var(--ai-pa-bg);
  box-shadow: 0 16px 48px rgb(16 24 40 / 24%);
}

.ai-pa__notice,
.ai-pa__live {
  grid-row: 2;
  grid-column: 1;
}

.ai-pa__composer {
  grid-row: 3;
  grid-column: 1;
}

.ai-pa__inline-reconsent {
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #fdb022;
  border-radius: 8px;
  background: #fffaeb;
}

.ai-pa__inline-reconsent p {
  margin: 0 0 6px;
  font-size: 13px;
}

.ai-pa__inline-reconsent button {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid #dc6803;
  border-radius: 8px;
  background: #f79009;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.ai-pa__inline-reconsent a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-left: 10px;
  color: #1849a9;
}

.ai-pa__consent-settings {
  grid-row: 2;
  grid-column: 1;
  overflow-y: auto;
}

.ai-pa__panel[hidden],
.ai-pa [hidden] {
  display: none !important;
}

.ai-pa__header {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--ai-pa-border);
}

.ai-pa__header-actions {
  display: flex;
  gap: 2px;
}

.ai-pa__title,
.ai-pa__summary h3 {
  margin: 0;
  color: var(--ai-pa-text);
  font-size: 17px;
  font-weight: 700;
}

.ai-pa__icon-button,
.ai-pa__start,
.ai-pa__actions button,
.ai-pa__summary button,
.ai-pa__handover button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--ai-pa-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ai-pa-text);
  cursor: pointer;
}

.ai-pa__icon-button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--ai-pa-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ai-pa-text);
  cursor: pointer;
}

.ai-pa__close {
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.ai-pa__notice {
  padding: 16px;
  border-bottom: 1px solid var(--ai-pa-border);
  background: #f9fafb;
}

.ai-pa__notice p {
  margin: 0 0 10px;
}

.ai-pa__notice a {
  display: inline-block;
  min-height: 44px;
  color: #1849a9;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-pa__start {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border-color: var(--ai-pa-accent);
  background: var(--ai-pa-accent);
  color: #ffffff;
  font-weight: 700;
}

.ai-pa__live {
  min-height: 160px;
  overflow-y: auto;
  padding: 8px 10px;
  overscroll-behavior: contain;
}

.ai-pa__message {
  max-width: 92%;
  margin: 0 0 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f2f4f7;
  overflow-wrap: anywhere;
}

.ai-pa__message--customer {
  margin-left: auto;
  background: #eaf2ff;
}

.ai-pa__message-label {
  display: block;
  margin-bottom: 1px;
  color: var(--ai-pa-muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-pa__message p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.38;
  white-space: pre-wrap;
}

.ai-pa__message-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.ai-pa__handover-open {
  min-height: 36px !important;
  padding: 5px 9px;
  font-size: 14px;
}

.ai-pa__handover {
  padding: 12px;
  border: 1px solid #b2ccff;
  border-radius: 10px;
  background: #ffffff;
}

.ai-pa__handover h3,
.ai-pa__handover p {
  margin: 0 0 8px;
}

.ai-pa__handover-back {
  min-height: 44px;
  margin: 0 0 10px;
  padding: 6px 10px;
}

.ai-pa__handover-preview {
  max-height: 140px;
  overflow: auto;
  padding: 8px;
  border-radius: 6px;
  background: #f2f4f7;
  font: inherit;
  white-space: pre-wrap;
}

.ai-pa__handover-field {
  display: grid;
  width: 100%;
  margin-top: 12px;
  gap: 9px;
}

.ai-pa__handover-field label {
  display: block;
  font-weight: 700;
}

.ai-pa__handover-field input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px;
  border: 1px solid #98a2b3;
  border-radius: 8px;
}

.ai-pa__consent {
  display: grid;
  min-height: 44px;
  align-items: start;
  margin-top: 10px;
  grid-template-columns: 24px 1fr;
  gap: 8px;
}

.ai-pa__consent input {
  width: 20px;
  height: 20px;
  margin: 2px;
}

.ai-pa__consent-settings {
  padding: 12px 14px;
  background: #f9fafb;
}

.ai-pa__consent-settings h3,
.ai-pa__consent-settings p {
  margin: 0 0 8px;
}

.ai-pa__consent-setting {
  display: grid;
  min-height: 44px;
  align-items: center;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  border-top: 1px solid var(--ai-pa-border);
}

.ai-pa__consent-setting button {
  min-height: 44px;
  grid-column: 1 / -1;
}

.ai-pa__consent-unavailable {
  color: var(--ai-pa-muted);
  font-weight: 700;
}

.ai-pa__handover-form > button {
  margin: 8px 8px 0 0;
  padding: 6px 10px;
}

.ai-pa__composer {
  position: sticky;
  bottom: 0;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--ai-pa-border);
  background: #ffffff;
}

.ai-pa__composer label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 700;
}

.ai-pa__composer textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 112px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #98a2b3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ai-pa-text);
  font-size: 14px;
}

.ai-pa__actions {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: stretch;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 6px;
}

.ai-pa__actions button {
  padding: 6px 14px;
  font-size: 14px;
}

.ai-pa__voice-button {
  display: inline-flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding-inline: 10px !important;
  line-height: 1.25;
  overflow-wrap: break-word;
  text-align: center;
  white-space: normal;
}

.ai-pa__voice-button[data-voice-state="RECORDING"] {
  border-color: #b42318;
  background: #b42318;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 0 0 3px rgb(180 35 24 / 18%);
}

.ai-pa__voice-button[data-voice-state="TRANSCRIBING"] {
  border-color: #175cd3;
  background: #eff4ff;
  color: #1849a9;
  font-weight: 700;
}

.ai-pa__voice-button[data-voice-state="REVIEW_READY"] {
  border-color: #84adff;
  background: #eff8ff;
  color: #1849a9;
  font-weight: 700;
}

@media (max-width: 640px) {
  .ai-pa__voice-button {
    padding-inline: 6px !important;
    font-size: 13px;
  }
}

.ai-pa__actions button[type="submit"] {
  flex: 0 0 auto;
  min-width: 64px;
  margin-left: auto;
  border-color: var(--ai-pa-accent);
  background: var(--ai-pa-accent);
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
}

.ai-pa__file-button {
  display: inline-grid !important;
  flex: 0 0 44px;
  width: 44px;
  place-items: center;
  margin: 0 !important;
  font-size: 22px !important;
}

.ai-pa__file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.ai-pa__attachment-preview {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #f2f4f7;
  overflow-wrap: anywhere;
}

.ai-pa__attachment-preview button {
  min-width: 44px;
  min-height: 36px;
}

.ai-pa__structured-input {
  max-height: 210px;
  overflow-y: auto;
  margin: 0 0 7px;
  padding: 7px 9px;
  border: 1px solid #b2ccff;
  border-radius: 8px;
}

.ai-pa__structured-input legend {
  padding: 0 3px;
  font-weight: 700;
}

.ai-pa__structured-option {
  display: grid !important;
  min-height: 36px;
  align-items: center;
  grid-template-columns: 24px 1fr;
  gap: 6px;
  margin: 0 !important;
  font-weight: 400 !important;
}

.ai-pa__structured-option input {
  width: 20px;
  height: 20px;
}

.ai-pa__structured-option button[role="radio"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  border: 2px solid #667085;
  border-radius: 50%;
  background: #fff;
}

.ai-pa__structured-option button[role="radio"][aria-checked="true"] {
  border: 6px solid #2563eb;
}

.ai-pa__structured-option button[role="radio"]:focus-visible {
  outline: 3px solid #f79009;
  outline-offset: 2px;
}

.ai-pa__other-input {
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
}

.ai-pa__privacy-links {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.ai-pa__privacy-links a {
  min-height: 44px;
  padding: 10px 0;
}

.ai-pa button:disabled,
.ai-pa textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.ai-pa__status {
  min-height: 0;
  margin: 4px 0 0;
  color: var(--ai-pa-muted);
  font-size: 13px;
}

.ai-pa__status:empty {
  display: none;
}

.ai-pa__status--error {
  color: #b42318;
}

@media (max-width: 640px) {
  .ai-pa__launcher {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .ai-pa__panel {
    inset: 0;
    width: 100vw;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-pa * {
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .ai-pa__launcher,
  .ai-pa__actions button[type="submit"] {
    border: 2px solid ButtonText;
  }
}
