:root {
  --dha-cyan: #56d8e8;
  --dha-cyan-strong: #7ae7f2;
  --dha-teal: #43d9c8;
  --dha-blue: #4a94ec;
  --dha-ink: #03111f;
  --dha-surface: rgba(5, 25, 43, .96);
  --dha-surface-soft: rgba(9, 39, 63, .78);
  --dha-line: rgba(91, 203, 224, .3);
  --dha-line-soft: rgba(91, 203, 224, .14);
  --dha-text: #e6f7fb;
  --dha-muted: #86a3b5;
  --dha-warning: #ffc65b;
}

.dha-trigger {
  position: relative;
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(77, 210, 229, .28);
  border-radius: 50%;
  color: #a8eff6;
  background:
    radial-gradient(circle at 50% 38%, rgba(74, 217, 232, .18), transparent 50%),
    rgba(4, 25, 41, .76);
  box-shadow: inset 0 0 13px rgba(51, 192, 216, .08);
  cursor: pointer;
  isolation: isolate;
  transition: border-color .18s ease, color .18s ease, background .18s ease, transform .18s ease;
}

.dha-trigger:hover {
  border-color: rgba(100, 229, 240, .68);
  color: #e6fdff;
  background: rgba(8, 46, 68, .9);
  transform: translateY(-1px);
}

.dha-trigger:focus-visible {
  outline: 2px solid #8cecf3;
  outline-offset: 2px;
}

.dha-trigger[aria-expanded="true"] {
  border-color: rgba(97, 229, 239, .88);
  color: #f1feff;
  box-shadow: 0 0 16px rgba(61, 210, 226, .2), inset 0 0 14px rgba(61, 210, 226, .16);
}

.dha-trigger svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.45;
}

.dha-trigger__status {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 7px;
  height: 7px;
  border: 1px solid #062035;
  border-radius: 50%;
  background: var(--dha-teal);
  box-shadow: 0 0 7px rgba(67, 217, 200, .76);
}

.dha-root {
  position: fixed;
  z-index: 110;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: var(--dha-text);
  font-family: "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

.dha-panel {
  position: absolute;
  top: 68px;
  right: 10px;
  bottom: auto;
  display: grid;
  width: clamp(356px, 22cqw, 420px);
  height: min(820px, calc(100cqh - 78px));
  min-height: 0;
  grid-template-rows: 52px minmax(220px, .92fr) minmax(230px, 1.08fr) auto;
  overflow: hidden;
  border: 1px solid rgba(92, 218, 235, .38);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(7, 34, 55, .98), rgba(3, 17, 31, .985)),
    var(--dha-ink);
  box-shadow:
    0 18px 46px rgba(0, 5, 14, .48),
    inset 0 1px rgba(195, 249, 255, .04);
  opacity: 0;
  pointer-events: auto;
  transform: translateX(calc(100% + 24px));
  transition: transform .26s cubic-bezier(.22, 1, .36, 1), opacity .2s ease;
}

.dha-root[data-open="true"] .dha-panel {
  opacity: 1;
  transform: translateX(0);
}

.dha-panel[hidden] { display: none; }

.dha-panel__edge {
  position: absolute;
  z-index: 6;
  width: 18px;
  height: 18px;
  border-color: rgba(122, 231, 242, .78);
  pointer-events: none;
}

.dha-panel__edge--tl { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.dha-panel__edge--tr { top: -1px; right: -1px; border-top: 2px solid; border-right: 2px solid; }
.dha-panel__edge--bl { bottom: -1px; left: -1px; border-bottom: 2px solid; border-left: 2px solid; }
.dha-panel__edge--br { right: -1px; bottom: -1px; border-right: 2px solid; border-bottom: 2px solid; }

.dha-panel__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid rgba(82, 207, 226, .22);
  background:
    linear-gradient(90deg, rgba(24, 81, 111, .42), transparent 72%),
    rgba(7, 36, 59, .62);
}

.dha-panel__title { min-width: 0; }

.dha-panel__title strong {
  display: block;
  overflow: hidden;
  color: #effdff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dha-panel__title span {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  color: var(--dha-muted);
  font-size: 10px;
}

