#phiber-cpan-widget-bar {
  --phiber-cpan-primary: #256091;
  --phiber-cpan-modal-width: 420px;
  --phiber-cpan-modal-height: 720px;
  --phiber-cpan-action-hover-bg: rgba(255,255,255,0.08);
  position: fixed;
  right: 24px;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  z-index: 999999;
  width: max-content;
  max-width: calc(100vw - 24px);
  flex-wrap: nowrap;
  transform: translateY(0);
  opacity: 1;
  transition: transform .28s ease, opacity .28s ease;
}

#phiber-cpan-widget-bar[data-position="left"] {
  left: 24px;
  right: auto;
}

#phiber-cpan-widget-bar button {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

#phiber-cpan-widget-bar button.phiber-cpan-widget-action {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  min-height: 64px;
  padding: 10px 14px;
  flex: 0 0 auto;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.96;
  text-align: center;
  background: var(--phiber-cpan-button-bg, transparent);
  color: var(--phiber-cpan-button-color, inherit);
}

#phiber-cpan-widget-bar button.phiber-cpan-widget-action:hover {
  background: var(--phiber-cpan-action-hover-bg);
  transform: translateY(-2px);
  opacity: 1;
}

#phiber-cpan-widget-bar button.phiber-cpan-widget-action:active {
  transform: scale(0.96);
}

#phiber-cpan-widget-bar button.phiber-cpan-widget-action.is-active {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  background: var(--phiber-cpan-primary);
}

#phiber-cpan-widget-bar button.phiber-cpan-widget-action:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: rgba(255, 255, 255, 0.14);
}

.phiber-cpan-widget-action-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  align-items: center;
  justify-content: center;
}

.phiber-cpan-widget-action-icon svg,
.phiber-cpan-widget-action-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.phiber-cpan-widget-action-label {
  line-height: 1.15;
  display: inline-block;
  font-size: 12px;
}

#phiber-cpan-widget-teaser {
  --phiber-cpan-teaser-bottom: 92px;
  position: fixed;
  right: 24px;
  bottom: var(--phiber-cpan-teaser-bottom);
  width: min(370px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
  z-index: 999997;
}

#phiber-cpan-widget-teaser[data-position="left"] {
  left: 24px;
  right: auto;
}

#phiber-cpan-widget-teaser.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#phiber-cpan-widget-teaser::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-right: 2px solid var(--phiber-cpan-primary);
  border-bottom: 2px solid var(--phiber-cpan-primary);
  transform: translateX(-50%) rotate(45deg);
  box-sizing: border-box;
}

.phiber-cpan-widget-teaser-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
  border: 2px solid var(--phiber-cpan-primary);
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
  cursor: pointer;
}

.phiber-cpan-widget-teaser-copy {
  min-width: 0;
}

.phiber-cpan-widget-teaser-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #0f172a;
}

.phiber-cpan-widget-teaser-text {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: #475569;
}

.phiber-cpan-widget-teaser-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

#phiber-cpan-widget-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 999998;
}

#phiber-cpan-widget-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

#phiber-cpan-widget-modal {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 96px;
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.985);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 999999;
  max-height: 80vh;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
}

#phiber-cpan-widget-modal.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#phiber-cpan-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #eceff3;
  background: #ffffff;
}

#phiber-cpan-widget-header-left {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

#phiber-cpan-widget-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex: 0 0 38px;
  border-radius: 10px;
}

#phiber-cpan-widget-client-name {
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
  line-height: 1.2;
}

#phiber-cpan-widget-client-subtitle {
  font-size: 12px;
  color: #64748b;
  line-height: 1.2;
  margin-top: 2px;
}

#phiber-cpan-widget-close {
  border: none;
  background: #f8fafc;
  color: #0f172a;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 34px;
}

#phiber-cpan-widget-content {
  height: min(68vh, var(--phiber-cpan-modal-height));
  background: #ffffff;
  position: relative;
}

#phiber-cpan-widget-content iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #ffffff;
}

.phiber-cpan-widget-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: #0f172a;
  background: #fff;
}

.phiber-cpan-widget-state-title {
  font-weight: 700;
  font-size: 16px;
}

.phiber-cpan-widget-state-text {
  font-size: 14px;
  line-height: 1.45;
  color: #475569;
  max-width: 34ch;
}

.phiber-cpan-widget-state-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(37,96,145,0.08);
  color: var(--phiber-cpan-primary);
  text-decoration: none;
  font-weight: 600;
}

.phiber-cpan-widget-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(37,96,145,0.18);
  border-top-color: var(--phiber-cpan-primary);
  border-radius: 50%;
  animation: phiber-cpan-spin .8s linear infinite;
}

@keyframes phiber-cpan-spin {
  to { transform: rotate(360deg); }
}

#phiber-cpan-widget-footer {
  padding: 9px 12px;
  text-align: center;
  border-top: 1px solid #eceff3;
  background: #ffffff;
}

#phiber-cpan-widget-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
}

