:root {
  --panical-lm-primary: #000;
  --panical-lm-text: #fff;
  --panical-lm-radius: 18px;
}
.panical-lm-root,
.panical-lm-root * { box-sizing: border-box; }
.panical-lm-root { position: fixed; inset: 0; z-index: 999999; pointer-events: none; font-family: inherit; }
.panical-lm-root.is-open { pointer-events: auto; }
.panical-lm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.16); opacity: 0; transition: opacity .22s ease; }
.panical-lm-root.is-open .panical-lm-backdrop { opacity: 1; }
.panical-lm-window { position: absolute; left: 28px; bottom: 28px; width: min(380px, calc(100vw - 32px)); height: min(620px, calc(100vh - 48px)); background: #fff; border: 1px solid rgba(0,0,0,.12); border-radius: var(--panical-lm-radius); box-shadow: 0 20px 70px rgba(0,0,0,.28); overflow: hidden; transform: translateY(18px) scale(.98); opacity: 0; transition: transform .22s ease, opacity .22s ease; display: flex; flex-direction: column; }
.panical-lm-root.is-open .panical-lm-window { transform: translateY(0) scale(1); opacity: 1; }
.panical-lm-header { height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: var(--panical-lm-primary); color: var(--panical-lm-text); }
.panical-lm-header strong { display: block; font-size: 15px; line-height: 1.2; letter-spacing: .02em; }
.panical-lm-header span { display: block; font-size: 12px; opacity: .72; margin-top: 4px; }
.panical-lm-close,
.panical-lm-info-close { appearance: none; border: 0; background: transparent; color: currentColor; cursor: pointer; font-size: 28px; line-height: 1; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.panical-lm-close:hover { background: rgba(255,255,255,.1); }
.panical-lm-messages { flex: 1; overflow: auto; padding: 18px 14px 16px; background: #f6f6f6; scroll-behavior: smooth; }
.panical-lm-msg { display: flex; margin: 10px 0; }
.panical-lm-msg-inner { max-width: 82%; }
.panical-lm-bubble { padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.panical-lm-time { font-size: 11px; color: #888; margin: 5px 4px 0; }
.panical-lm-msg.customer { justify-content: flex-end; }
.panical-lm-msg.customer .panical-lm-bubble { background: #111; color: #fff; border-bottom-right-radius: 4px; }
.panical-lm-msg.staff { justify-content: flex-start; }
.panical-lm-msg.staff .panical-lm-bubble { background: #fff; color: #111; border: 1px solid rgba(0,0,0,.08); border-bottom-left-radius: 4px; }
.panical-lm-msg.system { justify-content: center; }
.panical-lm-msg.system .panical-lm-msg-inner { max-width: 92%; }
.panical-lm-msg.system .panical-lm-bubble { background: transparent; border: 0; color: #666; font-size: 12px; box-shadow: none; text-align: center; padding: 4px 8px; }
.panical-lm-info-link { color: #111; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; background: transparent; border: 0; padding: 0; cursor: pointer; font: inherit; }
.panical-lm-image { display: block; max-width: 210px; border-radius: 12px; height: auto; }
.panical-lm-form { display: grid; grid-template-columns: 34px 34px 1fr auto; gap: 8px; align-items: end; padding: 12px; background: #fff; border-top: 1px solid rgba(0,0,0,.08); }
.panical-lm-tool,
.panical-lm-send { appearance: none; border: 1px solid rgba(0,0,0,.12); background: #fff; color: #111; border-radius: 999px; min-height: 38px; cursor: pointer; font-weight: 600; }
.panical-lm-tool { width: 34px; min-height: 34px; font-size: 18px; }
.panical-lm-send { padding: 0 15px; background: #000; color: #fff; border-color: #000; font-size: 13px; }
.panical-lm-form textarea { width: 100%; min-height: 38px; max-height: 110px; border: 1px solid rgba(0,0,0,.14); border-radius: 18px; padding: 9px 12px; resize: none; line-height: 1.35; font-size: 14px; outline: none; }
.panical-lm-emoji { position: absolute; left: 14px; right: 14px; bottom: 70px; padding: 10px; background: #fff; border: 1px solid rgba(0,0,0,.12); border-radius: 14px; box-shadow: 0 10px 34px rgba(0,0,0,.18); display: flex; flex-wrap: wrap; gap: 6px; }
.panical-lm-emoji[hidden] { display: none; }
.panical-lm-emoji button { width: 34px; height: 34px; border: 0; background: #f3f3f3; border-radius: 10px; cursor: pointer; font-size: 18px; }
.panical-lm-info-modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0,0,0,.25); }
.panical-lm-info-modal[hidden] { display: none; }
.panical-lm-info-panel { position: relative; width: min(520px, 100%); max-height: min(720px, calc(100vh - 42px)); overflow: auto; background: #fff; border-radius: 18px; padding: 22px; box-shadow: 0 20px 70px rgba(0,0,0,.28); }
.panical-lm-info-close { position: absolute; top: 10px; right: 10px; color: #111; }
.panical-lm-info-panel h3 { margin: 0 0 8px; font-size: 20px; }
.panical-lm-info-panel p { margin: 0 0 16px; color: #666; font-size: 13px; }
.panical-lm-info-panel label { display: block; font-size: 12px; font-weight: 700; color: #222; margin: 10px 0; }
.panical-lm-info-panel input,
.panical-lm-info-panel textarea { width: 100%; margin-top: 5px; border: 1px solid rgba(0,0,0,.16); border-radius: 10px; min-height: 38px; padding: 8px 10px; font-size: 14px; }
.panical-lm-info-panel button[type="submit"] { width: 100%; margin-top: 10px; border: 0; background: #000; color: #fff; min-height: 42px; border-radius: 999px; cursor: pointer; font-weight: 700; }

/* v1.0.1: keep customer bubbles/time tight to the right edge. */
.panical-lm-msg.customer .panical-lm-msg-inner {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.panical-lm-msg.customer .panical-lm-time {
  text-align: right;
}

@media (max-width: 600px) {
  .panical-lm-window { left: 12px; right: 12px; bottom: 14px; width: auto; height: min(620px, calc(100vh - 32px)); border-radius: 16px; }
  .panical-lm-form { grid-template-columns: 32px 32px 1fr auto; padding: 10px; gap: 6px; }
  .panical-lm-send { padding: 0 12px; }
}

/* v1.0.3: right-side chat window, Panical header status, and mobile-safe layout. */
.panical-lm-window {
  left: auto !important;
  right: 96px !important;
  bottom: 28px;
}
.panical-lm-status {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  margin-top: 5px !important;
  font-size: 12px !important;
  opacity: .9 !important;
}
.panical-lm-status i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
  background: #9ca3af;
  box-shadow: 0 0 0 2px rgba(255,255,255,.12);
}
.panical-lm-status em {
  font-style: normal;
}
.panical-lm-status.is-online i,
.panical-lm-root.is-staff-online .panical-lm-status i {
  background: #22c55e;
}
.panical-lm-root.is-staff-offline .panical-lm-status i {
  background: #9ca3af;
}
.panical-lm-msg.system .panical-lm-bubble {
  max-width: 94%;
  line-height: 1.5;
}
@media (max-width: 900px) {
  .panical-lm-window {
    right: 84px !important;
    bottom: 22px;
  }
}
@media (max-width: 600px) {
  .panical-lm-window {
    left: 12px !important;
    right: 12px !important;
    bottom: 14px !important;
    width: auto;
    height: min(620px, calc(100vh - 32px));
    border-radius: 16px;
  }
}

/* v1.0.4: centered header, tighter bubbles, emoji insertion, and message status. */
.panical-lm-header {
  position: relative;
  justify-content: center !important;
  text-align: center;
}
.panical-lm-header > div {
  min-width: 0;
  text-align: center;
}
.panical-lm-close {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}
.panical-lm-status {
  justify-content: center;
}
.panical-lm-msg-inner {
  width: auto;
  max-width: 82%;
}
.panical-lm-bubble {
  display: inline-block;
  max-width: 100%;
}
.panical-lm-msg.customer .panical-lm-msg-inner {
  align-items: flex-end;
}
.panical-lm-msg.customer .panical-lm-bubble {
  width: auto;
}
.panical-lm-time {
  display: flex;
  align-items: center;
  gap: 6px;
}
.panical-lm-msg.customer .panical-lm-time {
  justify-content: flex-end;
}
.panical-lm-checks {
  font-size: 12px;
  line-height: 1;
  letter-spacing: -2px;
  color: #9ca3af;
  margin-left: 3px;
}
.panical-lm-checks.is-read {
  color: #22c55e;
}
.panical-lm-checks.is-delivered {
  color: #9ca3af;
}
.panical-lm-send {
  min-width: 54px;
}


/* v1.0.6: remove emoji control and keep offline contact form English-only. */
.panical-lm-form {
  grid-template-columns: 34px 1fr auto !important;
}
.panical-lm-emoji,
[data-plm-emoji-toggle] {
  display: none !important;
}
.panical-lm-info-panel select {
  width: 100%;
  margin-top: 5px;
  border: 1px solid rgba(0,0,0,.16);
  border-radius: 10px;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
}
@media (max-width: 600px) {
  .panical-lm-form {
    grid-template-columns: 32px 1fr auto !important;
  }
}

/* v1.0.10 - Customer-side unread reminders for Floating Contact trigger */
.panical-lm-trigger-has-unread,
.pfc-main.panical-lm-trigger-has-unread,
.pfc-item.panical-lm-trigger-has-unread {
    position: relative !important;
}

.panical-lm-unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #d60000;
    color: #fff;
    border: 2px solid #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    z-index: 5;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .18);
    pointer-events: none;
}

.pfc-item .panical-lm-unread-badge {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
}

.pfc-main .panical-lm-unread-badge {
    top: -5px;
    right: -5px;
}

/* v1.0.11 - visible in-window notice when staff replies while chat is open */
.panical-lm-msg.is-fresh-staff .panical-lm-bubble {
  animation: panical-lm-fresh-message 1.5s ease-out 1;
}
@keyframes panical-lm-fresh-message {
  0% { box-shadow: 0 0 0 0 rgba(0, 0, 0, .22); transform: translateY(2px); }
  35% { box-shadow: 0 0 0 4px rgba(0, 0, 0, .10); transform: translateY(0); }
  100% { box-shadow: none; transform: translateY(0); }
}

/* v1.0.32: welcome quick question guide */
.panical-lm-quick-msg .panical-lm-msg-inner { max-width: 92%; }
.panical-lm-quick-bubble { width: 100%; padding: 12px; }
.panical-lm-quick-title { margin-bottom: 9px; color: #555; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.panical-lm-quick-list { display: grid; gap: 8px; }
.panical-lm-quick-btn { appearance: none; width: 100%; min-height: 38px; padding: 9px 12px; border: 1px solid rgba(0,0,0,.12); border-radius: 12px; background: #f8f8f8; color: #111; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; line-height: 1.35; text-align: left; transition: background-color .18s ease, border-color .18s ease, transform .18s ease; }
.panical-lm-quick-btn:hover, .panical-lm-quick-btn:focus { background: #111; border-color: #111; color: #fff; transform: translateY(-1px); }
.panical-lm-local-question .panical-lm-time, .panical-lm-local-answer .panical-lm-time { display: none; }


/* v1.0.36 - Appearance settings from backend color pickers */
.panical-lm-window {
  background: var(--panical-lm-window-bg, #fff) !important;
  border-color: var(--panical-lm-border, rgba(0,0,0,.12)) !important;
}
.panical-lm-header {
  background: var(--panical-lm-header-bg, var(--panical-lm-primary, #000)) !important;
  color: var(--panical-lm-header-text, var(--panical-lm-text, #fff)) !important;
}
.panical-lm-messages {
  background: var(--panical-lm-chat-bg, #f6f6f6) !important;
}
.panical-lm-msg.staff .panical-lm-bubble {
  background: var(--panical-lm-staff-bg, #fff) !important;
  color: var(--panical-lm-staff-text, #111) !important;
  border-color: var(--panical-lm-border, rgba(0,0,0,.08)) !important;
}
.panical-lm-msg.customer .panical-lm-bubble {
  background: var(--panical-lm-customer-bg, #111) !important;
  color: var(--panical-lm-customer-text, #fff) !important;
}
.panical-lm-send,
.panical-lm-info-panel button[type="submit"] {
  background: var(--panical-lm-button-bg, #000) !important;
  color: var(--panical-lm-button-text, #fff) !important;
  border-color: var(--panical-lm-button-bg, #000) !important;
}
.panical-lm-form,
.panical-lm-form textarea,
.panical-lm-tool {
  border-color: var(--panical-lm-border, rgba(0,0,0,.12)) !important;
}
