.xq-widget,
.xq-widget * {
  box-sizing: border-box;
}

.xq-widget {
  --xq-primary: #2563eb;
  color: #172033;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.xq-widget--floating {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
}
.xq-widget--floating.xq-position--left { right: auto; left: 24px; }

.xq-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.xq-launcher:focus-visible, .xq-form textarea:focus, .xq-form button:focus-visible, .xq-close:focus-visible, .xq-clear:focus-visible, .xq-speak:focus-visible, .xq-header-title a:focus-visible { outline: 3px solid color-mix(in srgb, var(--xq-primary) 35%, transparent); outline-offset: 2px; }
.xq-orb {
  --xq-orb-size: 62px;
  position: relative;
  display: block;
  width: var(--xq-orb-size);
  height: var(--xq-orb-size);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 50%;
  background: conic-gradient(from 40deg, #55e8ff, #2477ff 18%, #7555ff 36%, #f044d2 55%, #ff784c 73%, #ffd45a 86%, #55e8ff);
  box-shadow: 0 9px 26px rgba(38,77,180,.34), inset 0 0 9px rgba(255,255,255,.85);
  animation: xq-orb-rotate 5.5s linear infinite;
  transition: transform .2s ease, box-shadow .2s ease;
}
.xq-orb::before {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: inherit;
  background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.92), rgba(105,172,255,.34) 18%, rgba(22,30,68,.94) 61%, #0b1025 100%);
  box-shadow: inset 0 0 14px rgba(99,207,255,.42);
  content: "";
}
.xq-orb::after {
  position: absolute;
  inset: -4px;
  border: 2px solid rgba(112,213,255,.38);
  border-radius: inherit;
  content: "";
  animation: xq-orb-halo 2.4s ease-in-out infinite;
}
.xq-launcher:hover .xq-orb { transform: scale(1.08); box-shadow: 0 13px 32px rgba(38,77,180,.44), inset 0 0 9px rgba(255,255,255,.85); }
.xq-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; }
.xq-avatar .xq-orb { --xq-orb-size: 38px; box-shadow: 0 4px 12px rgba(9,19,51,.32), inset 0 0 7px rgba(255,255,255,.8); }

