.socium-support-launcher,
.socium-support-panel,
.socium-chat {
  --tc-ink: var(--ink);
  --tc-ink-2: var(--ink);
  --tc-ink-3: var(--soft);
  --tc-ink-4: var(--hint);
  --tc-line: var(--line);
  --tc-line-2: var(--line);
  --tc-field: var(--line);
  --tc-field-hover: var(--soft);
  --tc-field-bg: var(--bg);
  --tc-field-bg-focus: var(--paper);
  --tc-field-autofill: var(--bg);
  --tc-bubble: var(--bg);
  --tc-bubble-me: color-mix(in srgb, var(--blue) 12%, var(--paper));
  --tc-bubble-me-line: color-mix(in srgb, var(--blue) 30%, transparent);
  --tc-soft: var(--bg);
  --tc-hover-line: var(--ink);
  --tc-invalid: #d92d20;
  --tc-scroll: var(--line);
  --tc-accent: var(--blue);
  --tc-accent-hi: var(--link);
  --tc-accent-ink: #ffffff;
  --tc-danger: #d92d20;
  --tc-surface: var(--paper);
  --tc-focus: var(--w-blue, #ea580c);
  --tc-focus-width: 3px;
  --tc-focus-offset: var(--focus-ring-offset, 3px);
  --tc-ease: cubic-bezier(.23, 1, .32, 1);
  --tc-display: var(--font);
  --tc-text: var(--font);
  --tc-body: 16px;
  --tc-small: 14px;
}

:root[data-theme="dark"] .socium-support-launcher,
:root[data-theme="dark"] .socium-support-panel,
:root[data-theme="dark"] .socium-chat {
  --tc-invalid: #f97066;
  --tc-danger: #f97066;
}

.socium-support-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10020;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 16px 30px -14px rgb(234 88 12 / .9);
  cursor: pointer;
  transition: transform .16s var(--tc-ease), border-color .2s ease, opacity .2s ease, visibility 0s;
}

@media (hover: hover) and (pointer: fine) {
  .socium-support-launcher:hover {
    transform: translateY(-2px);
  }
}

.socium-support-unread {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--tc-accent);
  color: var(--tc-accent-ink);
  font: 700 11.5px/20px var(--tc-text);
  text-align: center;
  background: var(--inv-bg, #1b1d26);
  color: var(--inv-fg, #fff);
  box-shadow: 0 0 0 2px var(--bg);
}

.socium-support-unread[hidden] { display: none; }

.socium-support-launcher:active { transform: translateY(0) scale(.97); }

.socium-support-launcher.is-chat-open {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: transform .16s var(--tc-ease), opacity .16s ease, visibility 0s linear .16s;
}

.socium-support-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.socium-support-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10021;
  width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 44px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transform-origin: right bottom;
  border: 0;
  border-radius: 24px;
  background: var(--tc-surface);
  box-shadow: var(--shadow), 0 30px 70px -30px rgb(0 0 0 / .5);
  transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s;
}

.socium-support-panel.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity .2s var(--tc-ease), transform .2s var(--tc-ease), visibility 0s;
}

.socium-support-panel > .socium-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.socium-support-panel .socium-chat-head {
  position: sticky;
  top: 0;
  z-index: 1;
  flex-shrink: 0;
  background: var(--duo);
  color: #fff;
  --tc-ink: #fff;
  --tc-ink-2: #fff;
  --tc-ink-3: var(--night-soft);
  --tc-line-2: rgb(255 255 255 / .14);
}

.socium-support-close {
  flex: none;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 0;
  border-radius: 12px;
  background: rgb(255 255 255 / .1);
  color: #fff;
  font: 400 22px/1 system-ui, sans-serif !important;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}

.socium-support-close:hover {
  border-color: var(--tc-hover-line);
  color: var(--tc-ink);
}

.socium-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  color: var(--tc-ink-2);
  font-family: var(--tc-text) !important;
  font-size: var(--tc-body);
  line-height: 1.5;
  text-align: left;
}

.socium-chat *,
.socium-chat *::before,
.socium-chat *::after { box-sizing: border-box; }

.socium-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--tc-line);
}

.socium-chat-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: url("socium-logo.png") center / 28px no-repeat;
  filter: invert(1);
  box-shadow: none;
}

.socium-chat-id {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.socium-chat-id strong {
  color: var(--tc-ink);
  font: 600 var(--tc-body)/1.25 var(--tc-display) !important;
  letter-spacing: .01em;
}

.socium-chat-id span {
  color: var(--tc-ink-3);
  font-size: var(--tc-small);
  line-height: 1.4;
}

.socium-chat-thread {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 96px;
  overflow: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--tc-scroll) transparent;
}

