#mechlae-jarvis-launcher,
#mechlae-jarvis-greeting,
#mechlae-jarvis-dialog {
  --jarvis-red: #c50915;
  --jarvis-ink: #15171b;
  --jarvis-border: #dedfe3;
  --jarvis-surface: #fff;
  --jarvis-inset-inline: max(1rem, env(safe-area-inset-right));
  --jarvis-inset-bottom: max(1rem, env(safe-area-inset-bottom));
  --jarvis-launcher-size: 3.25rem;
  font: inherit;
}

#mechlae-jarvis-launcher {
  position: fixed;
  right: var(--jarvis-inset-inline);
  bottom: var(--jarvis-inset-bottom);
  z-index: 60;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: var(--jarvis-launcher-size);
  height: var(--jarvis-launcher-size);
  padding: 0;
  border: 1px solid var(--jarvis-ink);
  border-radius: 999px;
  color: #fff;
  background: var(--jarvis-ink);
  box-shadow: 0 .4rem 1.25rem rgb(21 23 27 / 20%);
  cursor: pointer;
}

#mechlae-jarvis-launcher:hover {
  background: #303237;
}

#mechlae-jarvis-launcher[hidden],
#mechlae-jarvis-greeting[hidden],
#mechlae-jarvis-dialog:not([open]),
#mechlae-jarvis-dialog [hidden] {
  display: none;
}

#mechlae-jarvis-greeting {
  --jarvis-greeting-gap: .75rem;
  position: fixed;
  right: calc(var(--jarvis-inset-inline) + var(--jarvis-launcher-size) + var(--jarvis-greeting-gap));
  bottom: calc(var(--jarvis-inset-bottom) + .1rem);
  z-index: 60;
  box-sizing: border-box;
  max-width: min(17rem, calc(100% - var(--jarvis-inset-inline) - var(--jarvis-launcher-size) - var(--jarvis-greeting-gap) - max(1rem, env(safe-area-inset-left))));
  margin: 0;
  padding: .6rem .8rem;
  border: 1px solid var(--jarvis-border);
  border-left: .2rem solid var(--jarvis-red);
  border-radius: .75rem;
  color: var(--jarvis-ink);
  background: var(--jarvis-surface);
  box-shadow: 0 .35rem 1.1rem rgb(21 23 27 / 14%);
  font-size: .875rem;
  line-height: 1.4;
  pointer-events: none;
}

#mechlae-jarvis-greeting::after {
  position: absolute;
  right: -.29rem;
  bottom: .9rem;
  width: .5rem;
  height: .5rem;
  transform: rotate(45deg);
  border-top: 1px solid var(--jarvis-border);
  border-right: 1px solid var(--jarvis-border);
  background: var(--jarvis-surface);
  content: "";
}

/* Two eyes and a red power glyph distinguish the assistant from a chat bubble. */
.mechlae-jarvis-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid #e6e7eb;
  border-radius: .7rem;
  color: var(--jarvis-ink);
  background: #fff;
}

.mechlae-jarvis-icon > span {
  position: relative;
  display: block;
  width: 1.38rem;
  height: .95rem;
  border: 1.5px solid currentColor;
  border-radius: .3rem;
}

.mechlae-jarvis-icon > span::before {
  position: absolute;
  top: .26rem;
  left: .28rem;
  width: .18rem;
  height: .18rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: .55rem 0 currentColor;
  animation: mechlae-jarvis-blink 5s ease-in-out infinite;
  content: "";
}

@keyframes mechlae-jarvis-blink {
  0%, 90%, 96%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(.16); }
}

.mechlae-jarvis-icon::after {
  position: absolute;
  top: .12rem;
  right: .1rem;
  width: .46rem;
  height: .58rem;
  background: var(--jarvis-red);
  clip-path: polygon(43% 0, 100% 0, 67% 40%, 100% 40%, 25% 100%, 44% 54%, 0 54%);
  content: "";
}

#mechlae-jarvis-dialog {
  position: fixed;
  inset: auto var(--jarvis-inset-inline) var(--jarvis-inset-bottom) auto;
  box-sizing: border-box;
  width: min(25rem, calc(100% - var(--jarvis-inset-inline) - max(1rem, env(safe-area-inset-left))));
  max-width: none;
  max-height: calc(100vh - var(--jarvis-inset-bottom) - max(1rem, env(safe-area-inset-top)));
  max-height: calc(100dvh - var(--jarvis-inset-bottom) - max(1rem, env(safe-area-inset-top)));
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--jarvis-border);
  border-radius: 1rem;
  color: var(--jarvis-ink);
  background: var(--jarvis-surface);
  box-shadow: 0 .8rem 2.5rem rgb(21 23 27 / 24%);
}

#mechlae-jarvis-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(5rem, 1fr) auto;
}

#mechlae-jarvis-dialog::backdrop {
  background: rgb(21 23 27 / 25%);
}

.mechlae-jarvis-header {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .8rem .55rem 1rem;
  border-top: .2rem solid var(--jarvis-red);
  border-bottom: 1px solid var(--jarvis-border);
}

