.elpos-ai {
  position: fixed;
  z-index: 2147483000;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  color: #18283b;
  font-family: Inter, "Segoe UI", Roboto, Arial, "Elpos_simboli_1000", sans-serif;
}

.elpos-ai button,
.elpos-ai textarea {
  font: inherit;
}

.elpos-ai__button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  color: #fff;
  background: #0252a4;
  box-shadow: 0 0.55rem 1.5rem rgba(0, 0, 0, 0.24);
  font-weight: 750;
  cursor: pointer;
}

.elpos-ai__button:hover {
  background: #013f80;
}

html.elpos-ai-introduction-active body > *:not(.elpos-ai) {
  filter: blur(0.15rem);
  opacity: 0.3;
  pointer-events: none;
  user-select: none;
}

.elpos-ai__introduction {
  position: absolute;
  right: 0;
  bottom: calc(100% + 1.25rem);
  width: min(21rem, calc(100vw - 2rem));
  box-sizing: border-box;
  padding: 1rem 2.5rem 1rem 1rem;
  border: 0.125rem solid #0252a4;
  border-radius: 0.5rem;
  color: #102841;
  background: #fff;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.28);
}

.elpos-ai__introduction strong {
  display: block;
  font-size: 1.05rem;
}

.elpos-ai__introduction p {
  margin: 0.45rem 0 0.8rem;
  line-height: 1.4;
}

.elpos-ai__introduction-language {
  display: block;
  margin-bottom: 0.35rem;
  color: #42536a;
  font-size: 0.78rem;
  font-weight: 700;
}

.elpos-ai__introduction-languages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.elpos-ai__introduction-language-choice,
.elpos-ai__introduction-dismiss {
  border: 0.0625rem solid #8ca8c5;
  border-radius: 0.35rem;
  color: #013f80;
  background: #fff;
  cursor: pointer;
}

.elpos-ai__introduction-language-choice {
  min-width: 2.6rem;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 750;
}

.elpos-ai__introduction-language-choice:hover,
.elpos-ai__introduction-language-choice:focus-visible {
  color: #fff;
  border-color: #0252a4;
  background: #0252a4;
}

.elpos-ai__introduction-language-choice[data-selected="true"] {
  color: #fff;
  border-color: #013f80;
  background: #013f80;
}

.elpos-ai__introduction-dismiss {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.8rem;
  height: 1.8rem;
  font-size: 1rem;
}

.elpos-ai__introduction-arrow {
  position: absolute;
  right: 2.3rem;
  bottom: -1.45rem;
  width: 0.14rem;
  height: 1.25rem;
  background: #0252a4;
}

.elpos-ai__introduction-arrow::after {
  position: absolute;
  left: -0.28rem;
  bottom: -0.05rem;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 0.14rem solid #0252a4;
  border-bottom: 0.14rem solid #0252a4;
  content: "";
  transform: rotate(45deg);
}

.elpos-ai__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: none;
  width: min(24rem, calc(100vw - 2rem));
  height: min(34rem, calc(100vh - 6rem));
  min-width: 24rem;
  min-height: 28rem;
  max-width: calc(100vw - 2rem);
  max-height: min(42rem, calc(100vh - 6rem));
  overflow: hidden;
  box-sizing: border-box;
  border: 0.0625rem solid #cfd9e5;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.28);
  resize: none;
}

.elpos-ai[data-open="true"] .elpos-ai__panel {
  display: grid;
  grid-template-rows: auto minmax(10rem, 1fr) auto;
}

.elpos-ai__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  color: #fff;
  background: #012142;
}

.elpos-ai__resize-handle {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 1.1rem;
  height: 1.1rem;
  cursor: nwse-resize;
  touch-action: none;
}

.elpos-ai__resize-handle::before,
.elpos-ai__resize-handle::after {
  position: absolute;
  left: 0.2rem;
  width: 0.62rem;
  height: 0.08rem;
  border-radius: 0.1rem;
  background: #c7d9eb;
  content: "";
  transform: rotate(-45deg);
  transform-origin: left center;
}

.elpos-ai__resize-handle::before {
  top: 0.38rem;
}

.elpos-ai__resize-handle::after {
  top: 0.66rem;
}

.elpos-ai__resize-handle:hover::before,
.elpos-ai__resize-handle:hover::after,
.elpos-ai__resize-handle:focus-visible::before,
.elpos-ai__resize-handle:focus-visible::after {
  background: #fff;
}

.elpos-ai__header-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.4rem;
}

