/* ЛапаПрогулка — виджет чата (тёмная тема: тёплые коричнево-серые тона + зелёные акценты) */

.lp-chat-fab {
  position: fixed;
  right: max(clamp(0.85rem, 3vw, 1.35rem), env(safe-area-inset-right, 0px));
  bottom: max(clamp(0.85rem, 3vw, 1.35rem), env(safe-area-inset-bottom, 0px));
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #34d399, #047857);
  color: #fff;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease;
}

.lp-chat-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(52, 211, 153, 0.35);
}

.lp-chat-fab.lp-chat-fab--has-unread {
  animation: lp-fab-pulse 2.2s ease-in-out infinite;
}

@keyframes lp-fab-pulse {
  0%,
  100% {
    box-shadow:
      0 8px 28px rgba(0, 0, 0, 0.45),
      0 0 0 0 rgba(52, 211, 153, 0.45);
  }
  50% {
    box-shadow:
      0 10px 32px rgba(0, 0, 0, 0.5),
      0 0 0 6px rgba(52, 211, 153, 0);
  }
}

.lp-chat-fab svg {
  width: 28px;
  height: 28px;
}

.lp-chat-fab:focus-visible {
  outline: 3px solid #5eead4;
  outline-offset: 3px;
}

.lp-chat-fab__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.32rem;
  border-radius: 999px;
  background: #e85d5d;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.lp-chat-fab__badge[hidden] {
  display: none !important;
}

.lp-chat[hidden] {
  display: none !important;
}

.lp-chat {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: end center;
  padding-top: max(clamp(0.5rem, 3vw, 1.25rem), env(safe-area-inset-top, 0px));
  padding-right: max(clamp(0.5rem, 3vw, 1.25rem), env(safe-area-inset-right, 0px));
  padding-bottom: max(clamp(0.5rem, 3vw, 1.25rem), env(safe-area-inset-bottom, 0px));
  padding-left: max(clamp(0.5rem, 3vw, 1.25rem), env(safe-area-inset-left, 0px));
  background: rgba(12, 10, 8, 0.62);
  backdrop-filter: blur(6px);
}

.lp-chat__panel {
  /* Токены тёмной темы */
  --lp-text: #f2ede6;
  --lp-text-muted: #9b948c;
  --lp-thread: #1f1c19;
  --lp-elev: #282521;
  --lp-header-bg: linear-gradient(180deg, #35302b 0%, #2a2622 100%);
  --lp-bubble-in: #3a3632;
  --lp-bubble-in-border: rgba(255, 255, 255, 0.07);
  --lp-bubble-out-a: #0f766e;
  --lp-bubble-out-b: #0d5c52;
  --lp-author: #5eead4;

  position: relative;
  width: min(100%, min(384px, calc(100vw - 1.25rem)));
  max-height: min(580px, 88vh, 88dvh);
  display: flex;
  flex-direction: column;
  background: var(--lp-elev);
  color: var(--lp-text);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 24px 56px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.35);
  animation: lp-chat-in 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes lp-chat-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lp-chat__panel.lp-chat__panel {
    animation: none;
  }
  .lp-chat-fab:hover {
    transform: none;
  }
  .lp-chat-fab.lp-chat-fab--has-unread {
    animation: none;
  }
}

.lp-chat__close-out {
  position: absolute;
  top: clamp(0.35rem, 2vw, 0.55rem);
  left: clamp(0.35rem, 2vw, 0.55rem);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  line-height: 1;
  z-index: 2;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.lp-chat__close-out:is(:hover, :focus-visible) {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
}

.lp-chat__header {
  flex-shrink: 0;
  background: var(--lp-header-bg);
  color: #fff;
  padding: 0.95rem 1rem 0.75rem;
  padding-left: 2.85rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
}

.lp-chat__header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.65rem;
}

.lp-chat__header-title {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.lp-chat__header-now {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  padding-top: 0.15rem;
}

.lp-chat__header-sub {
  margin: 0.4rem 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lp-chat__header-sub::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ddf8a;
  box-shadow: 0 0 0 2px rgba(125, 223, 138, 0.35);
  flex-shrink: 0;
}

.lp-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--lp-thread);
  min-height: 200px;
  font-size: 0.88rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.lp-chat__messages::-webkit-scrollbar {
  width: 6px;
}

