:root{
  --p4y-bg: rgba(255,255,255,0.84);
  --p4y-surface: rgba(255,255,255,0.66);
  --p4y-surface-strong: rgba(255,255,255,0.92);
  --p4y-border: rgba(255,255,255,0.50);
  --p4y-border-soft: rgba(15,23,42,0.06);
  --p4y-text: #0f172a;
  --p4y-muted: #64748b;
  --p4y-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
  --p4y-shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
  --p4y-radius: 24px;
  --p4y-radius-lg: 30px;
  --p4y-accent: linear-gradient(180deg, #d7b24d, #b68f21);
  --p4y-accent-soft: linear-gradient(180deg, rgba(215,178,77,0.20), rgba(182,143,33,0.12));
  --p4y-ai: linear-gradient(180deg, rgba(255,255,255,0.90), rgba(246,248,251,0.82));
  --p4y-user: linear-gradient(180deg, rgba(18, 138, 255, 0.96), rgba(6, 102, 214, 0.96));
  --p4y-blur: blur(22px) saturate(180%);

  --p4y-bubble-bottom-desktop: 14px;
  --p4y-popup-bottom-desktop: 84px;
  --p4y-bubble-bottom-mobile: calc(14px + env(safe-area-inset-bottom, 0px));
  --p4y-popup-bottom-mobile: calc(84px + env(safe-area-inset-bottom, 0px));

  --p4y-vh: 100vh;
  --p4y-vv-top: 0px;
  --p4y-kb-offset: 0px;
}

#p4y-chat,
#p4y-chat *{
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

html.p4y-chat-open,
body.p4y-chat-open{
  overflow: hidden !important;
  height: 100% !important;
  overscroll-behavior: none !important;
}

#p4y-chat-window{
  display: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;

  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: var(--p4y-vh, 100vh);
  max-height: var(--p4y-vh, 100vh);

  background:
    radial-gradient(circle at 16% 14%, rgba(255,255,255,0.98), transparent 24%),
    radial-gradient(circle at 82% 86%, rgba(228,194,123,0.12), transparent 28%),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.55), transparent 18%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  border: 1px solid var(--p4y-border);
  border-radius: var(--p4y-radius-lg);
  box-shadow: var(--p4y-shadow);
  backdrop-filter: var(--p4y-blur);
  -webkit-backdrop-filter: var(--p4y-blur);

  z-index: 999999;
  resize: none !important;

  display: flex;
  flex-direction: column;

  overflow: hidden;
  contain: none;
  overscroll-behavior: none;
  transform: none;
  transition: opacity .16s ease, visibility .16s ease;
  will-change: opacity, transform;
}

#p4y-chat-window.show{
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.p4y-chat-header{
  position: sticky;
  top: 0;
  z-index: 120;
  flex: 0 0 auto;

  padding: 10px 14px;
  min-height: 58px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  display: flex;
  align-items: center;
  gap: 12px;

  box-shadow: 0 1px 0 rgba(15,23,42,0.03);
}

.p4y-avatar{
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  position: relative;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p4y-avatar img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.p4y-avatar .p4y-badge{
  display: none !important;
}

.p4y-user-info{
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.p4y-name{
  font-size: 16px;
  font-weight: 750;
  color: var(--p4y-text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p4y-status{
  font-size: 12px;
  color: var(--p4y-muted);
  margin-left: 0;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#p4y-chat-close{
  margin-left: auto;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248,250,252,0.96);
  border: 1px solid rgba(15,23,42,0.05);
  border-radius: 999px;
  color: #334155;
  box-shadow: 0 6px 18px rgba(15,23,42,0.06);
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

#p4y-chat-messages{
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 14px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: flex-start;
  align-items: stretch;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.78), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.30), rgba(241,245,249,0.14));
  overscroll-behavior: contain;
  touch-action: pan-y;
  scroll-behavior: smooth;
}

#p4y-chat-window.empty #p4y-chat-messages{
  padding-top: 20px;
}