#phiber-cpan-widget-brand-mark {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 0px;
  background: rgba(37, 96, 145, 0.00);
  overflow: hidden;
  flex: 0 0 18px;
}

#phiber-cpan-widget-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#phiber-cpan-widget-brand-text {
  line-height: 1;
}

body.phiber-cpan-widget-lock {
  overflow: hidden;
}

@media (min-width: 981px) {
  #phiber-cpan-widget-modal {
    left: auto;
    right: 24px;
    width: min(var(--phiber-cpan-modal-width), calc(100vw - 48px));
    bottom: 100px;
  }

  #phiber-cpan-widget-modal[data-position="left"] {
    right: auto;
    left: 24px;
  }
}

@media (max-width: 580px) {
  #phiber-cpan-widget-bar {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0;
    box-sizing: border-box;
    transform: none;
    display: flex;
    flex-wrap: nowrap;
    justify-content: stretch;
    align-items: stretch;
    gap: 0;
    padding: 2px 6px calc(2px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    overflow: hidden;
  }

  #phiber-cpan-widget-bar button,
  #phiber-cpan-widget-bar button.phiber-cpan-widget-action {
    flex: 1 1 0 !important;
    width: 0;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0;
  }

  #phiber-cpan-widget-bar button {
    justify-content: center;
    padding: 0;
  }

  #phiber-cpan-widget-bar button.phiber-cpan-widget-action {
    min-height: 54px;
    padding: 8px 6px;
    gap: 3px;
    border-radius: 12px;
  }

  #phiber-cpan-widget-bar button.phiber-cpan-widget-action:not(:last-child)::after {
    right: 0;
    top: 10px;
    bottom: 10px;
  }

  .phiber-cpan-widget-action-label {
    font-size: 13px;
    line-height: 1;
  }

  #phiber-cpan-widget-teaser {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
  }

  .phiber-cpan-widget-teaser-inner {
    padding: 12px 14px;
    border-radius: 16px;
  }

  .phiber-cpan-widget-teaser-title {
    font-size: 13px;
  }

  .phiber-cpan-widget-teaser-text {
    font-size: 12px;
  }

  #phiber-cpan-widget-modal {
    left: 12px;
    right: 12px;
    top: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
    display: flex;
    flex-direction: column;
  }

  #phiber-cpan-widget-header,
  #phiber-cpan-widget-footer {
    flex: 0 0 auto;
  }

  #phiber-cpan-widget-content {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (prefers-reduced-motion: reduce) {
  #phiber-cpan-widget-bar,
  #phiber-cpan-widget-overlay,
  #phiber-cpan-widget-modal,
  #phiber-cpan-widget-teaser,
  #phiber-cpan-widget-bar button.phiber-cpan-widget-action,
  .phiber-cpan-widget-spinner {
    transition: none !important;
    animation: none !important;
  }
}

