.support-launcher {
  position: fixed;
  z-index: 20;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: .52rem;
  padding: .68rem .94rem;
  min-height: 2.75rem;
  border: 1px solid #ad8bd5;
  border-radius: .8rem;
  background: #7049a3;
  box-shadow: 0 .6rem 1.75rem #100b214d;
  color: #fff;
  font-size: .87rem;
  font-weight: 690;
}
.support-launcher:hover, .support-button:not(.secondary):hover { background: #5e3a91; }
.support-launcher:focus-visible, .support-widget-dialog :focus-visible, .support-page :focus-visible {
  outline: 2px solid var(--theme-focus);
  outline-offset: 3px;
}
.support-widget-dialog {
  position: fixed;
  inset: auto max(1rem, env(safe-area-inset-right)) max(4.65rem, env(safe-area-inset-bottom)) auto;
  width: min(26.5rem, calc(100% - 2rem));
  height: min(34rem, calc(100dvh - 6rem));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--theme-line);
  border-radius: 1rem;
  background: var(--theme-canvas);
  color: var(--theme-text);
  box-shadow: 0 1.35rem 4rem #160f254d;
}
.support-widget-dialog[open] { display: grid; grid-template-rows: auto minmax(0,1fr); }
.support-widget-dialog::backdrop { background: #100b2040; }
.support-widget-header, .support-page-header, .support-inbox-heading, .support-ticket-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.support-widget-header {
  padding: .7rem .85rem .7rem 1rem;
  background: var(--theme-panel);
  border-bottom: 1px solid var(--theme-line);
}
.support-widget-header h2 { font-size: 1rem; }
.support-widget-close, .support-header-actions .theme-toggle {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid var(--theme-line);
  border-radius: .5rem;
  color: var(--theme-text);
  background: var(--theme-raised);
  cursor: pointer;
}
.support-widget-close:hover, .support-header-actions .theme-toggle:hover { background: var(--theme-hover); }
.support-widget-frame iframe { display: block; width: 100%; height: 100%; border: 0; }

.support-page { color: var(--theme-text); background: var(--theme-canvas); }
.support-page-header {
  min-height: 4.2rem;
  padding: .65rem clamp(1rem, 3vw, 2.1rem);
  border-bottom: 1px solid var(--theme-line);
  background: var(--theme-header);
}
.support-brand, .support-header-actions { display: flex; gap: .6rem; align-items: center; }
.support-brand { min-width: 0; color: var(--theme-text); font-weight: 720; }
.support-brand img, .support-header-actions { flex: none; }
.support-brand span { font-size: .78rem; font-weight: 510; color: var(--theme-muted); }
.support-header-actions .icon { width: 1.05rem; height: 1.05rem; }
.support-page-main { width: min(100% - 2rem, 43rem); margin: 0 auto; padding: clamp(1.3rem, 5vw, 3.2rem) 0; }
.support-page-main > h1 { margin: 0 0 1rem; font-size: clamp(1.7rem, 5vw, 2.5rem); }
.support-thread {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: min(35rem, 74dvh);
  min-height: 18rem;
  overflow: hidden;
  border: 1px solid var(--theme-line);
  border-radius: .8rem;
  background: var(--theme-panel);
}
.support-embedded .support-page-main { width: 100%; padding: 0; }
.support-embedded .support-thread { height: 100dvh; min-height: 0; border: 0; border-radius: 0; }
.support-thread-info { display: flex; justify-content: space-between; align-items: center; padding: .45rem .85rem; }
.support-thread-info, .support-ticket-reference { color: var(--theme-muted); font-size: .8rem; }
.support-state { padding: .2rem .5rem; border-radius: .4rem; background: var(--theme-raised); color: var(--theme-muted); font-size: .73rem; }
.support-state[data-state="open"] { color: var(--theme-warning); }
.support-state[data-state="answered"] { color: var(--theme-success); }
.support-transcript { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--theme-canvas); scrollbar-width: thin; }
.support-transcript:focus-visible { outline-offset: -2px; }
.support-welcome { padding: 1.55rem 1rem; text-align: center; }
.support-welcome-icon { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; margin: 0 auto .7rem; border-radius: .8rem; color: var(--theme-accent); background: var(--theme-raised); }
.support-welcome h2 { font-size: 1.16rem; }
.support-welcome p { margin: .4rem auto 0; max-width: 28ch; font-size: .87rem; color: var(--theme-muted); }
.support-messages { display: grid; gap: .7rem; list-style: none; padding: .85rem; margin: 0; }
.support-messages:empty { display: none; }
.support-message { justify-self: start; max-width: min(100%, 32rem); padding: .55rem .7rem; border: 1px solid var(--theme-line); border-radius: .62rem; background: var(--theme-panel); }
.support-page:not(.support-admin) .support-message[data-sender="visitor"], .support-admin .support-message[data-sender="admin"] { justify-self: end; background: var(--theme-raised); }
.support-message-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .7rem; margin-bottom: .25rem; }
.support-message-meta strong { font-size: .8rem; color: var(--theme-accent); }
.support-message-meta time { color: var(--theme-muted); font-size: .69rem; }
.support-message p { font-size: .9rem; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-composer { flex: none; padding: .65rem .85rem .75rem; border-top: 1px solid var(--theme-line); }
.support-input-label { display: block; margin: 0 0 .35rem; font-size: .78rem; color: var(--theme-muted); }
.support-input-row { display: flex; align-items: flex-end; gap: .55rem; }
.support-input-row textarea { min-width: 0; width: 100%; min-height: 2.65rem; max-height: 9rem; resize: vertical; border: 1px solid var(--theme-line); padding: .48rem .55rem; border-radius: .48rem; color: var(--theme-text); background: var(--theme-canvas); font: inherit; font-size: .88rem; }
.support-input-row textarea::placeholder { color: var(--theme-muted); opacity: 1; }
.support-button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.55rem; padding: .48rem .7rem; border: 1px solid #7651a7; border-radius: .48rem; background: #7049a3; color: #fff; font: inherit; font-size: .83rem; font-weight: 670; cursor: pointer; }
.support-button.secondary { background: var(--theme-panel); color: var(--theme-accent); border-color: var(--theme-line); }
.support-button.secondary:hover { background: var(--theme-hover); }
.support-button:disabled { opacity: .65; cursor: wait; }
.support-composer-note, .support-error { margin-top: .38rem; color: var(--theme-muted); font-size: .75rem; }
.support-error { color: var(--theme-danger); margin: 0 0 .4rem; }

.support-inbox-filters a { display: block; color: var(--theme-muted); border-radius: .44rem; }
.support-inbox-filters a[aria-current], .support-inbox-list a[aria-current] { color: var(--theme-accent); background: var(--theme-raised); }
.support-inbox-filters a:hover, .support-inbox-list a:hover { color: var(--theme-text); background: var(--theme-hover); }
.support-inbox-heading { align-items: end; margin-bottom: 1rem; }
.support-inbox-heading h1 { font-size: clamp(1.55rem, 4vw, 2.5rem); }
.support-inbox-placeholder p { color: var(--theme-muted); font-size: .88rem; margin-top: .35rem; }
.support-inbox-columns { display: grid; grid-template-columns: minmax(14rem, .72fr) minmax(0,1.28fr); gap: .9rem; align-items: start; }
.support-inbox-queue, .support-inbox-placeholder { min-width: 0; border: 1px solid var(--theme-line); border-radius: .8rem; background: var(--theme-panel); }
.support-inbox-filters { display: flex; flex-wrap: wrap; gap: .2rem; padding: .5rem; border-bottom: 1px solid var(--theme-line); }
.support-inbox-filters a { font-size: .78rem; padding: .32rem .42rem; }
.support-inbox-list { list-style: none; margin: 0; padding: 0; max-height: 60dvh; overflow-y: auto; }
.support-inbox-list li + li { border-top: 1px solid var(--theme-line); }
.support-inbox-list a { display: grid; gap: .24rem; padding: .58rem .72rem; color: var(--theme-text); }
.support-inbox-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .2rem .35rem; font-size: .77rem; }
.support-inbox-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.support-inbox-list small, .support-inbox-empty { color: var(--theme-muted); font-size: .8rem; }
.support-inbox-empty, .support-inbox-placeholder { padding: 1rem; }
.support-inbox-placeholder h2 { font-size: 1.2rem; }
.support-inbox-pagination { display: flex; gap: .8rem; padding: .65rem; }
.support-inbox-pagination a { color: var(--theme-accent); font-size: .83rem; }
.support-ticket-heading { align-items: flex-start; padding: .7rem .85rem; }
.support-ticket-heading h2 { font-size: 1rem; overflow-wrap: anywhere; }
.support-ticket-heading p { margin-top: .22rem; color: var(--theme-muted); font-size: .8rem; overflow-wrap: anywhere; }
.support-ticket-heading .support-state { flex-shrink: 0; }
.support-inbox-thread { height: min(47rem, 77dvh); min-height: 23rem; }
.support-ticket-actions { padding: 0 .85rem .7rem; }
.support-ticket-actions .support-button { min-height: 2rem; }

@media (max-width: 800px) {
  .support-inbox-columns { grid-template-columns: minmax(0,1fr); }
  .support-inbox-list { max-height: 16rem; }
}
@media (max-width: 530px) {
  .support-launcher span { display: none; }
  .support-launcher { justify-content: center; padding: 0; width: 2.95rem; height: 2.95rem; }
  .support-widget-dialog { inset: auto .6rem max(.6rem, env(safe-area-inset-bottom)) .6rem; width: calc(100% - 1.2rem); height: min(34rem, calc(100dvh - 1.2rem)); }
  .support-brand span { display: none; }
  .support-inbox-heading { align-items: flex-start; flex-direction: column; gap: .6rem; }
  .support-ticket-heading { gap: .45rem; flex-wrap: wrap; }
  .support-input-row { gap: .4rem; }
  .support-input-row .support-button { max-width: 7rem; white-space: normal; }
}
