/*
 * Изолированные стили виджета Sophia Demo.
 * Не изменяют оформление кабинета и других модулей.
 */

body.sophiademo-available {
  padding-bottom: calc(102px + env(safe-area-inset-bottom, 0px));
}

html.sophiademo-modal-open,
html.sophiademo-modal-open body {
  overflow: hidden;
  overscroll-behavior: none;
}

.sophiademo-launcher,
.sophiademo-dialog {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sophiademo-launcher *,
.sophiademo-dialog * {
  box-sizing: border-box;
}

.sophiademo-launcher[hidden],
.sophiademo-dialog [hidden] {
  display: none !important;
}

.sophiademo-launcher {
  position: fixed;
  right: max(24px, env(safe-area-inset-right, 0px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 74px;
  max-width: calc(100vw - 32px);
  padding: 12px 19px 12px 12px;
  border: 1px solid #d9b4bb;
  border-radius: 24px;
  background: linear-gradient(125deg, #91415c, #602238);
  color: #fff;
  cursor: pointer;
  text-align: left;
  box-shadow:
    0 14px 40px #54203238,
    0 0 0 5px #ffffffa8,
    0 0 30px #bd627633;
  animation: sophiademo-glow 3s ease-in-out 3;
  -webkit-tap-highlight-color: transparent;
}

.sophiademo-launcher:focus-visible,
.sophiademo-dialog :focus-visible {
  outline: 3px solid #bc8758;
  outline-offset: 4px;
}

.sophiademo-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 45px;
  width: 45px;
  height: 45px;
  border: 1px solid #ffffff33;
  border-radius: 16px;
  background: #ffffff12;
  color: #f5dfb9;
  font: italic 31px Georgia, serif;
}

.sophiademo-launcher-copy {
  display: grid;
  gap: 4px;
}

.sophiademo-launcher-title {
  font-size: 15px;
  font-weight: 750;
  line-height: 1.25;
}

.sophiademo-launcher-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f3e1e5;
  font-size: 11px;
  line-height: 1.3;
}

.sophiademo-launcher-sub::before {
  content: "";
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #dfe6b8;
  box-shadow: 0 0 8px #dfe6b866;
}

.sophiademo-launcher-arrow {
  margin-left: 5px;
  color: #f5dfb9;
  font-size: 23px;
  line-height: 1;
}

.sophiademo-dialog {
  position: fixed;
  inset: 0;
  width: min(720px, calc(100vw - 48px));
  height: min(790px, calc(100vh - 64px));
  height: min(790px, calc(100dvh - 64px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #e3ced3;
  border-radius: 27px;
  background: #f8f2ef;
  color: #302126;
  box-shadow: 0 35px 100px #25111b55;
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.sophiademo-dialog:not([open]) {
  display: none;
}

.sophiademo-dialog[open] {
  display: flex;
  flex-direction: column;
}

.sophiademo-dialog::backdrop {
  background: #24131dd1;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.sophiademo-dialog button,
.sophiademo-dialog textarea {
  font: inherit;
}

.sophiademo-dialog button {
  -webkit-tap-highlight-color: transparent;
}

.sophiademo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 18px 22px;
  color: white;
  background: linear-gradient(120deg, #873a53, #522036);
}

.sophiademo-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sophiademo-identity h2 {
  margin: 0;
  color: white;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.3;
}

.sophiademo-header-sub {
  margin: 3px 0 0;
  color: #efd8df;
  font-size: 12px;
  line-height: 1.4;
}

.sophiademo-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #ffffff40;
  border-radius: 12px;
  background: #ffffff0d;
  color: white;
  cursor: pointer;
  font-size: 12px !important;
}

.sophiademo-collapse-symbol {
  font-size: 22px;
  line-height: 1;
}

.sophiademo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  padding: 10px 22px;
  border-bottom: 1px solid #e9dcda;
  color: #76636b;
  background: #fffaf7;
  font-size: 11px;
  line-height: 1.4;
}

.sophiademo-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbb0b8 transparent;
  -webkit-overflow-scrolling: touch;
}

.sophiademo-message {
  width: fit-content;
  max-width: 91%;
  margin-bottom: 16px;
  padding: 14px 17px;
  border: 1px solid #eadedb;
  border-radius: 18px 18px 18px 5px;
  background: #fffdfb;
  box-shadow: 0 5px 16px #4c223a04;
}

.sophiademo-message-user {
  margin-left: auto;
  border-color: #dfc7cf;
  border-radius: 18px 18px 5px 18px;
  background: #efe1e5;
}

.sophiademo-message-name {
  margin-bottom: 6px;
  color: #762c43;
  font-size: 11px;
  font-weight: 750;
}

.sophiademo-message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sophiademo-message-state {
  margin-top: 7px;
  color: #816a72;
  font-size: 10px;
}

.sophiademo-message-state[data-failed="true"] {
  color: #a32a40;
}

.sophiademo-welcome {
  max-width: 96%;
}

.sophiademo-welcome p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.65;
}

.sophiademo-welcome p:last-child {
  margin-bottom: 0;
}

.sophiademo-welcome a,
.sophiademo-full-links a {
  color: #762c43;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sophiademo-welcome .sophiademo-privacy {
  color: #76636b;
  font-size: 11px;
  line-height: 1.55;
}

.sophiademo-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 14px;
}

.sophiademo-suggestion {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #dcc5cd;
  border-radius: 13px;
  background: #fffaf7;
  color: #762c43;
  cursor: pointer;
  font-size: 12px !important;
  line-height: 1.4;
}

.sophiademo-bottom {
  flex: 0 0 auto;
  border-top: 1px solid #e9dcda;
  background: #fffdfb;
}

.sophiademo-status {
  min-height: 26px;
  padding: 9px 22px 0;
  color: #76636b;
  font-size: 12px;
  line-height: 1.45;
}

.sophiademo-status[data-error="true"] {
  color: #a32a40;
}

.sophiademo-status[data-busy="true"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #98516b;
  animation: sophiademo-dot 1.4s ease-in-out infinite;
}

.sophiademo-retry {
  display: block;
  margin: 8px 22px 0;
  padding: 7px 11px;
  border: 1px solid #dfc9cc;
  border-radius: 10px;
  color: #762c43;
  background: #fcf3ef;
  cursor: pointer;
  font-size: 12px !important;
}

.sophiademo-form {
  margin: 0;
  padding: 12px 22px 8px;
}

.sophiademo-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px;
  border: 1px solid #dbc5ce;
  border-radius: 18px;
  background: white;
  transition: border-color .15s, box-shadow .15s;
}