.socium-chat-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 6px 18px 18px 18px;
  background: var(--bg);
}

.socium-chat-msg p {
  margin: 0;
  color: var(--tc-ink-2);
  font-size: var(--tc-body);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.socium-chat-msg--me {
  align-self: flex-end;
  border-radius: 18px 6px 18px 18px;
  background: var(--tc-bubble-me);
  box-shadow: none;
}

.socium-chat-msg--contact {
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.socium-chat-msg--contact p {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: normal;
}

.socium-chat-contact { min-width: 0; overflow-wrap: anywhere; }

.socium-chat-msg--contact svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: var(--tc-accent-hi);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.socium-chat-contact-edit {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tc-accent-hi);
  font: inherit;
  font-size: var(--tc-small);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.socium-chat-contact-edit:hover { color: var(--tc-ink); }

.socium-chat-msg--me p { color: var(--tc-ink); }

.socium-chat-state {
  display: block;
  margin-top: 6px;
  color: var(--tc-ink-4);
  font-size: var(--tc-small);
  text-align: right;
}

.socium-chat-state.is-failed { color: var(--tc-danger); }

.socium-chat-info {
  align-self: center;
  max-width: 92%;
  margin: 2px 0 0;
  color: var(--tc-ink-3);
  font-size: var(--tc-small);
  line-height: 1.45;
  text-align: center;
}

.socium-chat-composer {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 6px 14px 14px;
}

.socium-chat-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px;
}

.socium-chat-topics[hidden] { display: none; }

.socium-chat-topic {
  min-height: 34px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--tc-line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--tc-ink-2);
  font: inherit;
  font-size: var(--tc-small);
  line-height: 1.3;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, transform .16s var(--tc-ease);
}

@media (hover: hover) and (pointer: fine) {
  .socium-chat-topic:hover { border-color: var(--tc-hover-line); color: var(--tc-ink); }
}

.socium-chat-topic:active { transform: scale(.97); }

.socium-chat-box--message,
.socium-chat.is-asking-contact .socium-chat-box--contact { display: flex; }
.socium-chat-box--contact,
.socium-chat-step,
.socium-chat.is-asking-contact .socium-chat-box--message { display: none; }
.socium-chat.is-asking-contact:not(.is-editing) .socium-chat-step { display: flex; }

.socium-chat-box-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-self: center;
  border-radius: 50%;
  background: var(--bg);
  color: var(--tc-ink-3);
}

.socium-chat-box-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.socium-chat .socium-chat-box--contact input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  align-self: center;
}

.socium-chat .socium-chat-box--contact input[type="text"]:hover,
.socium-chat .socium-chat-box--contact input[type="text"]:focus { border: 0; background: transparent; outline: none; }
.socium-chat .socium-chat-box--contact input.is-invalid { border: 0 !important; }
.socium-chat-box--contact:has(input.is-invalid) { border-color: var(--tc-invalid); }

.socium-chat-step {
  align-items: center;
  gap: 8px;
  margin: -2px 0 0;
  padding: 0 4px;
  color: var(--tc-ink-4);
  font-size: var(--tc-small);
}

.socium-chat-step strong { color: var(--tc-ink-2); font-weight: 600; }

.socium-chat-step-dots { display: inline-flex; gap: 4px; }

.socium-chat-step-dots i {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--tc-line-2);
}

.socium-chat-step-dots i:first-child { background: var(--tc-accent); }

.socium-chat input[type="text"] {
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--tc-field);
  border-radius: var(--r-m);
  outline: none;
  background: var(--tc-field-bg);
  color: var(--tc-ink);
  font: inherit;
  font-size: max(16px, var(--tc-body));
  transition: border-color .2s ease, background .2s ease;
}

.socium-chat input[type="text"]:hover { border-color: var(--tc-field-hover); }

.socium-chat input[type="text"]:focus {
  border-color: var(--tc-focus);
  background: var(--tc-field-bg-focus);
  outline: var(--tc-focus-width) solid var(--tc-focus);
  outline-offset: 1px;
}

.socium-chat input[type="text"]:-webkit-autofill {
  -webkit-text-fill-color: var(--tc-ink);
  caret-color: var(--tc-ink);
  box-shadow: inset 0 0 0 1000px var(--tc-field-autofill);
}

