/* Unified @ reference picker — aligned with Mahora tokens.css (light + dark) */
.ref-at-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  max-height: min(340px, 46vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-ctrl, 12px);
  border: 1px solid var(--border-strong, var(--border));
  background: var(--surface-elevated, var(--surface));
  color: var(--fg);
  font-family: var(--font-body);
  box-shadow: var(--shadow-elev-2);
  padding: 6px;
}

.ref-at-menu.hidden,
.ref-at-menu[hidden] {
  display: none !important;
}

.ref-at-menu.is-searching {
  border-color: var(--accent-line, var(--accent));
}

/* Lift parent composer stacking context above studio canvas floats while open */
.ig-gate-dock:has(.ref-at-menu:not(.hidden):not([hidden])),
.ig-chat-compose:has(.ref-at-menu:not(.hidden):not([hidden])) {
  z-index: 45;
}

.ref-at-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 5px 8px;
  border-radius: var(--radius-frame, 8px);
  font-size: var(--text-sm, 13px);
  line-height: var(--leading-normal, 1.45);
  color: var(--fg);
  cursor: pointer;
  user-select: none;
  box-sizing: border-box;
  transition:
    background 120ms cubic-bezier(0.2, 0, 0, 1),
    color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.ref-at-row:hover {
  background: var(--hover);
}

.ref-at-row.is-active,
.ref-at-row.is-active:hover {
  background: var(--accent-surface-strong, var(--accent-soft));
}

.ref-at-folder {
  min-height: 32px;
  color: var(--fg);
}

.ref-at-group:not(:first-child) {
  margin-top: 4px;
}

.ref-at-folder .ref-at-label {
  font-weight: 500;
  color: var(--fg);
}

.ref-at-tag .ref-at-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: var(--radius-pill, 999px);
  flex-shrink: 0;
}

.ref-at-thumb {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.ref-at-indent-1,
.ref-at-indent-2 {
  flex-shrink: 0;
}

.ref-at-indent-1 {
  width: 14px;
}

.ref-at-indent-2 {
  width: 26px;
}

.ref-at-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transform: rotate(0deg);
  transition: transform 0.12s ease, color 0.12s ease;
}

.ref-at-row:hover .ref-at-caret,
.ref-at-row.is-active .ref-at-caret {
  color: var(--fg);
}

.ref-at-caret.is-open {
  transform: rotate(90deg);
}

.ref-at-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-at-path {
  margin-left: auto;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs, 11px);
  color: var(--muted);
}

.ref-at-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs, 11px);
  font-weight: 500;
  color: var(--muted);
  padding: 1px 7px;
  border-radius: var(--radius-pill, 999px);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.ref-at-sub-act {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: var(--text-xs, 11px);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong, var(--border));
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.ref-at-sub-act:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line, var(--accent));
  color: var(--accent);
}

.ref-at-path + .ref-at-count,
.ref-at-path + .ref-at-sub-act,
.ref-at-count + .ref-at-sub-act {
  margin-left: 0;
}

.ref-at-empty {
  padding: 12px 10px;
  font-size: var(--text-xs, 11px);
  color: var(--muted);
  text-align: center;
}

/* Composer wells need positioning */
.vg-studio .ig-composer-well,
.vg-studio .ig-chat-compose,
.imgen-studio .ig-composer-well,
.imgen-studio .ig-chat-compose,
#vgDirectorCompose {
  position: relative;
}

/* Imgen ref chips */
.ig-ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 2px 4px 2px 3px;
  border-radius: var(--radius-frame, 8px);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--fg);
  font-size: var(--text-xs, 11px);
  max-width: 196px;
  box-sizing: border-box;
}

.ig-ref-pill img {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.ig-ref-pill .ig-ref-tag-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  padding: 2px 6px;
  border-radius: var(--radius-pill, 999px);
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.ig-ref-pill .ig-chip-x {
  flex-shrink: 0;
}

.ig-prop-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.ig-prop-refs .ig-ref-pill {
  max-width: none;
}

.ig-prop-verify-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: var(--text-xs, 11px);
  color: var(--warn);
}
