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

.hz-widget-root {
  --hz-primary: #6d5dfc;
  --hz-surface: #ffffff;
  --hz-surface-soft: #f6f7fb;
  --hz-text: #202334;
  --hz-muted: #7b8194;
  --hz-border: #e7e9f1;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  color: var(--hz-text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

.hz-widget-root.hz-left { right: auto; left: 24px; }
.hz-widget-root.hz-dark {
  --hz-surface: #161824;
  --hz-surface-soft: #202330;
  --hz-text: #f5f6fb;
  --hz-muted: #a2a7b8;
  --hz-border: #313545;
}

.hz-widget-launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  margin-left: auto;
  padding: 8px 17px 8px 8px;
  border: 0;
  border-radius: 28px;
  background: var(--hz-primary);
  color: #fff;
  box-shadow: 0 14px 36px color-mix(in srgb, var(--hz-primary) 38%, transparent);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  transition: transform .2s ease, box-shadow .2s ease;
}
.hz-left .hz-widget-launcher { margin-left: 0; margin-right: auto; }
.hz-widget-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 42px color-mix(in srgb, var(--hz-primary) 46%, transparent); }
.hz-widget-root.hz-vertical .hz-widget-launcher {
  flex-direction: column;
  width: 66px;
  min-height: 112px;
  gap: 3px;
  padding: 9px 8px 13px;
  border: 1px solid var(--hz-border);
  border-radius: 34px;
  background: var(--hz-surface);
  color: var(--hz-text);
  box-shadow: 0 12px 34px rgba(24, 28, 45, .18);
}
.hz-widget-root.hz-vertical .hz-widget-launcher-text { width: 2.5em; line-height: 1.35; text-align: center; white-space: normal; }
.hz-widget-launcher-logo,
.hz-widget-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-weight: 800;
}
.hz-widget-brand-image { display: block; width: 84%; height: 84%; object-fit: contain; }
.hz-widget-has-brand {
  border: 1px solid rgba(32, 42, 72, .1);
  background: #fff !important;
  box-shadow: 0 3px 10px rgba(22, 30, 54, .16);
}
.hz-widget-has-brand .hz-widget-brand-image { width: 76%; height: 76%; }
.hz-widget-mini-avatar.hz-widget-has-brand { width: 30px; height: 30px; border-radius: 10px; }
.hz-widget-avatar.hz-widget-has-brand { width: 42px; height: 42px; }
.hz-widget-root.hz-vertical .hz-widget-launcher-logo { width: 44px; height: 44px; background: color-mix(in srgb, var(--hz-primary) 8%, transparent); }

.hz-widget-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  width: min(var(--hz-width, 380px), calc(100vw - 32px));
  height: min(var(--hz-height, 560px), calc(100vh - 112px));
  border: 1px solid var(--hz-border);
  border-radius: 20px;
  background: var(--hz-surface);
  box-shadow: 0 24px 64px rgba(24, 28, 45, .22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease;
}
.hz-left .hz-widget-panel { right: auto; left: 0; transform-origin: bottom left; }
.hz-widget-root.hz-vertical .hz-widget-panel { bottom: 126px; }
.hz-widget-root.hz-open .hz-widget-panel { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }

.hz-widget-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 16px;
  background: linear-gradient(135deg, var(--hz-primary), color-mix(in srgb, var(--hz-primary) 65%, #22c6b8));
  color: #fff;
}
.hz-widget-avatar { width: 40px; height: 40px; background: rgba(255,255,255,.18); }
.hz-widget-heading { min-width: 0; flex: 1; }
.hz-widget-heading strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.hz-widget-heading span { display: flex; align-items: center; gap: 5px; margin-top: 1px; font-size: 11px; opacity: .86; }
.hz-widget-heading span::before { width: 7px; height: 7px; border-radius: 50%; background: #60f2a1; content: ""; }
.hz-widget-close { width: 34px; height: 34px; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; font-size: 20px; }

.hz-widget-messages { display: flex; overflow-y: auto; flex: 1; flex-direction: column; gap: 13px; padding: 18px 16px; background: var(--hz-surface-soft); scroll-behavior: smooth; }
.hz-widget-row { display: flex; align-items: flex-end; gap: 8px; }
.hz-widget-row.hz-user { justify-content: flex-end; }
.hz-widget-mini-avatar { display: flex; align-items: center; justify-content: center; flex: 0 0 26px; width: 26px; height: 26px; border-radius: 9px; background: var(--hz-primary); color: #fff; font-size: 10px; font-weight: 750; }
.hz-widget-bubble { max-width: 82%; padding: 10px 12px; border: 1px solid var(--hz-border); border-radius: 4px 14px 14px; background: var(--hz-surface); box-shadow: 0 4px 12px rgba(30,35,55,.04); color: var(--hz-text); white-space: pre-wrap; word-break: break-word; }
.hz-widget-bubble a { color: var(--hz-primary); font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.hz-widget-bubble strong { font-weight: 750; }
.hz-user .hz-widget-bubble { border-color: transparent; border-radius: 14px 4px 14px 14px; background: var(--hz-primary); color: #fff; }
.hz-widget-bubble.hz-error { color: #e05252; }
.hz-widget-thinking::after { content: "…"; animation: hz-pulse 1s infinite; }
@keyframes hz-pulse { 50% { opacity: .3; } }

.hz-widget-input-wrap { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--hz-border); background: var(--hz-surface); }
.hz-widget-input { min-width: 0; flex: 1; height: 42px; padding: 0 13px; border: 1px solid var(--hz-border); border-radius: 12px; outline: none; background: var(--hz-surface-soft); color: var(--hz-text); font: inherit; }
.hz-widget-input:focus { border-color: var(--hz-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hz-primary) 14%, transparent); }
.hz-widget-send { width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--hz-primary); color: #fff; cursor: pointer; font-size: 18px; }
.hz-widget-send:disabled { cursor: not-allowed; opacity: .55; }
.hz-widget-powered { padding: 0 12px 9px; background: var(--hz-surface); color: var(--hz-muted); text-align: center; font-size: 10px; }

@media (max-width: 520px) {
  .hz-widget-root { right: 16px; bottom: 16px; }
  .hz-widget-root.hz-left { right: auto; left: 16px; }
  .hz-widget-panel { position: fixed; inset: 12px 12px 82px; width: auto; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .hz-widget-root * { animation: none !important; transition: none !important; }
}