.socium-chat input[type="text"]:-webkit-autofill:focus {
  box-shadow: inset 0 0 0 1000px var(--tc-field-autofill);
}

.socium-chat input::selection,
.socium-chat textarea::selection {
  background: var(--blue);
  color: #fff;
}

.socium-chat input::placeholder,
.socium-chat textarea::placeholder { color: var(--tc-ink-4); }

.socium-chat .is-invalid { border-color: var(--tc-invalid) !important; }

.socium-chat-box {
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--tc-field);
  border-radius: 24px;
  background: var(--tc-field-bg);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.socium-chat-box:hover { border-color: var(--tc-field-hover); }

.socium-chat-box:focus-within {
  border-color: var(--tc-focus);
  background: var(--tc-field-bg-focus);
  outline: none;
}

.socium-chat-box textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 168px;
  margin: 0;
  padding: 6px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--tc-ink);
  font: inherit;
  font-size: max(16px, var(--tc-body));
  line-height: 1.5;
  resize: none;
}

.socium-chat-box textarea:focus-visible { outline: none !important; }

.socium-chat-box textarea.is-invalid { border: 0 !important; }
.socium-chat-box:has(textarea.is-invalid) { border-color: var(--tc-invalid); }

.socium-chat-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, opacity .2s ease;
}

.socium-chat-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
  .socium-chat-send:hover:not(:disabled) {
    background: var(--blue-deep);
    transform: translateY(-1px);
  }
}

.socium-chat-send:active:not(:disabled) { transform: scale(.96); }

.socium-chat-send:disabled {
  opacity: .5;
  cursor: default;
}

.socium-chat.is-sending .socium-chat-send { cursor: wait; }

.socium-chat-sr,
.socium-chat-trap {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.socium-chat-check:empty,
.socium-chat-error:empty { display: none; }

.socium-chat-error {
  margin: 0;
  color: var(--tc-danger);
  font-size: var(--tc-small);
  line-height: 1.45;
}

.socium-chat-error.is-quiet { color: var(--tc-ink-3); }

.socium-chat-note {
  margin: 0;
  color: var(--tc-ink-3);
  font-size: var(--tc-small);
  line-height: 1.5;
}

.socium-chat-note a {
  color: var(--tc-ink-3);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.socium-chat-note a:hover { color: var(--tc-ink); }

.socium-support-launcher:focus-visible,
.socium-support-close:focus-visible,
.socium-chat-send:focus-visible,
.socium-chat-topic:focus-visible,
.socium-chat-contact-edit:focus-visible,
.socium-chat-note a:focus-visible {
  outline: var(--tc-focus-width) solid var(--tc-focus);
  outline-offset: var(--tc-focus-offset);
}

.socium-chat--inline {
  height: 540px;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.socium-chat--inline .socium-chat-head { padding: 16px 20px; }

.socium-chat--inline .socium-chat-thread { padding: 18px 20px 10px; }

.socium-chat--inline .socium-chat-composer { padding: 6px 16px 16px; }

@media (max-width: 860px) {
  .socium-chat--inline { height: 600px; height: min(600px, 72svh); }
}

.socium-support-launcher.is-inline-shown {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1120px) {
  .socium-support-panel {
    height: min(600px, calc(100dvh - var(--site-header-bottom, 84px) - 30px));
  }

  .socium-support-close,
  .socium-chat-send {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 560px) {
  .socium-support-launcher {
    right: 14px;
    bottom: 14px;
    width: 48px;
    height: 48px;
  }

  .socium-support-panel {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    height: min(600px, calc(100dvh - var(--site-header-bottom, 84px) - 18px));
  }

  .socium-support-panel.is-keyboard {
    top: calc(var(--vv-top, 0px) + 8px);
    bottom: auto;
    height: calc(var(--vv-h, 100dvh) - 16px);
  }

  .socium-chat--inline .socium-chat-head,
  .socium-chat--inline .socium-chat-thread,
  .socium-chat--inline .socium-chat-composer {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .socium-support-launcher,
  .socium-support-launcher.is-chat-open,
  .socium-support-panel,
  .socium-support-panel.is-open,
  .socium-chat-send { transition: none; }
}

.socium-chat-count {
  margin: 0;
  color: var(--tc-ink-3);
  font-size: var(--tc-small);
  text-align: right;
}

.socium-chat-count[hidden] { display: none; }

@media (max-width: 1120px) and (max-height: 500px) {
  .socium-support-panel {
    bottom: 12px;
    height: min(600px, calc(100dvh - var(--site-header-bottom, 84px) - 20px));
  }
}
