.aoi-chat {
  --aoi-navy: #172a4d;
  --aoi-blue: #287ec7;
  --aoi-light: #eef7ff;
  --aoi-border: #cbd9e7;
  --aoi-text: #202a35;
  max-width: 760px;
  margin: 2rem auto;
  padding: 1.25rem;
  border: 1px solid var(--aoi-border);
  border-radius: 18px;
  background: #fff;
  color: var(--aoi-text);
  box-shadow: 0 10px 30px rgba(23, 42, 77, 0.09);
  font-size: 16px;
  line-height: 1.7;
}

.aoi-chat-about {
  max-width: 760px;
  margin: 1.5rem auto 2rem;
  padding: 1.25rem;
  border: 1px solid #cbd9e7;
  border-radius: 18px;
  background: #fff;
  color: #202a35;
  box-shadow: 0 8px 24px rgba(23, 42, 77, 0.06);
  font-size: 16px;
  line-height: 1.8;
}

.aoi-chat-about h2,
.aoi-chat-about h3 {
  color: #172a4d;
}

.aoi-chat-about h2 {
  margin: 0 0 0.85rem;
  font-size: 1.35rem;
}

.aoi-chat-about h3 {
  margin: 1.25rem 0 0.35rem;
  font-size: 1.05rem;
}

.aoi-chat-about p {
  margin: 0.45rem 0;
}

.aoi-chat-about__closing {
  margin-top: 1.25rem !important;
  padding-top: 1rem;
  border-top: 1px solid #dce5ee;
  color: #526071;
}

.aoi-chat button,
.aoi-chat textarea,
.aoi-chat input {
  font: inherit;
}

.aoi-chat__header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.aoi-chat__avatar {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--aoi-blue), var(--aoi-navy));
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}

.aoi-chat__title {
  margin: 0;
  color: var(--aoi-navy);
  font-size: 1.35rem;
}

.aoi-chat__subtitle,
.aoi-chat__footnote {
  margin: 0.2rem 0 0;
  color: #526071;
  font-size: 0.9rem;
}

.aoi-chat__safety {
  margin: 1rem 0;
  padding: 1rem;
  border-left: 5px solid #df8b19;
  border-radius: 10px;
  background: #fff8e8;
}

.aoi-chat__safety p {
  margin: 0.35rem 0;
}

.aoi-chat__confirm {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.7rem;
  font-weight: 700;
}

.aoi-chat__confirm input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.3rem;
}

.aoi-chat__mode p {
  margin-bottom: 0.55rem;
  font-weight: 700;
}

.aoi-chat__mode-buttons,
.aoi-chat__actions,
.aoi-chat__composer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.aoi-chat__mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.aoi-chat__mode-button,
.aoi-chat__send,
.aoi-chat__secondary,
.aoi-chat__contact,
.aoi-chat__clear {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--aoi-blue);
  border-radius: 999px;
  cursor: pointer;
}

.aoi-chat__mode-button,
.aoi-chat__secondary,
.aoi-chat__clear {
  background: #fff;
  color: var(--aoi-navy);
}

.aoi-chat__mode-button {
  display: flex;
  min-height: 68px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border-radius: 14px;
  text-align: left;
  font-weight: 700;
}

.aoi-chat__mode-button span {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.75;
}

.aoi-chat__mode-button.is-selected,
.aoi-chat__send,
.aoi-chat__contact {
  background: var(--aoi-navy);
  color: #fff;
}

.aoi-chat__topics {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--aoi-border);
  border-radius: 14px;
  background: #f8fafc;
}

.aoi-chat__topic-group + .aoi-chat__topic-group {
  margin-top: 1rem;
}

.aoi-chat__topic-group h3 {
  margin: 0 0 0.45rem;
  color: var(--aoi-navy);
  font-size: 0.95rem;
}

.aoi-chat__topic-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.aoi-chat__topic-button,
.aoi-chat__topic-refresh {
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--aoi-border);
  border-radius: 10px;
  background: #fff;
  color: var(--aoi-navy);
  cursor: pointer;
}

.aoi-chat__topic-button {
  text-align: left;
}

.aoi-chat__topic-button strong,
.aoi-chat__topic-button span {
  display: block;
}

.aoi-chat__topic-button strong {
  line-height: 1.45;
}

.aoi-chat__topic-button span {
  margin-top: 0.25rem;
  color: #596878;
  font-size: 0.78rem;
  line-height: 1.5;
}

.aoi-chat__topic-button:hover,
.aoi-chat__topic-refresh:hover {
  border-color: var(--aoi-blue);
  background: var(--aoi-light);
}

.aoi-chat__topic-refresh {
  margin-top: 1rem;
  border-color: var(--aoi-blue);
}