.lp-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 99px;
}

.lp-chat__messages::-webkit-scrollbar-track {
  background: transparent;
}

.lp-chat__hint {
  font-size: 0.76rem;
  color: #d4c4a8;
  padding: 0.5rem 0.6rem;
  background: rgba(80, 65, 40, 0.45);
  border-radius: 10px;
  border: 1px solid rgba(233, 196, 106, 0.25);
  line-height: 1.45;
}

.lp-chat__hint code {
  font-size: 0.7rem;
  word-break: break-all;
  color: #f0e6d2;
}

.lp-chat__hint[hidden] {
  display: none !important;
}

.lp-chat__row {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
}

.lp-chat__row--user {
  flex-direction: row-reverse;
}

.lp-chat__bubble {
  max-width: min(88%, 288px);
  padding: 0.62rem 0.8rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.lp-chat__bubble--in {
  background: var(--lp-bubble-in);
  border: 1px solid var(--lp-bubble-in-border);
  color: var(--lp-text);
  border-bottom-left-radius: 6px;
}

.lp-chat__bubble--out {
  background: linear-gradient(165deg, var(--lp-bubble-out-a), var(--lp-bubble-out-b));
  border: 1px solid rgba(127, 217, 154, 0.22);
  color: #f4fbf6;
  border-bottom-right-radius: 6px;
}

.lp-chat__bubble-meta {
  display: block;
  font-size: 0.65rem;
  color: var(--lp-text-muted);
  margin-top: 0.3rem;
  text-align: right;
}

.lp-chat__bubble--out .lp-chat__bubble-meta {
  color: rgba(255, 255, 255, 0.65);
}

.lp-chat__bubble-author {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--lp-author);
  margin-bottom: 0.28rem;
}

.lp-chat__bubble-author--user {
  color: #c5f2dc;
  text-align: right;
}

.lp-chat__row--user .lp-chat__mini-avatar {
  background: linear-gradient(145deg, #4a8f72, #2e6b4d);
  border-color: rgba(197, 242, 220, 0.35);
}

.lp-chat__mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2f8f5c, #1e5c40);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.lp-chat__mini-avatar svg {
  width: 17px;
  height: 17px;
  color: #fff;
}

.lp-chat__footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--lp-elev);
  padding: 0.55rem 0.75rem 0.5rem;
}

.lp-chat__input-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #1a1816;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 0.12rem 0.22rem 0.12rem 0.65rem;
}

.lp-chat__input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0;
  min-width: 0;
  color: var(--lp-text);
}

.lp-chat__input::placeholder {
  color: #6d6760;
}

.lp-chat__input:focus {
  outline: none;
}

.lp-chat__send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #36825f, #265d44);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.lp-chat__send:hover {
  transform: scale(1.06);
  filter: brightness(1.08);
}

.lp-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.lp-chat__toolbar {
  display: flex;
  gap: 0.55rem;
  padding: 0.35rem 0.1rem 0.05rem 0;
  color: var(--lp-text-muted);
}

.lp-chat__toolbar button {
  border: none;
  background: none;
  padding: 0.2rem;
  cursor: default;
  color: inherit;
  opacity: 0.75;
  line-height: 1;
  font-size: 0.95rem;
}

.lp-chat__toolbar button[aria-disabled="true"] {
  opacity: 0.45;
}

@media (min-width: 480px) {
  .lp-chat {
    place-items: end;
    padding-right: max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-right, 0px));
  }
}

/* Узкий телефон: панель на всю ширину с отступами safe-area */
@media (max-width: 400px) {
  .lp-chat__panel {
    width: calc(100vw - 0.75rem);
    max-width: none;
    border-radius: 14px 14px 0 0;
    max-height: min(92vh, 92dvh, 640px);
  }

  .lp-chat {
    place-items: end stretch;
    padding-left: max(0.35rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.35rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  }

  .lp-chat-fab {
    width: 56px;
    height: 56px;
  }

  .lp-chat-fab svg {
    width: 25px;
    height: 25px;
  }
}

@media (pointer: coarse) {
  .lp-chat__send {
    min-width: 44px;
    min-height: 44px;
  }

  .lp-chat__close-out {
    min-width: 44px;
    min-height: 44px;
  }
}