#mechlae-jarvis-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
}

#mechlae-jarvis-dialog button {
  font-family: inherit;
  cursor: pointer;
}

#mechlae-jarvis-close {
  flex: none;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin-left: auto;
  border: 0;
  border-radius: .5rem;
  color: inherit;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
}

#mechlae-jarvis-close:hover,
#mechlae-jarvis-listen:hover {
  background: #f2f3f5;
}

.mechlae-jarvis-body {
  overflow: auto;
  overscroll-behavior: contain;
  padding: .9rem 1rem;
}

#mechlae-jarvis-reply {
  margin: 0;
  padding: .75rem .85rem;
  border-left: .2rem solid var(--jarvis-red);
  border-radius: .4rem;
  color: var(--jarvis-ink);
  background: #f3f4f6;
  font-size: .95rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#mechlae-jarvis-reply[data-state="thinking"]::after {
  display: inline-block;
  color: var(--jarvis-red);
  animation: mechlae-jarvis-reply-pulse 1.2s ease-in-out infinite;
  content: "…";
}

#mechlae-jarvis-reply[data-state="typing"]::after {
  display: inline-block;
  width: 1px;
  height: .9em;
  margin-left: .14em;
  vertical-align: -.08em;
  background: var(--jarvis-red);
  animation: mechlae-jarvis-reply-pulse 1s step-end infinite;
  content: "";
}

@keyframes mechlae-jarvis-reply-pulse {
  50% { opacity: .2; }
}

#mechlae-jarvis-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .mechlae-jarvis-icon > span::before,
  #mechlae-jarvis-reply[data-state]::after {
    animation: none;
  }

  #mechlae-jarvis-reply[data-state="typing"]::after {
    display: none;
  }
}

#mechlae-jarvis-options,
#mechlae-jarvis-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .5rem;
}

#mechlae-jarvis-options:not(:empty),
#mechlae-jarvis-links:not(:empty) {
  margin-top: .6rem;
}

#mechlae-jarvis-dialog .mechlae-jarvis-option {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: .35rem .7rem;
  border: 1px solid var(--jarvis-border);
  border-radius: .6rem;
  color: var(--jarvis-ink);
  background: #fff;
  font-size: .84rem;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
}

#mechlae-jarvis-dialog .mechlae-jarvis-option:hover {
  border-color: var(--jarvis-red);
  color: var(--jarvis-red);
  background: #fff3f4;
}

.mechlae-jarvis-actions {
  padding: .65rem 1rem .45rem;
  border-top: 1px solid var(--jarvis-border);
}

#mechlae-jarvis-form label {
  display: block;
  margin-bottom: .3rem;
  font-size: .84rem;
  font-weight: 650;
}

.mechlae-jarvis-input-row {
  display: flex;
  gap: .45rem;
}

#mechlae-jarvis-input {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: .45rem .6rem;
  border: 1px solid #8b8d93;
  border-radius: .5rem;
  color: var(--jarvis-ink);
  background: #fff;
  font: inherit;
  font-size: 1rem;
}

#mechlae-jarvis-dialog .mechlae-jarvis-submit {
  padding: .4rem .8rem;
  border: 1px solid var(--jarvis-red);
  border-radius: .5rem;
  color: #fff;
  background: var(--jarvis-red);
  font-size: .9rem;
  font-weight: 700;
}

#mechlae-jarvis-dialog .mechlae-jarvis-submit:hover {
  background: #a70811;
}

.mechlae-jarvis-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1rem;
}

#mechlae-jarvis-dialog .mechlae-jarvis-link,
#mechlae-jarvis-faq-link,
#mechlae-jarvis-listen {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--jarvis-red);
  font-size: .85rem;
  font-weight: 650;
  text-underline-offset: .16rem;
  text-decoration: underline;
}

#mechlae-jarvis-dialog #mechlae-jarvis-listen {
  margin-inline-start: auto;
  padding-inline: .65rem;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  font-size: .85rem;
  font-weight: 650;
}

#mechlae-jarvis-dialog #mechlae-jarvis-listen:hover {
  background: #f2f3f5;
}

#mechlae-jarvis-launcher:focus-visible,
#mechlae-jarvis-dialog :is(a, button, input):focus-visible {
  outline: 2px solid var(--jarvis-red);
  outline-offset: 2px;
}

#mechlae-jarvis-options-label {
  margin: .65rem 0 0;
  font-size: .85rem;
  font-weight: 650;
}

#mechlae-home-faq {
  scroll-margin-top: 5.5rem;
}

.mechlae-jarvis-faq-item:last-child {
  border-block-end: 1px solid #dedfe3;
}

.mechlae-jarvis-faq-item summary::marker {
  color: #c50915;
}

.mechlae-jarvis-faq-answer {
  max-width: 66ch;
  padding: 0 0 1rem 1rem;
}

.mechlae-jarvis-faq-answer a {
  display: inline-block;
  margin-top: .5rem;
  color: #b40713;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .15em;
}
