/* DM to Close — visitor chat (DM link page and website chat bubble). */
:root { --c: #5b4ce6; --bg: #f6f5fb; --panel: #fff; --text: #141225; --muted: #6b6880; --line: #e7e5f0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body.embed { background: transparent; }
.chat { display: flex; flex-direction: column; height: 100dvh; max-width: 560px; margin: 0 auto; background: var(--panel); }
body:not(.embed) .chat { box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(20, 16, 60, .08); }
body.embed .chat { max-width: none; border-radius: 16px; overflow: hidden; }
.ch-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); background: var(--c); color: #fff; }
.ch-av { width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; overflow: hidden; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.ch-av img, .ch-av video, .mini-av img, .mini-av video { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 90%; }
.msg-row .b { max-width: 100%; }
.mini-av { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex: none; background: var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.mini-av.empty { visibility: hidden; }
.ch-who { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.ch-who b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-who span { font-size: 12.5px; opacity: .85; }
.ch-x { background: rgba(255, 255, 255, .18); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 15px; }
.ch-x:hover { background: rgba(255, 255, 255, .3); }
.ch-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); overscroll-behavior: contain; }
.b { max-width: 82%; padding: 9px 13px; border-radius: 18px; font-size: 15px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; animation: pop 220ms cubic-bezier(.23, 1, .32, 1); }
.b.them { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.b.you { align-self: flex-end; background: var(--c); color: #fff; border-bottom-right-radius: 6px; }
.b.you a { color: #fff; }
.b a { color: var(--c); }
.b.pending { opacity: .6; }
.b.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.b.typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: dmtcdot 1.1s infinite ease-in-out; }
.b.typing i:nth-child(2) { animation-delay: .15s; }
.b.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dmtcdot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: .8; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .b.typing i { animation: none; opacity: .5; } }
.when { align-self: center; font-size: 11px; color: var(--muted); margin: 6px 0 2px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.ch-start, .ch-reply { flex: none; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.ch-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.ch-fields input, textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); }
textarea { resize: none; display: block; min-height: 46px; max-height: 140px; line-height: 1.4; overflow-y: auto; }
.ch-row textarea { flex: 1; min-width: 0; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--c) 45%, transparent); border-color: var(--c); }
.ch-row { display: flex; gap: 8px; align-items: flex-end; }
.ch-send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--c); color: #fff; font-size: 17px; cursor: pointer; display: grid; place-items: center; transition: transform 200ms ease-out, box-shadow 200ms ease-out; }
.ch-send svg { display: block; transform: translate(-1.25px, 1.25px); transform-origin: 50% 50%; transition: transform 200ms ease-out, opacity 200ms ease-out, filter 200ms ease-out; }
.ch-send:active:not(.fly) { transform: scale(.94); }
.ch-send:disabled { opacity: .5; }
@media (hover: hover) and (pointer: fine) {
  .ch-send:hover:not(:disabled):not(.fly) { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 28%, transparent), 0 8px 18px color-mix(in srgb, var(--c) 42%, transparent); }
  .ch-send:hover:not(:disabled):not(.fly) svg, .ch-send:focus-visible:not(.fly) svg { transform: translate(3px, -3px) rotate(14deg); filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
}
.ch-send.fly svg { transform: translate(16px, -16px) rotate(28deg) scale(.55); opacity: 0; transition: transform 280ms ease-in, opacity 280ms ease-in; }
@media (prefers-reduced-motion: reduce) {
  .ch-send, .ch-send svg, .ch-send.fly svg { transition: none; }
  .ch-send svg, .ch-send:hover:not(:disabled) svg, .ch-send:focus-visible svg, .ch-send.fly svg { transform: translate(-1.25px, 1.25px); opacity: 1; filter: none; }
}
.ch-err { color: #c01048; font-size: 13px; min-height: 0; margin-top: 4px; }
.ch-foot { display: flex; flex-direction: column; gap: 2px; align-items: center; padding: 6px 12px 8px; font-size: 11px; color: var(--muted); background: var(--panel); text-align: center; }
.ch-foot a { color: var(--muted); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.ch-off { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
@media (max-width: 420px) { .ch-fields { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .b { animation: none; } }
.msg-col { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; max-width: 100%; }
.cta-row { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.cta { display: inline-block; max-width: 100%; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--c); background: #fff; color: var(--c); font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; overflow-wrap: anywhere; transition: transform 160ms, background 160ms; }
.cta:hover { background: color-mix(in srgb, var(--c) 10%, #fff); }
.cta:active { transform: scale(.97); }
.cta:disabled { opacity: .5; cursor: default; }
.cta:focus-visible { outline: 2px solid color-mix(in srgb, var(--c) 55%, transparent); outline-offset: 2px; }
/* Themed chat: link pages (/go/<slug>) and the dmtoclose.com home page. The server adds body.lpt only for those; every rule below is scoped to it, so the customer website widget and the plain DM link are unchanged. */
body.lpt { --lt-r: 14px; --lt-cta: 999px; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--tx); background: var(--bg1); -webkit-font-smoothing: antialiased; }
body.lpt.lpt-pill { --lt-r: 22px; }
body.lpt.lpt-square { --lt-r: 5px; --lt-cta: 5px; }
body.lpt .chat { color: var(--tx); background: radial-gradient(120% 55% at 50% -8%, var(--g1), transparent 62%), radial-gradient(80% 45% at 100% 100%, var(--g2), transparent 60%), radial-gradient(70% 40% at 0% 70%, var(--g3), transparent 60%), linear-gradient(180deg, var(--bg2), var(--bg1)); }
body.lpt:not(.embed) .chat { box-shadow: 0 0 0 1px var(--glassb), 0 20px 50px var(--sh); }
body.lpt .ch-head { color: var(--btx); background-color: var(--lt-panel); background-image: linear-gradient(90deg, var(--a1), var(--a2)); background-repeat: no-repeat; background-size: 100% 2px; background-position: 0 100%; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
body.lpt .ch-av { background: var(--ico); color: var(--gt1); box-shadow: 0 0 0 2px var(--icob), 0 0 18px var(--glow2); }
body.lpt .ch-who span { color: var(--mut); opacity: 1; }
body.lpt .ch-x { background: var(--glass); border: 1px solid var(--glassb); color: var(--btx); }
body.lpt .ch-x:hover { background: var(--hover); border-color: var(--gt1); }
body.lpt .ch-body { background: transparent; }
body.lpt .b.them { background: var(--glass); border: 1px solid var(--glassb); color: var(--btx); border-bottom-left-radius: 5px; box-shadow: 0 6px 18px var(--sh); }
body.lpt .b.you { background: linear-gradient(135deg, var(--a1), var(--a2)); color: var(--pt); border: 0; border-bottom-right-radius: 5px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 6px 18px var(--glow2); }
body.lpt .b.you a { color: var(--pt); text-decoration: underline; }
body.lpt .b a { color: var(--gt1); }
body.lpt .when { color: var(--mut); }
body.lpt .mini-av { background: var(--ico); color: var(--gt1); box-shadow: 0 0 0 1px var(--icob); }
body.lpt .ch-start, body.lpt .ch-reply { background: var(--lt-panel); border-top: 1px solid var(--glassb); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
body.lpt .ch-fields input, body.lpt textarea { background: var(--lt-field); color: var(--tx); border: 1px solid var(--glassb); border-radius: var(--lt-r); font-family: inherit; }
body.lpt input::placeholder, body.lpt textarea::placeholder { color: var(--mut); opacity: 1; }
body.lpt input:focus, body.lpt textarea:focus { outline: 2px solid var(--glow); border-color: var(--gt1); }
body.lpt .ch-send { background: linear-gradient(135deg, var(--a1), var(--a2)); color: var(--pt); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28), 0 6px 18px var(--glow2); }
body.lpt .ch-err { color: var(--lt-err); }
body.lpt .ch-foot { background: var(--lt-panel); color: var(--mut); }
body.lpt .ch-foot a { color: var(--mut); }
body.lpt .ch-off { color: var(--mut); }
body.lpt .cta { background: var(--ico); border: 1px solid var(--icob); color: var(--btx); border-radius: var(--lt-cta); font-weight: 650; }
body.lpt .cta:hover { background: var(--hover); border-color: var(--gt1); }
body.lpt .cta:focus-visible { outline: 2px solid var(--gt2); outline-offset: 2px; }

/* loading placeholder shown only on a first visit, until the chat's settings arrive */
.ch-sk { display: grid; gap: 10px; max-width: 80%; padding: 4px 0; }
.ch-sk i { display: block; height: 40px; border-radius: 16px; background: rgba(128, 128, 150, .16); animation: ch-sk 1.1s ease-in-out infinite; }
.ch-sk i.s1 { width: 72%; } .ch-sk i.s2 { width: 46%; height: 30px; animation-delay: .15s; } .ch-sk i.s3 { width: 58%; animation-delay: .3s; }
@keyframes ch-sk { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ch-sk i { animation: none; } }
.ch-head .dmtc-lang button { padding: 6px 8px; min-width: 26px; }
.ch-head .dmtc-lang { color: inherit; }
.ch-fld { min-width: 0; }
.ch-ferr { color: #c01048; font-size: 12.5px; line-height: 1.3; min-height: 0; margin-top: 3px; }
.ch-ferr:empty { display: none; }
.ch-fields input.bad { border-color: #c01048; }
.trc { box-sizing: border-box; width: min(100%, 320px); padding: 12px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 14px; line-height: 1.4; display: flex; flex-direction: column; gap: 8px; }
.trc-h { font-weight: 700; font-size: 13px; }
.trc-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.trc-list li { position: relative; padding-left: 20px; }
.trc-list li::before { content: "\2713"; position: absolute; left: 0; top: 0; color: var(--c); font-weight: 800; }
.trc-plans { display: grid; gap: 4px; }
.trc-plans label, .trc-ck { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13.5px; }
.trc input[type=checkbox], .trc input[type=radio] { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--c); }
.trc-ck { padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--c) 8%, #fff); }
.trc-go { width: 100%; padding: 11px 14px; font-size: 15px; background: var(--c); color: #fff; border-color: var(--c); }
.trc-go:hover { background: var(--c); }
.trc-go:disabled { background: color-mix(in srgb, var(--c) 35%, #fff); border-color: transparent; color: #fff; opacity: 1; cursor: not-allowed; }
.trc-note { font-size: 12.5px; color: var(--muted); text-align: center; }
body.lpt .trc { background: var(--glass); border: 1px solid var(--glassb); color: var(--btx); border-radius: var(--lt-r); box-shadow: 0 6px 18px var(--sh); }
body.lpt .trc-ck { background: var(--ico); }
body.lpt .trc-list li::before { color: var(--gt1); }
body.lpt .trc input[type=checkbox], body.lpt .trc input[type=radio] { accent-color: var(--gt1); }
body.lpt .trc-go { background: linear-gradient(135deg, var(--a1), var(--a2)); color: var(--pt); border: 0; }
body.lpt .trc-go:disabled { opacity: .45; background: linear-gradient(135deg, var(--a1), var(--a2)); }
body.lpt .trc-note { color: var(--mut); }
body.lpt .ch-ferr { color: var(--lt-err); }
body.lpt .ch-fields input.bad { border-color: var(--lt-err); }
