.tcw-root {
    --tcw-teal: var(--tc-primary, #0b7269);
    --tcw-teal-strong: #085b54;
    --tcw-teal-soft: #eaf7f5;
    --tcw-navy: var(--tc-secondary, #0a4772);
    --tcw-navy-strong: #073957;
    --tcw-ink: #132a3e;
    --tcw-muted: #526b7d;
    --tcw-faint: #718596;
    --tcw-line: #dce6ea;
    --tcw-canvas: #f4f8f8;
    --tcw-white: #fff;
    --tcw-danger: #b42318;
    --tcw-danger-soft: #fff1f0;
    --tcw-warning: #9a6700;
    --tcw-warning-soft: #fff8e6;
    position: fixed;
    left: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 9990;
    color: var(--tcw-ink);
    font-family: "Open Sans", "Open Sans Fallback", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0;
  }
  body.tcw-chat-open { overflow: hidden; }
  .tcw-root *,
  .tcw-root *::before,
  .tcw-root *::after { box-sizing: border-box; }
  .tcw-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
  .tcw-hide { display: none !important; }

  .tcw-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 0;
    border: 0;
    background: rgba(7, 34, 51, 0.24);
    cursor: default;
  }
  .tcw-root.tcw-open .tcw-scrim { display: block; }

  .tcw-fab {
    position: relative;
    z-index: 1;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: var(--tcw-teal);
    color: var(--tcw-white);
    box-shadow: 0 10px 28px rgba(10, 71, 114, 0.24);
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
  }
  .tcw-fab i { font-size: 1.25rem; }
  .tcw-fab:hover {
    background: var(--tcw-teal-strong);
    box-shadow: 0 12px 32px rgba(10, 71, 114, 0.3);
    transform: translateY(-2px);
  }
  .tcw-root.tcw-open .tcw-fab {
    opacity: 0;
    pointer-events: none;
  }

  .tcw-panel {
    display: none;
    position: fixed;
    left: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 2;
    width: min(400px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow: hidden;
    flex-direction: column;
    border: 1px solid var(--tcw-line);
    border-radius: 8px;
    background: var(--tcw-white);
    box-shadow: 0 24px 64px rgba(7, 34, 51, 0.24);
  }
  .tcw-root.tcw-has-session .tcw-panel {
    height: min(640px, calc(100vh - 40px));
    height: min(640px, calc(100dvh - 40px));
  }
  .tcw-panel.open { display: flex; }

  .tcw-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 70px;
    padding: 0.7rem 0.75rem;
    background: var(--tcw-navy);
    color: var(--tcw-white);
  }
  .tcw-brandmark {
    display: inline-flex;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 7px;
    background: var(--tcw-teal);
    font-size: 0.72rem;
    font-weight: 800;
  }
  .tcw-head-copy {
    min-width: 0;
    flex: 1;
  }
  .tcw-title {
    margin: 0;
    color: var(--tcw-white);
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0;
  }
  .tcw-state {
    display: block;
    max-width: 22ch;
    margin-top: 0.14rem;
    overflow: hidden;
    color: #d8e5ec;
    font-size: 0.72rem;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tcw-human,
  .tcw-close {
    min-width: 40px;
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 7px;
    background: transparent;
    color: var(--tcw-white);
    cursor: pointer;
  }
  .tcw-human {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
  }
  .tcw-close {
    flex: 0 0 40px;
    padding: 0;
    font-size: 1rem;
  }
  .tcw-human:hover,
  .tcw-close:hover { background: rgba(255, 255, 255, 0.12); }
  .tcw-human:disabled { cursor: default; opacity: 0.7; }

  .tcw-notice {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--tcw-line);
    background: var(--tcw-warning-soft);
    color: #674700;
    font-size: 0.75rem;
    line-height: 1.4;
  }
  .tcw-notice--danger {
    background: var(--tcw-danger-soft);
    color: var(--tcw-danger);
  }
  .tcw-notice--info {
    background: var(--tcw-teal-soft);
    color: var(--tcw-teal-strong);
  }
  .tcw-notice-text { flex: 1; }
  .tcw-notice-action {
    min-height: 32px;
    padding: 0.25rem 0.55rem;
    border: 1px solid currentColor;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
  }

  .tcw-pre {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.8rem;
    overflow-y: auto;
    padding: 1.15rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    background: var(--tcw-canvas);
  }
  .tcw-pre-intro {
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--tcw-line);
  }
  .tcw-pre-title {
    margin: 0 0 0.3rem;
    color: var(--tcw-ink);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0;
  }
  .tcw-pre p {
    margin: 0;
    color: var(--tcw-muted);
    font-size: 0.79rem;
    line-height: 1.55;
  }
  .tcw-field label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--tcw-ink);
    font-size: 0.76rem;
    font-weight: 700;
  }
  .tcw-optional {
    color: var(--tcw-faint);
    font-size: 0.7rem;
    font-weight: 600;
  }
  .tcw-field input {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.7rem;
    border: 1px solid #cbd9df;
    border-radius: 7px;
    background: var(--tcw-white);
    color: var(--tcw-ink);
    font-family: inherit;
    font-size: 0.84rem;
  }
  .tcw-pre-start {
    width: 100%;
    min-height: 46px;
    margin-top: 0.1rem;
    border: 1px solid var(--tcw-teal);
    border-radius: 7px;
    background: var(--tcw-teal);
    color: var(--tcw-white);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
  }
  .tcw-pre-start:hover { background: var(--tcw-teal-strong); }
  .tcw-pre-start:disabled { cursor: wait; opacity: 0.65; }
  .tcw-pre-err {
    display: none;
    padding: 0.55rem 0.65rem;
    border: 1px solid #f3b6b2;
    border-radius: 7px;
    background: var(--tcw-danger-soft);
    color: var(--tcw-danger) !important;
    font-size: 0.75rem !important;
  }
  .tcw-pre-err.show { display: block; }
  .tcw-privacy {
    color: var(--tcw-faint) !important;
    font-size: 0.7rem !important;
  }
  .tcw-hp { display: none; }

  .tcw-log {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.65rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.9rem;
    background: var(--tcw-canvas);
    scrollbar-color: #b8c8cf transparent;
    scrollbar-width: thin;
  }
  .tcw-entry {
    display: flex;
    max-width: 88%;
    flex-direction: column;
    gap: 0.2rem;
  }
  .tcw-entry--customer { align-self: flex-end; }
  .tcw-entry--agent,
  .tcw-entry--staff,
  .tcw-entry--system { align-self: flex-start; }
  .tcw-msg {
    padding: 0.58rem 0.72rem;
    border: 1px solid var(--tcw-line);
    border-radius: 8px;
    background: var(--tcw-white);
    color: var(--tcw-ink);
    font-size: 0.82rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }
  .tcw-msg--customer {
    border-color: var(--tcw-teal);
    border-bottom-right-radius: 3px;
    background: var(--tcw-teal);
    color: var(--tcw-white);
  }
  .tcw-msg--agent {
    border-bottom-left-radius: 3px;
    box-shadow: inset 3px 0 0 var(--tcw-teal);
  }
  .tcw-msg--staff {
    border-color: var(--tcw-navy);
    border-bottom-left-radius: 3px;
    background: var(--tcw-navy);
    color: var(--tcw-white);
  }
  .tcw-msg--system {
    border-color: #c9dadd;
    background: #edf4f4;
    color: var(--tcw-muted);
    font-size: 0.76rem;
  }
  .tcw-sender {
    display: block;
    margin-bottom: 0.18rem;
    color: var(--tcw-teal-strong);
    font-size: 0.68rem;
    font-weight: 800;
  }
  .tcw-msg--staff .tcw-sender { color: #d9e8ee; }
  .tcw-msg a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .tcw-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.5rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--tcw-line);
  }
  .tcw-sources-label {
    flex-basis: 100%;
    color: var(--tcw-faint);
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
  }
  .tcw-source {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    max-width: 100%;
    padding: 0.25rem 0.45rem;
    border: 1px solid #bfd8d4;
    border-radius: 6px;
    background: var(--tcw-teal-soft);
    color: var(--tcw-teal-strong) !important;
    font-size: 0.7rem;
    text-decoration: none !important;
  }
  .tcw-source span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tcw-delivery {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    min-height: 18px;
    color: var(--tcw-faint);
    font-size: 0.67rem;
  }
  .tcw-delivery--failed { color: var(--tcw-danger); }
  .tcw-retry {
    min-height: 28px;
    padding: 0.1rem 0.45rem;
    border: 1px solid currentColor;
    border-radius: 5px;
    background: var(--tcw-white);
    color: var(--tcw-danger);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  .tcw-typing {
    align-self: flex-start;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--tcw-line);
    border-radius: 7px;
    background: var(--tcw-white);
    color: var(--tcw-muted);
    font-size: 0.72rem;
  }
  .tcw-typing-dots::after {
    content: "...";
    display: inline-block;
    width: 1.2rem;
    overflow: hidden;
    vertical-align: bottom;
    animation: tcw-dots 1.15s steps(4, end) infinite;
  }

  .tcw-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 0.5rem;
    align-items: end;
    padding: 0.65rem calc(0.65rem + env(safe-area-inset-right, 0px))
      calc(0.65rem + env(safe-area-inset-bottom, 0px))
      calc(0.65rem + env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--tcw-line);
    background: var(--tcw-white);
  }
  .tcw-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    padding: 0.58rem 0.7rem;
    border: 1px solid #cbd9df;
    border-radius: 7px;
    background: var(--tcw-white);
    color: var(--tcw-ink);
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.4;
  }
  .tcw-attach {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0a4772 !important;
  }
  .tcw-attach:disabled { opacity: .55; }
  .tcw-send {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--tcw-teal);
    border-radius: 7px;
    background: var(--tcw-teal);
    color: var(--tcw-white);
    cursor: pointer;
  }
  .tcw-send:hover { background: var(--tcw-teal-strong); }
  .tcw-send:disabled { cursor: wait; opacity: 0.55; }

  .tcw-csat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.45rem;
    align-items: center;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--tcw-line);
    background: var(--tcw-white);
    color: var(--tcw-ink);
    font-size: 0.75rem;
  }
  .tcw-csat-actions { display: flex; gap: 0.35rem; }
  .tcw-csat-rate,
  .tcw-new {
    min-height: 38px;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--tcw-line);
    border-radius: 6px;
    background: var(--tcw-white);
    color: var(--tcw-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  .tcw-csat-rate:hover { border-color: var(--tcw-teal); color: var(--tcw-teal); }
  .tcw-new {
    border-color: var(--tcw-teal);
    color: var(--tcw-teal);
  }

  .tcw-root :is(button, input, textarea, a):focus-visible,
  .tcw-panel:focus-visible {
    outline: 3px solid #58bcb0;
    outline-offset: 2px;
  }

  @keyframes tcw-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes tcw-dots {
    0% { width: 0; }
    100% { width: 1.2rem; }
  }
  @media (prefers-reduced-motion: no-preference) {
    .tcw-panel.open { animation: tcw-in 180ms ease-out; }
  }
  @media (prefers-reduced-motion: reduce) {
    .tcw-root *,
    .tcw-root *::before,
    .tcw-root *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      scroll-behavior: auto !important;
      transition-duration: 0.01ms !important;
    }
  }

  @media (max-width: 575px) {
    .tcw-root {
      left: calc(14px + env(safe-area-inset-left, 0px));
      bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
    .tcw-panel,
    .tcw-root.tcw-has-session .tcw-panel {
      inset: 0;
      width: 100vw;
      height: 100vh;
      height: 100dvh;
      max-width: none;
      max-height: none;
      border: 0;
      border-radius: 0;
    }
    .tcw-head {
      min-height: calc(68px + env(safe-area-inset-top, 0px));
      padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
      padding-right: calc(0.65rem + env(safe-area-inset-right, 0px));
      padding-left: calc(0.65rem + env(safe-area-inset-left, 0px));
    }
    .tcw-human,
    .tcw-close {
      min-width: 44px;
      min-height: 44px;
    }
    .tcw-human { padding-inline: 0.5rem; }
    .tcw-state { max-width: 18ch; }
    .tcw-log { padding-inline: calc(0.75rem + env(safe-area-inset-left, 0px)); }
    .tcw-entry { max-width: 92%; }
    .tcw-csat {
      grid-template-columns: 1fr;
      padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
      padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
    }
    .tcw-csat-actions { width: 100%; }
    .tcw-csat-rate,
    .tcw-new {
      min-height: 44px;
      flex: 1;
    }
  }
