.consult-launch, .consult-panel {
  --consult-edge: 20px;
  --consult-line: color-mix(in srgb, var(--muted) 22%, var(--panel));
  position: fixed;
  z-index: 40;
  right: var(--consult-edge);
  border: 1px solid var(--consult-line);
  background: var(--panel);
  box-shadow: 0 8px 30px rgb(0 0 0 / 30%);
}
.consult-launch {
  bottom: var(--consult-edge);
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 800;
}
.consult-launch i { color: var(--blue-2); font-size: 21px; }
.consult-panel {
  bottom: calc(var(--consult-edge) + 58px);
  width: 390px;
  height: min(600px, calc(100dvh - var(--consult-edge) - 70px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.48;
}
.consult-panel p, .consult-panel h2 { margin: 0; }
.consult-head, .consult-foot { padding: 12px 18px; }
.consult-head { border-bottom: 1px solid var(--consult-line); }
.consult-bar, .consult-box { display: flex; align-items: center; gap: 6px; }
.consult-bar h2 { flex: 1; font-size: 19px; line-height: 1.2; font-weight: 800; letter-spacing: -.035em; }
.consult-reset, .consult-close {
  min-height: 44px;
  color: var(--muted);
  border-radius: var(--r-sm);
}
.consult-reset { font-size: 12px; padding: 0 8px; }
.consult-close { width: 44px; background: var(--ctl); font-size: 19px; }
.consult-head p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.consult-scroll { overflow-y: auto; display: flex; flex-direction: column-reverse; background: var(--ctl-3); scrollbar-width: thin; overscroll-behavior: contain; }
.consult-thread { display: grid; flex: none; gap: 14px; padding: 18px; overflow-wrap: anywhere; }
.consult-scroll-start { flex-direction: column; }
.consult-reply { padding-left: 12px; border-left: 2px solid var(--blue-2); font-weight: 500; }
.consult-reply p + p { margin-top: 8px; }
.consult-user {
  justify-self: end;
  max-width: 86%;
  background: var(--ctl);
  padding: 9px 13px;
  border-radius: var(--r-md) var(--r-md) 4px var(--r-md);
}
.consult-thread a, .consult-human { color: var(--blue-2); text-decoration: underline; text-underline-offset: 3px; }
.consult-questions { display: grid; border: 1px solid var(--consult-line); border-radius: var(--r-md); overflow: hidden; }
.consult-choice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  text-align: left; padding: 10px 13px; min-height: 45px;
  background: var(--panel); font-size: 13px;
}
.consult-choice + .consult-choice { border-top: 1px solid var(--consult-line); }
.consult-choice i { color: var(--blue-2); font-size: 17px; }
.consult-notice, .consult-typing { color: var(--muted); font-size: 13px; }
.consult-notice { padding: 12px; border: 1px solid var(--consult-line); border-radius: var(--r-sm); }
.consult-notice i, .consult-typing i { margin-right: 5px; }
.consult-retry { display: block; min-height: 44px; color: var(--blue-2); }
.consult-foot { border-top: 1px solid var(--consult-line); padding-bottom: 4px; }
.consult-box { background: var(--bg); border: 1px solid var(--consult-line); border-radius: var(--r-md); padding: 4px; align-items: flex-end; }
.consult-box:focus-within { border-color: var(--blue-2); }
.consult-box textarea {
  flex: 1; min-width: 0; field-sizing: content; min-height: 44px; max-height: 108px;
  resize: none; padding: 12px 6px 12px 9px; font: 500 14px/20px Manrope, sans-serif;
  color: var(--text); border: 0; background: transparent; outline: none;
}
.consult-box textarea::placeholder { color: var(--muted); }
.consult-send { width: 44px; height: 44px; flex: none; border-radius: var(--r-sm); background: var(--blue-2); color: var(--on-light); font-size: 22px; }
.consult-send:disabled { color: var(--muted); background: var(--ctl); cursor: default; }
.consult-count { display: block; text-align: right; color: var(--muted); font-size: 12px; }
.consult-foot p { color: var(--muted); font-size: 12px; margin-top: 8px; }
.consult-human { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; font-size: 13px; }
.consult-human i { font-size: 17px; }
.consult-choice:hover, .consult-reset:hover, .consult-close:hover, .consult-launch:hover { background: var(--ctl); color: var(--text); }
.consult-panel :is(button,a):focus-visible, .consult-launch:focus-visible { outline: 2px solid var(--blue-2); outline-offset: -2px; }
@media (min-width: 769px) and (max-width: 900px) {
  .consult-panel { bottom: 86px; right: 12px; height: min(600px, calc(100dvh - 98px)); }
}
@media (max-width: 900px) {
  .consult-launch { display: none; }
}
@media (max-width: 768px) {
  .consult-panel {
    inset: var(--consult-viewport-top, 0px) 0 0;
    width: 100%; height: var(--consult-viewport-height, 100dvh);
    border: 0; border-radius: 0;
  }
  .consult-head, .consult-foot, .consult-thread { padding-inline: max(16px, calc((100% - 560px) / 2)); }
  .consult-head { padding-top: max(12px, env(safe-area-inset-top)); }
  .consult-foot { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .consult-box textarea { font-size: 16px; }
}

.consult-root [hidden] { display: none; }
.consult-user, .consult-reply { white-space: pre-line; }