#p4y-chat-messages > .ai:first-child{
  margin-top: 4px;
  max-width: min(86%, 340px);
}

#p4y-chat-messages::-webkit-scrollbar{
  width: 8px;
}

#p4y-chat-messages::-webkit-scrollbar-thumb{
  background: rgba(100,116,139,0.18);
  border-radius: 999px;
}

#p4y-chat-messages::-webkit-scrollbar-track{
  background: transparent;
}

@keyframes p4y-pop{
  0%{ opacity:0; transform: translateY(8px) scale(.985); }
  60%{ opacity:1; transform: translateY(-1px) scale(1.01); }
  100%{ opacity:1; transform: translateY(0) scale(1); }
}

.user{
  align-self: flex-end;
  max-width: 82%;
  padding: 12px 14px;
  border-radius: 20px 20px 6px 20px;
  font-size: 15px;
  line-height: 1.38;
  word-break: break-word;
  position: relative;
  color: #1e293b;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.20), rgba(255,255,255,0.08)),
    linear-gradient(180deg, #E4C27B, #d4af37) !important;
  border: 1px solid rgba(255,255,255,0.22) !important;
  box-shadow:
    0 10px 24px rgba(0,0,0,0.14),
    inset 0 1px 0 rgba(255,255,255,0.35) !important;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  animation: p4y-pop .22s ease;
}

.user::before{
  content:"";
  position:absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 45%) !important;
  pointer-events:none;
}

.user::after{
  display: none !important;
}

.ai{
  align-self: flex-start;
  max-width: 82%;
  padding: 12px 14px;
  border-radius: 20px 20px 20px 6px;
  font-size: 15px;
  line-height: 1.42;
  word-break: break-word;
  position: relative;
  color: #0f172a !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(246,248,251,0.90)) !important;
  border: 1px solid rgba(15,23,42,0.05) !important;
  box-shadow:
    0 8px 18px rgba(15,23,42,0.08),
    inset 0 1px 0 rgba(255,255,255,0.70) !important;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  animation: p4y-pop .22s ease;
}

.ai::before{
  content:"";
  position:absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 45%) !important;
  pointer-events:none;
}

.ai::after{
  display: none !important;
}

.typing{
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(243,246,250,0.82));
  border: 1px solid rgba(255,255,255,0.68);
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(15,23,42,0.06);
  color: #64748b;
  font-size: 13px;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  animation: p4y-pop .18s ease;
}

.typing .dots{
  display: inline-flex;
  gap: 6px;
}

.typing .dots span{
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(15,23,42,0.24);
  animation: p4y-dot 1s infinite;
}


.typing.p4y-typing-operator{
  color: #475569;
  background: linear-gradient(180deg, rgba(255,251,235,0.92), rgba(255,247,237,0.86));
}

.p4y-live-operator{
  background: linear-gradient(180deg, rgba(255,251,235,0.94), rgba(255,247,237,0.9)) !important;
  border-color: rgba(251,191,36,0.28) !important;
}

@keyframes p4y-dot{
  0%{ transform: translateY(0); opacity: .55; }
  50%{ transform: translateY(-6px); opacity: 1; }
  100%{ transform: translateY(0); opacity: .55; }
}

.p4y-chat-input{
  position: sticky;
  bottom: 0;
  z-index: 120;
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(15,23,42,0.05);
  background: rgba(255,255,255,0.97);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 -1px 0 rgba(15,23,42,0.03);
}

.p4y-chat-input input,
#p4y-chat-text{
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(226,232,240,0.9);
  background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(248,250,252,0.96));
  padding: 11px 16px;
  border-radius: 22px;
  font-size: 16px;
  height: 48px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-text-size-adjust: 100%;
  color: #0f172a;
  box-shadow:
    0 4px 14px rgba(15,23,42,0.04),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

.p4y-chat-input input::placeholder,
#p4y-chat-text::placeholder{
  color: #94a3b8;
}

