.asw-toggle,.asw-panel {
  --asw-blue: #165ad7;
  --asw-border: #d5e0ed;
  color-scheme: light;
  font: 1rem/1.45 system-ui, sans-serif;
  box-sizing: border-box;
  position: fixed;
  inset: auto max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) auto;
}

.asw-toggle {
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  inline-size: max-content;
  min-height: 48px;
  padding: 0 14px 0 9px;
  background: var(--asw-blue);
  color: #fff;
  border: 1px solid #fff;
  border-radius: 999px;
  box-shadow: 0 5px 20px #142c5750;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.asw-mark {
  position: relative; flex: 0 0 29px; height: 29px;
  background: #ff8b34; border: 1px solid #ffbc81; border-radius: 50%;
}
.asw-mark-bubble { position: absolute; inset: 7px 6px 8px; border: 2px solid #fff; border-radius: 8px; }
.asw-mark-bubble::after {
  content: ''; position: absolute; left: 1px; bottom: -4px; width: 4px; height: 4px;
  border-left: 2px solid #fff; transform: skewY(-32deg);
}
.asw-mark-light {
  position: absolute; left: 11px; top: 12px; width: 3px; height: 3px;
  border-radius: 50%; background: #fff; box-shadow: 5px 0 #fff;
  animation: asw-mark-pulse 1.6s ease-in-out 2;
}
@keyframes asw-mark-pulse { 50% { opacity: .55; transform: translateY(-1px); } }
@media (prefers-reduced-motion: reduce) { .asw-mark-light { animation: none; } }
@media (max-width: 600px) {
  .asw-toggle {
    inline-size: 48px;
    block-size: 48px;
    padding: 0;
    gap: 0;
    justify-content: center;
  }
  .asw-toggle-label { display: none; }
}

.asw-panel {
  bottom: calc(max(16px,env(safe-area-inset-bottom)) + var(--asw-keyboard,0px));
  width: min(420px,calc(100vw - 2 * max(16px,env(safe-area-inset-right))));
  height: min(600px,calc(var(--asw-view-height,100dvh) - 36px));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--asw-border);
  border-radius: 18px;
  background: #fff;
  color: #152948;
  box-shadow: 0 16px 50px #142c5740;
}
.asw-panel[open] { display: grid; grid-template-rows: auto minmax(0,1fr) auto auto auto; }
.asw-panel::backdrop { background: #14274735; }
.asw-panel :where(button,textarea) { font: inherit; color: inherit; }
.asw-head,.asw-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; }
.asw-head { background: #edf4ff; border-bottom: 1px solid var(--asw-border); }
.asw-head h2 { font-size: 1.125rem; margin: 0; }
.asw-close {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px;
  background: transparent; font-size: 1.5rem; cursor: pointer;
}
.asw-thread { overflow: auto; overscroll-behavior: contain; padding: 12px 14px; }
.asw-reply,.asw-user {
  white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px;
  margin: 0 0 10px; border-radius: 12px; background: #f0f4f9;
}
.asw-user { margin-left: 24px; background: #e6efff; }
.asw-ticket-hint { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--asw-border); font-size: .875rem; }
.asw-ticket-hint p { margin: 0 0 4px; }
.asw-guest { padding: 10px 12px; border: 1px solid var(--asw-border); border-radius: 10px; font-size: .875rem; }
.asw-guest p { margin: 0; }
.asw-guest button { padding: 0; border: 0; background: transparent; color: #1754b9; text-decoration: underline; cursor: pointer; }
.asw-refs { display: flex; flex-wrap: wrap; margin-top: 8px; gap: 8px; }
.asw-panel a { color: #1754b9; text-decoration: underline; }
.asw-examples:not([hidden]) { display: grid; gap: 6px; justify-items: start; }
.asw-examples button {
  min-height: 40px; padding: 6px 10px; text-align: start;
  border: 1px solid var(--asw-border); border-radius: 9px; background: #fff; cursor: pointer;
}
.asw-form { display: grid; gap: 6px; padding: 8px 14px; }
.asw-compose { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 8px; }
.asw-entry {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center;
  border: 1px solid var(--asw-border); border-radius: 10px; background: #fff;
}
.asw-form textarea {
  box-sizing: border-box; display: block; width: 100%; padding: 8px 10px; resize: none;
  border: 0; border-radius: 9px; background: transparent; font-size: 16px;
}
.asw-send,.asw-send-voice {
  min-height: 44px; padding: 6px 12px; border: 0; border-radius: 10px;
  background: var(--asw-blue); color: #fff; cursor: pointer;
}
.asw-send:disabled,.asw-send-voice:disabled { opacity: .55; cursor: default; }
.asw-inputs { display: flex; align-items: center; padding-right: 2px; }
.asw-media-button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: #1754b9; cursor: pointer;
}
.asw-media-button svg { width: 21px; height: 21px; }
.asw-media-button:hover:enabled { background: #edf4ff; }
.asw-media-button[data-recording] { background: #fff0ef; color: #a22524; }
.asw-media-button:disabled { opacity: .5; cursor: default; }
.asw-recording { min-width: 0; padding: 8px; border: 1px solid var(--asw-border); border-radius: 10px; }
.asw-recording audio { display: block; width: 100%; height: 36px; }
.asw-recording-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.asw-recording-actions button:not(.asw-send-voice) {
  min-height: 44px; padding: 6px 9px; border: 1px solid var(--asw-border);
  border-radius: 9px; background: #fff; color: #1754b9; cursor: pointer;
}
.asw-recording-actions button:disabled { opacity: .55; cursor: default; }
.asw-attachment { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asw-attachment[hidden],.asw-form [hidden] { display: none; }
.asw-attachment button {
  min-height: 44px; padding: 4px 9px; border: 1px solid var(--asw-border); border-radius: 8px;
  background: #fff; color: #1754b9; cursor: pointer; font-size: .875rem;
}
.asw-attachment img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.asw-form .asw-status { margin: 0; }
.asw-status { margin: 0 14px; font-size: .875rem; color: #405570; }
.asw-status:empty { display: none; }
.asw-foot { justify-content: flex-start; flex-wrap: wrap; font-size: .875rem; border-top: 1px solid var(--asw-border); }
.asw-panel :focus-visible,.asw-toggle:focus-visible { outline: 2px solid #165ad7; outline-offset: 2px; }
@media (max-width: 360px) {
  .asw-panel {
    right: max(10px,env(safe-area-inset-right));
    width: calc(100vw - 2 * max(10px,env(safe-area-inset-right)));
  }
  .asw-form { padding-inline: 10px; }
  .asw-compose { gap: 5px; }
  .asw-send { padding-inline: 8px; }
}