.dha-panel__title i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dha-teal);
  box-shadow: 0 0 6px rgba(67, 217, 200, .75);
}

.dha-panel__tools { display: flex; gap: 4px; }

.dha-icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #8faebe;
  background: transparent;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}

.dha-icon-button:hover {
  border-color: rgba(92, 216, 232, .25);
  color: #dcfbff;
  background: rgba(66, 182, 207, .08);
}

.dha-icon-button:focus-visible,
.dha-quick-action:focus-visible,
.dha-composer button:focus-visible,
.dha-composer input:focus-visible {
  outline: 2px solid rgba(122, 231, 242, .9);
  outline-offset: 1px;
}

.dha-icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.dha-icon-button[data-muted="true"] .dha-volume-on,
.dha-icon-button[data-muted="false"] .dha-volume-off { display: none; }

.dha-stage-wrap {
  position: relative;
  min-height: 0;
  margin: 9px 10px 0;
  overflow: hidden;
  border: 1px solid rgba(87, 202, 222, .24);
  border-radius: 4px;
  background:
    radial-gradient(circle at 50% 40%, rgba(24, 117, 156, .2), transparent 47%),
    rgba(2, 17, 31, .86);
}

.dha-stage-wrap__line {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 16px;
  width: 82px;
  height: 2px;
  background: linear-gradient(90deg, var(--dha-cyan-strong), transparent);
  pointer-events: none;
}

.dha-stage-wrap__meta {
  position: absolute;
  z-index: 4;
  right: 10px;
  bottom: 9px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid rgba(76, 198, 218, .18);
  border-radius: 3px;
  color: #82a4b7;
  background: rgba(2, 18, 31, .72);
  font-size: 10px;
  pointer-events: none;
}

.dha-stage-wrap__meta i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dha-cyan);
}

.dha-stage-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.dha-stage-placeholder {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  width: 100%;
  height: 100%;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--dha-muted);
  font-size: 11px;
  text-align: center;
  padding: 18px;
  background: #041526;
}

.dha-stage-placeholder[hidden], .dha-retry[hidden] { display: none; }
.dha-stage-wrap[data-avatar-state="error"] .dha-stage-placeholder__ring { display: none; }
.dha-stage-placeholder [data-dha-loading-message] { font-size: 13px; line-height: 1.65; }
.dha-retry {
  min-height: 34px;
  padding: 5px 14px;
  border: 1px solid #347bb6;
  color: #def4ff;
  background: #0b2858;
  font: inherit;
  cursor: pointer;
}
.dha-retry:hover { background: #12386e; }
.dha-retry:focus-visible { outline: 2px solid #65dfff; outline-offset: 3px; }
.dha-icon-button:disabled { opacity: .45; cursor: default; }

.dha-stage-placeholder__ring {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(84, 216, 232, .22);
  border-top-color: var(--dha-cyan);
  border-radius: 50%;
  animation: dha-rotate 1.15s linear infinite;
}

.dha-conversation {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 11px 11px 8px;
}

.dha-context-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--dha-line-soft);
}

.dha-context-bar span:first-child {
  overflow: hidden;
  color: #c8e4ec;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dha-signal-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.dha-signal-strip > span {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(84, 201, 219, .14);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(16, 61, 82, .46), rgba(7, 34, 52, .5));
}

.dha-signal-strip small {
  display: block;
  overflow: hidden;
  color: #708fa1;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dha-signal-strip b {
  display: block;
  margin-top: 2px;
  color: #dff9fc;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}

.dha-messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(77, 200, 219, .26) transparent;
  scrollbar-width: thin;
}

.dha-message {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  margin: 0 0 9px;
  color: #c9dce5;
  font-size: 12px;
  line-height: 1.65;
}