.elpos-ai__title {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.elpos-ai__title strong,
.elpos-ai__title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elpos-ai__title span {
  color: #c6d9ef;
  font-size: 0.78rem;
}

.elpos-ai__clear,
.elpos-ai__close {
  display: grid;
  min-width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 0.0625rem solid rgba(255, 255, 255, 0.28);
  border-radius: 0.4rem;
  color: #fff;
  background: transparent;
  cursor: pointer;
}

.elpos-ai__clear {
  padding-inline: 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.elpos-ai__messages {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  min-height: 0;
  overflow-y: auto;
  padding: 0.9rem;
  background: #f6f8fb;
}

.elpos-ai__message {
  max-width: 100%;
  padding: 0.7rem 0.78rem;
  border: 0.0625rem solid #dbe4ee;
  border-radius: 0.5rem;
  background: #fff;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.elpos-ai__message,
.elpos-ai__message * {
  font-family: Inter, "Segoe UI", Roboto, Arial, "Elpos_simboli_1000", sans-serif;
}

.elpos-ai__message--user {
  justify-self: end;
  color: #fff;
  border-color: #0252a4;
  background: #0252a4;
}

.elpos-ai__message a {
  color: #0252a4;
  font-weight: 700;
  text-decoration: underline;
}

.elpos-ai__message--status {
  color: #536176;
  background: transparent;
  border-color: transparent;
  padding-inline: 0;
}

.elpos-ai__message--busy {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.elpos-ai__spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  border: 0.15rem solid #c7d5e5;
  border-top-color: #0252a4;
  border-radius: 50%;
  animation: elpos-ai-spin 0.8s linear infinite;
}

.elpos-ai__truncated-notice {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 0.0625rem solid #e1e8f0;
  color: #8a4b08;
  font-size: 0.82rem;
}

@keyframes elpos-ai-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .elpos-ai__spinner {
    animation-duration: 1.8s;
  }
}

.elpos-ai__symbol {
  display: inline-block;
  min-width: 1.1em;
  color: inherit;
  font-family: "Elpos_simboli_1000", sans-serif;
  font-style: normal;
  font-weight: normal;
  text-align: center;
  vertical-align: -0.08em;
}

.elpos-ai__citations,
.elpos-ai__media {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 0.0625rem solid #e1e8f0;
  font-size: 0.88rem;
}

.elpos-ai__citations a,
.elpos-ai__media a {
  color: #0252a4;
  font-weight: 700;
}

.elpos-ai__media-description {
  display: block;
  color: #536176;
  font-size: 0.82rem;
  line-height: 1.35;
}

.elpos-ai__feedback {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
  padding-top: 0.55rem;
  border-top: 0.0625rem solid #e1e8f0;
}

.elpos-ai__feedback-label,
.elpos-ai__feedback-status,
.elpos-ai__feedback-form small {
  color: #536176;
  font-size: 0.78rem;
  line-height: 1.35;
}

.elpos-ai__feedback-status {
  display: block;
  margin-top: 0.4rem;
}

.elpos-ai__feedback-status[data-error="true"] {
  color: #b42318;
}

.elpos-ai__feedback-button,
.elpos-ai__feedback-text-button {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.3rem 0.45rem;
  border: 0.0625rem solid #bdc9d7;
  border-radius: 0.35rem;
  color: #0252a4;
  background: #fff;
  cursor: pointer;
  line-height: 1;
}

.elpos-ai__feedback-button:hover,
.elpos-ai__feedback-text-button:hover {
  border-color: #0252a4;
  background: #edf5ff;
}

.elpos-ai__feedback-button:disabled,
.elpos-ai__feedback-text-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.elpos-ai__feedback-text-button {
  font-size: 0.78rem;
  font-weight: 700;
}

.elpos-ai__feedback-submit {
  color: #fff;
  border-color: #0252a4;
  background: #0252a4;
}

.elpos-ai__feedback-submit:hover {
  color: #fff;
  background: #013f80;
}

.elpos-ai__feedback-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.elpos-ai__feedback-form label {
  display: grid;
  gap: 0.3rem;
  color: #18283b;
  font-size: 0.82rem;
  font-weight: 700;
}

.elpos-ai__feedback-form textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  padding: 0.55rem;
  border: 0.0625rem solid #bdc9d7;
  border-radius: 0.35rem;
  color: #18283b;
  background: #fff;
}

.elpos-ai__feedback-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.elpos-ai__form {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border-top: 0.0625rem solid #dbe4ee;
  background: #fff;
}

.elpos-ai__input {
  width: 100%;
  min-height: 5rem;
  max-height: 9rem;
  resize: vertical;
  padding: 0.7rem;
  border: 0.0625rem solid #bdc9d7;
  border-radius: 0.45rem;
  color: #18283b;
  background: #fff;
}

.elpos-ai__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}

.elpos-ai__mic-status {
  min-width: 0;
  margin-right: auto;
  color: #536176;
  font-size: 0.78rem;
}

.elpos-ai__mic {
  display: grid;
  width: 2.65rem;
  min-height: 2.65rem;
  place-items: center;
  padding: 0;
  border: 0.0625rem solid #bdc9d7;
  border-radius: 0.45rem;
  color: #0252a4;
  background: #fff;
  cursor: pointer;
  font-size: 1.1rem;
}

.elpos-ai__mic[data-state="recording"] {
  border-color: #b42318;
  color: #b42318;
  background: #fff4f2;
}

.elpos-ai__mic:disabled {
  cursor: wait;
  opacity: 0.6;
}

.elpos-ai__send {
  min-height: 2.65rem;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 0.45rem;
  color: #fff;
  background: #0252a4;
  font-weight: 750;
  cursor: pointer;
}

.elpos-ai__send:disabled {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 32rem) {
  .elpos-ai {
    right: 0.65rem;
    bottom: 0.65rem;
    left: 0.65rem;
  }

  .elpos-ai__button {
    width: 100%;
    justify-content: center;
  }

  .elpos-ai__introduction {
    right: 0;
    bottom: calc(100% + 1.1rem);
    width: 100%;
  }

  .elpos-ai__panel {
    right: 0;
    left: 0;
    width: auto;
    min-width: 0;
    height: min(34rem, calc(100vh - 5.5rem));
    max-height: calc(100vh - 5.5rem);
    resize: none;
  }
}
