.ava-launch {
  position: fixed;
  right: 24px;
  bottom: 28px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e6c85a;
  border-radius: 50px;
  padding: 12px 20px 12px 12px;
  background: linear-gradient(125deg, #173e38, #102c35);
  color: #fff;
  box-shadow: 0 8px 30px #102c3540;
  cursor: pointer;
  font:
    600 14px Arial,
    sans-serif;
}
.ava-orb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fff5bc, #d3ac39 55%, #709b81);
  color: #16372e;
  font-size: 25px;
  animation: ava-glow 3s ease-in-out infinite;
}
.ava-launch small {
  display: block;
  text-align: left;
  font-size: 10px;
  font-weight: 400;
  color: #dae8dd;
  margin-top: 3px;
}
.ava-panel {
  position: fixed;
  right: 24px;
  bottom: 104px;
  width: min(390px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 130px));
  z-index: 901;
  border: 1px solid var(--line, #d7dfd8);
  border-radius: 24px;
  background: var(--surface, #fff);
  color: var(--ink, #193237);
  box-shadow: 0 22px 80px #061e3540;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ava-open 0.3s ease;
}
.ava-panel[hidden] {
  display: none;
}
.ava-head {
  background: #173e38;
  color: #fff;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ava-head strong {
  display: block;
}
.ava-head small {
  font-size: 11px;
  color: #d5e4da;
}
.ava-head button {
  margin-left: auto;
  background: transparent;
  color: white;
  border: 1px solid #ffffff55;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
}
.ava-feed {
  flex: 1;
  overflow: auto;
  padding: 16px;
  overscroll-behavior: contain;
}
.ava-message {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg, #edf2e8);
  font:
    14px/1.6 Arial,
    sans-serif;
  margin: 0 16px 12px 0;
  white-space: pre-wrap;
}
.ava-message.user {
  margin: 0 0 12px 30px;
  background: #285a48;
  color: white;
}
.ava-profile {
  padding: 12px;
  border: 1px solid var(--line, #d7dfd8);
  border-radius: 14px;
  margin-bottom: 10px;
  font:
    13px/1.5 Arial,
    sans-serif;
}
.ava-profile a {
  display: inline-block;
  margin: 8px 12px 0 0;
  color: var(--ink, #193237);
  text-decoration: underline;
}
.ava-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 16px 10px;
}
.ava-chips button {
  border: 1px solid var(--line, #d7dfd8);
  border-radius: 30px;
  padding: 8px 10px;
  background: var(--surface, #fff);
  color: inherit;
  font-size: 11px;
  cursor: pointer;
}
.ava-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line, #d7dfd8);
}
.ava-form input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line, #d7dfd8);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface, #fff);
  color: inherit;
  font-size: 16px;
}
.ava-form button {
  border: 0;
  border-radius: 12px;
  background: #285a48;
  color: white;
  padding: 10px 14px;
  cursor: pointer;
}
.ava-form button:disabled {
  opacity: 0.5;
}
.ava-privacy {
  padding: 0 16px 12px;
  margin: 0;
  font:
    10px/1.4 Arial,
    sans-serif;
  color: var(--muted, #526563);
}
.ava-panel :focus-visible,
.ava-launch:focus-visible {
  outline: 3px solid #d5b33c;
  outline-offset: 3px;
}
@keyframes ava-glow {
  50% {
    box-shadow:
      0 0 0 7px #e6c85a18,
      0 0 22px #e6c85a55;
    transform: rotate(12deg);
  }
}
@keyframes ava-open {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (max-width: 650px) {
  .ava-launch {
    right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    padding: 8px;
  }
  .ava-launch .ava-label {
    display: none;
  }
  .ava-panel {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    height: min(650px, calc(100dvh - 32px));
    width: calc(100vw - 32px);
  }
  .ava-launch[aria-expanded="true"] {
    visibility: hidden;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ava-orb,
  .ava-panel {
    animation: none;
  }
}

/* Centre the drawn icon rather than relying on a font glyph baseline. */
.ava-orb {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  line-height: 1;
}
.ava-orb svg {
  display: block;
  width: 25px;
  height: 25px;
  flex-shrink: 0;
}
.ava-profile > div {
  white-space: pre-line;
}

/* One calm mobile action bar replaces the two stacked floating controls. */
.ava-mobile-dock {
  display: contents;
}
@media (max-width: 650px) {
  .ava-mobile-dock {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    z-index: 900;
    left: 16px;
    right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    padding: 8px;
    border: 1px solid var(--line, #d7dfd8);
    border-radius: 20px;
    background: var(--surface, #fff);
    box-shadow: 0 6px 24px #102c3526;
  }
  .ava-mobile-dock .mobile-enquire {
    position: static;
    flex: 1;
    min-width: 0;
    min-height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-radius: 12px;
    box-shadow: none;
    font-size: 14px;
    line-height: 1.2;
  }
  .ava-mobile-dock .ava-launch {
    position: static;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    gap: 7px;
    padding: 8px 12px;
    background: transparent;
    color: var(--ink, #193237);
    border: 0;
    border-radius: 12px;
    box-shadow: none;
  }
  .ava-mobile-dock .ava-launch::after {
    content: "Ask AI";
    font-size: 13px;
  }
  .ava-mobile-dock .ava-orb {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    animation: none;
    background: #f3df97;
  }
  .ava-mobile-dock .ava-orb svg {
    width: 22px;
    height: 22px;
  }
  .ava-mobile-dock:has(.ava-launch[aria-expanded="true"]) {
    visibility: hidden;
  }
 
}

/* Homepage dock follows the header; teacher directory keeps only AI. */
@media (max-width: 650px) {
  .ava-mobile-dock {
    transition:
      transform 0.28s ease,
      opacity 0.28s ease;
  }
  .ava-mobile-dock.ava-dock-away {
    transform: translateY(calc(100% + 32px + env(safe-area-inset-bottom)));
    opacity: 0;
    pointer-events: none;
  }
  .ava-teachers-page .ava-launch {
    bottom: calc(16px + env(safe-area-inset-bottom));
    gap: 8px;
    padding: 8px 14px 8px 8px;
  }
  .ava-teachers-page .ava-launch::after {
    content: "Ask AI";
    font-size: 13px;
  }
  body.ava-teachers-page {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  #teacher-search-form {
    scroll-margin-top: 110px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ava-mobile-dock {
    transition: none;
  }
}

/* Fit the iOS visual viewport, which shrinks and pans with the keyboard. */
.ava-feed {
  min-height: 0;
}
.ava-head,
.ava-chips,
.ava-form,
.ava-privacy {
  flex-shrink: 0;
}
@media (max-width: 650px) {
  .ava-panel {
    top: var(--ava-visible-top, 8px);
    bottom: auto;
    height: var(--ava-visible-height, calc(100dvh - 16px));
    max-height: none;
    min-height: 0;
    border-radius: 20px;
  }
  .ava-panel .ava-head {
    padding: 12px 14px;
  }
  .ava-panel .ava-head strong {
    font-size: 15px;
  }
  .ava-panel .ava-head button {
    flex-shrink: 0;
  }
  .ava-panel .ava-form {
    margin: 0;
    padding: 10px 12px;
  }
  .ava-panel .ava-form input {
    font-size: 16px;
  }
  .ava-panel.ava-keyboard-open .ava-chips {
    display: none;
  }
  .ava-panel.ava-keyboard-open .ava-privacy {
    padding: 0 12px 6px;
    font-size: 9px;
  }
  .ava-panel.ava-keyboard-open .ava-head {
    padding: 8px 12px;
  }
}