.p4y-chat-input input:focus,
#p4y-chat-text:focus{
  box-shadow:
    0 12px 28px rgba(10,132,255,0.12),
    inset 0 1px rgba(255,255,255,0.82);
}

#p4y-chat-send{
  width: 44px;
  height: 44px;
  background: transparent;
  box-shadow: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 44px;
  padding: 0;
  touch-action: manipulation;
}

#p4y-chat-send:not(.enabled){
  opacity: 0.55;
  transform: scale(.98);
  box-shadow: none;
}

#p4y-chat-send svg{
  width: 22px;
  height: 22px;
  display: block;
  fill: #0f172a;
}

#p4y-chat-bubble{
  position: fixed;
  left: 16px;
  bottom: var(--p4y-bubble-bottom-desktop);

  width: 64px;
  height: 64px;
  border-radius: 50%;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.35)),
    linear-gradient(135deg, rgba(212,175,55,0.18), rgba(212,175,55,0.06));

  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);

  border: 1px solid rgba(212,175,55,0.45);

  box-shadow:
    0 10px 28px rgba(0,0,0,0.18),
    0 0 0 1px rgba(255,255,255,0.4) inset;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 13000;
  cursor: pointer;
  touch-action: manipulation;

  transition: transform .2s ease, box-shadow .2s ease;
}

.p4y-chat-circle{
  position: relative;
}

#p4y-chat-bubble::after,
.p4y-chat-circle::after{
  content: none !important;
  display: none !important;
}

.p4y-bubble-icon,
.p4y-bubble-icon svg,
#p4y-chat-bubble svg{
  pointer-events: none;
}

.p4y-bubble-icon{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.p4y-bubble-icon svg{
  width: 76%;
  height: 76%;
  display: block;
  filter:
    drop-shadow(0 2px 4px rgba(0,0,0,0.25))
    drop-shadow(0 0 6px rgba(212,175,55,0.25));
}

@media (hover:hover){
  #p4y-chat-bubble:hover{
    transform: scale(1.08);
    box-shadow:
      0 18px 40px rgba(0,0,0,0.28),
      0 0 0 10px rgba(212,175,55,0.08);
  }
}

@keyframes p4y-pulse {
  0% { box-shadow: 0 10px 30px rgba(0,0,0,0.25), 0 0 0 0 rgba(182,143,33,0.20); }
  70% { box-shadow: 0 10px 30px rgba(0,0,0,0.25), 0 0 0 10px rgba(182,143,33,0); }
  100% { box-shadow: 0 10px 30px rgba(0,0,0,0.25), 0 0 0 0 rgba(182,143,33,0); }
}

.p4y-chat-popup{
  position: fixed;
  left: 20px;
  bottom: var(--p4y-popup-bottom-desktop);
  max-width: min(300px, calc(100vw - 40px));

  background: rgba(255,255,255,0.86) !important;
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);

  border: 1px solid rgba(15,23,42,0.08) !important;
  border-radius: 18px;
  padding: 10px 14px;

  font-size: 13px;
  line-height: 1.35;
  color: #0f172a;

  box-shadow: 0 12px 30px rgba(15,23,42,0.12);

  opacity: 0;
  transform: translateY(8px) scale(.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 12999;
}

.p4y-chat-popup.show{
  opacity: 1;
  transform: translateY(0) scale(1);
}

.cc_banner,
.cc-banner,
.cookie-consent,
.cc-window,
#cookie-consent,
.cookie-banner,
.cc-banner-wrapper{
  z-index: 1000 !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}