.aoi-chat button:focus-visible,
.aoi-chat textarea:focus-visible,
.aoi-chat input:focus-visible {
  outline: 3px solid rgba(40, 126, 199, 0.3);
  outline-offset: 2px;
}

.aoi-chat button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.aoi-chat__messages {
  min-height: 140px;
  max-height: 430px;
  margin: 1rem 0;
  padding: 1rem;
  overflow-y: auto;
  border: 1px solid var(--aoi-border);
  border-radius: 14px;
  background: #f8fafc;
}

.aoi-chat__message {
  max-width: 88%;
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.aoi-chat__message p {
  margin: 0;
}

.aoi-chat__message--assistant {
  margin-right: auto;
  border-bottom-left-radius: 4px;
  background: var(--aoi-light);
}

.aoi-chat__message--user {
  margin-left: auto;
  border-bottom-right-radius: 4px;
  background: var(--aoi-navy);
  color: #fff;
}

.aoi-chat__message-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.8;
}

.aoi-chat__composer textarea {
  width: 100%;
  min-height: 92px;
  padding: 0.8rem;
  resize: vertical;
  border: 1px solid #9fb2c5;
  border-radius: 12px;
  background: #fff;
  color: var(--aoi-text);
}

.aoi-chat__composer-row {
  justify-content: space-between;
  margin-top: 0.55rem;
}

.aoi-chat__counter,
.aoi-chat__status {
  color: #526071;
  font-size: 0.85rem;
}

.aoi-chat__actions {
  margin-top: 1rem;
}

.aoi-chat__clear {
  margin-left: auto;
  border-color: #9aa6b2;
  color: #53606d;
}

.aoi-chat__status {
  min-height: 1.5em;
  margin: 0.8rem 0 0;
  font-weight: 700;
}

.aoi-chat__status.is-error {
  color: #b42318;
}

.aoi-chat-transfer-notice {
  margin: 0 0 0.65rem;
  padding: 0.75rem 0.9rem;
  border-left: 4px solid #287ec7;
  background: #eef7ff;
  color: #172a4d;
  font-weight: 700;
}

@media (max-width: 600px) {
  .aoi-chat {
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 12px;
  }

  .aoi-chat-about {
    margin: 1rem 0.75rem 1.5rem;
    padding: 1rem;
    border-radius: 14px;
  }

  .aoi-chat__mode-button,
  .aoi-chat__secondary,
  .aoi-chat__contact {
    width: 100%;
  }

  .aoi-chat__mode-buttons,
  .aoi-chat__topic-buttons {
    grid-template-columns: 1fr;
  }

  .aoi-chat__clear {
    width: 100%;
    margin-left: 0;
  }

  .aoi-chat__message {
    max-width: 94%;
  }
}

/* 0.1.9: answer visibility and compact, reopenable safety notice */
.aoi-chat [hidden] { display: none !important; }
.aoi-chat__messages { scroll-margin-top: 80px; }
.aoi-chat__message.is-latest { border: 2px solid var(--aoi-blue); }
.aoi-chat__safety summary { cursor: pointer; font-weight: 700; }
.aoi-chat__safety.is-confirmed { padding: 0.55rem 0.8rem; }
.aoi-chat__summary-help { font-size: 0.85rem; color: #526071; }
@media (max-width: 600px) {
  .aoi-chat__messages { max-height: 42vh; max-height: 42dvh; }
}

/* 0.1.12: tap-friendly help beside the draft button */
.aoi-chat__draft-actions { display: flex; align-items: center; gap: 0.35rem; max-width: 100%; }
.aoi-chat__help-button { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--aoi-navy); cursor: pointer; }
.aoi-chat__help-button span { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--aoi-blue); border-radius: 50%; font-weight: 700; }
.aoi-chat__help-dialog { box-sizing: border-box; width: min(540px, calc(100vw - 32px)); max-height: 80vh; max-height: 80dvh; overflow-y: auto; padding: 1.25rem; border: 1px solid var(--aoi-border); border-radius: 14px; background: #fff; color: var(--aoi-text); line-height: 1.7; }
.aoi-chat__help-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.aoi-chat__help-dialog h2 { margin-top: 0; font-size: 1.2rem; }
.aoi-chat__help-dialog ol { padding-left: 1.4rem; }
.aoi-chat__help-dialog li { margin-bottom: 0.8rem; }
.aoi-chat__help-dialog p { margin: 0.4rem 0; }
@media (max-width: 600px) { .aoi-chat__draft-actions { width: 100%; } .aoi-chat__draft-actions .aoi-chat__secondary { flex: 1; width: auto; min-width: 0; } }