.sophiademo-input-row:focus-within {
  border-color: #a36279;
  box-shadow: 0 0 0 3px #762c4310;
}

.sophiademo-input {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 46px;
  min-height: 46px;
  max-height: 120px;
  padding: 11px 6px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: none !important;
  background: transparent;
  color: #302126;
  font-size: 16px !important;
  line-height: 24px;
  box-shadow: none;
}

.sophiademo-input::placeholder {
  color: #94828a;
}

.sophiademo-input:disabled {
  opacity: 1;
  color: #887780;
  -webkit-text-fill-color: #887780;
}

.sophiademo-send {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  color: white;
  background: linear-gradient(140deg, #8d3c57, #64253d);
  cursor: pointer;
}

.sophiademo-send svg {
  width: 22px;
  height: 22px;
}

.sophiademo-dialog button:disabled {
  cursor: default;
  opacity: .45;
}

.sophiademo-input-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  color: #887780;
  font-size: 10px;
  line-height: 1.4;
}

.sophiademo-counter[data-invalid="true"] {
  color: #a32a40;
  font-weight: 700;
}

.sophiademo-full-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px 14px;
  padding: 3px 22px 14px;
  color: #887780;
  font-size: 11px;
  line-height: 1.5;
}

.sophiademo-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;
}

@keyframes sophiademo-glow {
  0%, 100% {
    box-shadow: 0 14px 40px #54203238, 0 0 0 5px #ffffffa8, 0 0 30px #bd627633;
  }
  50% {
    box-shadow: 0 14px 40px #54203245, 0 0 0 7px #ffffffc9, 0 0 42px #bd62765e;
  }
}

@keyframes sophiademo-dot {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

@media (hover: hover) {
  .sophiademo-launcher:hover {
    background: linear-gradient(125deg, #a34a66, #6c2942);
  }

  .sophiademo-collapse:hover {
    background: #ffffff20;
  }

  .sophiademo-suggestion:hover,
  .sophiademo-retry:hover {
    background: #f1e3e5;
  }

  .sophiademo-send:not(:disabled):hover {
    background: #542034;
  }
}

@media (max-width: 680px) {
  .sophiademo-launcher {
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    min-height: 68px;
    gap: 10px;
    padding: 10px 15px 10px 10px;
    border-radius: 22px;
  }

  .sophiademo-launcher-title {
    font-size: 14px;
  }

  .sophiademo-launcher-sub {
    font-size: 10px;
  }

  .sophiademo-dialog {
    inset: auto;
    top: calc(var(--sophiademo-vv-top, 0px) + 8px);
    left: 8px;
    width: calc(100vw - 16px);
    height: calc(var(--sophiademo-vv-height, 100dvh) - 16px);
    margin: 0;
    border-radius: 22px;
  }

  .sophiademo-header {
    gap: 8px;
    padding: 13px 14px;
  }

  .sophiademo-identity {
    gap: 9px;
  }

  .sophiademo-identity .sophiademo-avatar {
    width: 39px;
    height: 39px;
    flex-basis: 39px;
    border-radius: 13px;
    font-size: 28px;
  }

  .sophiademo-identity h2 {
    font-size: 17px;
  }

  .sophiademo-header-sub {
    font-size: 10px;
  }

  .sophiademo-collapse {
    gap: 5px;
    padding: 7px 9px;
    font-size: 11px !important;
  }

  .sophiademo-meta {
    padding: 8px 14px;
    font-size: 10px;
  }

  .sophiademo-scroll {
    padding: 16px 13px;
  }

  .sophiademo-message {
    max-width: 94%;
    padding: 12px 14px;
    font-size: 14px;
  }

  .sophiademo-welcome {
    max-width: 100%;
  }

  .sophiademo-welcome p {
    font-size: 13px;
  }

  .sophiademo-status {
    padding: 8px 14px 0;
    font-size: 11px;
  }

  .sophiademo-retry {
    margin-left: 14px;
    margin-right: 14px;
  }

  .sophiademo-form {
    padding: 9px 12px 7px;
  }

  .sophiademo-input-row {
    gap: 5px;
    padding: 5px;
    border-radius: 16px;
  }

  .sophiademo-full-links {
    padding: 2px 12px max(10px, env(safe-area-inset-bottom, 0px));
    font-size: 10px;
  }

  .sophiademo-keyboard-help {
    display: none;
  }
}

@media (max-height: 520px) {
  .sophiademo-header {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .sophiademo-meta,
  .sophiademo-full-links,
  .sophiademo-input-meta {
    display: none;
  }

  .sophiademo-status {
    min-height: 20px;
    padding-top: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sophiademo-launcher,
  .sophiademo-status::before {
    animation: none !important;
  }

  .sophiademo-dialog * {
    transition: none !important;
  }
}