/* Mic-y is positioned and clamped by micy.js; only the header and mascot drag. */
[data-micy] {
  position: fixed;
  z-index: 260;
  right: auto;
  bottom: auto;
  width: min(410px, calc(100vw - 24px));
  max-width: min(var(--micy-max-width, 100vw), calc(100vw - 24px));
  max-height: var(--micy-max-height, calc(100dvh - 120px));
  align-items: flex-end;
  gap: 9px;
  transform: none;
  transition: opacity 180ms ease;
}

/* app.css used to suppress Mic-y entirely on small screens. */
[data-micy]:not([hidden]) { display: flex !important; }
[data-micy][hidden] { display: none !important; }
[data-micy].is-visible { transform: none; }
[data-micy].is-dragging { transition: none; }

[data-micy] .micy-bubble {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  max-height: var(--micy-max-height, calc(100dvh - 120px));
  padding: 0;
  color: var(--window-content-text);
}

[data-micy] .micy-bubble-header {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border-bottom: 1px solid var(--window-content-border);
}

[data-micy] .micy-drag-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 auto;
  gap: 12px;
  min-width: 0;
  min-height: 32px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--surface-muted-text);
}

[data-micy] .micy-bubble-title {
  margin: 0;
  font-family: var(--font-ui);
  line-height: 1.5;
}

[data-micy] .micy-drag-grip {
  flex: 0 0 12px;
  width: 12px;
  height: 10px;
  opacity: .6;
  background: repeating-linear-gradient(to bottom, currentColor 0 1px, transparent 1px 4px);
}

[data-micy] [data-micy-drag] {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

[data-micy].is-dragging [data-micy-drag] { cursor: grabbing; }
[data-micy].is-dragging .micy-character { animation: none; }
[data-micy] .micy-character img { width: 100%; height: 100%; object-fit: cover; object-position: center; pointer-events: none; -webkit-user-drag: none; }

[data-micy] .micy-bubble-header .micy-dismiss {
  position: relative;
  inset: auto;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--window-content-text);
  touch-action: manipulation;
}

[data-micy] .micy-bubble-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  font-size: .72rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

[data-micy] .micy-ask-form { display: flex; gap: 6px; align-items: stretch; }
[data-micy] .micy-ask-input { flex: 1 1 auto; width: 0; }
[data-micy] .micy-ask-submit { flex: 0 0 auto; padding: 6px 10px; }
[data-micy] .micy-bubble-actions .window-action-btn { max-width: 100%; white-space: normal; }
[data-micy] .micy-character { width: 92px; height: min(144px, var(--micy-max-height, 144px)); }
[data-micy] :is(button, input):focus-visible { outline: 2px solid var(--highlight-ring); outline-offset: 2px; }
.dock .dock-btn--micy { display: none; }
.dock-btn--micy .dock-icon-img { --dock-icon-scale: 1.2; object-fit: cover; object-position: center; }

@media (max-width: 980px) {
  .dock .dock-btn--micy { display: flex; }
}

@media (max-width: 980px), (pointer: coarse) {
  [data-micy] { width: min(360px, calc(100vw - 16px)); max-width: min(var(--micy-max-width, 100vw), calc(100vw - 16px)); gap: 8px; }
  [data-micy] .micy-character { width: 56px; height: min(96px, var(--micy-max-height, 96px)); }
  [data-micy] .micy-bubble-body { padding: 10px; font-size: .76rem; }
  [data-micy] .micy-drag-handle { min-height: 44px; padding-inline: 6px; gap: 6px; }
  [data-micy] .micy-bubble-header .micy-dismiss { flex-basis: 44px; width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  [data-micy] .micy-ask-input { min-height: 44px; font-size: 16px; }
  [data-micy] .micy-ask-submit { min-width: 44px; min-height: 44px; padding-inline: 8px; }
  [data-micy] .micy-bubble-actions .window-action-btn { min-height: 44px; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  [data-micy] { transition: none; }
  [data-micy] .micy-character { animation: none; }
}
