:root {
  /* Sampled from the public AOI site visual register: deep blue navigation,
     sky blue accents, airport-status green, warm page background, dark text. */
  --aoi-navy: #123c69;
  --aoi-blue: #1d75bb;
  --aoi-sky: #69b9df;
  --aoi-green: #79b441;
  --aoi-cream: #f6f2e9;
  --ink: #172331;
  --muted: #607083;
  --line: #d7e1ea;
  --surface: #ffffff;
  --surface-soft: #f8fbfd;
  --danger: #c83e3e;
  --shadow: 0 18px 48px rgba(18, 60, 105, 0.15);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(105, 185, 223, 0.18), transparent 34rem),
    linear-gradient(180deg, #fbfdff 0%, var(--aoi-cream) 100%);
  color: var(--ink);
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

.app-header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(215, 225, 234, 0.9);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--aoi-navy), var(--aoi-blue));
}

.brand-mark svg {
  width: 34px;
  height: 34px;
}

.brand-mark circle {
  fill: rgba(255, 255, 255, 0.08);
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.5;
}

.brand-mark path:first-of-type {
  fill: #ffffff;
  opacity: 0.92;
}

.brand-mark path:last-of-type {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1.6;
}

h1 {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
}

.language-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(29, 117, 187, 0.28);
  border-radius: 14px;
  background: rgba(238, 246, 251, 0.88);
}

.language-button {
  min-width: 38px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 10px;
  background: transparent;
  color: var(--aoi-navy);
  font-size: 0.78rem;
  font-weight: 800;
}

.language-button:hover {
  background: rgba(29, 117, 187, 0.12);
}

.language-button.active {
  background: var(--aoi-blue);
  color: #ffffff;
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(215, 225, 234, 0.95);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.thread {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.thread::-webkit-scrollbar {
  width: 10px;
}

.thread::-webkit-scrollbar-track {
  background: rgba(215, 225, 234, 0.45);
}

.thread::-webkit-scrollbar-thumb {
  background: rgba(29, 117, 187, 0.42);
  border: 2px solid rgba(248, 251, 253, 0.9);
  border-radius: 999px;
}

.message {
  width: fit-content;
  max-width: min(76%, 680px);
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: var(--aoi-navy);
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.message.assistant {
  align-self: flex-start;
  background: #eef6fb;
  color: var(--ink);
  border: 1px solid #cfe4f2;
  border-bottom-left-radius: 6px;
}

.message.error {
  align-self: flex-start;
  background: #fff8f2;
  border: 1px solid #f0d2b5;
  color: #5b3c1d;
}

.intro-message {
  max-width: min(84%, 720px);
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
}

.privacy-link {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--aoi-navy);
  font-size: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.privacy-link:hover {
  background: transparent;
  color: var(--aoi-blue);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 35, 49, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.privacy-modal {
  width: min(100%, 620px);
  max-height: min(720px, calc(100dvh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid rgba(215, 225, 234, 0.95);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(18, 35, 49, 0.28);
  overflow: hidden;
}

.modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
}

.modal-close {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 12px;
  background: #eef6fb;
  color: var(--aoi-navy);
  font-size: 1.5rem;
  line-height: 1;
}

.modal-close:hover {
  background: #dceef8;
}

.modal-body {
  overflow-y: auto;
  padding: 18px;
  color: var(--ink);
  line-height: 1.48;
}

.modal-body p {
  margin: 0 0 12px;
}

.modal-body h3 {
  margin: 16px 0 6px;
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--aoi-navy);
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body a {
  color: var(--aoi-blue);
  font-weight: 700;
  text-decoration: none;
}

.modal-body a:hover {
  text-decoration: underline;
}

.modal-body ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.modal-body li + li {
  margin-top: 8px;
}

.consent-backdrop {
  z-index: 30;
  background: rgba(18, 35, 49, 0.52);
}

.consent-modal {
  width: min(100%, 680px);
}

.consent-body {
  display: grid;
  gap: 14px;
}

.consent-body p {
  margin-bottom: 0;
}

.consent-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  line-height: 1.42;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--aoi-blue);
}

.consent-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.consent-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.secondary-button {
  background: #eef6fb;
  color: var(--aoi-navy);
}

.secondary-button:hover {
  background: #dceef8;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--aoi-blue);
  animation: bounce 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  background: rgba(248, 251, 253, 0.96);
  border-top: 1px solid var(--line);
}

textarea {
  width: 100%;
  max-height: 150px;
  resize: none;
  border: 1px solid #c9d8e3;
  border-radius: 16px;
  padding: 13px 14px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  line-height: 1.35;
}

textarea:focus {
  border-color: var(--aoi-blue);
  box-shadow: 0 0 0 4px rgba(29, 117, 187, 0.14);
}

.turnstile-widget {
  grid-column: 1 / -1;
  min-height: 0;
}

.turnstile-widget:empty {
  display: none;
}

button {
  min-width: 92px;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: var(--aoi-blue);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

button:hover {
  background: var(--aoi-navy);
}

button:active {
  transform: translateY(1px);
}

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

.app-footer {
  display: grid;
  justify-content: center;
  align-items: center;
  gap: 4px;
  text-align: center;
  font-size: 0.9rem;
}

.app-footer a,
.footer-link {
  color: var(--aoi-navy);
  font-weight: 700;
  text-decoration: none;
}

.footer-link {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: inherit;
  justify-self: center;
}

.app-footer a:hover,
.footer-link:hover {
  background: transparent;
  text-decoration: underline;
}

.privacy-note.is-hidden {
  display: none;
}

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

@media (max-width: 680px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .app-header {
    grid-template-columns: 42px minmax(0, 1fr);
    border-radius: 18px;
    gap: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .language-toggle {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .chat-panel {
    border-radius: 18px;
  }

  .thread {
    padding: 14px;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .consent-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
