/* An optional guest, contained within the editor rather than its document. */
:root {
  --duck-surface: #222426;
  --duck-border: #41403a;
  --duck-label: #efd081;
  --duck-shadow: #0006;
}
body.light {
  --duck-surface: #fffefa;
  --duck-border: #dbd5c6;
  --duck-label: #896011;
  --duck-shadow: #32250c1c;
}
.editor-group { position: relative; }
.duck-companion {
  position: absolute;
  bottom: 0;
  right: 18px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: min(300px, calc(100% - 28px));
  max-height: calc(100% - 8px);
  pointer-events: none;
}
.duck-speech {
  position: relative;
  flex: 0 1 auto;
  width: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--duck-border);
  border-radius: 14px 14px 5px 14px;
  background: var(--duck-surface);
  box-shadow: 0 8px 28px var(--duck-shadow), inset 0 1px #ffffff05;
  pointer-events: auto;
  animation: duck-speech-in 180ms ease-out both;
}
.duck-speech-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding-left: 18px;
}
.duck-speaker { font: 12px var(--mono); color: var(--duck-label); }
.duck-dismiss { flex: 0 0 44px; height: 44px; border-radius: 0 14px 0 6px; color: var(--muted); }
.duck-dismiss svg { width: 16px; height: 16px; }
.duck-message { margin: 0; padding: 0 18px 12px; color: var(--strong); font: 16px/1.5 var(--sans); text-wrap: pretty; }
.duck-speech-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 6px; border-top: 1px solid var(--border); padding: 0 8px 0 18px; }
.duck-speech-footer>span { font-size: 12px; color: var(--muted); line-height: 1.5; padding: 6px 0; }
.duck-quiet { min-height: 44px; padding: 0 8px; color: var(--text); font-size: 14px; border-radius: 6px; }
.duck-perch { display: flex; align-items: flex-end; justify-content: flex-end; gap: 0; flex: 0 0 auto; padding-right: 1px; margin-bottom: -10px; }
.duck-toy { display: block; position: relative; padding: 0; border-radius: 35%; pointer-events: auto; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.duck-toy:hover, .duck-toy:active { background: transparent; }
.duck-toy:focus-visible { outline: 2px solid var(--blue); outline-offset: -5px; }
.duck-toy img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; transform-origin: 50% 85%; filter: drop-shadow(0 5px 4px var(--duck-shadow)); transition: transform 180ms ease-out; }
.duck-big { width: 112px; height: 112px; animation: duck-arrive 580ms cubic-bezier(.2,.7,.3,1) both; }
.duck-small { width: 64px; height: 64px; margin: 0 -13px 4px 0; z-index: 1; animation: duck-hatch 420ms cubic-bezier(.2,.7,.3,1) both; }
.duck-speaking-small .duck-speech { border-radius: 14px 14px 14px 5px; }
/* When the terminal takes over, use the workspace edge so advice is never clipped. */
.duck-companion.duck-compact {
  position: fixed;
  bottom: 30px;
  right: 10px;
  width: min(300px, calc(100vw - 72px));
  max-height: calc(100dvh - 110px);
}
.duck-compact .duck-perch { margin-bottom: -5px; }
.duck-compact .duck-big { width: 68px; height: 68px; }
.duck-compact .duck-small { width: 48px; height: 48px; margin-right: -8px; }
.main-area:has(#tour-banner) .duck-companion { visibility: hidden; }
@media (hover: hover) {
  .duck-toy:hover img { transform: rotate(-5deg) translateY(-3px); }
}
@media (max-width: 600px) {
  .duck-companion { right: 10px; width: calc(100% - 20px); max-width: 300px; }
  .duck-big { width: 96px; height: 96px; }
  .duck-small { width: 56px; height: 56px; }
  .duck-speech-header { padding-left: 14px; }
  .duck-message { padding: 0 14px 12px; }
  .duck-speech-footer { padding-left: 14px; }
}
@keyframes duck-arrive {
  from { opacity: 0; transform: translateY(45px) rotate(14deg); }
  65% { opacity: 1; transform: translateY(-5px) rotate(-5deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}
@keyframes duck-hatch {
  from { opacity: 0; transform: translate(20px, 12px) scale(.55); }
  to { opacity: 1; transform: translate(0, 0) scale(1); }
}
@keyframes duck-speech-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .duck-companion, .duck-companion * { animation: none !important; transition: none !important; }
  .duck-toy:hover img { transform: none; }
}
