.assist-fab {
  position: fixed;
  z-index: 60;
  inset-inline-start: 16px;
  bottom: calc(var(--dock) + 12px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 24px rgba(14, 54, 68, .22);
  cursor: pointer;
  overflow: visible;
}
.assist-fab:hover { background: var(--teal-dark); }
.assist-label {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}
.assist-fab:focus-visible,
.assist-close:focus-visible,
.assist-send:focus-visible,
.assist-chip:focus-visible,
.assist-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.assist-wave {
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  border: 1.5px solid var(--teal);
  pointer-events: none;
  animation: assist-wave 8.5s ease-out infinite;
}
@keyframes assist-wave {
  0% { transform: scale(1); opacity: .45; }
  70% { opacity: .1; }
  100% { transform: scale(1.55); opacity: 0; }
}

.assist-panel {
  position: fixed;
  z-index: 80;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.assist-panel:not([hidden]) { animation: assist-screen .36s ease; }
body.assist-open { overflow: hidden; }
.assist-fab[hidden],
.assist-panel[hidden] { display: none !important; }
/* Mobile menu sits under the assistant; hide the button and the panel together. */
#menu-sheet.is-open ~ .assist,
.assist.is-behind-menu {
  visibility: hidden;
  pointer-events: none;
}
@keyframes assist-screen {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.assist-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  background: var(--teal);
  color: #fff;
  animation: assist-rise .45s ease both;
}
.assist-head img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, .35);
}
.assist-head h2 {
  margin: 0;
  color: #fff;
  font-size: 1.05rem;
  line-height: 1.3;
}
.assist-head p {
  margin: 0;
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  text-align: start;
}
.assist-close {
  margin-inline-start: auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.assist-note {
  margin: 0;
  padding: 10px 18px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
  text-align: start;
  animation: assist-rise .5s ease both;
}
.assist-log {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px clamp(16px, 4vw, 48px) 20px;
  background:
    radial-gradient(circle at 100% 0, rgba(43, 122, 142, .08), transparent 32%),
    var(--bg);
}
.assist-msg {
  max-width: min(640px, 88%);
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 15.5px;
  line-height: 1.8;
  animation: assist-rise .42s ease both;
}
.assist-msg p { margin: 0 0 .55em; text-align: start; }
.assist-msg p:last-child { margin-bottom: 0; }
.assist-msg-bot {
  margin-inline-end: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-right-radius: 6px;
}
.assist-msg-user {
  margin-inline-start: auto;
  background: var(--teal);
  color: #fff;
  border-bottom-left-radius: 6px;
}
.assist-msg-alert {
  background: var(--danger-soft);
  border-color: #f1c9a5;
}
.assist-links { display: grid; gap: 8px; margin-top: 10px; }
.assist-link {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 14.5px;
  animation: assist-rise .4s ease both;
}
.assist-link:nth-child(2) { animation-delay: .06s; }
.assist-link:nth-child(3) { animation-delay: .12s; }
.assist-link:nth-child(4) { animation-delay: .18s; }
.assist-link:hover { background: #d7eef3; }
.assist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.assist-actions .btn {
  min-height: 42px;
  padding: 0 14px;
  font-size: 14px;
  animation: assist-rise .4s ease .08s both;
}
.assist-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  width: max-content;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  animation: assist-rise .3s ease both;
}
.assist-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  animation: assist-dot 1s ease-in-out infinite;
}
.assist-typing span:nth-child(2) { animation-delay: .15s; }
.assist-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes assist-dot {
  0%, 70%, 100% { transform: translateY(0); opacity: .35; }
  35% { transform: translateY(-4px); opacity: 1; }
}
.assist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px clamp(16px, 4vw, 48px) 0;
  background: #fff;
}
.assist-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  animation: assist-rise .38s ease both;
}
.assist-chip:nth-child(2) { animation-delay: .05s; }
.assist-chip:nth-child(3) { animation-delay: .1s; }
.assist-chip:nth-child(4) { animation-delay: .15s; }
.assist-chip:nth-child(5) { animation-delay: .2s; }
.assist-chip:hover { background: var(--teal-soft); border-color: var(--teal); }
.assist-chip:disabled { opacity: .45; cursor: default; }
.assist-form {
  display: flex;
  gap: 8px;
  padding: 12px clamp(16px, 4vw, 48px) 16px;
  background: #fff;
  animation: assist-rise .5s ease both;
}
.assist-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
}
.assist-form input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.assist-send {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: 0;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
}
.assist-send:hover { background: var(--teal-dark); }
.assist-send svg { width: 20px; height: 20px; margin-inline: auto; display: block; }
@keyframes assist-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
body.has-instr-dl .assist-fab {
  bottom: calc(var(--dock) + 80px + env(safe-area-inset-bottom));
}
@media (min-width: 768px) {
  .assist-fab {
    inset-inline-start: 28px;
    bottom: 28px;
    width: 61px;
    height: 61px;
  }
  .assist-label { font-size: 12px; }
  body.has-instr-dl .assist-fab { bottom: 96px; }
  .assist-log { padding-top: 28px; }
  .assist-msg { font-size: 16.5px; max-width: min(720px, 70%); }
}
@media (prefers-reduced-motion: reduce) {
  .assist-wave,
  .assist-panel:not([hidden]),
  .assist-head,
  .assist-note,
  .assist-msg,
  .assist-link,
  .assist-actions .btn,
  .assist-chip,
  .assist-form,
  .assist-typing,
  .assist-typing span {
    animation: none;
  }
}
