:host {
  all: initial;
  --wcpec-accent: #ff4b12;
  --wcpec-ink: #172434;
  --wcpec-muted: #687686;
  --wcpec-border: #dce5eb;
  --wcpec-soft: #f5f8fa;
  --wcpec-danger: #b42318;
  --wcpec-success: #1f8f4d;
  display: block;
  min-width: 0;
  direction: rtl;
  color: var(--wcpec-ink);
  font-family: "Tajawal", Tahoma, Arial, sans-serif;
  line-height: 1.5;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}
:host([data-mode="floating"]) {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  width: auto;
  height: auto;
  pointer-events: none;
}
:host([data-mode="inline"]),
:host([data-mode="embedded"]),
:host([data-mode="account"]),
:host([data-mode="new-request"]) {
  width: 100%;
  max-width: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, textarea, select, label, a { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(255,75,18,.2);
  outline-offset: 2px;
}
.app { min-width: 0; direction: rtl; color: var(--wcpec-ink); }
:host([data-mode="floating"]) .app { width: 100%; height: 100%; pointer-events: none; }
.launcher {
  all: unset;
  position: fixed;
  right: max(var(--wcpec-side, 24px), env(safe-area-inset-right));
  left: auto;
  bottom: calc(var(--wcpec-bottom, 24px) + env(safe-area-inset-bottom));
  width: var(--wcpec-size, 58px);
  height: var(--wcpec-size, 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--wcpec-accent), #e83c08);
  color: #fff;
  box-shadow: 0 13px 34px rgba(18,38,58,.3);
  cursor: pointer;
  pointer-events: auto;
  transition: transform .18s ease, box-shadow .18s ease;
}
:host([data-position="left"]) .launcher {
  right: auto;
  left: max(var(--wcpec-side, 24px), env(safe-area-inset-left));
}
.launcher:hover { transform: translateY(-2px); box-shadow: 0 17px 40px rgba(18,38,58,.35); }
.launcher svg { display: block; width: 29px; height: 29px; fill: currentColor; }
.badge {
  position: absolute;
  top: -5px;
  left: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #c81e1e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.panel {
  width: min(430px, calc(100vw - 24px));
  height: min(720px, calc(100dvh - 92px));
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--wcpec-border);
  border-radius: 22px;
  background: #fff;
  color: var(--wcpec-ink);
  max-width: 100%;
  min-height: 0;
  box-shadow: 0 26px 76px rgba(18,38,58,.24);
  isolation: isolate;
}
:host([data-mode="floating"]) .panel {
  position: fixed;
  right: max(var(--wcpec-side, 24px), env(safe-area-inset-right));
  left: auto;
  bottom: calc(var(--wcpec-bottom, 24px) + var(--wcpec-size, 58px) + 14px + env(safe-area-inset-bottom));
  pointer-events: auto;
}
:host([data-mode="floating"][data-position="left"]) .panel {
  right: auto;
  left: max(var(--wcpec-side, 24px), env(safe-area-inset-left));
}
:host([data-mode="inline"]) .panel,
:host([data-mode="embedded"]) .panel,
:host([data-mode="account"]) .panel,
:host([data-mode="new-request"]) .panel {
  position: relative;
  width: 100%;
  height: min(760px, max(620px, 78dvh));
  max-width: 100%;
  box-shadow: 0 14px 42px rgba(18,38,58,.1);
}
.panel-header {
  min-height: 84px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e9eef2;
  background: #fff;
}
.brand-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(145deg,var(--wcpec-accent),#e83c08);
  color: #fff;
  box-shadow: 0 9px 22px rgba(255,75,18,.22);
}
.brand-icon svg { width: 27px; height: 27px; display: block; fill: currentColor; }
.heading { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.heading strong { color: #162333; font-size: 15px; font-weight: 900; line-height: 1.55; white-space: normal; }
.service-status { display: flex; align-items: center; gap: 7px; color: #788590; font-size: 10px; }
.service-status i { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #a1abb3; box-shadow: 0 0 0 3px rgba(161,171,179,.15); }
.service-status.is-open i { background: #25a85c; box-shadow: 0 0 0 3px rgba(37,168,92,.15); }
.service-status b { font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.header-actions button, .icon-button {
  all: unset;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #52616e;
  font-size: 16px;
  cursor: pointer;
}
.header-actions button:hover, .icon-button:hover { background: #f0f3f5; }
.body { min-height: 0; flex: 1; overflow: hidden; background: #fff; position: relative; }
.view { width: 100%; height: 100%; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.welcome-view { padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.welcome-icon { width: 78px; height: 78px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; border: 1px solid #ffe0d5; border-radius: 25px; background: linear-gradient(145deg,#fff0ea,#fff); font-size: 35px; box-shadow: 0 9px 26px rgba(255,75,18,.08); }
.welcome-view h2, .view-heading h2 { margin: 0; color: var(--wcpec-ink); font-weight: 900; }
.welcome-view h2 { font-size: 21px; }
.welcome-view p { margin: 10px 0 22px; color: var(--wcpec-muted); font-size: 13px; line-height: 1.9; }
.primary, .secondary {
  all: unset;
  width: 100%;
  min-height: 45px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.primary { background: linear-gradient(135deg,var(--wcpec-accent),#e9430d); color: #fff; box-shadow: 0 7px 18px rgba(255,75,18,.2); }
.primary:hover { filter: brightness(.97); }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.secondary { margin-top: 9px; border: 1px solid var(--wcpec-border); background: #fff; color: var(--wcpec-ink); }
.secondary:hover { background: #f7f9fa; }
.preform-view, .history-view { padding: 17px 18px 20px; }
.view-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.view-heading h2 { font-size: 17px; }
.view-heading p { margin: 3px 0 0; color: var(--wcpec-muted); font-size: 11px; }
.preform { width: 100%; min-width: 0; display: block; }
.preform label { width: 100%; min-width: 0; display: block; margin-bottom: 12px; }
.preform label > span { display: block; margin-bottom: 6px; color: #31404e; font-size: 12px; font-weight: 800; }
.preform input, .preform select, .preform textarea, .rating textarea {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
  padding: 10px 11px;
  border: 1px solid #d8e0e6;
  border-radius: 10px;
  background: #fff;
  color: #172434;
  caret-color: #172434;
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
  direction: rtl;
}
.preform select { min-height: 43px; appearance: auto; }
.preform textarea, .rating textarea { min-height: 96px; white-space: pre-wrap; resize: vertical; }
.preform input::placeholder, .preform textarea::placeholder, .rating textarea::placeholder, .composer textarea::placeholder { color: #8b96a1; opacity: 1; }
.preform input:focus, .preform select:focus, .preform textarea:focus, .rating textarea:focus { border-color: var(--wcpec-accent); box-shadow: 0 0 0 3px rgba(255,75,18,.11); }
.guest-fields { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 10px; }
.saved-profile {
  width: 100%;
  margin-bottom: 13px;
  padding: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #cce5d6;
  border-radius: 12px;
  background: #f3fbf6;
}
.saved-profile__icon { width: 34px; height: 34px; flex: 0 0 34px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #1f8f4d; color: #fff; font-size: 15px; font-weight: 900; }
.saved-profile__content { min-width: 0; flex: 1; }
.saved-profile__content strong, .saved-profile__content span, .saved-profile__content small { display: block; }
.saved-profile__content strong { color: #1d5735; font-size: 11px; font-weight: 900; }
.saved-profile__content span { margin-top: 2px; color: #243a2f; font-size: 12px; font-weight: 800; }
.saved-profile__content small { margin-top: 2px; overflow: hidden; color: #5c7567; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.edit-profile { all: unset; min-height: 32px; padding: 0 10px; display: flex; align-items: center; justify-content: center; border: 1px solid #b9d8c5; border-radius: 9px; background: #fff; color: #1d6b3e; font-size: 10px; font-weight: 900; cursor: pointer; }
.file-field small { display: block; margin-top: 6px; color: var(--wcpec-muted); font-size: 9px; line-height: 1.6; }
.file-picker { width: 100%; min-width: 0; min-height: 43px; padding: 5px; display: flex; align-items: center; gap: 8px; overflow: hidden; border: 1px solid #d8e0e6; border-radius: 10px; background: #fff; }
.file-select-button { all: unset; min-height: 31px; padding: 0 10px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: #eef2f4; color: #344250; font-size: 10px; font-weight: 800; cursor: pointer; }
.file-selected-name { min-width: 0; margin: 0; flex: 1; overflow: hidden; color: #657481; font-size: 10px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.privacy-check { display: flex; align-items: flex-start; gap: 8px; }
.privacy-check input { all: revert; width: auto; margin-top: 3px; accent-color: var(--wcpec-accent); }
.privacy-check span { margin: 0; color: #556371; font-size: 11px; font-weight: 500; line-height: 1.7; }
.honeypot { position: absolute; right: -99999px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.form-error, .network { padding: 9px 11px; border: 1px solid #f2c5c5; border-radius: 9px; background: #fff1f1; color: var(--wcpec-danger); font-size: 12px; line-height: 1.7; }
.form-error { margin-bottom: 10px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { all: unset; display: block; padding: 12px; border: 1px solid var(--wcpec-border); border-radius: 12px; background: #fff; color: var(--wcpec-ink); cursor: pointer; }
.history-item:hover { border-color: var(--wcpec-accent); background: #fffaf7; }
.history-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.history-item strong { font-size: 13px; font-weight: 800; }
.history-item time { color: var(--wcpec-muted); font-size: 10px; white-space: nowrap; }
.history-item p { margin: 6px 0 0; overflow: hidden; color: var(--wcpec-muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.history-status { display: inline-block; margin-top: 8px; padding: 3px 8px; border-radius: 999px; background: #f0f3f5; color: #4c5966; font-size: 10px; }
.loading, .empty-state { padding: 22px 14px; border: 1px dashed #d9e0e6; border-radius: 13px; background: #fbfcfd; color: var(--wcpec-muted); font-size: 12px; text-align: center; }
.conversation-view { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.conversation-bar { min-height: 74px; padding: 11px 12px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid #e8edf1; background: #fff; }
.conversation-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.current-subject { color: var(--wcpec-ink); font-size: 13px; font-weight: 900; line-height: 1.5; white-space: normal; }
.current-reference, .current-agent { color: var(--wcpec-muted); font-size: 9px; line-height: 1.45; overflow-wrap: anywhere; }
.close-conversation { all: unset; min-width: 70px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: #f0f3f5; color: #344250; font-size: 11px; font-weight: 800; cursor: pointer; }
.messages { min-height: 0; flex: 1; padding: 18px 14px 14px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; display: flex; flex-direction: column; gap: 12px; background: #f6f8fa; scrollbar-width: thin; }
.message { max-width: 86%; display: flex; flex-direction: column; align-self: flex-start; }
.message.mine { align-self: flex-end; }
.bubble { padding: 10px 12px; border: 1px solid #dfe6eb; border-radius: 16px 16px 16px 5px; background: #fff; color: #1b2936; box-shadow: 0 4px 14px rgba(30,45,60,.055); font-size: 12.5px; line-height: 1.75; overflow-wrap: anywhere; }
.message.mine .bubble { border-color: var(--wcpec-accent); border-radius: 16px 16px 5px 16px; background: linear-gradient(135deg,var(--wcpec-accent),#e9430d); color: #fff; box-shadow: 0 5px 16px rgba(255,75,18,.14); }
.message-meta { margin-top: 3px; padding: 0 3px; display: flex; align-items: center; gap: 6px; color: #7e8a95; font-size: 9px; }
.message.mine .message-meta { justify-content: flex-end; }
.message-image { all: unset; width: min(280px, 100%); max-width: 100%; margin-top: 8px; display: block; overflow: hidden; border: 1px solid rgba(25,48,68,.11); border-radius: 13px; background: #fff; color: #233544; cursor: zoom-in; box-shadow: 0 4px 14px rgba(30,45,60,.06); }
.message-image img { display: block; width: 100%; max-height: 250px; object-fit: contain; background: #f3f6f8; }
.message-image span { min-width: 0; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; text-align: right; }
.message-image span b { color: #263746; font-size: 10px; font-weight: 900; }
.message-image span small { overflow: hidden; color: #74818c; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.attachment-card { min-width: 0; margin-top: 8px; padding: 10px; display: flex; align-items: center; gap: 9px; border: 1px solid #e0e6ea; border-radius: 12px; background: #f7f9fa; color: #263441; text-decoration: none; }
.message.mine .attachment-card { background: rgba(255,255,255,.94); color: #263441; }
.attachment-card i { font-style: normal; font-size: 20px; }
.attachment-card strong { display: block; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.attachment-card small { color: #74818c; font-size: 9px; }
.typing { padding: 6px 13px; background: #f7f9fa; color: var(--wcpec-muted); font-size: 10px; }
.typing span { width: 5px; height: 5px; display: inline-block; margin: 0 1px; border-radius: 50%; background: #99a4ad; animation: wcpec-bounce 1.3s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wcpec-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-4px)} }
.composer { padding: 10px 11px max(11px, env(safe-area-inset-bottom)); border-top: 1px solid #e1e7eb; background: #fff; box-shadow: 0 -6px 18px rgba(25,45,62,.035); }
.selected-file { margin-bottom: 7px; padding: 7px 9px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 9px; background: #f1f4f6; color: #40505e; font-size: 10px; }
.selected-file button { all: unset; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: #384957; cursor: pointer; }
.composer-row { min-width: 0; display: flex; align-items: flex-end; gap: 7px; }
.attach { all: unset; width: 38px; height: 38px; flex: 0 0 38px; display: flex; align-items: center; justify-content: center; border-radius: 10px; color: #536370; cursor: pointer; }
.attach:hover { background: #f0f3f5; }
.attach svg { width: 22px; height: 22px; display: block; fill: currentColor; }
.composer textarea { all: unset; box-sizing: border-box; min-width: 0; min-height: 44px; max-height: 125px; flex: 1; padding: 10px 12px; overflow-y: auto; overflow-x: hidden; border: 1px solid #d6dfe5; border-radius: 13px; background: #fff; color: #172434; caret-color: #172434; font-size: 13px; line-height: 1.6; text-align: right; white-space: pre-wrap; }
.composer textarea:focus { border-color: var(--wcpec-accent); box-shadow: 0 0 0 3px rgba(255,75,18,.11); }
.send { all: unset; width: 40px; height: 40px; flex: 0 0 40px; display: flex; align-items: center; justify-content: center; border-radius: 11px; background: linear-gradient(135deg,var(--wcpec-accent),#e9430d); color: #fff; cursor: pointer; }
.send:disabled { opacity: .55; cursor: not-allowed; }
.send svg { width: 21px; height: 21px; display: block; fill: currentColor; transform: scaleX(-1); }
.composer > small { display: block; margin-top: 4px; color: #929da6; font-size: 8px; text-align: center; }
.rating { position: absolute; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.rating-backdrop { position: absolute; inset: 0; background: rgba(16,32,46,.48); backdrop-filter: blur(3px); }
.rating-card { position: relative; width: 100%; max-width: 360px; padding: 22px 18px 17px; border: 1px solid #e1e8ed; border-radius: 20px; background: #fff; color: var(--wcpec-ink); box-shadow: 0 24px 64px rgba(16,32,46,.28); text-align: center; }
.rating-close { all: unset; position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: #f2f5f7; color: #53616d; font-size: 18px; cursor: pointer; }
.rating-icon { width: 48px; height: 48px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: #eef9f2; color: #1f8f4d; font-size: 23px; font-weight: 900; }
.rating-card > strong { display: block; color: #162536; font-size: 17px; font-weight: 900; }
.rating-card > p:not(.rating-result) { margin: 7px 0 12px; color: #667683; font-size: 11px; line-height: 1.7; }
.rating-agent { color: #253c4c; font-weight: 900; }
.rating-stars { direction: rtl; display: flex; align-items: center; justify-content: center; gap: 6px; }
.rating-stars button { all: unset; color: #d8dee3; font-size: 34px; line-height: 1; cursor: pointer; transition: transform .12s ease, color .12s ease; }
.rating-stars button:hover { transform: translateY(-2px) scale(1.05); }
.rating-stars button.active { color: #ffad18; text-shadow: 0 2px 8px rgba(255,173,24,.22); }
.rating-label { min-height: 18px; margin-top: 5px; display: block; color: #7b8791; font-size: 10px; font-weight: 800; }
.rating textarea { min-height: 68px; margin-top: 9px; text-align: right; }
.rating-submit { all: unset; width: 100%; min-height: 42px; margin-top: 10px; display: flex; align-items: center; justify-content: center; border-radius: 11px; background: linear-gradient(135deg,var(--wcpec-accent),#e9430d); color: #fff; font-size: 12px; font-weight: 900; cursor: pointer; }
.rating-submit:disabled { opacity: .5; cursor: not-allowed; }
.rating-later { all: unset; margin-top: 9px; color: #75828d; font-size: 10px; font-weight: 800; cursor: pointer; }
.rating-result { margin: 10px 0 0; color: #17603a; font-size: 11px; font-weight: 900; }
.image-viewer { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 14px; }
.image-viewer-backdrop { all: unset; position: absolute; inset: 0; background: rgba(12,25,36,.78); backdrop-filter: blur(4px); cursor: zoom-out; }
.image-viewer-card { position: relative; width: 100%; max-width: 390px; max-height: calc(100% - 20px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.18); border-radius: 18px; background: #fff; box-shadow: 0 24px 72px rgba(0,0,0,.38); }
.image-viewer-head { min-height: 48px; padding: 9px 11px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #e7ecef; }
.image-viewer-name { min-width: 0; flex: 1; overflow: hidden; color: #1d2d3a; font-size: 11px; font-weight: 900; white-space: nowrap; text-overflow: ellipsis; }
.image-viewer-close { all: unset; width: 30px; height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: #f1f4f6; color: #455561; font-size: 18px; cursor: pointer; }
.image-viewer-stage { min-height: 0; flex: 1; padding: 10px; display: flex; align-items: center; justify-content: center; overflow: auto; background: #eef2f4; }
.image-viewer-stage img { display: block; max-width: 100%; max-height: 520px; object-fit: contain; border-radius: 10px; background: #fff; }
.image-viewer-open { min-height: 40px; display: flex; align-items: center; justify-content: center; border-top: 1px solid #e7ecef; color: #087aa4; font-size: 10px; font-weight: 900; text-decoration: none; }
.footer { min-height: 30px; display: flex; align-items: center; justify-content: center; border-top: 1px solid #edf0f2; background: #fff; color: #7c8892; font-size: 9px; }
:host([data-mode="new-request"]) .panel-header,
:host([data-mode="new-request"]) .footer,
:host([data-mode="new-request"]) .welcome-view { display: none; }
:host([data-mode="new-request"]) .panel { height: auto; min-height: 620px; }
@media (max-width: 700px) {
  :host([data-mode="floating"]) .panel,
  :host([data-mode="floating"][data-position="left"]) .panel {
    inset: max(7px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-width: none;
    border-radius: 18px;
  }
  .launcher {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
  :host([data-position="left"]) .launcher { right: auto; left: max(14px, env(safe-area-inset-left)); }
  .panel-header { position: sticky; top: 0; z-index: 5; min-height: 76px; padding: 12px 13px; }
  .brand-icon { width: 43px; height: 43px; flex-basis: 43px; }
  .heading strong { font-size: 13px; }
  .preform-view, .history-view { padding: 15px 14px 18px; }
  .guest-fields { grid-template-columns: minmax(0,1fr); }
  .message { max-width: 94%; }
  .saved-profile__contact { max-width: 190px; }
  .rating { padding: 10px; }
  .rating-card { max-width: none; border-radius: 18px; }
  .image-viewer { padding: 8px; }
  .image-viewer-card { max-height: calc(100% - 8px); border-radius: 15px; }
  .image-viewer-stage img { max-height: calc(100dvh - 150px); }
}
@media (max-width: 380px) {
  .header-actions .sound { display: none; }
  .heading strong { font-size: 12px; }
  .close-conversation { min-width: 60px; }
  .saved-profile { align-items: flex-start; flex-wrap: wrap; }
  .edit-profile { margin-right: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .launcher, .typing span { transition: none; animation: none; }
}

/* Queue state shown while the conversation is waiting for an agent. */
.queue-notice {
  margin: 10px 12px 0;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #cfe2eb;
  border-radius: 12px;
  background: linear-gradient(135deg, #f3fbfe, #ffffff);
  color: #24485d;
  box-shadow: 0 5px 16px rgba(8,122,164,.055);
}
.queue-notice__spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid #c9e1eb;
  border-top-color: #087aa4;
  border-radius: 50%;
  animation: wcpec-spin .9s linear infinite;
}
.queue-notice > div { min-width: 0; flex: 1; }
.queue-notice strong { display: block; margin-bottom: 2px; color: #14384e; font-size: 11px; font-weight: 900; }
.queue-notice p { margin: 0; color: #49697b; font-size: 10px; line-height: 1.7; }
.queue-notice time { display: block; margin-top: 3px; color: #7c919e; font-size: 8px; }
.queue-notice.is-updated { animation: wcpec-notice-pulse .65s ease; }
@keyframes wcpec-spin { to { transform: rotate(360deg); } }
@keyframes wcpec-notice-pulse { 0% { transform: translateY(0); } 45% { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(8,122,164,.12); } 100% { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .queue-notice__spinner, .queue-notice.is-updated { animation: none; }
}
.service-status.is-busy i { background: #e2a51a; box-shadow: 0 0 0 3px rgba(226,165,26,.16); }


.message-bubble, .attachment-name, .history-item, .network-message { overflow-wrap: anywhere; word-break: break-word; }
.preform input, .preform textarea, .preform select, .composer textarea { font-size: 16px; }
@media (max-width: 700px) {
  :host([data-mode="inline"]) .panel,
  :host([data-mode="embedded"]) .panel,
  :host([data-mode="account"]) .panel,
  :host([data-mode="new-request"]) .panel { height: min(700px, calc(100dvh - 24px)); min-height: 0; border-radius: 15px; }
  .composer { position: sticky; bottom: 0; z-index: 5; }
}
@media (max-width: 420px) {
  :host([data-mode="floating"]) .panel { border-radius: 12px; }
  .panel-header { min-height: 68px; padding: 10px; }
  .brand-icon { width: 38px; height: 38px; flex-basis: 38px; border-radius: 11px; }
  .header-actions button { width: 29px; height: 29px; }
  .preform-view, .history-view { padding: 12px; }
  .composer { gap: 6px; padding-inline: 8px; }
  .attach, .send { flex: 0 0 42px; width: 42px; height: 42px; }
}
.load-older-messages {
  align-self: center;
  margin: 4px auto 8px;
  padding: 7px 13px;
  border: 1px solid #cedbe2;
  border-radius: 999px;
  background: #fff;
  color: #315064;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.load-older-messages:disabled { opacity: .6; cursor: wait; }

/* State, accessibility and pagination refinements. */
.message.system { align-self: center; max-width: min(92%, 520px); }
.message.system .bubble { background: #f1f6f8; border-color: #d8e4e9; color: #3b5969; text-align: center; }
.history-pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; }
.history-pagination button { min-width: 78px; min-height: 36px; border: 1px solid #ccdbe2; border-radius: 9px; background: #fff; color: #27495b; font: inherit; font-weight: 800; cursor: pointer; }
.history-pagination button:disabled { opacity: .5; cursor: not-allowed; }
.history-pagination span { min-width: 74px; text-align: center; color: #587181; font-size: 10px; font-weight: 800; }
.header-actions .notifications { font-size: 14px; }
.message-status { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.attachment-card.attachment-grant { width: 100%; border: 0; font: inherit; text-align: right; cursor: pointer; }
.attachment-card.attachment-grant:disabled { cursor: progress; opacity: .72; }


/* WCPEC 3.0 rating and responsive refinements */
.rating-card{max-height:min(760px,92dvh);overflow:auto}.rating-question{display:grid;gap:5px;width:100%;padding:9px 0;border-bottom:1px solid #edf0f4}.rating-question:last-of-type{border-bottom:0}.rating-question>b{font-size:12px;color:#27364a}.rating-question .rating-stars{display:flex;justify-content:center;gap:5px}.rating-question .rating-label{font-size:11px}.guest-fields label small{font-weight:400;color:#7b8797}