.dha-message__avatar {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  margin-top: 1px;
  border: 1px solid rgba(84, 216, 232, .3);
  border-radius: 50%;
  color: var(--dha-cyan);
  background: rgba(38, 145, 173, .12);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.dha-message__content {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(82, 193, 213, .15);
  border-radius: 2px 6px 6px;
  background: rgba(15, 49, 70, .44);
}

.dha-message__content p { margin: 0; }

.dha-message__source {
  display: block;
  margin-top: 5px;
  color: #658699;
  font-size: 10px;
}

.dha-message--user {
  grid-template-columns: minmax(0, 1fr);
  margin-left: 38px;
}

.dha-message--user .dha-message__content {
  justify-self: end;
  border-color: rgba(76, 147, 232, .2);
  border-radius: 6px 2px 6px 6px;
  color: #d7e9f7;
  background: rgba(43, 90, 145, .2);
}

.dha-message--thinking .dha-message__content {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
}

.dha-message--thinking b {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dha-cyan);
  animation: dha-thinking .9s ease-in-out infinite alternate;
}

.dha-message--thinking b:nth-child(2) { animation-delay: .16s; }
.dha-message--thinking b:nth-child(3) { animation-delay: .32s; }

.dha-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.dha-quick-action {
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
  border: 1px solid rgba(83, 199, 219, .18);
  border-radius: 3px;
  color: #9bb8c8;
  background: rgba(9, 40, 61, .54);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}

.dha-quick-action:hover {
  border-color: rgba(96, 222, 235, .46);
  color: #e4fbff;
  background: rgba(25, 78, 101, .42);
}

.dha-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 7px;
  padding: 9px 10px 10px;
  border-top: 1px solid rgba(85, 207, 225, .18);
  background: rgba(2, 15, 27, .58);
}

.dha-composer input {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(84, 200, 219, .24);
  border-radius: 3px;
  color: #e3f6fa;
  background: rgba(7, 30, 48, .86);
  font: inherit;
  font-size: 12px;
}

.dha-composer input::placeholder { color: #628093; }

.dha-composer button {
  display: grid;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(97, 224, 237, .5);
  border-radius: 3px;
  color: #071c2a;
  background: linear-gradient(135deg, #75e2ec, #46bdcf);
  cursor: pointer;
}

.dha-composer button:disabled {
  opacity: .46;
  cursor: not-allowed;
}

.dha-composer button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.dha-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes dha-rotate { to { transform: rotate(360deg); } }

@keyframes dha-thinking {
  from { opacity: .35; transform: translateY(1px); }
  to { opacity: 1; transform: translateY(-1px); }
}

@container console-screen (max-width: 1500px) {
  .dha-panel {
    top: 64px;
    right: 8px;
    bottom: auto;
    height: min(800px, calc(100cqh - 72px));
    width: clamp(326px, 24cqw, 368px);
  }
}

@container console-screen (max-width: 1366px) {
  .dha-panel {
    width: 332px;
    grid-template-rows: 50px minmax(190px, .82fr) minmax(218px, 1.18fr) auto;
  }

  .dha-panel__title strong { font-size: 15px; }
  .dha-conversation { padding-top: 9px; }
}

@container console-screen (max-width: 920px) {
  .dha-panel {
    top: 60px;
    right: 6px;
    bottom: auto;
    height: calc(100cqh - 66px);
    width: min(360px, calc(100cqw - 12px));
  }
}

@container console-screen (max-height: 820px) {
  .dha-panel {
    grid-template-rows: 48px minmax(178px, .72fr) minmax(196px, 1.28fr) auto;
  }

  .dha-panel__header { padding-top: 6px; padding-bottom: 6px; }
  .dha-stage-wrap { margin-top: 7px; }
  .dha-conversation { gap: 6px; padding-top: 8px; }
  .dha-context-bar { padding-bottom: 6px; }
  .dha-message { margin-bottom: 7px; font-size: 11px; }
  .dha-message__content { padding: 6px 8px; }
  .dha-quick-action { min-height: 38px; padding: 4px 3px; }
  .dha-composer { padding-top: 7px; padding-bottom: 7px; }
  .dha-composer input,
  .dha-composer button { height: 34px; }
}

@container console-screen (max-height: 700px) {
  .dha-panel {
    top: 58px;
    bottom: auto;
    height: calc(100cqh - 62px);
    grid-template-rows: 46px 164px minmax(180px, 1fr) auto;
  }

  .dha-stage-wrap__meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dha-panel,
  .dha-trigger,
  .dha-quick-action,
  .dha-icon-button { transition: none; }

  .dha-stage-placeholder__ring,
  .dha-message--thinking b { animation: none; }
}