@media (min-width:768px){
  html.p4y-chat-open,
  body.p4y-chat-open{
    overflow: auto !important;
    height: auto !important;
    touch-action: auto !important;
  }

  #p4y-chat-window{
    width: min(390px, calc(100vw - 40px));
    height: clamp(540px, 72vh, 700px);
    max-height: calc(100vh - 40px);
    right: 20px;
    left: auto;
    bottom: 20px;
    top: auto;
    border-radius: 28px;
  }

  .p4y-chat-header{
    border-radius: 28px 28px 0 0;
    cursor: grab;
    padding-top: 10px;
  }

  .p4y-chat-input{
    border-radius: 0 0 28px 28px;
  }

  #p4y-chat-messages{
    padding-bottom: 18px;
  }

  #p4y-chat-bubble{
    position: fixed;
    left: 16px;
    bottom: var(--p4y-bubble-bottom-desktop);

    width: 64px;
    height: 64px;
    border-radius: 50%;

    background:
      linear-gradient(180deg, rgba(255,255,255,0.70), rgba(255,255,255,0.35)),
      radial-gradient(circle at 30% 30%, rgba(255,255,255,0.6), transparent 60%),
      linear-gradient(135deg, rgba(212,175,55,0.18), rgba(212,175,55,0.05));

    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);

    border: 1px solid rgba(212,175,55,0.45);

    box-shadow:
      0 12px 30px rgba(0,0,0,0.22),
      inset 0 1px 0 rgba(255,255,255,0.6),
      0 0 0 1px rgba(255,255,255,0.25);

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 13000;
    cursor: pointer;
    transition: all .2s ease;
  }

  .p4y-chat-popup{
    bottom: var(--p4y-popup-bottom-desktop);
  }
}

@media (max-width:767px){
  html.p4y-chat-open,
  body.p4y-chat-open{
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none !important;
  }

  #p4y-chat-window{
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: var(--p4y-vh, 100vh);
    max-height: var(--p4y-vh, 100vh);
    min-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }

  .p4y-chat-header{
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    min-height: calc(58px + env(safe-area-inset-top, 0px));
  }

  #p4y-chat-messages{
    padding: 16px 14px 18px;
  }

  .p4y-chat-input{
    padding: 10px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .p4y-chat-popup{
    left: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
    bottom: calc(var(--p4y-popup-bottom-mobile));
  }

  #p4y-chat-bubble{
    left: 12px;
    bottom: var(--p4y-bubble-bottom-mobile);
  }
}

@media (max-width:360px){
  .p4y-name{ font-size: 15px; }
  .p4y-status{ font-size: 11px; }

  .p4y-chat-input{
    gap: 8px;
    padding: 10px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
  }

  .p4y-chat-input input,
  #p4y-chat-text{
    height: 46px;
    padding: 10px 12px;
    font-size: 16px;
  }
}

#p4y-chat-window.show .p4y-chat-header,
#p4y-chat-window.show #p4y-chat-messages,
#p4y-chat-window.show .p4y-chat-input{
  animation: p4y-pop .18s ease;
}

@supports (-webkit-touch-callout: none){
  body.p4y-chat-open{
    position: fixed !important;
    overflow: hidden !important;
    width: 100%;
  }
}

html, body{
  overscroll-behavior: none;
}

#p4y-chat-messages{
  overscroll-behavior: contain;
}

@media (min-width:768px){
  .p4y-avatar .p4y-badge,
  .p4y-avatar::before,
  .p4y-avatar::after,
  .p4y-avatar img::before,
  .p4y-avatar img::after{
    display: none !important;
    content: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
  }
}

/* === stability patch, bez zmiany stylu === */
#p4y-chat-window,
#p4y-chat-messages,
.p4y-chat-input,
#p4y-chat-text,
#p4y-chat-close,
#p4y-chat-send{
  -webkit-touch-callout: none;
}

#p4y-chat-window{
  touch-action: pan-y;
}

#p4y-chat-text{
  transform: translateZ(0);
}

@media (max-width:767px){
  #p4y-chat-window{
    inset: 0 !important;
    width: 100% !important;
    height: var(--p4y-vh, 100dvh) !important;
    max-height: var(--p4y-vh, 100dvh) !important;
  }

  #p4y-chat-messages{
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .p4y-chat-input{
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}