/* Desktop conversational panel. All selectors stay inside the CPAN namespace. */
#phiber-cpan-side-panel { display: none; }
@media (min-width: 981px) and (hover: hover) and (pointer: fine) {
  #phiber-cpan-side-panel {
    position: fixed; top: 0; right: 0; width: var(--phiber-cpan-side-width);
    height: 100vh; height: 100dvh; display: flex; flex-direction: column;
    box-sizing: border-box; color: #203436; background: #fff;
    border: 0; z-index: 1000000;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    transform: translateX(100%); visibility: hidden; pointer-events: none;
    transition: transform .24s ease; box-shadow: -5px 0 12px -4px rgba(15,23,42,.05);
  }
  #phiber-cpan-side-panel.is-open { transform: none; visibility: visible; pointer-events: auto; }
  #phiber-cpan-side-panel[data-animate-open="false"] { transition: none; }
  #phiber-cpan-side-panel *, #phiber-cpan-side-panel *::before, #phiber-cpan-side-panel *::after { box-sizing: border-box; }
  #phiber-cpan-side-panel [hidden] { display: none !important; }
  #phiber-cpan-side-panel .phiber-cpan-toolbar {
    display: flex; align-items: stretch; gap: 0; flex: 0 0 auto;
    padding: 0; background: var(--phiber-cpan-toolbar-background, #f1f3f5);
  }
  #phiber-cpan-side-panel .phiber-cpan-side-nav { flex: 1; min-width: 0; }
  #phiber-cpan-side-panel #phiber-cpan-widget-bar {
    position: static; width: 100%; max-width: none; display: flex; gap: 0;
    padding: 0; border: 0; border-radius: 0;
    background: var(--phiber-cpan-toolbar-background, #f1f3f5) !important; box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none; transform: none; transition: none;
  }
  #phiber-cpan-side-panel #phiber-cpan-widget-bar button.phiber-cpan-widget-action {
    flex: 1 1 0; width: 0; min-width: 0; min-height: 62px; padding: 10px 6px;
    gap: 6px; border-radius: 0; color: var(--phiber-cpan-toolbar-text, #45515e); white-space: normal;
    background: transparent; opacity: 1; transform: none;
    transition: background .16s ease, color .16s ease, box-shadow .16s ease;
  }
  #phiber-cpan-side-panel #phiber-cpan-widget-bar button.phiber-cpan-widget-action::after { display: none; }
  #phiber-cpan-side-panel #phiber-cpan-widget-bar button.phiber-cpan-widget-action:hover { background: var(--phiber-cpan-toolbar-hoverBackground, #e4e8ed); color: var(--phiber-cpan-toolbar-text, #45515e); }
  #phiber-cpan-side-panel #phiber-cpan-widget-bar button.phiber-cpan-widget-action.is-active {
    background: var(--phiber-cpan-toolbar-activeBackground, #374151) !important; color: var(--phiber-cpan-toolbar-activeText, #fff); box-shadow: none;
  }
  #phiber-cpan-side-panel .phiber-cpan-widget-action-label { font: 600 13px/1.25 "Segoe UI", system-ui, sans-serif; letter-spacing: .005em; text-transform: none; overflow-wrap: anywhere; }
  #phiber-cpan-side-panel .phiber-cpan-widget-action-icon { width: 18px; height: 18px; flex-basis: 18px; }
  #phiber-cpan-side-panel .phiber-cpan-panel-close {
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 36px; width: 36px; min-width: 36px; align-self: stretch;
    padding: 0; margin: 0; border: 0; border-radius: 0;
    background: transparent; color: var(--phiber-cpan-toolbar-text, #45515e); cursor: pointer;
  }
  #phiber-cpan-side-panel .phiber-cpan-panel-close svg { width: 18px; height: 18px; display: block; }
  #phiber-cpan-side-panel .phiber-cpan-panel-close:hover { background: var(--phiber-cpan-toolbar-hoverBackground, #e4e8ed); }
  #phiber-cpan-side-panel button:focus-visible, #phiber-cpan-side-panel a:focus-visible { outline: 2px solid #397c6c; outline-offset: -3px; }
  #phiber-cpan-side-panel .phiber-cpan-chat-intro {
    flex: 0 1 auto; min-height: 0; max-height: 34vh; overflow: auto;
    padding: 16px 18px 12px; background: #fff;
  }
  #phiber-cpan-side-panel .phiber-cpan-chat-image {
    display: block; width: 82%; max-width: 266px; height: auto; aspect-ratio: 16 / 9;
    object-fit: cover; border-radius: 22px; margin: 0 auto 12px;
    border: 0; box-shadow: none;
  }
  #phiber-cpan-side-panel .phiber-cpan-chat-disclaimer {
    margin: 0; padding: 0 6px; font: 11px/1.55 system-ui,sans-serif;
    color: #73817f; text-align: center; white-space: pre-line; overflow-wrap: anywhere;
  }
  #phiber-cpan-side-panel .phiber-cpan-chat-disclaimer a { color: #315f54; text-decoration: underline; text-underline-offset: 3px; }
  #phiber-cpan-side-panel .phiber-cpan-side-frames {
    flex: 1 1 0; min-height: 0; position: relative; overflow: hidden;
    margin: 0; border: 0; border-radius: 0; background: #fff;
    box-shadow: none;
  }
  #phiber-cpan-side-panel .phiber-cpan-side-frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; background: #fff; }
  #phiber-cpan-side-panel .phiber-cpan-panel-loading {
    position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 9px; padding: 24px; text-align: center;
    background: #fff;
  }
  #phiber-cpan-side-panel .phiber-cpan-panel-loading strong { color: #2e5148; font-size: 14px; font-weight: 600; }
  #phiber-cpan-side-panel .phiber-cpan-panel-loading > span { color: #7b8d85; font-size: 12px; }
  #phiber-cpan-side-panel .phiber-cpan-loading-mark {
    width: 34px; height: 34px; border: 1px solid #c7dcd1; border-radius: 12px;
    margin-bottom: 8px; background: linear-gradient(135deg,#d9eddf,#f7fbf7); box-shadow: 0 3px 10px #193b3910;
  }
  #phiber-cpan-side-panel .phiber-cpan-skeleton { width: 80%; margin-top: 22px; }
  #phiber-cpan-side-panel .phiber-cpan-skeleton i { display: block; height: 8px; margin: 9px 0; border-radius: 9px; background: #edf3ef; }
  #phiber-cpan-side-panel .phiber-cpan-skeleton i:nth-child(2) { width: 85%; }
  #phiber-cpan-side-panel .phiber-cpan-skeleton i:nth-child(3) { width: 62%; }
  #phiber-cpan-side-panel .phiber-cpan-panel-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 3px 10px; background: #fff; }
  #phiber-cpan-side-panel .phiber-cpan-credit {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    color: #687b74; font: 500 11px/1.3 system-ui,sans-serif; text-decoration: none;
  }
  #phiber-cpan-side-panel .phiber-cpan-credit:hover { color: #245f49; }
  #phiber-cpan-side-panel .phiber-cpan-credit img { width: 18px; height: 18px; object-fit: contain; border-radius: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  #phiber-cpan-side-panel, #phiber-cpan-side-panel button { transition: none !important; }
}