.xq-panel {
  overflow: hidden;
  width: min(390px, calc(100vw - 32px));
  height: min(610px, calc(100vh - 120px));
  border: 1px solid #e3e8f0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.xq-widget--floating .xq-panel { position: absolute; right: 0; bottom: 78px; }
.xq-widget--floating.xq-position--left .xq-panel { right: auto; left: 0; }
.xq-widget--inline { width: 100%; margin: 24px 0; }
.xq-widget--inline .xq-panel { width: 100%; height: var(--xq-inline-height, 600px); max-height: 85vh; border-radius: 18px; box-shadow: 0 12px 40px rgba(15, 23, 42, .12); }
.xq-panel[hidden] { display: none !important; }

.xq-header {
  display: flex;
  align-items: center;
  min-height: 68px;
  padding: 12px 14px;
  color: #fff;
  background: var(--xq-primary);
  background: linear-gradient(135deg, var(--xq-primary), color-mix(in srgb, var(--xq-primary) 72%, #111827));
}

.xq-header .xq-avatar { flex: 0 0 auto; margin-right: 10px; }
.xq-header strong { display: block; }
.xq-header strong { font-size: 16px; }
.xq-header-title a { display: inline-block; margin-top: 2px; color: rgba(255,255,255,.88); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.xq-header-tools { display: flex; flex-wrap: wrap; gap: 2px 9px; }
.xq-header-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.xq-close, .xq-clear { padding: 4px 8px; border: 0; color: #fff; background: transparent; cursor: pointer; font-size: 24px; line-height: 1; }
.xq-clear { font-size: 20px; }
.xq-is-speaking .xq-orb { animation: xq-orb-rotate 1.8s linear infinite, xq-voice-pulse .85s ease-in-out infinite; }
.xq-is-listening .xq-orb { animation: xq-orb-rotate .8s linear infinite, xq-listening-pulse .75s ease-in-out infinite; }

.xq-messages {
  height: calc(100% - 184px);
  min-height: 210px;
  overflow-y: auto;
  padding: 18px 15px;
  background: #f7f9fc;
  scrollbar-width: thin;
}

.xq-message { display: flex; margin-bottom: 12px; }
.xq-message--user { justify-content: flex-end; }
.xq-message__bubble { max-width: 88%; padding: 10px 13px; border: 1px solid #e1e7f0; border-radius: 14px 14px 14px 4px; background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.04); white-space: pre-wrap; overflow-wrap: anywhere; }
.xq-message--user .xq-message__bubble { color: #fff; border-color: var(--xq-primary); border-radius: 14px 14px 4px 14px; background: var(--xq-primary); }
.xq-message--loading .xq-message__bubble { color: #64748b; font-size: 13px; animation: xq-pulse 1.2s ease-in-out infinite; }

.xq-sources { margin-top: 10px; padding-top: 9px; border-top: 1px solid #e8edf4; font-size: 12px; }
.xq-sources strong { color: #475569; }
.xq-sources ul { margin: 5px 0 0; padding-left: 18px; }
.xq-sources a { color: var(--xq-primary); text-decoration: none; }
.xq-sources a:hover { text-decoration: underline; }
.xq-speech-actions { margin-top: 9px; padding-top: 8px; border-top: 1px solid #edf0f5; white-space: normal; }
.xq-speak { padding: 3px 8px; border: 1px solid color-mix(in srgb, var(--xq-primary) 34%, #d7dee8); border-radius: 999px; color: var(--xq-primary); background: #fff; cursor: pointer; font-size: 12px; line-height: 1.5; }
.xq-speak:hover, .xq-speak.is-speaking { color: #fff; background: var(--xq-primary); }
.xq-feedback { margin: -6px 0 10px 12px; color: #7b8798; font-size: 12px; }
.xq-feedback button { margin-left: 5px; padding: 1px 5px; border: 0; background: transparent; cursor: pointer; }
.xq-feedback.is-saved { color: #247a46; }

.xq-quota { min-height: 22px; padding: 2px 15px; color: #64748b; background: #fff; font-size: 12px; text-align: right; }
.xq-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid #e8edf4; background: #fff; }
.xq-form textarea { flex: 1; min-height: 44px; max-height: 112px; resize: vertical; padding: 9px 11px; border: 1px solid #ccd5e2; border-radius: 11px; background: #fff; color: #172033; font: inherit; line-height: 1.45; }
.xq-form button { min-width: 64px; min-height: 44px; padding: 0 15px; border: 0; border-radius: 11px; color: #fff; background: var(--xq-primary); cursor: pointer; font: inherit; font-weight: 700; }
.xq-form .xq-mic { min-width: 44px; width: 44px; padding: 0; border: 1px solid color-mix(in srgb, var(--xq-primary) 30%, #d7dee8); color: var(--xq-primary); background: #fff; font-size: 19px; }
.xq-form .xq-mic:hover { background: color-mix(in srgb, var(--xq-primary) 8%, #fff); }
.xq-form .xq-mic.is-listening { color: #fff; background: #d63638; border-color: #d63638; animation: xq-mic-pulse 1s ease-in-out infinite; }
.xq-form .xq-mic:disabled { color: #8a96a8; background: #f1f3f6; border-color: #d7dee8; cursor: not-allowed; }
.xq-form button:disabled { cursor: wait; opacity: .6; }
.xq-limit-blocked .xq-form button:disabled { cursor: not-allowed; }
.xq-footer { height: 24px; padding: 1px 12px; color: #8a96a8; background: #fff; font-size: 11px; text-align: center; }
.xq-honeypot { position: absolute !important; left: -99999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }

@keyframes xq-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes xq-voice-pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,.42); } 50% { transform: scale(1.08); box-shadow: 0 0 0 7px rgba(255,255,255,0); } }
@keyframes xq-orb-rotate { to { transform: rotate(360deg); } }
@keyframes xq-orb-halo { 0%, 100% { opacity: .35; transform: scale(.96); } 50% { opacity: .9; transform: scale(1.06); } }
@keyframes xq-listening-pulse { 0%, 100% { filter: saturate(1); } 50% { filter: saturate(1.8) brightness(1.15); } }
@keyframes xq-mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214,54,56,.35); } 50% { box-shadow: 0 0 0 7px rgba(214,54,56,0); } }

@media (prefers-reduced-motion: reduce) { .xq-orb, .xq-orb::after, .xq-form .xq-mic.is-listening { animation: none; } }

@media (max-width: 600px) {
  .xq-widget--floating { right: 12px; bottom: 12px; }
  .xq-widget--floating.xq-position--left { right: auto; left: 12px; }
  .xq-widget--floating .xq-panel { position: fixed; inset: 10px 10px 76px; width: auto; height: auto; max-height: none; border-radius: 16px; }
  .xq-launcher { width: 60px; height: 60px; }
  .xq-launcher .xq-orb { --xq-orb-size: 56px; }
  .xq-widget--floating .xq-panel { bottom: 76px; }
}
