:root {
  --brand: #2f6fde;
  --brand-dark: #1f56b8;
  --text: #1d2330;
  --muted: #4a5466;
  --bot-bubble: #eef2f7;
  --border: #c9d1dd;
  --error: #a32020;
  --error-bg: #fdecec;
  --page: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--page);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

.page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.75rem 16px;
  gap: 0.75rem;
}

.intro h1 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 0 0 0.25rem;
}

.lead {
  margin: 0;
  color: var(--muted);
}

.disclaimer {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
}

.disclaimer a {
  color: var(--brand-dark);
  overflow-wrap: anywhere;
}

.about summary {
  cursor: pointer;
  color: var(--brand-dark);
  text-decoration: underline;
  margin-top: 0.25rem;
}

.about p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0.5rem 0 0;
}

.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bubble {
  max-width: 88%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bot-bubble);
  align-self: flex-start;
}

.bubble.me {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
}

.bubble.error {
  background: var(--error-bg);
  color: var(--error);
}

.bubble a {
  color: var(--brand-dark);
}

.bubble.pending::after {
  content: "…";
}

.composer {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.composer textarea {
  flex: 1;
  min-width: 0;
  font: inherit;
  /* 16px keeps iOS from zooming on focus */
  font-size: max(1rem, 16px);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  resize: none;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.composer button,
.contact button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--brand);
  border-radius: 0.5rem;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

.actions button {
  flex: 1;
  white-space: nowrap;
}

.composer button.secondary,
.contact button.secondary {
  background: var(--page);
  color: var(--brand-dark);
}

.composer button:disabled,
.composer textarea:disabled,
.contact button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.contact {
  width: min(24rem, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  color: var(--text);
  background: var(--page);
}

.contact::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.contact form {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.contact h2 {
  font-size: 1.15rem;
  margin: 0;
}

.contact .note {
  margin: 0 0 0.5rem;
  color: var(--muted);
  line-height: 1.45;
}

.contact input {
  font: inherit;
  /* 16px keeps iOS from zooming on focus */
  font-size: max(1rem, 16px);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-error {
  margin: 0 0 0.5rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: var(--error-bg);
  color: var(--error);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dialog-actions button {
  flex: 1 1 auto;
}

:focus-visible {
  outline: 3px solid var(--brand-dark);
  outline-offset: 2px;
}

.closed {
  flex: 1;
  font-size: 1.1rem;
  line-height: 1.5;
}

.closed a {
  color: var(--brand-dark);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}
